diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 73b6dc59b81..2794bffcbb3 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -634,7 +634,7 @@ else if ($action == "setabsolutediscount" && $user->rights->propale->creer)
else if ($action == "addline" && $user->rights->propale->creer)
{
$idprod=GETPOST('idprod', 'int');
- //var_dump($_POST);
+
if (empty($idprod) && GETPOST('type') < 0)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors');
@@ -667,8 +667,6 @@ else if ($action == "addline" && $user->rights->propale->creer)
$prod->fetch($idprod);
$tva_tx = get_default_tva($mysoc,$object->client,$prod->id);
- $localtax1_tx= get_localtax($tva_tx, 1, $object->client); //get_default_localtax($mysoc,$object->client,1,$prod->id);
- $localtax2_tx= get_localtax($tva_tx, 2, $object->client); //get_default_localtax($mysoc,$object->client,2,$prod->id);
$tva_npr = get_default_npr($mysoc,$object->client,$prod->id);
// On defini prix unitaire
@@ -752,8 +750,6 @@ else if ($action == "addline" && $user->rights->propale->creer)
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):'');
$type = $prod->type;
- $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
- $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
}
else
{
@@ -763,12 +759,16 @@ else if ($action == "addline" && $user->rights->propale->creer)
$label=(GETPOST('product_label')?GETPOST('product_label'):'');
$desc=GETPOST('product_desc');
$type=GETPOST('type');
- $localtax1_tx=get_localtax($tva_tx,1,$object->client);
- $localtax2_tx=get_localtax($tva_tx,2,$object->client);
- $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
- $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
}
+ // Margin
+ $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
+ $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
+
+ // Local Taxes
+ $localtax1_tx= get_localtax($tva_tx, 1, $object->client);
+ $localtax2_tx= get_localtax($tva_tx, 2, $object->client);
+
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
@@ -822,6 +822,8 @@ else if ($action == "addline" && $user->rights->propale->creer)
unset($_POST['qty']);
unset($_POST['type']);
+ unset($_POST['idprod']);
+ unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 857de5cab90..b60b0bcb86b 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -741,7 +741,6 @@ class Propal extends CommonObject
$result = $this->addline(
$this->id,
- $this->lines[$i]->label,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,
@@ -758,7 +757,8 @@ class Propal extends CommonObject
$this->lines[$i]->special_code,
$fk_parent_line,
$this->lines[$i]->fk_fournprice,
- $this->lines[$i]->pa_ht
+ $this->lines[$i]->pa_ht,
+ $this->lines[$i]->label
);
if ($result < 0)
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 11ce0f53b4b..15194b7738a 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -697,7 +697,8 @@ class Commande extends CommonOrder
$this->lines[$i]->special_code,
$fk_parent_line,
$this->lines[$i]->fk_fournprice,
- $this->lines[$i]->pa_ht
+ $this->lines[$i]->pa_ht,
+ $this->lines[$i]->label
);
if ($result < 0)
{
@@ -896,6 +897,7 @@ class Commande extends CommonOrder
$line = new OrderLine($this->db);
$line->libelle = $object->lines[$i]->libelle;
+ $line->label = $object->lines[$i]->label;
$line->desc = $object->lines[$i]->desc;
$line->price = $object->lines[$i]->price;
$line->subprice = $object->lines[$i]->subprice;
@@ -1006,7 +1008,7 @@ class Commande extends CommonOrder
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
- function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0)
+ function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='')
{
dol_syslog(get_class($this)."::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
@@ -1038,6 +1040,7 @@ class Commande extends CommonOrder
{
$pu=$pu_ttc;
}
+ $label=trim($label);
$desc=trim($desc);
// Check parameters
@@ -1080,6 +1083,7 @@ class Commande extends CommonOrder
$this->line=new OrderLine($this->db);
$this->line->fk_commande=$commandeid;
+ $this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
@@ -1425,7 +1429,7 @@ class Commande extends CommonOrder
{
$this->lines=array();
- $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
+ $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label';
@@ -1452,6 +1456,7 @@ class Commande extends CommonOrder
$line->id = $objp->rowid;
$line->fk_commande = $objp->fk_commande;
$line->commande_id = $objp->fk_commande; // \deprecated
+ $line->label = $objp->custom_label;
$line->desc = $objp->description; // Description ligne
$line->product_type = $objp->product_type;
$line->qty = $objp->qty;
@@ -1468,11 +1473,11 @@ class Commande extends CommonOrder
$line->remise_percent = $objp->remise_percent;
$line->price = $objp->price;
$line->fk_product = $objp->fk_product;
- $line->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
- $line->pa_ht = $marginInfos[0];
- $line->marge_tx = $marginInfos[1];
- $line->marque_tx = $marginInfos[2];
+ $line->fk_fournprice = $objp->fk_fournprice;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
+ $line->pa_ht = $marginInfos[0];
+ $line->marge_tx = $marginInfos[1];
+ $line->marque_tx = $marginInfos[2];
$line->rang = $objp->rang;
$line->info_bits = $objp->info_bits;
$line->special_code = $objp->special_code;
@@ -2156,14 +2161,14 @@ class Commande extends CommonOrder
* @param int $pa_ht Buying price (without tax)
* @return int < 0 if KO, > 0 if OK
*/
- function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0)
+ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='')
{
global $conf;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type");
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
- if ($this->brouillon)
+ if (! empty($this->brouillon))
{
$this->db->begin();
@@ -2178,7 +2183,7 @@ class Commande extends CommonOrder
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu = price2num($pu);
- $pa_ht=price2num($pa_ht);
+ $pa_ht=price2num($pa_ht);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
@@ -2220,6 +2225,7 @@ class Commande extends CommonOrder
}
$this->line->rowid=$rowid;
+ $this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
@@ -2239,9 +2245,9 @@ class Commande extends CommonOrder
$this->line->fk_parent_line=$fk_parent_line;
$this->line->skip_update_total=$skip_update_total;
- // infos marge
- $this->line->fk_fournprice = $fk_fournprice;
- $this->line->pa_ht = $pa_ht;
+ // infos marge
+ $this->line->fk_fournprice = $fk_fournprice;
+ $this->line->pa_ht = $pa_ht;
// TODO deprecated
$this->line->price=$price;
@@ -2741,7 +2747,7 @@ class Commande extends CommonOrder
{
$lines = array();
- $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
+ $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,';
$sql.= ' l.date_start, l.date_end,';
@@ -2763,6 +2769,7 @@ class Commande extends CommonOrder
$obj = $this->db->fetch_object($resql);
$this->lines[$i]->id = $obj->rowid;
+ $this->lines[$i]->label = $obj->custom_label;
$this->lines[$i]->description = $obj->description;
$this->lines[$i]->fk_product = $obj->fk_product;
$this->lines[$i]->ref = $obj->ref;
@@ -2788,7 +2795,7 @@ class Commande extends CommonOrder
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht);
$this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1];
- $this->lines[$i]->marque_tx = $marginInfos[2];
+ $this->lines[$i]->marque_tx = $marginInfos[2];
$i++;
}
@@ -2823,6 +2830,7 @@ class OrderLine
var $rowid;
var $fk_parent_line;
var $fk_facture;
+ var $label;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
var $product_type = 0; // Type 0 = product, 1 = Service
@@ -2851,8 +2859,10 @@ class OrderLine
var $price;
// From llx_product
- var $ref; // Reference produit
- var $product_libelle; // Label produit
+ var $ref; // deprecated
+ var $libelle; // deprecated
+ var $product_ref;
+ var $product_label; // Label produit
var $product_desc; // Description produit
// Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
@@ -2881,7 +2891,7 @@ class OrderLine
*/
function fetch($rowid)
{
- $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
+ $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
@@ -2896,6 +2906,7 @@ class OrderLine
$this->rowid = $objp->rowid;
$this->fk_commande = $objp->fk_commande;
$this->fk_parent_line = $objp->fk_parent_line;
+ $this->label = $objp->custom_label;
$this->desc = $objp->description;
$this->qty = $objp->qty;
$this->price = $objp->price;
@@ -2914,11 +2925,11 @@ class OrderLine
$this->total_localtax1 = $objp->total_localtax1;
$this->total_localtax2 = $objp->total_localtax2;
$this->total_ttc = $objp->total_ttc;
- $this->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
- $this->pa_ht = $marginInfos[0];
- $this->marge_tx = $marginInfos[1];
- $this->marque_tx = $marginInfos[2];
+ $this->fk_fournprice = $objp->fk_fournprice;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
+ $this->pa_ht = $marginInfos[0];
+ $this->marge_tx = $marginInfos[1];
+ $this->marque_tx = $marginInfos[2];
$this->special_code = $objp->special_code;
$this->rang = $objp->rang;
@@ -3015,12 +3026,13 @@ class OrderLine
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
- $sql.= ' (fk_commande, fk_parent_line, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
+ $sql.= ' (fk_commande, fk_parent_line, label, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
$sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end)';
$sql.= " VALUES (".$this->fk_commande.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
+ $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " '".price2num($this->qty)."',";
$sql.= " '".price2num($this->tva_tx)."',";
@@ -3114,6 +3126,9 @@ class OrderLine
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
$sql.= " description='".$this->db->escape($this->desc)."'";
+ if (empty($this->label)) {
+ $sql.= " , label='".$this->db->escape($this->label)."'";
+ }
$sql.= " , tva_tx=".price2num($this->tva_tx);
$sql.= " , localtax1_tx=".price2num($this->localtax1_tx);
$sql.= " , localtax2_tx=".price2num($this->localtax2_tx);
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index b76be6a5d79..a5ed509a7e6 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -520,20 +520,22 @@ else if ($action == 'addline' && $user->rights->commande->creer)
{
$langs->load('errors');
$error = false;
-var_dump($_POST); exit;
- if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0))
+
+ $idprod=GETPOST('idprod', 'int');
+
+ if ((empty($idprod) || GETPOST('update_price')) && (GETPOST('price_ht') < 0) && (GETPOST('qty') < 0))
{
- setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
+ setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
$error = true;
}
- if (! GETPOST('idprod') && GETPOST('type') < 0)
+ if (empty($idprod) && GETPOST('type') < 0)
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error = true;
}
- if (! GETPOST('idprod') && GETPOST('np_price') == '') // Unit price can be 0 but not ''
+ if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not ''
{
- setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
+ setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPriceHT'))), 'errors');
$error = true;
}
if (! GETPOST('qty') && GETPOST('qty') == '')
@@ -541,16 +543,16 @@ var_dump($_POST); exit;
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
$error = true;
}
- if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == ''))
+ if (empty($idprod) && ! GETPOST('product_desc'))
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error = true;
}
- if (!$error && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
+ if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod)))
{
// Clean parameters
- $suffixe = GETPOST('idprod') ? '_predef' : '';
+ $suffixe = (! empty($idprod) ? '_predef' : '');
$date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year'));
$date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year'));
$price_base_type = 'HT';
@@ -559,15 +561,16 @@ var_dump($_POST); exit;
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
// Ecrase $base_price_type par celui du produit
- if (GETPOST('idprod'))
+ if (! empty($idprod))
{
$prod = new Product($db);
- $prod->fetch(GETPOST('idprod'));
+ $prod->fetch($idprod);
$tva_tx = get_default_tva($mysoc,$object->client,$prod->id);
+ $tva_npr = get_default_npr($mysoc,$object->client,$prod->id);
// multiprix
- if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level)
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
{
$pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
@@ -582,6 +585,24 @@ var_dump($_POST); exit;
$price_base_type = $prod->price_base_type;
}
+ // Update if prices fields are defined
+ if (GETPOST('update_price') && (GETPOST('price_ht') || GETPOST('price_ttc')))
+ {
+ $price_ht=price2num(GETPOST('price_ht'), 'MU');
+ $price_ttc=price2num(GETPOST('price_ttc'), 'MU');
+
+ if ($price_base_type == 'TTC' && $price_ttc != $pu_ttc)
+ {
+ $pu_ttc = $price_ttc;
+ $pu_ht = price2num($price_ttc / (1 + ($prod->tva_tx / 100)),'MU');
+ }
+ else if ($price_base_type != 'TTC' && $price_ht != $pu_ht)
+ {
+ $pu_ht = $price_ht;
+ $pu_ttc = price2num($price_ht * (1 + ($prod->tva_tx / 100)),'MU');
+ }
+ }
+
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($tva_tx != $prod->tva_tx)
@@ -596,39 +617,54 @@ var_dump($_POST); exit;
}
}
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
- {
- $outputlangs = $langs;
- $newlang='';
- if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
- if (empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ if (GETPOST('update_desc')) {
+
+ $desc = (GETPOST('product_desc')?GETPOST('product_desc'):'');
+
+ } else {
+
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
+ if (empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
+ }
+ else
+ {
+ $desc = $prod->description;
+ }
+
+ $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : "";
+ $desc.= GETPOST('product_desc');
+ }
+
+ $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):'');
- $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
- }
- else
- {
- $desc = $prod->description;
- }
-
- $desc.= ($desc && GETPOST('np_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('np_desc')))?"
\n":"\n") : "";
- $desc.= GETPOST('np_desc');
$type = $prod->type;
}
else
{
- $pu_ht=GETPOST('np_price');
- $tva_tx=str_replace('*','',GETPOST('np_tva_tx'));
- $tva_npr=preg_match('/\*/',GETPOST('np_tva_tx'))?1:0;
- $desc=GETPOST('dp_desc');
+ $pu_ht=GETPOST('price_ht');
+ $tva_tx=str_replace('*','',GETPOST('tva_tx'));
+ $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0;
+ $label=(GETPOST('product_label')?GETPOST('product_label'):'');
+ $desc=GETPOST('product_desc');
$type=GETPOST('type');
}
+ // Margin
+ $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
+ $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
+
// Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $object->client);
$localtax2_tx= get_localtax($tva_tx, 2, $object->client);
@@ -638,73 +674,74 @@ var_dump($_POST); exit;
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
- if ($result >= 0)
- {
- if($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
- {
- //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min;
- $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ;
- }
- else
- {
- // Insert line
- $result = $object->addline(
- $object->id,
- $desc,
- $pu_ht,
- GETPOST('qty'),
- $tva_tx,
- $localtax1_tx,
- $localtax2_tx,
- GETPOST('idprod'),
- GETPOST('remise_percent'),
- $info_bits,
+ if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
+ {
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
+ setEventMessage($mesg, 'errors');
+ }
+ else
+ {
+ // Insert line
+ $result = $object->addline(
+ $object->id,
+ $desc,
+ $pu_ht,
+ GETPOST('qty'),
+ $tva_tx,
+ $localtax1_tx,
+ $localtax2_tx,
+ $idprod,
+ GETPOST('remise_percent'),
+ $info_bits,
+ 0,
+ $price_base_type,
+ $pu_ttc,
+ $date_start,
+ $date_end,
+ $type,
+ -1,
0,
- $price_base_type,
- $pu_ttc,
- $date_start,
- $date_end,
- $type,
- -1,
- '',
- GETPOST('fk_parent_line'),
- GETPOST('np_fournprice'),
- GETPOST('np_buying_price')
- );
-
- if ($result > 0)
- {
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
- // Define output language
- $outputlangs = $langs;
- $newlang=GETPOST('lang_id','alpha');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
-
- $ret=$object->fetch($object->id); // Reload to get new records
- commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
- }
-
- unset($_POST['qty']);
- unset($_POST['type']);
- unset($_POST['idprod']);
- unset($_POST['remise_percent']);
- unset($_POST['dp_desc']);
- unset($_POST['np_desc']);
- unset($_POST['np_price']);
- unset($_POST['np_tva_tx']);
- unset($_POST['np_buying_price']);
- }
- else
- {
- setEventMessage($object->error, 'errors');
- }
- }
+ GETPOST('fk_parent_line'),
+ $fournprice,
+ $buyingprice,
+ $label
+ );
+
+ if ($result > 0)
+ {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
+ // Define output language
+ $outputlangs = $langs;
+ $newlang=GETPOST('lang_id','alpha');
+ if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $ret=$object->fetch($object->id); // Reload to get new records
+ commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
+ }
+
+ unset($_POST['qty']);
+ unset($_POST['type']);
+ unset($_POST['idprod']);
+ unset($_POST['remise_percent']);
+ unset($_POST['price_ht']);
+ unset($_POST['price_ttc']);
+ unset($_POST['tva_tx']);
+ unset($_POST['product_ref']);
+ unset($_POST['product_label']);
+ unset($_POST['product_desc']);
+ unset($_POST['fournprice']);
+ unset($_POST['buying_price']);
+ }
+ else
+ {
+ setEventMessage($object->error, 'errors');
+ }
}
}
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index f1b2b081a64..44c1ee105d5 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -940,35 +940,38 @@ else if ($action == 'add' && $user->rights->facture->creer)
// Add a new line
else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
{
- $result=0;
+ $langs->load('errors');
+ $error = false;
- if ($_POST['np_price'] < 0 && $_POST["qty"] < 0)
+ $idprod=GETPOST('idprod', 'int');
+
+ if ((empty($idprod) || GETPOST('update_price')) && (GETPOST('price_ht') < 0) && (GETPOST('qty') < 0))
{
- $langs->load("errors");
- $mesgs[]=''.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
+ $error = true;
}
- if (empty($_POST['idprod']) && $_POST["type"] < 0)
+ if (empty($idprod) && GETPOST('type') < 0)
{
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
+ $error = true;
}
- if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
+ if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not ''
{
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPriceHT'))), 'errors');
+ $error = true;
}
- if (empty($_POST['idprod']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"]))
+ if (! GETPOST('qty') && GETPOST('qty') == '')
{
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
+ $error = true;
}
- if (! isset($_POST['qty']) || $_POST['qty']=='')
+ if (empty($idprod) && ! GETPOST('product_desc'))
{
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
';
- $result = -1 ;
+ setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
+ $error = true;
}
- if ($result >= 0 && ( ($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'] ) )
+
+ if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod)))
{
$ret=$object->fetch($id);
if ($ret < 0)
@@ -978,26 +981,26 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
$ret=$object->fetch_thirdparty();
- $suffixe = $_POST['idprod'] ? '_predef' : '';
- $date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']);
- $date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']);
-
+ // Clean parameters
+ $suffixe = (! empty($idprod) ? '_predef' : '');
+ $date_start=dol_mktime(GETPOST('date_start'.$suffixe.'hour'), GETPOST('date_start'.$suffixe.'min'), GETPOST('date_start'.$suffixe.'sec'), GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year'));
+ $date_end=dol_mktime(GETPOST('date_end'.$suffixe.'hour'), GETPOST('date_end'.$suffixe.'min'), GETPOST('date_end'.$suffixe.'sec'), GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year'));
$price_base_type = 'HT';
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
// Ecrase $base_price_type par celui du produit
- if ($_POST['idprod'])
+ if (! empty($idprod))
{
$prod = new Product($db);
- $prod->fetch($_POST['idprod']);
+ $prod->fetch($idprod);
$tva_tx = get_default_tva($mysoc,$object->client,$prod->id);
$tva_npr = get_default_npr($mysoc,$object->client,$prod->id);
// We define price for product
- if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level)
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
{
$pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
@@ -1012,6 +1015,24 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$price_base_type = $prod->price_base_type;
}
+ // Update if prices fields are defined
+ if (GETPOST('update_price') && (GETPOST('price_ht') || GETPOST('price_ttc')))
+ {
+ $price_ht=price2num(GETPOST('price_ht'), 'MU');
+ $price_ttc=price2num(GETPOST('price_ttc'), 'MU');
+
+ if ($price_base_type == 'TTC' && $price_ttc != $pu_ttc)
+ {
+ $pu_ttc = $price_ttc;
+ $pu_ht = price2num($price_ttc / (1 + ($prod->tva_tx / 100)),'MU');
+ }
+ else if ($price_base_type != 'TTC' && $price_ht != $pu_ht)
+ {
+ $pu_ht = $price_ht;
+ $pu_ttc = price2num($price_ht * (1 + ($prod->tva_tx / 100)),'MU');
+ }
+ }
+
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($tva_tx != $prod->tva_tx)
@@ -1026,28 +1047,36 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
}
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
- {
- $outputlangs = $langs;
- $newlang='';
- if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
- if (empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ if (GETPOST('update_desc')) {
+
+ $desc = (GETPOST('product_desc')?GETPOST('product_desc'):'');
+
+ } else {
+
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
+ if (empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
+ }
+ else
+ {
+ $desc = $prod->description;
+ }
+
+ $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : "";
+ $desc.= GETPOST('product_desc');
+ }
- $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
- }
- else
- {
- $desc = $prod->description;
- }
-
- $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : "";
- $desc.= $_POST['np_desc'];
if (! empty($prod->customcode) || ! empty($prod->country_code))
{
$tmptxt='(';
@@ -1057,103 +1086,107 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$tmptxt.=')';
$desc.= (dol_textishtml($desc)?"
\n":"\n").$tmptxt;
}
+
+ $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):'');
+
$type = $prod->type;
}
else
{
- $pu_ht=$_POST['np_price'];
- $tva_tx=str_replace('*','',$_POST['np_tva_tx']);
- $tva_npr=preg_match('/\*/',$_POST['np_tva_tx'])?1:0;
- $desc=$_POST['dp_desc'];
- $type=$_POST["type"];
+ $pu_ht=GETPOST('price_ht');
+ $tva_tx=str_replace('*','',GETPOST('tva_tx'));
+ $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0;
+ $label=(GETPOST('product_label')?GETPOST('product_label'):'');
+ $desc=GETPOST('product_desc');
+ $type=GETPOST('type');
}
- $localtax1_tx=get_localtax($tva_tx,1,$object->client);
- $localtax2_tx=get_localtax($tva_tx,2,$object->client);
-
- // ajout prix achat
- $fk_fournprice = $_POST['np_fournprice'];
- if ( ! empty($_POST['np_buying_price']) )
- $pa_ht = $_POST['np_buying_price'];
- else
- $pa_ht = null;
+ // Margin
+ $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
+ $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
+
+ // Local Taxes
+ $localtax1_tx= get_localtax($tva_tx, 1, $object->client);
+ $localtax2_tx= get_localtax($tva_tx, 2, $object->client);
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
- if ($result >= 0)
- {
- if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
- {
- $object->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency));
- $result = -1 ;
- }
- else
- {
- // Insert line
- $result = $object->addline(
- $id,
- $desc,
- $pu_ht,
- $_POST['qty'],
- $tva_tx,
- $localtax1_tx,
- $localtax2_tx,
- $_POST['idprod'],
- $_POST['remise_percent'],
- $date_start,
- $date_end,
- 0,
- $info_bits,
- '',
- $price_base_type,
- $pu_ttc,
- $type,
- -1,
- 0,
- '',
- 0,
- GETPOST('fk_parent_line'),
- $fk_fournprice,
- $pa_ht
- );
- }
- }
- }
+ if (! empty($price_min) && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
+ {
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
+ setEventMessage($mesg, 'errors');
+ }
+ else
+ {
+ // Insert line
+ $result = $object->addline(
+ $id,
+ $desc,
+ $pu_ht,
+ GETPOST('qty'),
+ $tva_tx,
+ $localtax1_tx,
+ $localtax2_tx,
+ $idprod,
+ GETPOST('remise_percent'),
+ $date_start,
+ $date_end,
+ 0,
+ $info_bits,
+ '',
+ $price_base_type,
+ $pu_ttc,
+ $type,
+ -1,
+ 0,
+ '',
+ 0,
+ GETPOST('fk_parent_line'),
+ $fournprice,
+ $buyingprice,
+ $label
+ );
- if ($result > 0)
- {
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
+ if ($result > 0)
+ {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
+ // Define output language
+ $outputlangs = $langs;
+ $newlang=GETPOST('lang_id','alpha');
+ if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $ret=$object->fetch($id); // Reload to get new records
+ facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
+ }
+
+ unset($_POST['qty']);
+ unset($_POST['type']);
+ unset($_POST['idprod']);
+ unset($_POST['remise_percent']);
+ unset($_POST['price_ht']);
+ unset($_POST['price_ttc']);
+ unset($_POST['tva_tx']);
+ unset($_POST['product_ref']);
+ unset($_POST['product_label']);
+ unset($_POST['product_desc']);
+ unset($_POST['fournprice']);
+ unset($_POST['buying_price']);
+ }
+ else
+ {
+ setEventMessage($object->error, 'errors');
+ }
+
+ $action='';
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
- $ret=$object->fetch($id); // Reload to get new records
- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
- }
- unset($_POST['qty']);
- unset($_POST['type']);
- unset($_POST['idprod']);
- unset($_POST['remise_percent']);
- unset($_POST['dp_desc']);
- unset($_POST['np_desc']);
- unset($_POST['np_price']);
- unset($_POST['np_tva_tx']);
- unset($_POST['np_buying_price']);
}
- else
- {
- $mesgs[]=''.$object->error.'
';
- }
-
- $action='';
}
else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
@@ -2956,13 +2989,6 @@ else if ($id > 0 || ! empty($ref))
$object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager);
- // Add predefined products/services
- if ($conf->product->enabled || $conf->service->enabled)
- {
- $var=!$var;
- $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
- }
-
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 462ba7d6289..2e2760151bf 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -363,7 +363,8 @@ class Facture extends CommonInvoice
0,
$fk_parent_line,
$this->lines[$i]->fk_fournprice,
- $this->lines[$i]->pa_ht
+ $this->lines[$i]->pa_ht,
+ $this->lines[$i]->label
);
if ($result < 0)
{
@@ -504,7 +505,6 @@ class Facture extends CommonInvoice
if ($invertdetail)
{
$facture->lines[$i]->subprice = -$facture->lines[$i]->subprice;
- //$facture->lines[$i]->price = -$facture->lines[$i]->price;
$facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht;
$facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva;
$facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1;
@@ -643,8 +643,8 @@ class Facture extends CommonInvoice
$line = new FactureLigne($this->db);
$line->libelle = $object->lines[$i]->libelle;
+ $line->label = $object->lines[$i]->label;
$line->desc = $object->lines[$i]->desc;
- //$line->price = $object->lines[$i]->price;
$line->subprice = $object->lines[$i]->subprice;
$line->total_ht = $object->lines[$i]->total_ht;
$line->total_tva = $object->lines[$i]->total_tva;
@@ -881,7 +881,7 @@ class Facture extends CommonInvoice
{
$this->lines=array();
- $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
+ $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.remise, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.rang, l.special_code,';
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
@@ -904,6 +904,7 @@ class Facture extends CommonInvoice
$line = new FactureLigne($this->db);
$line->rowid = $objp->rowid;
+ $line->label = $objp->custom_label;
$line->desc = $objp->description; // Description line
$line->product_type = $objp->product_type; // Type of line
$line->product_ref = $objp->product_ref; // Ref product
@@ -931,11 +932,11 @@ class Facture extends CommonInvoice
$line->total_ttc = $objp->total_ttc;
$line->export_compta = $objp->fk_export_compta;
$line->code_ventilation = $objp->fk_code_ventilation;
- $line->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
- $line->pa_ht = $marginInfos[0];
- $line->marge_tx = $marginInfos[1];
- $line->marque_tx = $marginInfos[2];
+ $line->fk_fournprice = $objp->fk_fournprice;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
+ $line->pa_ht = $marginInfos[0];
+ $line->marge_tx = $marginInfos[1];
+ $line->marque_tx = $marginInfos[2];
$line->rang = $objp->rang;
$line->special_code = $objp->special_code;
$line->fk_parent_line = $objp->fk_parent_line;
@@ -1871,7 +1872,7 @@ class Facture extends CommonInvoice
* @param int $pa_ht Buying price of line
* @return int <0 if KO, Id of line if OK
*/
- function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0)
+ function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='')
{
dol_syslog(get_class($this)."::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
@@ -1908,7 +1909,7 @@ class Facture extends CommonInvoice
// Check parameters
if ($type < 0) return -1;
- if ($this->brouillon)
+ if (! empty($this->brouillon))
{
$this->db->begin();
@@ -1943,6 +1944,7 @@ class Facture extends CommonInvoice
// Insert line
$this->line=new FactureLigne($this->db);
$this->line->fk_facture=$facid;
+ $this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty= ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->tva_tx=$txtva;
@@ -2025,7 +2027,7 @@ class Facture extends CommonInvoice
* @param int $pa_ht Buying price of line
* @return int < 0 if KO, > 0 if OK
*/
- function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0)
+ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='')
{
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
@@ -2089,6 +2091,7 @@ class Facture extends CommonInvoice
}
$this->line->rowid = $rowid;
+ $this->line->label = $label;
$this->line->desc = $desc;
$this->line->qty= ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->tva_tx = $txtva;
@@ -2996,7 +2999,7 @@ class Facture extends CommonInvoice
*/
function getLinesArray()
{
- $sql = 'SELECT l.rowid, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,';
+ $sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,';
$sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,';
$sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
@@ -3019,6 +3022,7 @@ class Facture extends CommonInvoice
$obj = $this->db->fetch_object($resql);
$this->lines[$i]->id = $obj->rowid;
+ $this->lines[$i]->label = $obj->custom_label;
$this->lines[$i]->description = $obj->description;
$this->lines[$i]->fk_product = $obj->fk_product;
$this->lines[$i]->ref = $obj->product_ref;
@@ -3044,7 +3048,7 @@ class Facture extends CommonInvoice
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht);
$this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1];
- $this->lines[$i]->marque_tx = $marginInfos[2];
+ $this->lines[$i]->marque_tx = $marginInfos[2];
$i++;
}
@@ -3082,6 +3086,7 @@ class FactureLigne
var $fk_facture;
//! Id parent line
var $fk_parent_line;
+ var $label;
//! Description ligne
var $desc;
var $fk_product; // Id of predefined product
@@ -3160,7 +3165,7 @@ class FactureLigne
*/
function fetch($rowid)
{
- $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.description, fd.price, fd.qty, fd.tva_tx,';
+ $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.tva_tx,';
$sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
$sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,';
$sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,';
@@ -3178,6 +3183,7 @@ class FactureLigne
$this->rowid = $objp->rowid;
$this->fk_facture = $objp->fk_facture;
$this->fk_parent_line = $objp->fk_parent_line;
+ $this->label = $objp->label;
$this->desc = $objp->description;
$this->qty = $objp->qty;
$this->subprice = $objp->subprice;
@@ -3199,15 +3205,11 @@ class FactureLigne
$this->fk_code_ventilation = $objp->fk_code_ventilation;
$this->fk_export_compta = $objp->fk_export_compta;
$this->rang = $objp->rang;
- $this->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
- $this->pa_ht = $marginInfos[0];
- $this->marge_tx = $marginInfos[1];
- $this->marque_tx = $marginInfos[2];
-
- // Ne plus utiliser
- //$this->price = $objp->price;
- //$this->remise = $objp->remise;
+ $this->fk_fournprice = $objp->fk_fournprice;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
+ $this->pa_ht = $marginInfos[0];
+ $this->marge_tx = $marginInfos[1];
+ $this->marque_tx = $marginInfos[2];
$this->ref = $objp->product_ref; // deprecated
$this->product_ref = $objp->product_ref;
@@ -3245,11 +3247,9 @@ class FactureLigne
if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0;
if (empty($this->rang)) $this->rang=0;
- //if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->subprice)) $this->subprice=0;
- //if (empty($this->price)) $this->price=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
@@ -3268,13 +3268,14 @@ class FactureLigne
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
- $sql.= ' (fk_facture, fk_parent_line, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
+ $sql.= ' (fk_facture, fk_parent_line, label, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
$sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,';
$sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, ';
$sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)';
$sql.= " VALUES (".$this->fk_facture.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
+ $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".price2num($this->tva_tx).",";
@@ -3398,7 +3399,6 @@ class FactureLigne
if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->total_localtax1)) $this->total_localtax1=0;
if (empty($this->total_localtax2)) $this->total_localtax2=0;
- //if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->product_type)) $this->product_type=0;
@@ -3420,9 +3420,10 @@ class FactureLigne
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
$sql.= " description='".$this->db->escape($this->desc)."'";
+ if (! empty($this->label)) {
+ $sql.= " , label='".$this->db->escape($this->label)."'";
+ }
$sql.= ",subprice=".price2num($this->subprice)."";
- //$sql.= ",price=".price2num($this->price)."";
- //$sql.= ",remise=".price2num($this->remise)."";
$sql.= ",remise_percent=".price2num($this->remise_percent)."";
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
else $sql.= ",fk_remise_except=null";
diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php
index 7688f969828..23077b3e5b5 100644
--- a/htdocs/core/tpl/freeproductline_create.tpl.php
+++ b/htdocs/core/tpl/freeproductline_create.tpl.php
@@ -214,6 +214,9 @@ $(document).ready(function() {
} else {
$('#product_desc').focus();
}
+
+ } else {
+ $('#update_desc_checkbox').removeAttr('checked').trigger('change');
}
});
diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
index 3685e5a56e3..404e036f866 100755
--- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
+++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
@@ -73,4 +73,5 @@ INSERT INTO llx_const (name, value, type, note, visible) values ('PRODUCT_CODEPR
ALTER TABLE llx_c_barcode_type ADD UNIQUE INDEX uk_c_barcode_type(code, entity);
ALTER TABLE llx_propaldet ADD COLUMN label varchar(255) DEFAULT NULL AFTER fk_product;
-
+ALTER TABLE llx_commandedet ADD COLUMN label varchar(255) DEFAULT NULL AFTER fk_product;
+ALTER TABLE llx_facturedet ADD COLUMN label varchar(255) DEFAULT NULL AFTER fk_product;
diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql
index 36318a566e7..42a9bb1845d 100644
--- a/htdocs/install/mysql/tables/llx_commandedet.sql
+++ b/htdocs/install/mysql/tables/llx_commandedet.sql
@@ -1,7 +1,8 @@
-- ===================================================================
--- Copyright (C) 2003 Rodolphe Quiedeville
--- Copyright (C) 2006-2009 Laurent Destailleur
--- Copyright (C) 2010 Juanjo Menent
+-- Copyright (C) 2003 Rodolphe Quiedeville
+-- Copyright (C) 2005-2012 Regis Houssin
+-- Copyright (C) 2006-2009 Laurent Destailleur
+-- Copyright (C) 2010 Juanjo Menent
--
-- 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
@@ -20,34 +21,36 @@
create table llx_commandedet
(
- rowid integer AUTO_INCREMENT PRIMARY KEY,
- fk_commande integer NOT NULL,
- fk_parent_line integer NULL,
- fk_product integer NULL,
- description text,
- tva_tx double(6,3), -- vat rate
- localtax1_tx double(6,3), -- localtax1 rate
- localtax2_tx double(6,3), -- localtax2 rate
- qty real, -- quantity
- remise_percent real DEFAULT 0, -- pourcentage de remise
- remise real DEFAULT 0, -- montant de la remise
- fk_remise_except integer NULL, -- Lien vers table des remises fixes
- price real, -- prix final
- subprice double(24,8) DEFAULT 0, -- prix unitaire
- total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale
- total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale
- total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1
- total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2
- total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
- product_type integer DEFAULT 0,
- date_start datetime DEFAULT NULL, -- date debut si service
- date_end datetime DEFAULT NULL, -- date fin si service
- info_bits integer DEFAULT 0, -- TVA NPR ou non
- buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT
- fk_product_fournisseur_price int(11) DEFAULT NULL, -- référence prix fournisseur
- special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
- rang integer DEFAULT 0,
- import_key varchar(14)
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ fk_commande integer NOT NULL,
+ fk_parent_line integer NULL,
+ fk_product integer NULL,
+ label varchar(255) DEFAULT NULL,
+ description text,
+ tva_tx double(6,3), -- vat rate
+ localtax1_tx double(6,3), -- localtax1 rate
+ localtax2_tx double(6,3), -- localtax2 rate
+ qty real, -- quantity
+ remise_percent real DEFAULT 0, -- pourcentage de remise
+ remise real DEFAULT 0, -- montant de la remise
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
+ price real, -- prix final
+ subprice double(24,8) DEFAULT 0, -- prix unitaire
+ total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale
+ total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale
+ total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1
+ total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2
+ total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
+ product_type integer DEFAULT 0,
+ date_start datetime DEFAULT NULL, -- date debut si service
+ date_end datetime DEFAULT NULL, -- date fin si service
+ info_bits integer DEFAULT 0, -- TVA NPR ou non
+ buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT
+ fk_product_fournisseur_price int(11) DEFAULT NULL, -- reference prix fournisseur
+ special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
+ rang integer DEFAULT 0,
+ import_key varchar(14)
+
)ENGINE=innodb;
--
diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql
index f2dba3e600e..8ccfeb35fb7 100644
--- a/htdocs/install/mysql/tables/llx_facturedet.sql
+++ b/htdocs/install/mysql/tables/llx_facturedet.sql
@@ -1,8 +1,8 @@
-- ===================================================================
--- Copyright (C) 2001-2005 Rodolphe Quiedeville
--- Copyright (C) 2004-2005 Laurent Destailleur
--- Copyright (C) 2005-2010 Regis Houssin
--- Copyright (C) 2010 Juanjo Menent
+-- Copyright (C) 2001-2005 Rodolphe Quiedeville
+-- Copyright (C) 2004-2005 Laurent Destailleur
+-- Copyright (C) 2005-2012 Regis Houssin
+-- Copyright (C) 2010 Juanjo Menent
--
-- 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
@@ -22,36 +22,38 @@
create table llx_facturedet
(
- rowid integer AUTO_INCREMENT PRIMARY KEY,
- fk_facture integer NOT NULL,
- fk_parent_line integer NULL,
- fk_product integer NULL, -- Doit pouvoir etre nul pour ligne detail sans produits
- description text,
- tva_tx double(6,3), -- Taux tva produit/service (exemple 19.6)
- localtax1_tx double(6,3) DEFAULT 0, -- tax local tax 1
- localtax2_tx double(6,3) DEFAULT 0, -- tax local tax 2
- qty real, -- Quantity (exemple 2)
- remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)
- remise real DEFAULT 0, -- Montant calcule de la remise % sur PU HT (exemple 20)
- fk_remise_except integer NULL, -- Lien vers table des remises fixes
- subprice double(24,8), -- P.U. HT (exemple 100)
- price double(24,8), -- P.U. HT apres remise % de ligne
- total_ht double(24,8), -- Total HT de la ligne toute quantite et incluant remise ligne et globale
- total_tva double(24,8), -- Total TVA de la ligne toute quantite et incluant remise ligne et globale
- total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line
- total_localtax2 double(24,8) DEFAULT 0, -- total LocalTax2 for total quantity of line
- total_ttc double(24,8), -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
- product_type integer DEFAULT 0,
- date_start datetime DEFAULT NULL, -- date debut si service
- date_end datetime DEFAULT NULL, -- date fin si service
- info_bits integer DEFAULT 0, -- TVA NPR ou non
- buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT
- fk_product_fournisseur_price int(11) DEFAULT NULL, -- référence prix fournisseur
- fk_code_ventilation integer DEFAULT 0 NOT NULL,
- fk_export_compta integer DEFAULT 0 NOT NULL,
- special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
- rang integer DEFAULT 0, -- ordre d'affichage
- import_key varchar(14)
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ fk_facture integer NOT NULL,
+ fk_parent_line integer NULL,
+ fk_product integer NULL, -- Doit pouvoir etre nul pour ligne detail sans produits
+ label varchar(255) DEFAULT NULL,
+ description text,
+ tva_tx double(6,3), -- Taux tva produit/service (exemple 19.6)
+ localtax1_tx double(6,3) DEFAULT 0, -- tax local tax 1
+ localtax2_tx double(6,3) DEFAULT 0, -- tax local tax 2
+ qty real, -- Quantity (exemple 2)
+ remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)
+ remise real DEFAULT 0, -- Montant calcule de la remise % sur PU HT (exemple 20)
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
+ subprice double(24,8), -- P.U. HT (exemple 100)
+ price double(24,8), -- P.U. HT apres remise % de ligne
+ total_ht double(24,8), -- Total HT de la ligne toute quantite et incluant remise ligne et globale
+ total_tva double(24,8), -- Total TVA de la ligne toute quantite et incluant remise ligne et globale
+ total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line
+ total_localtax2 double(24,8) DEFAULT 0, -- total LocalTax2 for total quantity of line
+ total_ttc double(24,8), -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
+ product_type integer DEFAULT 0,
+ date_start datetime DEFAULT NULL, -- date debut si service
+ date_end datetime DEFAULT NULL, -- date fin si service
+ info_bits integer DEFAULT 0, -- TVA NPR ou non
+ buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT
+ fk_product_fournisseur_price int(11) DEFAULT NULL, -- reference prix fournisseur
+ fk_code_ventilation integer DEFAULT 0 NOT NULL,
+ fk_export_compta integer DEFAULT 0 NOT NULL,
+ special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
+ rang integer DEFAULT 0, -- ordre d'affichage
+ import_key varchar(14)
+
)ENGINE=innodb;
--