Fix: Update request

This commit is contained in:
Laurent Destailleur 2011-04-19 22:12:31 +00:00
parent 96af6396a5
commit 55eb37ac4c

View File

@ -597,7 +597,7 @@ class Commande extends CommonObject
{ {
$fk_parent_line=0; $fk_parent_line=0;
$num=sizeof($this->lines); $num=sizeof($this->lines);
/* /*
* Insertion du detail des produits dans la base * Insertion du detail des produits dans la base
*/ */
@ -607,7 +607,7 @@ class Commande extends CommonObject
if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
$result = $this->addline( $result = $this->addline(
$this->id, $this->id,
$this->lines[$i]->desc, $this->lines[$i]->desc,
@ -918,7 +918,7 @@ class Commande extends CommonObject
if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
@ -1008,7 +1008,7 @@ class Commande extends CommonObject
{ {
// Reorder if child line // Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la commande meme // Mise a jour informations denormalisees au niveau de la commande meme
$this->id=$commandeid; // TODO A virer $this->id=$commandeid; // TODO A virer
$result=$this->update_price(1); $result=$this->update_price(1);
@ -1460,8 +1460,10 @@ class Commande extends CommonObject
*/ */
function nb_expedition() function nb_expedition()
{ {
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql = 'SELECT count(*) ';
$sql .=" WHERE e.fk_commande = ".$this->id; $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e,';
$sql.= ' '.MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = 'shipping'";
$sql.= " WHERE el.fk_source = ".$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -1480,9 +1482,7 @@ class Commande extends CommonObject
function livraison_array($filtre_statut=-1) function livraison_array($filtre_statut=-1)
{ {
$delivery = new Livraison($this->db); $delivery = new Livraison($this->db);
$deliveryArray = $delivery->livraison_array($filtre_statut); $deliveryArray = $delivery->livraison_array($filtre_statut);
return $deliveryArray; return $deliveryArray;
} }
@ -1552,7 +1552,7 @@ class Commande extends CommonObject
// Delete line // Delete line
$line = new OrderLine($this->db); $line = new OrderLine($this->db);
// For triggers // For triggers
$line->fetch($lineid); $line->fetch($lineid);
@ -1760,7 +1760,7 @@ class Commande extends CommonObject
} }
} }
} }
/** /**
* \brief Set delivery * \brief Set delivery
* \param user Objet utilisateur qui modifie * \param user Objet utilisateur qui modifie
@ -1899,7 +1899,7 @@ class Commande extends CommonObject
return -2; return -2;
} }
} }
/** /**
* \brief Change le delai de livraison * \brief Change le delai de livraison
* \param mode Id du nouveau mode * \param mode Id du nouveau mode
@ -2058,15 +2058,15 @@ class Commande extends CommonObject
$remise = round(($pu * $remise_percent / 100),2); $remise = round(($pu * $remise_percent / 100),2);
$price = ($pu - $remise); $price = ($pu - $remise);
} }
// Update line // Update line
$this->line=new OrderLine($this->db); $this->line=new OrderLine($this->db);
// Stock previous line records // Stock previous line records
$staticline=new OrderLine($this->db); $staticline=new OrderLine($this->db);
$staticline->fetch($rowid); $staticline->fetch($rowid);
$this->line->oldline = $staticline; $this->line->oldline = $staticline;
$this->line->rowid=$rowid; $this->line->rowid=$rowid;
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty=$qty; $this->line->qty=$qty;
@ -2086,7 +2086,7 @@ class Commande extends CommonObject
$this->line->product_type=$type; $this->line->product_type=$type;
$this->line->fk_parent_line=$fk_parent_line; $this->line->fk_parent_line=$fk_parent_line;
$this->line->skip_update_total=$skip_update_total; $this->line->skip_update_total=$skip_update_total;
// TODO deprecated // TODO deprecated
$this->line->price=$price; $this->line->price=$price;
$this->line->remise=$remise; $this->line->remise=$remise;
@ -2662,7 +2662,7 @@ class OrderLine
// Start and end date of the line // Start and end date of the line
var $date_start; var $date_start;
var $date_end; var $date_end;
var $skip_update_total; // Skip update price total for special lines var $skip_update_total; // Skip update price total for special lines
@ -2869,7 +2869,7 @@ class OrderLine
function update($notrigger=0) function update($notrigger=0)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@ -2883,7 +2883,7 @@ class OrderLine
if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->product_type)) $this->product_type=0; if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
$this->db->begin(); $this->db->begin();
// Mise a jour ligne en base // Mise a jour ligne en base
@ -2912,7 +2912,7 @@ class OrderLine
if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; } if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; }
$sql.= " , product_type=".$this->product_type; $sql.= " , product_type=".$this->product_type;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("OrderLine::update sql=$sql"); dol_syslog("OrderLine::update sql=$sql");
@ -2929,7 +2929,7 @@ class OrderLine
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2941,7 +2941,7 @@ class OrderLine
return -2; return -2;
} }
} }
/** /**
* \brief Mise a jour de l'objet ligne de commande en base * \brief Mise a jour de l'objet ligne de commande en base
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
@ -2949,7 +2949,7 @@ class OrderLine
function update_total() function update_total()
{ {
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters
if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->total_localtax2)) $this->total_localtax2=0;