diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3b2b4be54e4..b818fde5c5c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -775,8 +775,16 @@ if (empty($reshook)) } } } - } // Add line - elseif ($action == 'addline' && $usercancreate) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + // Define vat_rate + $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); + $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); + foreach($object->lines as $line) { + $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } + } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 72efdf89dc6..ccaabcbe765 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -725,15 +725,15 @@ class Propal extends CommonObject /** * Update a proposal line * - * @param int $rowid Id de la ligne - * @param float $pu Prix unitaire (HT ou TTC selon price_base_type) + * @param int $rowid Id of line + * @param float $pu Unit price (HT or TTC depending on price_base_type) * @param float $qty Quantity - * @param float $remise_percent Remise effectuee sur le produit - * @param float $txtva Taux de TVA + * @param float $remise_percent Discount on line + * @param float $txtva VAT Rate (Can be '1.23' or '1.23 (ABC)') * @param float $txlocaltax1 Local tax 1 rate * @param float $txlocaltax2 Local tax 2 rate * @param string $desc Description - * @param string $price_base_type HT ou TTC + * @param string $price_base_type HT or TTC * @param int $info_bits Miscellaneous informations * @param int $special_code Special code (also used by externals modules!) * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). @@ -4121,6 +4121,8 @@ class PropaleLigne extends CommonObjectLine $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. + if (empty($this->id) && ! empty($this->rowid)) $this->id = $this->rowid; + // Clean parameters if (empty($this->tva_tx)) $this->tva_tx = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; @@ -4194,7 +4196,7 @@ class PropaleLigne extends CommonObjectLine $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql .= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -4202,7 +4204,6 @@ class PropaleLigne extends CommonObjectLine { if (!$error) { - $this->id = $this->rowid; $result = $this->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f9288f49d20..becaaf2b6bf 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -624,10 +624,16 @@ if (empty($reshook)) $result = $object->set_remise($user, GETPOST('remise_percent')); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); - } - - // Add a new line - elseif ($action == 'addline' && $usercancreate) + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + // Define vat_rate + $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); + $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); + foreach($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } + } elseif ($action == 'addline' && $usercancreate) // Add a new line { $langs->load('errors'); $error = 0; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c62bb4fc1e7..5bd4f3345e2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1867,8 +1867,16 @@ if (empty($reshook)) $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); } - } // Add a new line - elseif ($action == 'addline' && $usercancreate) + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + // Define vat_rate + $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); + $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); + foreach($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); + } + } elseif ($action == 'addline' && $usercancreate) // Add a new line { $langs->load('errors'); $error = 0; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index f04bfc50da8..886f921d4dd 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -59,7 +59,19 @@ if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' } // VAT -print '