From 1e0d7d92a956d36c4b6f67a8178bb5d60577a5e6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 14:09:18 +0100 Subject: [PATCH 01/13] NEW : addline with position choice when MAIN_VIEW_LINE_NUMBER is enabled --- htdocs/comm/propal/card.php | 3 ++- htdocs/comm/propal/class/propal.class.php | 5 +++++ htdocs/commande/card.php | 3 ++- htdocs/commande/class/commande.class.php | 5 +++++ htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 5 +++++ htdocs/core/tpl/objectline_create.tpl.php | 12 ++++++++++++ .../fourn/class/fournisseur.commande.class.php | 16 +++++++++++++--- htdocs/fourn/class/fournisseur.facture.class.php | 5 +++++ htdocs/fourn/commande/card.php | 4 +++- htdocs/fourn/facture/card.php | 3 ++- htdocs/langs/en_US/main.lang | 2 ++ htdocs/supplier_proposal/card.php | 3 ++- .../class/supplier_proposal.class.php | 5 +++++ 14 files changed, 65 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 483f7b543f5..559ceba1548 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -76,6 +76,7 @@ $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -1127,7 +1128,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7bdb531ec9b..8ba39410380 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -710,6 +710,11 @@ class Propal extends CommonObject { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la propale meme $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b9900459006..a241222ae73 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -75,6 +75,7 @@ $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -953,7 +954,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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_options, $fk_unit, '', 0, $pu_ht_devise); + $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, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3712a6eea1b..d9921ca1d14 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1658,6 +1658,11 @@ class Commande extends CommonOrder { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la commande meme $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86d3abedd2b..62dcfaa5ddc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -87,6 +87,7 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2228,7 +2229,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); + $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, $rank, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); if ($result > 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8eb749b1d6b..81e3584b773 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3209,6 +3209,11 @@ class Facture extends CommonInvoice { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8da4d30af02..153f1b26775 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -296,6 +296,18 @@ if ($nolinesbefore) { echo ''; echo ''; } + + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $tab = array(-1 => $langs->trans('AtTheEnd')); + if (!empty($object->lines)) { + $langs->load('admin'); + foreach ($object->lines as $k => $v) { + $tab[$v->rang] = $langs->trans('OnLine') . ' ' . ($k + 1); + } + } + echo '
'.$langs->trans('Position').' : '.$form->selectarray('rank', $tab); + } + if (is_object($hookmanager) && empty($senderissupplier)) { $parameters = array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 08516fbc7d2..ff2e07b9600 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1597,9 +1597,10 @@ class CommandeFournisseur extends CommonOrder * @param string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object + * @param int $rang Position of line * @return int <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $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, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $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, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1) { global $langs, $mysoc, $conf; @@ -1616,6 +1617,7 @@ class CommandeFournisseur extends CommonOrder if (!$qty) $qty = 1; if (!$info_bits) $info_bits = 0; if (empty($txtva)) $txtva = 0; + if (empty($rang)) $rang = 0; if (empty($txlocaltax1)) $txlocaltax1 = 0; if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($remise_percent)) $remise_percent = 0; @@ -1776,8 +1778,11 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = $localtaxes_type[0]; $localtax2_type = $localtaxes_type[2]; - $rangmax = $this->line_max(); - $rang = $rangmax + 1; + if ($rang < 0) + { + $rangmax = $this->line_max(); + $rang = $rangmax + 1; + } // Insert line $this->line = new CommandeFournisseurLigne($this->db); @@ -1839,6 +1844,11 @@ class CommandeFournisseur extends CommonOrder { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la commande meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 72d040583b2..34c9f8de335 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1857,6 +1857,11 @@ class FactureFournisseur extends CommonInvoice { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79f37d16e5..4dee5059223 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -66,6 +66,7 @@ $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; $lineid = GETPOST('lineid', 'int'); $origin = GETPOST('origin', 'alpha'); @@ -532,7 +533,8 @@ if (empty($reshook)) $productsupplier->fk_unit, $pu_ht_devise, '', - 0 + 0, + $rank ); } if ($idprod == -99 || $idprod == 0) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 985c9a4cc62..b60ee380cf4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -70,6 +70,7 @@ $lineid = GETPOST('lineid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -1379,7 +1380,7 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - -1, + $rank, 0, $array_options, $productsupplier->fk_unit, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 67c78bf2915..3f21e47bc5f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1074,3 +1074,5 @@ AmountMustBePositive=Amount must be positive ByStatus=By status InformationMessage=Information Used=Used +AtTheEnd=At the end +OnLine=On line diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 708844b71c8..1fc8723951c 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -65,6 +65,7 @@ $confirm = GETPOST('confirm', 'alpha'); $projectid = GETPOST('projectid', 'int'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -678,7 +679,7 @@ if (empty($reshook)) $pu_ttc, $tva_npr, $type, - -1, + $rank, 0, GETPOST('fk_parent_line'), $fournprice, diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d28a0ef3b72..91652248395 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -618,6 +618,11 @@ class SupplierProposal extends CommonObject { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la propale meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. From c55008e8af0b79536c88ea9a1a50d773b48a79ed Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 16:02:55 +0100 Subject: [PATCH 02/13] NEW : insert_discount() functions handle --- htdocs/compta/facture/class/facture.class.php | 9 ++++++++- htdocs/fourn/class/fournisseur.facture.class.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 81e3584b773..44297da0ff3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1954,7 +1954,7 @@ class Facture extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1986,6 +1986,13 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + for ($ii = 1; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } + } + // Get buy/cost price of invoice that is source of discount if ($remise->fk_facture_source > 0) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 34c9f8de335..8e12bf11b45 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1025,7 +1025,7 @@ class FactureFournisseur extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1058,6 +1058,13 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + for ($ii = 1; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } + } + // Get buy/cost price of invoice that is source of discount if ($remise->fk_invoice_supplier_source > 0) { From 19171d4f8ea2e0ff588104ff764bf5da45f15511 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 16 Nov 2021 15:15:55 +0000 Subject: [PATCH 03/13] Fixing style errors. --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 5 ++--- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- htdocs/supplier_proposal/card.php | 2 +- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a532a874d65..37636e51b54 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -734,7 +734,7 @@ class Propal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 67cb1a1790f..b43a231b7e9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1648,7 +1648,7 @@ class Commande extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d092a25d680..e806bc72dd5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2087,7 +2087,7 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; for ($ii = 1; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); @@ -3362,7 +3362,7 @@ class Facture extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f1a15e0d537..2f5b8397bdd 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -310,7 +310,7 @@ if ($nolinesbefore) { echo ''; } - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $tab = array(-1 => $langs->trans('AtTheEnd')); if (!empty($object->lines)) { $langs->load('admin'); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 790f67623d8..c9e32fbb1f7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1857,8 +1857,7 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - if ($rang < 0) - { + if ($rang < 0) { $rangmax = $this->line_max(); $rang = $rangmax + 1; } @@ -1923,7 +1922,7 @@ class CommandeFournisseur extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines for ($ii = $rang; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb137410b6d..6a46695135a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1111,7 +1111,7 @@ class FactureFournisseur extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $conf, $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1142,7 +1142,7 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; for ($ii = 1; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); @@ -2014,7 +2014,7 @@ class FactureFournisseur extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines for ($ii = $rang; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index eaed94f6529..29c147e142e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -673,7 +673,7 @@ if (empty($reshook)) { $pu_ttc, $tva_npr, $type, - $rank, + $rank, 0, GETPOST('fk_parent_line'), $fournprice, diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f90555f9f1e..08a3a03476a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -621,7 +621,7 @@ class SupplierProposal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } From 375dcf702819705c4478705d3f008502375368cb Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 16:42:48 +0100 Subject: [PATCH 04/13] FIX : dev name --- htdocs/comm/propal/card.php | 1 + htdocs/comm/propal/class/propal.class.php | 1 + htdocs/commande/card.php | 1 + htdocs/commande/class/commande.class.php | 1 + htdocs/compta/facture/card.php | 1 + htdocs/compta/facture/class/facture.class.php | 1 + htdocs/core/tpl/objectline_create.tpl.php | 1 + htdocs/fourn/class/fournisseur.commande.class.php | 1 + htdocs/fourn/class/fournisseur.facture.class.php | 1 + htdocs/fourn/commande/card.php | 1 + htdocs/fourn/facture/card.php | 1 + htdocs/supplier_proposal/card.php | 1 + htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 13 files changed, 13 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 98ea79b078f..e6ae2f2ab87 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -14,6 +14,7 @@ * Copyright (C) 2016 Marcos García * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a532a874d65..675ed2e2687 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9e682805d20..cfa21ce1534 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -13,6 +13,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 67cb1a1790f..49012e486b0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index abed475fbb5..c4cb861b2b6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -15,6 +15,7 @@ * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d092a25d680..6bec2c37d5c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -17,6 +17,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f1a15e0d537..30d0ae09fc4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -9,6 +9,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 790f67623d8..b8a0ac93d3d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Josep Lluís Amador + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb137410b6d..ddd79cc46c2 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c341a529123..70b2908eb45 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ion Agorria * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 57356bbc1e9..aeb0681547f 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -11,6 +11,7 @@ * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Ferran Marcet + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index eaed94f6529..b299176c56e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -12,6 +12,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f90555f9f1e..632b44dba2a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019-2020 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL * * 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 From e75b6ae0b408c93c2406c58fe3c635e6510d6438 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 22 Nov 2021 16:13:46 +0100 Subject: [PATCH 05/13] FIX : it's better with an input number --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 9 +-------- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/langs/en_US/main.lang | 3 +-- htdocs/supplier_proposal/card.php | 2 +- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 559ceba1548..1cd02b05755 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1128,7 +1128,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a241222ae73..eabdea93e01 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -954,7 +954,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $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, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 62dcfaa5ddc..db984666449 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2229,7 +2229,7 @@ if (empty($reshook)) setEventMessages($mesg, null, '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, $rank, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); + $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, min($rank, count($object->lines) + 1), $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); if ($result > 0) { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 153f1b26775..5e0a3bbbec8 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -298,14 +298,7 @@ if ($nolinesbefore) { } if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $tab = array(-1 => $langs->trans('AtTheEnd')); - if (!empty($object->lines)) { - $langs->load('admin'); - foreach ($object->lines as $k => $v) { - $tab[$v->rang] = $langs->trans('OnLine') . ' ' . ($k + 1); - } - } - echo '
'.$langs->trans('Position').' : '.$form->selectarray('rank', $tab); + echo '
'.$langs->trans('AddLineOnPosition').' : '; } if (is_object($hookmanager) && empty($senderissupplier)) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4dee5059223..4fd29a872d8 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -534,7 +534,7 @@ if (empty($reshook)) $pu_ht_devise, '', 0, - $rank + min($rank, count($object->lines) + 1) ); } if ($idprod == -99 || $idprod == 0) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b60ee380cf4..0d8f59aa33d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1380,7 +1380,7 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - $rank, + min($rank, count($object->lines) + 1), 0, $array_options, $productsupplier->fk_unit, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 3f21e47bc5f..1c7a1d47ebb 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1074,5 +1074,4 @@ AmountMustBePositive=Amount must be positive ByStatus=By status InformationMessage=Information Used=Used -AtTheEnd=At the end -OnLine=On line +AddLineOnPosition=Add line on position (at the end if empty) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1fc8723951c..1fce863ed84 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -679,7 +679,7 @@ if (empty($reshook)) $pu_ttc, $tva_npr, $type, - $rank, + min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, From 9975587cd59d8905874faaa18837283ed8df84c4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 22 Nov 2021 15:26:46 +0000 Subject: [PATCH 06/13] Fixing style errors. --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index dba5e5be695..b0c33e934fc 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -311,7 +311,7 @@ if ($nolinesbefore) { echo ''; } - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { echo '
'.$langs->trans('AddLineOnPosition').' : '; } From 74f5c092dcfdc84dc56f8b22dea117d2dee4a2d3 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 23 Nov 2021 10:44:43 +0100 Subject: [PATCH 07/13] FIX : use $linecount = count($this->lines); --- htdocs/comm/propal/class/propal.class.php | 3 ++- htdocs/commande/class/commande.class.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 6 ++++-- htdocs/fourn/class/fournisseur.commande.class.php | 3 ++- htdocs/fourn/class/fournisseur.facture.class.php | 14 ++++++++------ .../class/supplier_proposal.class.php | 3 ++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8ba39410380..c192136fbd2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -711,7 +711,8 @@ class Propal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d9921ca1d14..e758eaee9a9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1659,7 +1659,8 @@ class Commande extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 44297da0ff3..0ec9db3ea44 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1988,7 +1988,8 @@ class Facture extends CommonInvoice if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; - for ($ii = 1; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = 1; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); } } @@ -3217,7 +3218,8 @@ class Facture extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ff2e07b9600..5ee4ea285b3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1845,7 +1845,8 @@ class CommandeFournisseur extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8e12bf11b45..1cf23600e6d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1058,12 +1058,13 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $facligne->rang = 1; - for ($ii = 1; $ii <= count($this->lines); $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + $linecount = count($this->lines); + for ($ii = 1; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } } - } // Get buy/cost price of invoice that is source of discount if ($remise->fk_invoice_supplier_source > 0) @@ -1865,7 +1866,8 @@ class FactureFournisseur extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 91652248395..4dee2294fcd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -619,7 +619,8 @@ class SupplierProposal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } From 19104236845f5ede2a35fc0d0955837b163808e6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 11 Jan 2022 09:54:27 +0100 Subject: [PATCH 08/13] FIX : conf name is MAIN_ADD_LINE_AT_POSITION --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 19aa36e09bc..2c8f87291c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2088,7 +2088,7 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { $facligne->rang = 1; $linecount = count($this->lines); for ($ii = 1; $ii <= $linecount; $ii++) { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b0c33e934fc..887ed5c0b7e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -311,7 +311,7 @@ if ($nolinesbefore) { echo ''; } - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { echo '
'.$langs->trans('AddLineOnPosition').' : '; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 04c49d1065e..cc2de5b9df9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1143,7 +1143,7 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { $facligne->rang = 1; $linecount = count($this->lines); for ($ii = 1; $ii <= $linecount; $ii++) { From 8be5cccb4ef0a6c4352d9b4903e4f09dae8e6d38 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 6 Apr 2022 12:32:10 +0200 Subject: [PATCH 09/13] Reverse stock movements on mo consumed product --- htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/class/mo.class.php | 72 ++++++++++++++++++++++++++++++++++- htdocs/mrp/mo_production.php | 10 ++++- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 4dc74122ea9..525c0f4c150 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -69,6 +69,7 @@ ForAQuantityToConsumeOf=For a quantity to disassemble of %s ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements. ProductionForRef=Production of %s +CancelProductionForRef=Cancellation of product stock decrementation for product %s AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached NoStockChangeOnServices=No stock change on services ProductQtyToConsumeByMO=Product quantity still to consume by open MO diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index de9913fdb9f..f3600960706 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -750,12 +750,82 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { + global $langs; + $langs->load('stocks'); + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } - return $this->deleteLineCommon($user, $idline, $notrigger); + $productstatic = new Product($this->db); + $fk_movement = GETPOST('fk_movement', 'int'); + $arrayoflines = $this->fetchLinesLinked('consumed', $idline); + + if (! empty($arrayoflines)) { + $this->db->begin(); + + $stockmove = new MouvementStock($this->db); + $stockmove->setOrigin($this->element, $this->id); + + if (! empty($fk_movement)) { + $moline = new MoLine($this->db); + $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); + $moline = array_shift($TArrayMoLine); + + $movement = new MouvementStock($this->db); + $movement->fetch($fk_movement); + $productstatic->fetch($movement->product_id); + $qtytoprocess = $movement->qty; + + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); + + if (($qtytoprocess >= 0)) { + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $movement->batch, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $movement->batch, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + return $moline->delete($user, $notrigger); + } + else { + foreach ($arrayoflines as $key => $arrayofline) { + $lineDetails = $arrayoflines[$key]; + $productstatic->fetch($lineDetails['fk_product']); + $qtytoprocess = $lineDetails['qty']; + $id_product_batch = (! empty($lineDetails['batch']) ? $lineDetails['batch'] : 0); + + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); + + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $id_product_batch, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $id_product_batch, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + } + return $this->deleteLineCommon($user, $idline, $notrigger); + } + } + else { + return $this->deleteLineCommon($user, $idline, $notrigger); + } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 545a7aaf202..ba04152bd7d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -49,6 +49,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$fk_movement = GETPOST('fk_movement', 'int'); $collapse = GETPOST('collapse', 'aZ09comma'); @@ -445,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation to delete line if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&fk_movement='.$fk_movement, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation if ($action == 'clone') { @@ -969,7 +970,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Action delete line if ($permissiontodelete) { - print ''; + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); + print ''; + print ''; + print img_picto('', 'delete'); + print ''; + print ''; } print ''; From 69eaf1e708867db595f32182b8fd731dfb53ab5d Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 6 Apr 2022 14:59:18 +0200 Subject: [PATCH 10/13] Rework some code --- htdocs/mrp/class/mo.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f3600960706..147a600cbc2 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -783,9 +783,9 @@ class Mo extends CommonObject $codemovementCancel = $langs->trans("StockIncrease"); if (($qtytoprocess >= 0)) { - $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $movement->batch, $codemovementCancel); + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); } else { - $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $movement->batch, $codemovementCancel); + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); } if ($idstockmove < 0) { $this->error++; @@ -801,16 +801,15 @@ class Mo extends CommonObject $lineDetails = $arrayoflines[$key]; $productstatic->fetch($lineDetails['fk_product']); $qtytoprocess = $lineDetails['qty']; - $id_product_batch = (! empty($lineDetails['batch']) ? $lineDetails['batch'] : 0); // Reverse stock movement $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); $codemovementCancel = $langs->trans("StockIncrease"); if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $id_product_batch, $codemovementCancel); + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); } else { - $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $id_product_batch, $codemovementCancel); + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); } if ($idstockmove < 0) { $this->error++; From de6e3c6d5513a1255d50124e2f7e6779e47510f5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 6 Apr 2022 13:19:34 +0000 Subject: [PATCH 11/13] Fixing style errors. --- htdocs/mrp/class/mo.class.php | 120 +++++++++++++++++----------------- htdocs/mrp/mo_production.php | 12 ++-- 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 147a600cbc2..2c0773dd9be 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -750,81 +750,79 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - global $langs; - $langs->load('stocks'); + global $langs; + $langs->load('stocks'); if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } - $productstatic = new Product($this->db); - $fk_movement = GETPOST('fk_movement', 'int'); - $arrayoflines = $this->fetchLinesLinked('consumed', $idline); + $productstatic = new Product($this->db); + $fk_movement = GETPOST('fk_movement', 'int'); + $arrayoflines = $this->fetchLinesLinked('consumed', $idline); - if (! empty($arrayoflines)) { - $this->db->begin(); + if (! empty($arrayoflines)) { + $this->db->begin(); - $stockmove = new MouvementStock($this->db); - $stockmove->setOrigin($this->element, $this->id); + $stockmove = new MouvementStock($this->db); + $stockmove->setOrigin($this->element, $this->id); - if (! empty($fk_movement)) { - $moline = new MoLine($this->db); - $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); - $moline = array_shift($TArrayMoLine); + if (! empty($fk_movement)) { + $moline = new MoLine($this->db); + $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); + $moline = array_shift($TArrayMoLine); - $movement = new MouvementStock($this->db); - $movement->fetch($fk_movement); - $productstatic->fetch($movement->product_id); - $qtytoprocess = $movement->qty; + $movement = new MouvementStock($this->db); + $movement->fetch($fk_movement); + $productstatic->fetch($movement->product_id); + $qtytoprocess = $movement->qty; - // Reverse stock movement - $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); - $codemovementCancel = $langs->trans("StockIncrease"); + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); - if (($qtytoprocess >= 0)) { - $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); - } else { - $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); - } - if ($idstockmove < 0) { - $this->error++; - $this->db->rollback(); - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } else { - $this->db->commit(); - } - return $moline->delete($user, $notrigger); - } - else { - foreach ($arrayoflines as $key => $arrayofline) { - $lineDetails = $arrayoflines[$key]; - $productstatic->fetch($lineDetails['fk_product']); - $qtytoprocess = $lineDetails['qty']; + if (($qtytoprocess >= 0)) { + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + return $moline->delete($user, $notrigger); + } else { + foreach ($arrayoflines as $key => $arrayofline) { + $lineDetails = $arrayoflines[$key]; + $productstatic->fetch($lineDetails['fk_product']); + $qtytoprocess = $lineDetails['qty']; - // Reverse stock movement - $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); - $codemovementCancel = $langs->trans("StockIncrease"); + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); - if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); - } else { - $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); - } - if ($idstockmove < 0) { - $this->error++; - $this->db->rollback(); - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } else { - $this->db->commit(); - } - } - return $this->deleteLineCommon($user, $idline, $notrigger); - } - } - else { - return $this->deleteLineCommon($user, $idline, $notrigger); - } + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + } + return $this->deleteLineCommon($user, $idline, $notrigger); + } + } else { + return $this->deleteLineCommon($user, $idline, $notrigger); + } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index ba04152bd7d..fc9f5ee1a11 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -970,12 +970,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Action delete line if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); - print ''; - print ''; - print img_picto('', 'delete'); - print ''; - print ''; + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); + print ''; + print ''; + print img_picto('', 'delete'); + print ''; + print ''; } print ''; From 135e4f1768690e9a7f27ae562533a51fd258897e Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 8 Apr 2022 09:50:40 +0200 Subject: [PATCH 12/13] Add tooltip to explain the trash action --- htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/mo_production.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 525c0f4c150..224273d84e6 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -70,6 +70,7 @@ ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements. ProductionForRef=Production of %s CancelProductionForRef=Cancellation of product stock decrementation for product %s +TooltipDeleteAndRevertStockMovement=Delete line and revert stock movement AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached NoStockChangeOnServices=No stock change on services ProductQtyToConsumeByMO=Product quantity still to consume by open MO diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index ba04152bd7d..c9d171a0300 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -915,7 +915,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id); print ''; print ''; - print img_picto('', 'delete'); + print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete'); print ''; print ''; } @@ -973,7 +973,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); print ''; print ''; - print img_picto('', 'delete'); + print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete'); print ''; print ''; } @@ -1226,7 +1226,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $href .= '&lineid='.$line->id; print ''; print ''; - print img_picto('', "delete"); + print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), "delete"); print ''; print ''; } From 284649fd4b52b4f789eeacac7543785a198145a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 8 Apr 2022 13:35:21 +0200 Subject: [PATCH 13/13] Update objectonoff.php --- htdocs/core/ajax/objectonoff.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 5bac89345ce..ffd05c4747e 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -88,7 +88,10 @@ if (($action == 'set') && !empty($id)) { $triggerkey = strtoupper($element).'_UPDATE'; // Special case if ($triggerkey == 'SOCIETE_UPDATE') { - $triggerkey = 'COMPANY_UPDATE'; + $triggerkey = 'COMPANY_MODIFY'; + } + if ($triggerkey == 'PRODUCT_UPDATE') { + $triggerkey = 'PRODUCT_MODIFY'; } $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey);