Fix: uniformize code

Fix: services do not stock
This commit is contained in:
Regis Houssin 2010-01-30 07:45:57 +00:00
parent a54e98ed23
commit 7d10f8533e
8 changed files with 190 additions and 159 deletions

View File

@ -80,7 +80,7 @@ $com->note = 'A comment';
$com->source = 1; $com->source = 1;
$com->remise_percent = 0; $com->remise_percent = 0;
$orderline1=new CommandeLigne($db); $orderline1=new OrderLine($db);
$orderline1->tva_tx=10.0; $orderline1->tva_tx=10.0;
$orderline1->remise_percent=0; $orderline1->remise_percent=0;
$orderline1->qty=1; $orderline1->qty=1;

View File

@ -120,19 +120,21 @@ class Commande extends CommonObject
$this->source = 0; $this->source = 0;
for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++) for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++)
{ {
$CommLigne = new CommandeLigne($this->db); $line = new OrderLine($this->db);
$CommLigne->libelle = $propal->lignes[$i]->libelle;
$CommLigne->desc = $propal->lignes[$i]->desc; $line->libelle = $propal->lignes[$i]->libelle;
$CommLigne->price = $propal->lignes[$i]->price; $line->desc = $propal->lignes[$i]->desc;
$CommLigne->subprice = $propal->lignes[$i]->subprice; $line->price = $propal->lignes[$i]->price;
$CommLigne->tva_tx = $propal->lignes[$i]->tva_tx; $line->subprice = $propal->lignes[$i]->subprice;
$CommLigne->qty = $propal->lignes[$i]->qty; $line->tva_tx = $propal->lignes[$i]->tva_tx;
$CommLigne->fk_remise_except = $propal->lignes[$i]->fk_remise_except; $line->qty = $propal->lignes[$i]->qty;
$CommLigne->remise_percent = $propal->lignes[$i]->remise_percent; $line->fk_remise_except = $propal->lignes[$i]->fk_remise_except;
$CommLigne->fk_product = $propal->lignes[$i]->fk_product; $line->remise_percent = $propal->lignes[$i]->remise_percent;
$CommLigne->info_bits = $propal->lignes[$i]->info_bits; $line->fk_product = $propal->lignes[$i]->fk_product;
$CommLigne->product_type = $propal->lignes[$i]->product_type; $line->info_bits = $propal->lignes[$i]->info_bits;
$this->lines[$i] = $CommLigne; $line->product_type = $propal->lignes[$i]->product_type;
$this->lines[$i] = $line;
} }
$this->socid = $propal->socid; $this->socid = $propal->socid;
@ -797,31 +799,31 @@ class Commande extends CommonObject
} }
// Insert line // Insert line
$ligne=new CommandeLigne($this->db); $line=new OrderLine($this->db);
$ligne->fk_commande=$commandeid; $line->fk_commande=$commandeid;
$ligne->desc=$desc; $line->desc=$desc;
$ligne->qty=$qty; $line->qty=$qty;
$ligne->tva_tx=$txtva; $line->tva_tx=$txtva;
$ligne->fk_product=$fk_product; $line->fk_product=$fk_product;
$ligne->fk_remise_except=$fk_remise_except; $line->fk_remise_except=$fk_remise_except;
$ligne->remise_percent=$remise_percent; $line->remise_percent=$remise_percent;
$ligne->subprice=$pu_ht; $line->subprice=$pu_ht;
$ligne->rang=-1; $line->rang=-1;
$ligne->info_bits=$info_bits; $line->info_bits=$info_bits;
$ligne->total_ht=$total_ht; $line->total_ht=$total_ht;
$ligne->total_tva=$total_tva; $line->total_tva=$total_tva;
$ligne->total_ttc=$total_ttc; $line->total_ttc=$total_ttc;
$ligne->product_type=$type; $line->product_type=$type;
// \TODO Ne plus utiliser // \TODO Ne plus utiliser
$ligne->price=$price; $line->price=$price;
$ligne->remise=$remise; $line->remise=$remise;
$ligne->date_start=$date_start; $line->date_start=$date_start;
$ligne->date_end=$date_end; $line->date_end=$date_end;
$result=$ligne->insert(); $result=$line->insert();
if ($result > 0) if ($result > 0)
{ {
// Mise a jour informations denormalisees au niveau de la commande meme // Mise a jour informations denormalisees au niveau de la commande meme
@ -840,7 +842,7 @@ class Commande extends CommonObject
} }
else else
{ {
$this->error=$ligne->error; $this->error=$line->error;
dol_syslog("Commande::addline error=".$this->error, LOG_ERR); dol_syslog("Commande::addline error=".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
@ -879,7 +881,8 @@ class Commande extends CommonObject
else else
$price = $prod->price; $price = $prod->price;
$line=new CommandeLigne($this->db); $line=new OrderLine($this->db);
$line->fk_product=$idproduct; $line->fk_product=$idproduct;
$line->desc=$prod->description; $line->desc=$prod->description;
$line->qty=$qty; $line->qty=$qty;
@ -1063,25 +1066,26 @@ class Commande extends CommonObject
return -5; return -5;
} }
$comligne=new CommandeLigne($this->db); $line = new OrderLine($this->db);
$comligne->fk_commande=$this->id;
$comligne->fk_remise_except=$remise->id; $line->fk_commande=$this->id;
$comligne->desc=$remise->description; // Description ligne $line->fk_remise_except=$remise->id;
$comligne->tva_tx=$remise->tva_tx; $line->desc=$remise->description; // Description ligne
$comligne->subprice=-$remise->amount_ht; $line->tva_tx=$remise->tva_tx;
$comligne->price=-$remise->amount_ht; $line->subprice=-$remise->amount_ht;
$comligne->fk_product=0; // Id produit predefini $line->price=-$remise->amount_ht;
$comligne->qty=1; $line->fk_product=0; // Id produit predefini
$comligne->remise=0; $line->qty=1;
$comligne->remise_percent=0; $line->remise=0;
$comligne->rang=-1; $line->remise_percent=0;
$comligne->info_bits=2; $line->rang=-1;
$line->info_bits=2;
$comligne->total_ht = -$remise->amount_ht; $line->total_ht = -$remise->amount_ht;
$comligne->total_tva = -$remise->amount_tva; $line->total_tva = -$remise->amount_tva;
$comligne->total_ttc = -$remise->amount_ttc; $line->total_ttc = -$remise->amount_ttc;
$result=$comligne->insert(); $result=$line->insert();
if ($result > 0) if ($result > 0)
{ {
$result=$this->update_price(); $result=$this->update_price();
@ -1098,7 +1102,7 @@ class Commande extends CommonObject
} }
else else
{ {
$this->error=$comligne->error; $this->error=$line->error;
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -1114,7 +1118,7 @@ class Commande extends CommonObject
/** /**
* \brief Reinitialize array lignes * \brief Reinitialize array lignes
* \param only_product Return only physical products * \param only_product Return only physical products
* \return array Array of CommandeLigne * \return array Array of OrderLine
*/ */
function fetch_lines($only_product=0) function fetch_lines($only_product=0)
{ {
@ -1142,38 +1146,39 @@ class Commande extends CommonObject
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$ligne = new CommandeLigne($this->db); $line = new OrderLine($this->db);
$ligne->rowid = $objp->rowid; // \deprecated
$ligne->id = $objp->rowid; $line->rowid = $objp->rowid; // \deprecated
$ligne->fk_commande = $objp->fk_commande; $line->id = $objp->rowid;
$ligne->commande_id = $objp->fk_commande; // \deprecated $line->fk_commande = $objp->fk_commande;
$ligne->desc = $objp->description; // Description ligne $line->commande_id = $objp->fk_commande; // \deprecated
$ligne->product_type = $objp->product_type; $line->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty; $line->product_type = $objp->product_type;
$ligne->tva_tx = $objp->tva_tx; $line->qty = $objp->qty;
$ligne->total_ht = $objp->total_ht; $line->tva_tx = $objp->tva_tx;
$ligne->total_ttc = $objp->total_ttc; $line->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc;
$ligne->subprice = $objp->subprice; $line->total_tva = $objp->total_tva;
$ligne->fk_remise_except = $objp->fk_remise_except; $line->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except;
$ligne->price = $objp->price; $line->remise_percent = $objp->remise_percent;
$ligne->fk_product = $objp->fk_product; $line->price = $objp->price;
$ligne->marge_tx = $objp->marge_tx; $line->fk_product = $objp->fk_product;
$ligne->marque_tx = $objp->marque_tx; $line->marge_tx = $objp->marge_tx;
$ligne->rang = $objp->rang; $line->marque_tx = $objp->marque_tx;
$ligne->info_bits = $objp->info_bits; $line->rang = $objp->rang;
$line->info_bits = $objp->info_bits;
$ligne->ref = $objp->product_ref; $line->ref = $objp->product_ref;
$ligne->libelle = $objp->label; $line->libelle = $objp->label;
$ligne->product_desc = $objp->product_desc; // Description produit $line->product_desc = $objp->product_desc; // Description produit
$ligne->fk_product_type = $objp->fk_product_type; // Produit ou service $line->fk_product_type = $objp->fk_product_type; // Produit ou service
$ligne->date_start = $this->db->jdate($objp->date_start); $line->date_start = $this->db->jdate($objp->date_start);
$ligne->date_end = $this->db->jdate($objp->date_end); $line->date_end = $this->db->jdate($objp->date_end);
$this->lignes[$i] = $ligne; // For backward compatibility $this->lignes[$i] = $line; // For backward compatibility
$this->lines[$i] = $ligne; $this->lines[$i] = $line;
$i++; $i++;
} }
$this->db->free($result); $this->db->free($result);
@ -1348,10 +1353,12 @@ class Commande extends CommonObject
$product->id = $obj->fk_product; $product->id = $obj->fk_product;
// Supprime ligne // Supprime ligne
$ligne = new CommandeLigne($this->db); $line = new OrderLine($this->db);
$ligne->id = $idligne;
$ligne->fk_commande = $this->id; // On en a besoin dans les triggers $line->id = $idligne;
$result=$ligne->delete($user); $line->fk_commande = $this->id; // On en a besoin dans les triggers
$result=$line->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -1794,7 +1801,8 @@ class Commande extends CommonObject
$subprice = price2num($subprice); $subprice = price2num($subprice);
$LigneOld = new CommandeLigne($this->db); // TODO: utile ?
$LigneOld = new OrderLine($this->db);
$LigneOld->fetch($rowid); $LigneOld->fetch($rowid);
// Mise a jour ligne en base // Mise a jour ligne en base
@ -2219,19 +2227,24 @@ class Commande extends CommonObject
$xnbp = 0; $xnbp = 0;
while ($xnbp < $nbp) while ($xnbp < $nbp)
{ {
$ligne=new CommandeLigne($this->db); $line=new OrderLine($this->db);
$ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1;
$ligne->subprice=100;
$ligne->price=100;
$ligne->tva_tx=19.6;
$ligne->total_ht=100;
$ligne->total_ttc=119.6;
$ligne->total_tva=19.6;
$prodid = rand(1, $num_prods); $prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid];
$ligne->fk_product=$prodids[$prodid]; $line->desc=$langs->trans("Description")." ".$xnbp;
$this->lignes[$xnbp]=$ligne; $line->qty=1;
$line->subprice=100;
$line->price=100;
$line->tva_tx=19.6;
$line->total_ht=100;
$line->total_ttc=119.6;
$line->total_tva=19.6;
$line->produit_id=$prodids[$prodid];
$line->fk_product=$prodids[$prodid];
$this->lignes[$xnbp]=$line; // TODO: deprecated
$this->lines[$xnbp]=$line;
$xnbp++; $xnbp++;
} }
@ -2286,10 +2299,10 @@ class Commande extends CommonObject
/** /**
* \class CommandeLigne * \class OrderLine
* \brief Classe de gestion des lignes de commande * \brief Classe de gestion des lignes de commande
*/ */
class CommandeLigne class OrderLine
{ {
var $db; var $db;
var $error; var $error;
@ -2333,7 +2346,7 @@ class CommandeLigne
* \brief Constructeur d'objets ligne de commande * \brief Constructeur d'objets ligne de commande
* \param DB handler d'acces base de donnee * \param DB handler d'acces base de donnee
*/ */
function CommandeLigne($DB) function OrderLine($DB)
{ {
$this->db= $DB; $this->db= $DB;
} }
@ -2405,7 +2418,7 @@ class CommandeLigne
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';"; $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
dol_syslog("CommandeLigne::delete sql=".$sql); dol_syslog("OrderLine::delete sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2421,7 +2434,7 @@ class CommandeLigne
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("CommandeLigne::delete ".$this->error, LOG_ERR); dol_syslog("OrderLine::delete ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -2435,7 +2448,7 @@ class CommandeLigne
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
dol_syslog("CommandeLigne::insert rang=".$this->rang); dol_syslog("OrderLine::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
@ -2497,7 +2510,7 @@ class CommandeLigne
else { $sql.='null'; } else { $sql.='null'; }
$sql.= ')'; $sql.= ')';
dol_syslog("CommandeLigne::insert sql=".$sql); dol_syslog("OrderLine::insert sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2519,7 +2532,7 @@ class CommandeLigne
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("CommandeLigne::insert Error ".$this->error, LOG_ERR); dol_syslog("OrderLine::insert Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -2541,7 +2554,7 @@ class CommandeLigne
$sql.= ",total_ttc='".price2num($this->total_ttc)."'"; $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("CommandeLigne::update_total sql=$sql"); dol_syslog("OrderLine::update_total sql=$sql");
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -2552,7 +2565,7 @@ class CommandeLigne
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("CommandeLigne::update_total Error ".$this->error, LOG_ERR); dol_syslog("OrderLine::update_total Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -497,7 +497,7 @@ if ($id > 0 || ! empty($ref))
$product->fetch($objp->fk_product); $product->fetch($objp->fk_product);
} }
if ($objp->fk_product > 0 && $conf->stock->enabled) if ($objp->fk_product > 0 && $type == 0 && $conf->stock->enabled)
{ {
print '<td align="center">'; print '<td align="center">';
print $product->stock_reel; print $product->stock_reel;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
@ -383,11 +383,13 @@ class Expedition extends CommonObject
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
// Loop on each product line to add a stock movement // Loop on each product line to add a stock movement
// TODO possibilite d'expedier a partir d'une propale ou autre origine
$sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot"; $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " WHERE ed.fk_expedition = ".$this->id;
$sql.= " AND cd.rowid = ed.fk_origin_line"; $sql.= " AND cd.rowid = ed.fk_origin_line";
dol_syslog("Expedition::valid select details sql=".$sql); dol_syslog("Expedition::valid select details sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -403,7 +405,7 @@ class Expedition extends CommonObject
{ {
$mouvS = new MouvementStock($this->db); $mouvS = new MouvementStock($this->db);
// We decrement stock of product (and sub-products) // We decrement stock of product (and sub-products)
$entrepot_id = "1"; // TODO ajouter possibilit<EFBFBD> de choisir l'entrepot $entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice); $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
} }

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -388,39 +388,48 @@ if ($_GET["action"] == 'create')
{ {
$product = new Product($db); $product = new Product($db);
$ligne = $object->lignes[$indiceAsked]; $line = $object->lines[$indiceAsked];
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
// Desc // Desc
if ($ligne->fk_product > 0) if ($line->fk_product > 0)
{ {
$product->fetch($ligne->fk_product); $product->fetch($line->fk_product);
print '<td>'; print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle; print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product.'">';
if ($ligne->desc) print '<br>'.dol_nl2br(dol_htmlcleanlastbr($ligne->desc),1); if ($line->product_type == 1)
{
print img_object($langs->trans("ShowService"),"service");
}
else
{
print img_object($langs->trans("ShowProduct"),"product");
}
print ' '.$product->ref.'</a> - '.$product->libelle;
if ($line->desc) print '<br>'.dol_nl2br(dol_htmlcleanlastbr($line->desc),1);
print '</td>'; print '</td>';
} }
else else
{ //var_dump($ligne); { //var_dump($ligne);
print "<td>".nl2br($ligne->desc)."</td>\n"; print "<td>".nl2br($line->desc)."</td>\n";
} }
// Qty // Qty
print '<td align="center">'.$ligne->qty.'</td>'; print '<td align="center">'.$line->qty.'</td>';
$qtyProdCom=$ligne->qty; $qtyProdCom=$line->qty;
// Sendings // Sendings
print '<td align="center">'; print '<td align="center">';
$quantityDelivered = $object->expeditions[$ligne->id]; $quantityDelivered = $object->expeditions[$line->id];
print $quantityDelivered; print $quantityDelivered;
print '</td>'; print '</td>';
$quantityAsked = $ligne->qty; $quantityAsked = $line->qty;
$quantityToBeDelivered = $quantityAsked - $quantityDelivered; $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
if ($conf->stock->enabled) if ($conf->stock->enabled && $line->product_type == 0)
{ {
$defaultqty=0; $defaultqty=0;
if ($_GET["entrepot_id"]) if ($_GET["entrepot_id"])
@ -433,8 +442,8 @@ if ($_GET["action"] == 'create')
// Quantity // Quantity
print '<td align="center">'; print '<td align="center">';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$defaultqty.'">'; print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$defaultqty.'">';
print '</td>'; print '</td>';
// Stock // Stock
@ -453,8 +462,11 @@ if ($_GET["action"] == 'create')
$array=array(); $array=array();
$sql = "SELECT e.rowid, e.label, ps.reel"; $sql = "SELECT e.rowid, e.label, ps.reel";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " WHERE ps.fk_entrepot = e.rowid";
$sql.= " AND fk_product = '".$product->id."'";
$result = $db->query($sql) ; $result = $db->query($sql) ;
if ($result) if ($result)
{ {
@ -486,16 +498,17 @@ if ($_GET["action"] == 'create')
else else
{ {
// Quantity // Quantity
print '<td align="center">'; print '<td align="center" '.$colspan.'>';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">'; print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">';
print '</td>'; print '</td>';
if ($line->product_type == 1) print '<td>&nbsp;</td>';
} }
print "</tr>\n"; print "</tr>\n";
// Show subproducts of product // Show subproducts of product
if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $ligne->fk_product > 0) if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
{ {
$product->get_sousproduits_arbo (); $product->get_sousproduits_arbo ();
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom); $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);

View File

@ -1462,7 +1462,7 @@ class CommandeFournisseur extends Commande
* \class CommandeFournisseurLigne * \class CommandeFournisseurLigne
* \brief Classe de gestion des lignes de commande * \brief Classe de gestion des lignes de commande
*/ */
class CommandeFournisseurLigne extends CommandeLigne class CommandeFournisseurLigne extends OrderLine
{ {
// From llx_commandedet // From llx_commandedet
var $qty; var $qty;

View File

@ -231,8 +231,8 @@ class InterfaceEcotax
else else
{ {
// Insertion dans base de la ligne // Insertion dans base de la ligne
// See class CommandeLigne // See class OrderLine
// we don't use the class CommandeLigne for insert, because // we don't use the class OrderLine for insert, because
// then the trigger would be called again ... and again ... and ... // then the trigger would be called again ... and again ... and ...
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commandedet"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commandedet";
$sql.= " (fk_commande, description, qty, tva_tx,"; $sql.= " (fk_commande, description, qty, tva_tx,";

View File

@ -89,6 +89,8 @@ class Propal extends CommonObject
var $adresse; var $adresse;
var $products=array(); var $products=array();
var $lines = array();
var $labelstatut=array(); var $labelstatut=array();
var $labelstatut_short=array(); var $labelstatut_short=array();
@ -887,33 +889,34 @@ class Propal extends CommonObject
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne($this->db); $line = new PropaleLigne($this->db);
$ligne->product_type = $objp->product_type; $line->product_type = $objp->product_type;
$ligne->desc = $objp->description; // Description ligne $line->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty; $line->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx; $line->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$ligne->fk_remise_except = $objp->fk_remise_except; $line->fk_remise_except = $objp->fk_remise_except;
$ligne->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; // deprecated $line->price = $objp->price; // deprecated
$ligne->info_bits = $objp->info_bits; $line->info_bits = $objp->info_bits;
$ligne->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva; $line->total_tva = $objp->total_tva;
$ligne->total_ttc = $objp->total_ttc; $line->total_ttc = $objp->total_ttc;
$ligne->marge_tx = $objp->marge_tx; $line->marge_tx = $objp->marge_tx;
$ligne->marque_tx = $objp->marque_tx; $line->marque_tx = $objp->marque_tx;
$ligne->special_code = $objp->special_code; $line->special_code = $objp->special_code;
$ligne->rang = $objp->rang; $line->rang = $objp->rang;
$ligne->fk_product = $objp->fk_product; $line->fk_product = $objp->fk_product;
$ligne->libelle = $objp->label; // Label produit $line->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit $line->product_desc = $objp->product_desc; // Description produit
$ligne->ref = $objp->ref; $line->ref = $objp->ref;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $line; // TODO: deprecated
$this->lines[$i] = $line;
//dol_syslog("1 ".$ligne->fk_product); //dol_syslog("1 ".$ligne->fk_product);
//print "xx $i ".$this->lignes[$i]->fk_product; //print "xx $i ".$this->lignes[$i]->fk_product;
$i++; $i++;