/[dolibarr]/dolibarr/htdocs/facture.class.php
ViewVC logotype

Diff of /dolibarr/htdocs/facture.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.117 by eldy, Sun Sep 4 02:22:52 2005 UTC revision 1.118 by eldy, Tue Sep 6 01:20:13 2005 UTC
# Line 896  class Facture Line 896  class Facture
896      */      */
897      function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)      function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
898      {      {
899            dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
900          if ($this->brouillon)          if ($this->brouillon)
901          {          {
902                // Nettoyage paramètres
903              /* Lecture du rang max de la facture */              if (strlen(trim($qty))==0) $qty=1;
   
             $sql = "SELECT max(rang) FROM ".MAIN_DB_PREFIX."facturedet";  
             $sql .= " WHERE fk_facture =".$facid;  
             $resql = $this->db->query($sql);  
   
             if ($resql)  
             {  
               $row = $this->db->fetch_row($resql);  
               $rangmax = $row[0];  
             }  
   
             /* -- */  
   
             if (strlen(trim($qty))==0)  
             {  
               $qty=1;  
             }  
904              $remise = 0;              $remise = 0;
905              $_price = $pu;              $_price = $pu;
906              $subprice = $pu;              $subprice = $pu;
907        
908              $remise_percent = trim($remise_percent);              $remise_percent = trim($remise_percent);
909                
910              if ($this->socidp)              if ($this->socidp)
911              {              {
912                  $soc = new Societe($this->db);                  $soc = new Societe($this->db);
# Line 933  class Facture Line 917  class Facture
917                      $remise_percent = $remise_client ;                      $remise_percent = $remise_client ;
918                  }                  }
919              }              }
920        
921              if ($remise_percent > 0)              if ($remise_percent > 0)
922              {              {
923                  $remise = ($pu * $remise_percent / 100);                  $remise = ($pu * $remise_percent / 100);
924                  $_price = ($pu - $remise);                  $_price = ($pu - $remise);
925              }              }
926                
927              /* Formatage des prix */              // Lecture du rang max de la facture
928                $sql = "SELECT max(rang) FROM ".MAIN_DB_PREFIX."facturedet";
929                $sql .= " WHERE fk_facture =".$facid;
930                $resql = $this->db->query($sql);
931                if ($resql)
932                {
933                    $row = $this->db->fetch_row($resql);
934                    $rangmax = $row[0];
935                }
936        
937                // Formatage des prix
938              $_price    = ereg_replace(",",".",$_price);              $_price    = ereg_replace(",",".",$_price);
939              $subprice  = ereg_replace(",",".",$subprice);              $subprice  = ereg_replace(",",".",$subprice);
940        
941              $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet ";              $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet ";
942              $sql .= " (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)";              $sql .= " (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)";
943              $sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', ";              $sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', ";
944        
945              if ($datestart) { $sql.= "'$datestart', "; }              if ($datestart) { $sql.= "'$datestart', "; }
946              else { $sql.=" null, "; }              else { $sql.=" null, "; }
947              if ($dateend) { $sql.= "'$dateend' "; }              if ($dateend) { $sql.= "'$dateend' "; }
948              else { $sql.=" null "; }              else { $sql.=" null "; }
949        
950              $sql .= ",".$ventil;              $sql .= ",".$ventil;
951              $sql .=",".($rangmax + 1).")";              $sql .=",".($rangmax + 1).")";
952        
953              if ( $this->db->query( $sql) )              if ( $this->db->query( $sql) )
954              {              {
955                  $this->updateprice($facid);                  $this->updateprice($facid);

Legend:
Removed from v.1.117  
changed lines
  Added in v.1.118

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26