From 8b02d9e912320b7a54275e6423c2da9c4d5a5c5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Oct 2012 21:37:06 +0200 Subject: [PATCH] Fix: Can edit qty of an option --- htdocs/commande/fiche.php | 5 +++++ htdocs/compta/facture.php | 13 +++++++++++-- htdocs/compta/facture/class/facture.class.php | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 7da88461ee6..43d4a52b1ae 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -738,6 +738,11 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['s $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; $result = -1 ; } + + // Define special_code for special lines + $special_code=0; + if (empty($_POST['qty'])) $special_code=3; + // Check minimum price if(! empty($_POST['productid'])) { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 41e9c6abf01..a0c7591cc34 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -980,7 +980,11 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $price_base_type = 'HT'; - // Ecrase $pu par celui du produit + // Define special_code for special lines + $special_code=0; + //if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + + // 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 @@ -1099,7 +1103,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc, $type, -1, - 0, + $special_code, '', 0, GETPOST('fk_parent_line') @@ -1171,6 +1175,11 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; $result = -1 ; } + + // Define special_code for special lines + $special_code=0; + //if (empty($_POST['qty'])) $special_code=3; // Option should not exists onto invoices + // Check minimum price if (GETPOST('productid')) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 15c05c36ea7..032f49848e8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2017,9 +2017,10 @@ class Facture extends CommonObject * @param int $type Type of line (0=product, 1=service) * @param int $fk_parent_line ??? * @param int $skip_update_total ??? + * @param int $special_code Special code * @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) + 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, $special_code=0) { include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); @@ -2100,6 +2101,7 @@ class Facture extends CommonObject $this->line->product_type = $type; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; + $this->line->special_code = $special_code; // A ne plus utiliser //$this->line->price=$price; @@ -3632,6 +3634,7 @@ class FactureLigne //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->special_code)) $this->special_code=0; if (empty($this->product_type)) $this->product_type=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; @@ -3659,6 +3662,7 @@ class FactureLigne else { $sql.=',date_end=null'; } $sql.= ",product_type=".$this->product_type; $sql.= ",info_bits='".$this->info_bits."'"; + $sql.= ",special_code='".$this->special_code."'"; if (empty($this->skip_update_total)) { $sql.= ",total_ht=".price2num($this->total_ht)."";