diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 430f71ae540..104c0215c2f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -435,12 +435,12 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); - $array_option = $lines[$i]->array_options; + $array_options = $lines[$i]->array_options; } $tva_tx=get_default_tva($mysoc, $object->thirdparty); - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options); if ($result > 0) { $lineid = $result; @@ -652,7 +652,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -812,7 +812,7 @@ if (empty($reshook)) setEventMessage($mesg, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options); if ($result > 0) { $db->commit(); @@ -895,7 +895,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -940,7 +940,7 @@ if (empty($reshook)) if (! $error) { $db->begin(); - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options); if ($result >= 0) { $db->commit(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index dc1184b7490..189c6101594 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -314,12 +314,12 @@ class Propal extends CommonObject * @param string $label ??? * @param int $date_start Start date of the line * @param int $date_end End date of the line - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0) { global $mysoc; @@ -440,8 +440,8 @@ class Propal extends CommonObject $this->line->price=$price; $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->insert(); @@ -496,10 +496,10 @@ class Propal extends CommonObject * @param int $type 0/1=Product/service * @param int $date_start Start date of the line * @param int $date_end End date of the line - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0) { global $mysoc; @@ -601,8 +601,8 @@ class Propal extends CommonObject $this->line->price=$price; $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->update(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6696dffed21..5f57170eef5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -343,10 +343,10 @@ if (empty($reshook)) // trigger used { $lines[$i]->fetch_optionals($lines[$i]->rowid); - $array_option = $lines[$i]->array_options; + $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options); if ($result < 0) { $error ++; @@ -561,7 +561,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -734,7 +734,7 @@ if (empty($reshook)) setEventMessage($mesg, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -821,7 +821,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -859,7 +859,7 @@ if (empty($reshook)) } if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1687,9 +1687,7 @@ if ($action == 'create' && $user->rights->commande->creer) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); } - /* - * Confirmation de la suppression d'une ligne produit - */ + // Confirmation to delete line if ($action == 'ask_deleteline') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1817ea4a992..c1c0fa9ec4e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1101,7 +1101,7 @@ class Commande extends CommonOrder * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) * @param string $label Label - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int >0 if OK, <0 if KO * * @see add_product @@ -1111,7 +1111,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($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='',$array_option=0) + function addline($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='',$array_options=0) { global $mysoc, $conf, $langs; @@ -1250,8 +1250,8 @@ class Commande extends CommonOrder $this->line->price=$price; $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->insert(); @@ -2346,10 +2346,10 @@ class Commande extends CommonOrder * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label * @param int $special_code Special code (also used by externals modules!) - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.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='', $special_code=0, $array_option=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.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='', $special_code=0, $array_options=0) { global $conf, $mysoc; @@ -2458,8 +2458,8 @@ class Commande extends CommonOrder $this->line->price=$price; $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->update(); @@ -3516,7 +3516,7 @@ class OrderLine extends CommonOrderLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEORDER_INSERT',$user); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index dd440c6d547..fa7f50c0628 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1061,10 +1061,10 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); - $array_option = $lines[$i]->array_options; + $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id); if ($result > 0) { $lineid = $result; @@ -1196,7 +1196,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1374,7 +1374,7 @@ if (empty($reshook)) setEventMessage($mesg, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $_POST['progress']); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress']); if ($result > 0) { @@ -1469,7 +1469,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1528,7 +1528,7 @@ if (empty($reshook)) // Update line if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option, GETPOST('progress')); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options, GETPOST('progress')); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0c277014a64..4fbdddd5703 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2034,12 +2034,12 @@ class Facture extends CommonInvoice * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' * @param string $label Label of the line (deprecated, do not use) - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @param int $situation_percent Situation advance percentage * @param int $fk_prev_id Previous situation line id reference * @return int <0 if KO, Id of line if OK */ - function addline($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=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='') + function addline($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=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='') { global $mysoc, $conf, $langs; @@ -2162,8 +2162,8 @@ class Facture extends CommonInvoice $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->insert(); @@ -2217,11 +2217,11 @@ class Facture extends CommonInvoice * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label of the line (deprecated, do not use) * @param int $special_code Special code (also used by externals modules!) - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @param int $situation_percent Situation advance percentage * @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= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0, $situation_percent=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= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2322,8 +2322,8 @@ class Facture extends CommonInvoice } $this->line->pa_ht = $pa_ht; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->update(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3948418312f..2674d30c57d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) { // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); -// fetch optionals attributes lines and labels +// fetch optionals attributes lines and labels $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -416,7 +416,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -538,7 +538,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $info_bits, $fk_fournprice, $pa_ht, - $array_option + $array_options ); } @@ -638,9 +638,9 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - $objectline->array_options=$array_option; - + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $objectline->array_options=$array_options; + // TODO verifier price_min si fk_product et multiprix $result=$objectline->update($user); @@ -1416,8 +1416,8 @@ else print ''; print ''; } - - + + //Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; @@ -1483,7 +1483,7 @@ else print '
'.$langs->trans("DateEndPlanned").' '; $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update"); print ''; - + if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; $line = new ContratLigne($db); @@ -1491,7 +1491,7 @@ else print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan)); print ''; } - + print ''; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index bb00a5d9838..0a93dc07701 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1239,10 +1239,10 @@ class Contrat extends CommonObject * @param int $info_bits Bits de type de lignes * @param int $fk_fournprice Fourn price id * @param int $pa_ht Buying price HT - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int <0 si erreur, >0 si ok */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_option=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0) { global $user, $langs, $conf, $mysoc; @@ -1350,11 +1350,11 @@ class Contrat extends CommonObject $result=$this->update_statut($user); if ($result > 0) { - - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_option) && count($array_option)>0) // For avoid conflicts if trigger used + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_option; + $contractline->array_options=$array_options; $contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element); $result=$contractline->insertExtraFields(); if ($result < 0) @@ -1363,7 +1363,7 @@ class Contrat extends CommonObject $error++; } } - + if (empty($error)) { // Call trigger $result=$this->call_trigger('LINECONTRACT_CREATE',$user); @@ -1373,7 +1373,7 @@ class Contrat extends CommonObject return -1; } // End call triggers - + $this->db->commit(); return 1; } @@ -1417,10 +1417,10 @@ class Contrat extends CommonObject * @param int $info_bits Bits de type de lignes * @param int $fk_fournprice Fourn price id * @param int $pa_ht Buying price HT - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_option=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0) { global $user, $conf, $langs, $mysoc; @@ -1520,8 +1520,8 @@ class Contrat extends CommonObject $result=$this->update_statut($user); if ($result >= 0) { - - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_option) && count($array_option)>0) // For avoid conflicts if trigger used + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); $contractline->array_options=$array_option; @@ -1533,7 +1533,7 @@ class Contrat extends CommonObject $error++; } } - + if (empty($error)) { // Call trigger $result=$this->call_trigger('LINECONTRACT_UPDATE',$user); @@ -1543,7 +1543,7 @@ class Contrat extends CommonObject return -3; } // End call triggers - + $this->db->commit(); return 1; } @@ -1597,7 +1597,7 @@ class Contrat extends CommonObject $this->error="Error ".$this->db->lasterror(); $error++; } - + if (empty($error)) { // Remove extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used @@ -2522,10 +2522,10 @@ class ContratLigne extends CommonObject $error++; //return -1; } - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used { - + $result=$this->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php new file mode 100644 index 00000000000..825bdac1615 --- /dev/null +++ b/htdocs/core/actions_lineupdown.inc.php @@ -0,0 +1,73 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_lineupdown.inc.php + * \brief Code for actions on moving lines up or down onto object page + */ + + +// $action must be defined +// $permissiontoedit must be defined to permission to edit object +// $object must be defined +// $langs must be defined +// $hidedetails, $hidedesc, $hideref must de defined + +if ($action == 'up' && $permissiontoedit) +{ + $object->line_up(GETPOST('rowid')); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); + exit(); +} + +if ($action == 'down' && $permissiontoedit) +{ + $object->line_down(GETPOST('rowid')); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); + exit(); +} + diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 1746db04abf..661ffc9af30 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -206,9 +206,9 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) // Extrafields $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $array_option = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($extralabels); - $object->array_options = $array_option; + $object->array_options = $array_options; $id = $object->create($user); @@ -288,7 +288,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); $result = $object->addline( @@ -297,7 +297,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $desc, $date_intervention, $duration, - $array_option + $array_options ); if ($result < 0) @@ -327,9 +327,9 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) // Extrafields $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $array_option = $extrafields->getOptionalsFromPost($extralabels); + $array_options = $extrafields->getOptionalsFromPost($extralabels); - $object->array_options = $array_option; + $object->array_options = $array_options; $result = $object->create($user); if ($result > 0) @@ -470,7 +470,7 @@ else if ($action == "addline" && $user->rights->ficheinter->creer) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); $result=$object->addline( $user, @@ -478,7 +478,7 @@ else if ($action == "addline" && $user->rights->ficheinter->creer) $desc, $date_intervention, $duration, - $array_option + $array_options ); // Define output language @@ -568,8 +568,8 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST( // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - $objectline->array_options = $array_option; + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $objectline->array_options = $array_options; $result = $objectline->update($user); if ($result < 0) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6ec66add085..7be3b0bf3bd 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -889,10 +889,10 @@ class Fichinter extends CommonObject * @param string $desc Line description * @param date $date_intervention Intervention date * @param int $duration Intervention duration - * @param array $array_option Array option + * @param array $array_options Array option * @return int >0 if ok, <0 if ko */ - function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option='') + function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_options='') { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); @@ -908,8 +908,8 @@ class Fichinter extends CommonObject $line->datei = $date_intervention; $line->duration = $duration; - if (is_array($array_option) && count($array_option)>0) { - $line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $line->array_options=$array_options; } $result=$line->insert($user); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 57a9a2806c3..14ba275d044 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1122,10 +1122,10 @@ class CommandeFournisseur extends CommonOrder * @param bool $notrigger Disable triggers * @param int $date_start Date start of service * @param int $date_end Date end of service - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int <=0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_option=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0) { global $langs,$mysoc; @@ -1260,7 +1260,19 @@ class CommandeFournisseur extends CommonOrder { $this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande_fournisseurdet'); - if (! $notrigger) + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $linetmp = new CommandeFournisseurLigne($this->db); + $linetmp->id=$this->rowid; + $linetmp->array_options = $array_options; + $result=$linetmp->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $error && ! $notrigger) { global $conf, $langs, $user; // Call trigger @@ -1399,51 +1411,53 @@ class CommandeFournisseur extends CommonOrder * * @param int $idline Id of line to delete * @param int $notrigger 1=Disable call to triggers - * @return >=0 if OK, <0 if KO + * @return <0 if KO, >0 if OK */ function deleteline($idline, $notrigger=0) { global $user,$langs,$conf; - if ($this->statut == 0) + + if ($this->statut != 0) { - $this->db->begin(); + return -1; + } - if (! $notrigger) + $this->db->begin(); + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline; + $resql=$this->db->query($sql); + + dol_syslog(get_class($this)."::deleteline sql=".$sql); + if (! $resql) { - // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user); - if ($result < 0) $error++; - // End call triggers + $this->error=$this->db->lasterror(); + $error++; } + } - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline; - $resql=$this->db->query($sql); + if (! $error) + { + $result=$this->update_price(); + } - dol_syslog(get_class($this)."::deleteline sql=".$sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $error++; - } - } - - if (! $error) - { - $result=$this->update_price(); - - $this->db->commit(); - return 0; - } - else - { - $this->db->rollback(); - return -1; - } + if (! $error) + { + $this->db->commit(); + return 1; } else - { + { + $this->db->rollback(); return -1; } } @@ -1779,10 +1793,10 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger Disable triggers * @param timestamp $date_start Date start of service * @param timestamp $date_end Date end of service - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int < 0 if error, > 0 if ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_option=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0) { global $mysoc; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type"); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1adeb714792..cada8c42af9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1115,12 +1115,12 @@ class FactureFournisseur extends CommonInvoice * @param int $type Type of line (0=product, 1=service) * @param int $rang Position of line * @param int $notrigger Disable triggers - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int >0 if OK, <0 if KO * * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. */ - function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_option=0) + function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0) { dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1157,7 +1157,7 @@ class FactureFournisseur extends CommonInvoice { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); - $result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true); + $result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options); if ($result > 0) { $this->rowid = $idligne; @@ -1211,10 +1211,10 @@ class FactureFournisseur extends CommonInvoice * @param int $notrigger Disable triggers * @param timestamp $date_start Date start of service * @param timestamp $date_end Date end of service - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_option=0) + function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0) { global $mysoc; dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); @@ -1295,7 +1295,19 @@ class FactureFournisseur extends CommonInvoice { $this->rowid = $id; - if (! $notrigger) + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $linetmp = new FactureFournisseurLigne($this->db); + $linetmp->id=$this->rowid; + $linetmp->array_options = $array_options; + $result=$linetmp->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $error && ! $notrigger) { global $conf, $langs, $user; // Call trigger @@ -1328,7 +1340,7 @@ class FactureFournisseur extends CommonInvoice * * @param int $rowid Id of line to delete * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return void + * @return int <0 if KO, >0 if OK */ function deleteline($rowid, $notrigger=0) { @@ -1366,7 +1378,7 @@ class FactureFournisseur extends CommonInvoice if (! $error) { // Mise a jour prix facture - $this->update_price(); + $result=$this->update_price(); } if (! $error) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8b5cef74098..0fe73c981f4 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -229,7 +229,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -442,7 +442,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -507,37 +507,37 @@ if (empty($reshook)) } } - if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) + // Remove a product line + if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { + $result = $object->deleteline($lineid); + if ($result > 0) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } - $result = $object->deleteline(GETPOST('lineid')); - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - $error++; - setEventMessage($object->error, 'errors'); - } - - if (! $error) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; - } + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ + $action=''; + } } if ($action == 'confirm_valid' && $confirm == 'yes' && @@ -1352,12 +1352,14 @@ elseif (! empty($object->id)) dol_fiche_head($head, 'card', $title, 0, 'order'); + $formconfirm=''; + /* * Confirmation de la suppression de la commande */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); } @@ -1369,7 +1371,7 @@ elseif (! empty($object->id)) //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1) ); // Paiement incomplet. On demande si motif = escompte ou autre - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); } @@ -1400,7 +1402,7 @@ elseif (! empty($object->id)) $text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid); } - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1); } } @@ -1433,7 +1435,7 @@ elseif (! empty($object->id)) ); } - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$object->ref),"confirm_approve", $formquestion, 1, 1, 240); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$object->ref),"confirm_approve", $formquestion, 1, 1, 240); } @@ -1442,7 +1444,7 @@ elseif (! empty($object->id)) */ if ($action == 'refuse') { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1); } @@ -1451,7 +1453,7 @@ elseif (! empty($object->id)) */ if ($action == 'cancel') { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1); } @@ -1461,19 +1463,24 @@ elseif (! empty($object->id)) if ($action == 'commande') { $date_com = dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2); } - /* - * Confirmation de la suppression d'une ligne produit - */ - if ($action == 'delete_product_line') + // Confirmation to delete line + if ($action == 'ask_deleteline') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline','',0,2); - + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } + if (!$formconfirm) { + $parameters=array('lineid'=>$lineid); + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + + // Print form confirm + print $formconfirm; + /* * Commande */ @@ -1718,6 +1725,10 @@ elseif (! empty($object->id)) print ''; + // Add free products/services form + global $forceall, $senderissupplier, $dateSelector; + $forceall=1; $senderissupplier=1; $dateSelector=0; + // Show object lines $inputalsopricewithtax=1; if (! empty($object->lines)) @@ -1904,19 +1915,18 @@ elseif (! empty($object->id)) } */ // Form to add new line - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'editline') + if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { - // Add free products/services form - global $forceall, $senderissupplier, $dateSelector; - $forceall=1; $senderissupplier=1; $dateSelector=0; + if ($action != 'editline') + { + $var = true; - $var = true; + // Add free products/services + $object->formAddObjectLine(1, $societe, $mysoc); - // Add free products/services - $object->formAddObjectLine(1, $societe, $mysoc); - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } } print '
'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 8875e56800c..c2628b0cd0c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -187,13 +187,29 @@ if (empty($reshook)) } } - elseif ($action == 'confirm_delete_line' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) + // Remove a product line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { - $object->fetch($id); - $ret = $object->deleteline(GETPOST('lineid')); - if ($ret > 0) + $result = $object->deleteline($lineid); + if ($result > 0) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else @@ -555,7 +571,7 @@ if (empty($reshook)) // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -613,7 +629,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1589,12 +1605,6 @@ else dol_fiche_head($head, 'card', $titre, 0, 'bill'); - // Confirmation de la suppression d'une ligne produit - if ($action == 'confirm_delete_line') - { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_delete_line', '', 1, 1); - } - // Clone confirmation if ($action == 'clone') { @@ -1678,7 +1688,13 @@ else } - if (!$formconfirm) { + // Confirmation to delete line + if ($action == 'ask_deleteline') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + } + + if (!$formconfirm) { $parameters=array('lineid'=>$lineid); $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } @@ -2026,6 +2042,9 @@ else print ''; + global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; + $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; + // Show object lines if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->facture->creer); @@ -2215,22 +2234,17 @@ else } */ // Form to add new line - if ($object->statut == 0 && $action != 'editline') - { - global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; - if ($object->statut == 0 && $user->rights->fournisseur->facture->creer) + if ($object->statut == 0 && $user->rights->fournisseur->facture->creer) + { + if ($action != 'editline') { - if ($action != 'editline') - { - $var = true; + $var = true; - // Add free products/services - $object->formAddObjectLine(1, $societe, $mysoc); + // Add free products/services + $object->formAddObjectLine(1, $societe, $mysoc); - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } }