From 7239fa36052c68e8761b1753fd0806a485db608e Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 3 Mar 2022 12:19:47 +0100 Subject: [PATCH 01/20] FIX: project creation prevented if PROJECTLEADER contact role renamed, de-activated or deleted --- htdocs/projet/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 3f496de2f66..ab61a613734 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -174,10 +174,11 @@ if (empty($reshook)) if (!$error && $result > 0) { // Add myself as project leader - $typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error. + $typeofcontact = 'PROJECTLEADER'; $result = $object->add_contact($user->id, $typeofcontact, 'internal'); - if ($result < 0) - { + + // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case + if ($result < 0 && $result != -3) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; From e9893716519da24ded648c4b51c872ffbccc148d Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:49:26 +0100 Subject: [PATCH 02/20] FIX: better error management at product selling price update --- htdocs/product/class/product.class.php | 3 +- htdocs/product/price.php | 40 +++++++++++++------ .../class/ProductCombination.class.php | 20 +++++++++- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ce7a5858a6a..cdab6a18c38 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2045,7 +2045,8 @@ class Product extends CommonObject $this->db->commit(); } else { $this->db->rollback(); - dol_print_error($this->db); + $this->error = $this->db->lasterror(); + return -1; } } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 9c084cd8352..704db910147 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -163,11 +163,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - if ($error) - { + if (!$error) { //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. - $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); + $ret = $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); + + if ($ret < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } if (!$error) @@ -400,14 +404,22 @@ if (empty($reshook)) { // Activating product price by quantity add a new price line with price_by_qty set to 1 $level = GETPOST('level', 'int'); - $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + + if ($ret < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Unset Price by quantity if ($action == 'disable_price_by_qty') { // Disabling product price by quantity add a new price line with price_by_qty set to 0 $level = GETPOST('level', 'int'); - $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); + $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); + + if ($ret < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($action == 'edit_price_by_qty') @@ -1444,17 +1456,21 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul { $db->free($result); - // Il doit au moins y avoir la ligne de prix initial. - // On l'ajoute donc pour remettre a niveau (pb vieilles versions) - // We emulate the change of the price from interface with the same value than the one into table llx_product + // Il doit au moins y avoir la ligne de prix initial. + // On l'ajoute donc pour remettre a niveau (pb vieilles versions) + // We emulate the change of the price from interface with the same value than the one into table llx_product if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); + $ret = $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); } else { - $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); + $ret = $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); } - $result = $db->query($sql); - $num = $db->num_rows($result); + if ($ret < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + $result = $db->query($sql); + $num = $db->num_rows($result); + } } if ($num > 0) { diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 336503056f9..93960b62f9e 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -534,7 +534,14 @@ class ProductCombination $new_price += $variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code); + $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code); + + if ($ret < 0) { + $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; + return $ret; + } } } } else { @@ -556,7 +563,14 @@ class ProductCombination $new_price += $this->variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq); + $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq); + + if ($ret < 0) { + $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; + return $ret; + } } $this->db->commit(); @@ -565,6 +579,8 @@ class ProductCombination } $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; return -1; } From f837845c122840182ca1f52e0f5a50066accbc70 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 8 Mar 2022 15:07:02 +0100 Subject: [PATCH 03/20] FIX: still prevent project creation if PROJECTLEADER role unavailable, but with a specific error message --- htdocs/langs/en_US/projects.lang | 3 ++- htdocs/projet/card.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 2aedbd53377..d93bbbe4a9d 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -267,4 +267,5 @@ NewInvoice=New invoice OneLinePerTask=One line per task OneLinePerPeriod=One line per period RefTaskParent=Ref. Parent Task -ProfitIsCalculatedWith=Profit is calculated using \ No newline at end of file +ProfitIsCalculatedWith=Profit is calculated using +ErrorPROJECTLEADERRoleMissingOrDeActivatedPleaseRestoreItInContactTypesDictionary=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types \ No newline at end of file diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index ab61a613734..8c921c0868e 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -178,7 +178,10 @@ if (empty($reshook)) $result = $object->add_contact($user->id, $typeofcontact, 'internal'); // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case - if ($result < 0 && $result != -3) { + if ($result == -3) { + setEventMessage('ErrorPROJECTLEADERRoleMissingOrDeActivatedPleaseRestoreItInContactTypesDictionary', 'errors'); + $error++; + } elseif ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; From 3dfd92e9c0fda483facd6b6a39b71604d8718609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 8 Mar 2022 21:19:29 +0100 Subject: [PATCH 04/20] Fix do not modify entity on group edit https://www.dolibarr.fr/forum/t/etoile-globalgroup-dans-les-groupes-dutilisateurs-quelle-signification-quel-usage/38772/26 --- htdocs/user/group/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index c3e0e00fdf6..3cce6710f7f 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -206,8 +206,8 @@ if (empty($reshook)) { $object->oldcopy = clone $object; - $object->name = GETPOST("nom", 'nohtml'); - $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml'))); + $object->name = GETPOST("nom", 'nohtml'); + $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml'))); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); @@ -218,7 +218,7 @@ if (empty($reshook)) { if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 0; } else { - $object->entity = GETPOST("entity"); + $object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity; } $ret = $object->update(); From 63b96e22b0998e165bb06750a789feb2cbdfbc40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Mar 2022 02:37:30 +0100 Subject: [PATCH 05/20] Update card.php --- htdocs/projet/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 8c921c0868e..04eba73b794 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -179,7 +179,7 @@ if (empty($reshook)) // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case if ($result == -3) { - setEventMessage('ErrorPROJECTLEADERRoleMissingOrDeActivatedPleaseRestoreItInContactTypesDictionary', 'errors'); + setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors'); $error++; } elseif ($result < 0) { $langs->load("errors"); From c147acabe1ce7656258b695a7ba655dd9f04c5c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Mar 2022 02:37:46 +0100 Subject: [PATCH 06/20] Update projects.lang --- htdocs/langs/en_US/projects.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d93bbbe4a9d..fbbef5fe2bd 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -268,4 +268,4 @@ OneLinePerTask=One line per task OneLinePerPeriod=One line per period RefTaskParent=Ref. Parent Task ProfitIsCalculatedWith=Profit is calculated using -ErrorPROJECTLEADERRoleMissingOrDeActivatedPleaseRestoreItInContactTypesDictionary=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types \ No newline at end of file +ErrorPROJECTLEADERRoleMissingRestoreIt=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types From 53909828f9db5a1e019b170166ecfaac21fca24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 17 Mar 2022 10:56:14 +0100 Subject: [PATCH 07/20] Update card.php --- htdocs/user/group/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 3cce6710f7f..f698d1b5a07 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -217,8 +217,8 @@ if (empty($reshook)) { if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 0; - } else { - $object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity; + } elseif (GETPOSTISSET("entity")) { + $object->entity = GETPOST("entity", "int"); } $ret = $object->update(); From f1f3a0aa24b8eff7f1f8a14b5224b89ece8c2755 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 17 Mar 2022 14:56:25 +0100 Subject: [PATCH 08/20] Fix missing AutoFill Trad --- htdocs/langs/en_US/other.lang | 1 + htdocs/langs/fr_FR/other.lang | 2 ++ 2 files changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 91dd5ba4509..7b4c2d86bc9 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -302,3 +302,4 @@ SelectTheTypeOfObjectToAnalyze=Select an object to view its statistics... ConfirmBtnCommonContent = Are you sure you want to "%s" ? ConfirmBtnCommonTitle = Confirm your action CloseDialog = Close +Autofill = Auto fill diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 87237e4acef..60c84bca1f4 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -303,3 +303,5 @@ SelectTheTypeOfObjectToAnalyze=Sélectionner un objet pour en voir les statistiq ConfirmBtnCommonContent = Êtes-vous sûr de vouloir "%s" ? ConfirmBtnCommonTitle = Confirmer votre action CloseDialog = Fermer + +Autofill = Remplissage auto From 989f00ae63e8b1721a6a56f285640a65eb2a2eea Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 18 Mar 2022 09:42:37 +0100 Subject: [PATCH 09/20] Update other.lang --- htdocs/langs/fr_FR/other.lang | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 60c84bca1f4..87237e4acef 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -303,5 +303,3 @@ SelectTheTypeOfObjectToAnalyze=Sélectionner un objet pour en voir les statistiq ConfirmBtnCommonContent = Êtes-vous sûr de vouloir "%s" ? ConfirmBtnCommonTitle = Confirmer votre action CloseDialog = Fermer - -Autofill = Remplissage auto From 62ca286ac92c24ecbcf02c3b789599db1d382ec5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Mar 2022 12:07:00 +0100 Subject: [PATCH 10/20] Try a fix to solve backup that fails on large database --- htdocs/core/class/utils.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 17afecde14a..9907ae29834 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -356,10 +356,19 @@ class Utils dol_syslog("Utils::dumpDatabase execmethod=".$execmethod." command:".$fullcommandcrypted, LOG_INFO); + + /* If value has been forced with a php_admin_value, this has no effect. Example of value: '512M' */ + $MemoryLimit = getDolGlobalString('MAIN_MEMORY_LIMIT_DUMP'); + if (!empty($MemoryLimit)) { + @ini_set('memory_limit', $MemoryLimit); + } + + // TODO Replace with executeCLI function if ($execmethod == 1) { $output_arr = array(); $retval = null; + exec($fullcommandclear, $output_arr, $retval); if ($retval != 0) { From 8ef55eae0734cfc71f80082a791dc08625333eeb Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:04:05 +0100 Subject: [PATCH 11/20] FIX: propal list: missing translation keys for transifex --- htdocs/langs/en_US/propal.lang | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 557df2f840f..afab92970ef 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -84,6 +84,17 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature ProposalsStatisticsSuppliers=Vendor proposals statistics CaseFollowedBy=Case followed by SignedOnly=Signed only +IsNotADraft=is not a draft +PassedInOpenStatus=has been validated +CantBeSign=cannot be signed +Sign=Sign +Signed=signed +CantBeSign=cannot be signed +CantBeValidated=cannot be validated +ConfirmMassValidation=Bulk Validate confirmation +ConfirmMassSignature=Bulk Signature confirmation +ConfirmMassValidationQuestion=Are you sure you want to validate the selected records ? +ConfirmMassSignatureQuestion=Are you sure you want to sign the selected records ? IdProposal=Proposal ID IdProduct=Product ID PrParentLine=Proposal Parent Line From d4f55ae1167087452c177cdded0ae7b5973131af Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:11:10 +0100 Subject: [PATCH 12/20] FIX: propal list: bad error management in mass actions --- htdocs/comm/propal/list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d92ec87ca29..5b25fd89819 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -272,9 +272,9 @@ if ($action == 'validate') { $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) { - if ($tmpproposal->valid($user)) { + if ($tmpproposal->valid($user) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); @@ -285,7 +285,7 @@ if ($action == 'validate') { $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } @@ -305,14 +305,14 @@ if ($action == "sign") { $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { $tmpproposal->statut = $tmpproposal::STATUS_SIGNED; - if ($tmpproposal->update($user)) { + if ($tmpproposal->update($user) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { @@ -320,7 +320,7 @@ if ($action == "sign") { $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } From cf64fc288d36fb1bbf2433949b3e831dcf3cf580 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:49:03 +0100 Subject: [PATCH 13/20] FIX: propal list: missing not signed massaction translation keys for transifex --- htdocs/langs/en_US/propal.lang | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index edbc08236d3..86ee94ceee3 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -85,6 +85,11 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature ProposalsStatisticsSuppliers=Vendor proposals statistics CaseFollowedBy=Case followed by SignedOnly=Signed only +NoSign=Set not signed +NoSigned=set not signed +CantBeSign=cannot be set not signed +ConfirmMassNoSignature=Bulk Not signed confirmation +ConfirmMassNoSignatureQuestion=Are you sure you want to set not signed the selected records ? IdProposal=Proposal ID IdProduct=Product ID PrParentLine=Proposal Parent Line From 3aae8cc3bbc10f5f07333e54f3b7430146808a4b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:54:04 +0100 Subject: [PATCH 14/20] FIX: propal list: bad error management for set not ssigned mass action --- htdocs/comm/propal/list.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 3e467539c88..16a754a61bb 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -405,27 +405,28 @@ if ($action == "sign" && $permissiontoclose) { } } } + if ($action == "nosign" && $permissiontoclose) { if (GETPOST('confirm') == 'yes') { $tmpproposal = new Propal($db); $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { $tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED; - if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED)) { + if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeClosed'), 'errors'); + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors'); $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } From 5914f2ac65622478c06d6f396e601e0a8c365f90 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 22 Mar 2022 11:17:27 +0100 Subject: [PATCH 15/20] FIX include discount price for PMP after a reception (Issue #20029) --- htdocs/reception/class/reception.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index ef12d844ddc..2b458f9d57c 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -554,7 +554,7 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO in future, reception lines may not be linked to order line - $sql = "SELECT cd.fk_product, cd.subprice,"; + $sql = "SELECT cd.fk_product, cd.subprice, cd.remise_percent,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql .= " ed.eatby, ed.sellby, ed.batch"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; @@ -580,12 +580,18 @@ class Reception extends CommonObject $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + // get unit price with discount + $up_ht_disc = $obj->subprice; + if (!empty($obj->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { + $up_ht_disc = price2num($up_ht_disc * (100 - $obj->remise_percent) / 100, 'MU'); + } + if (empty($obj->batch)) { // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref)); if ($result < 0) { $error++; $this->errors[] = $mouvS->error; @@ -597,7 +603,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $error++; $this->errors[] = $mouvS->error; From 344c29ae151fa0c7cb1ba865802c4ce1a69966f7 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 11:35:37 +0100 Subject: [PATCH 16/20] FIX: trans --- htdocs/langs/en_US/propal.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 86ee94ceee3..c7332005f86 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -87,7 +87,7 @@ CaseFollowedBy=Case followed by SignedOnly=Signed only NoSign=Set not signed NoSigned=set not signed -CantBeSign=cannot be set not signed +CantBeNoSign=cannot be set not signed ConfirmMassNoSignature=Bulk Not signed confirmation ConfirmMassNoSignatureQuestion=Are you sure you want to set not signed the selected records ? IdProposal=Proposal ID From ccf8b01020330d0d012e131a13fe6ce68649901d Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 22 Mar 2022 13:46:55 +0100 Subject: [PATCH 17/20] Fix: The origin of the stock movement is not being recorded --- htdocs/commande/class/commande.class.php | 5 ++++- htdocs/compta/facture/class/facture.class.php | 5 ++++- htdocs/expedition/class/expedition.class.php | 5 ++++- htdocs/fourn/class/fournisseur.commande.class.php | 6 +++--- htdocs/fourn/class/fournisseur.facture.class.php | 4 +++- htdocs/fourn/commande/dispatch.php | 4 +++- htdocs/reception/class/reception.class.php | 6 +++++- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 429996ee314..f51c8026672 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2016-2018 Ferran Marcet + * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -518,6 +518,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We decrement stock of product (and sub-products) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); if ($result < 0) { @@ -645,6 +646,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We increment stock of product (and sub-products) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref)); if ($result < 0) { @@ -823,6 +825,7 @@ class Commande extends CommonOrder for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->setOrigin($this->element, $this->id); // We increment stock of product (and sub-products) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed if ($result < 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5e61499464c..55fa26d3c6b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -14,7 +14,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Cedric Gross * Copyright (C) 2013 Florian Henry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2022 Sylvain Legrand @@ -2323,6 +2323,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) { $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); @@ -2759,6 +2760,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) { $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); @@ -3051,6 +3053,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) { $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 600f498da7c..a29919b7346 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2017 Francis Appels * Copyright (C) 2015 Claudio Aschieri - * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2020 Lenin Rivas @@ -753,6 +753,7 @@ class Expedition extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = dol_clone($this, 1); + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->edbrowid)) { // line without batch detail @@ -2233,6 +2234,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->edbrowid)) { // line without batch detail @@ -2404,6 +2406,7 @@ class Expedition extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->edbrowid)) { // line without batch detail diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 649fb0e106f..a20075295d9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France - * Copyright (C) 2018-2021 Ferran Marcet + * Copyright (C) 2018-2022 Ferran Marcet * Copyright (C) 2021 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -1071,6 +1071,7 @@ class CommandeFournisseur extends CommonOrder $this->line = $this->lines[$i]; $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We decrement stock of product (and sub-products) $up_ht_disc = $this->lines[$i]->subprice; if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { @@ -2037,8 +2038,7 @@ class CommandeFournisseur extends CommonOrder if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; - $mouv->origin_type = $this->element; - $mouv->origin_id = $this->id; + $mouv->setOrigin($this->element, $this->id); $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); if ($result < 0) { $this->error = $mouv->error; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2a1a54e70d3..bd25fbea6ec 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Bahfir Abbes - * Copyright (C) 2015-2019 Ferran Marcet + * Copyright (C) 2015-2022 Ferran Marcet * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2022 Frédéric France @@ -1605,6 +1605,7 @@ class FactureFournisseur extends CommonInvoice $this->line = $this->lines[$i]; $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We increase stock for product $up_ht_disc = $this->lines[$i]->pu_ht; if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { @@ -1734,6 +1735,7 @@ class FactureFournisseur extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; + $mouvP->setOrigin($this->element, $this->id); // We increase stock for product if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index bb56e5d4555..a1ddef959a0 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -6,7 +6,7 @@ * Copyright (C) 2010-2021 Juanjo Menent * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2020 Ferran Marcet + * Copyright (C) 2017-2022 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * @@ -423,6 +423,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoreceive $mouv = new MouvementStock($db); if ($product > 0) { $mouv->origin = &$object; + $mouv->setOrigin($object->element, $object->id); $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); if ($result < 0) { $errors = $mouv->errors; @@ -469,6 +470,7 @@ if ($action == 'updateline' && $permissiontoreceive) { $mouv = new MouvementStock($db); if ($product > 0) { $mouv->origin = &$object; + $mouv->setOrigin($object->element, $object->id); $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); if ($result < 0) { $errors = $mouv->errors; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 28fb783e2c9..b8246b7fe8e 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2020 Francis Appels * Copyright (C) 2015 Claudio Aschieri - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Quentin Vial-Gouteyron * * This program is free software; you can redistribute it and/or modify @@ -591,6 +591,7 @@ class Reception extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->batch)) { // line without batch detail @@ -1632,6 +1633,7 @@ class Reception extends CommonObject $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->batch)) { // line without batch detail @@ -1796,6 +1798,7 @@ class Reception extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->batch)) { // line without batch detail @@ -1926,6 +1929,7 @@ class Reception extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + $mouvS->setOrigin($this->element, $this->id); if (empty($obj->batch)) { // line without batch detail From 100c48372b7f806dbac0a6e43725221ac306944a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Mar 2022 17:13:48 +0100 Subject: [PATCH 18/20] FIX: permit access to medias when logged in a different entity --- htdocs/viewimage.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 69d0b38571c..fda4cdfbf20 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -186,6 +186,13 @@ $refname = basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 0, 0, 1); +// When logged in a different entity, medias cannot be accessed because $conf->$module->multidir_output +// is not set on the requested entity, but they are public documents, so reset entity +if ($modulepart === 'medias' && $entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); +} + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $user, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; From 01396cc07aea83ae20565bb4feadb62e1348d362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Mar 2022 15:58:55 +0100 Subject: [PATCH 19/20] Code comment --- htdocs/core/actions_dellink.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index fbecacce515..9bf56b2f876 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -32,7 +32,7 @@ $addlinkid = GETPOST('idtolinkto', 'int'); $addlinkref = GETPOST('reftolinkto', 'alpha'); $cancellink = GETPOST('cancel', 'alpha'); -// Link invoice to order +// Link object to another object if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > 0 && $addlinkid > 0) { $object->fetch($id); $object->fetch_thirdparty(); @@ -61,7 +61,7 @@ if ($action == 'addlinkbyref' && ! empty($permissiondellink) && !$cancellink && } } -// Delete link +// Delete link in table llx_element_element if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) { $result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid); if ($result < 0) { From 61ed36e1814470398bb941dbff7651eb3ba6b6ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Mar 2022 16:19:06 +0100 Subject: [PATCH 20/20] Update other.lang --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 7b4c2d86bc9..3b71c29da24 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -302,4 +302,4 @@ SelectTheTypeOfObjectToAnalyze=Select an object to view its statistics... ConfirmBtnCommonContent = Are you sure you want to "%s" ? ConfirmBtnCommonTitle = Confirm your action CloseDialog = Close -Autofill = Auto fill +Autofill = Autofill