From 1adda9817ab1d5f17c159527e69677d659455825 Mon Sep 17 00:00:00 2001 From: atm-jonathan <146709163+atm-jonathan@users.noreply.github.com> Date: Fri, 12 Apr 2024 02:38:00 +0200 Subject: [PATCH 01/17] FIX round capital societe (#29211) * round capital societe * new key formated --- htdocs/core/class/commondocgenerator.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 03adbbb6a66..ab8d1e36224 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -324,6 +324,7 @@ abstract class CommonDocGenerator 'company_juridicalstatus'=>$object->forme_juridique, 'company_outstanding_limit'=>$object->outstanding_limit, 'company_capital'=>$object->capital, + 'company_capital_formated'=> price($object->capital, 0, '', 1, -1), 'company_idprof1'=>$object->idprof1, 'company_idprof2'=>$object->idprof2, 'company_idprof3'=>$object->idprof3, From de1d67a6aef942b397096e7584857434ea14e33f Mon Sep 17 00:00:00 2001 From: IC-Ilies <86972374+IC-Ilies@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:12:49 +0200 Subject: [PATCH 02/17] FIX #29333 supplier order extrafields of link type displays error (#29334) --- htdocs/core/lib/functions.lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dc880290ea2..b22c23c8699 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12027,6 +12027,14 @@ function getElementProperties($element_type) $subelement = ''; $classname = 'CommandeFournisseur'; $table_element = 'commande_fournisseur'; + } elseif ($element_type == 'commande_fournisseurdet') { + $classpath = 'fourn/class'; + $module = 'fournisseur'; + $classfile = 'fournisseur.commande'; + $element = 'commande_fournisseurdet'; + $subelement = ''; + $classname = 'CommandeFournisseurLigne'; + $table_element = 'commande_fournisseurdet'; } elseif ($element_type == 'invoice_supplier') { $classpath = 'fourn/class'; $module = 'fournisseur'; From 394ed480d3a4d4d038701c0bb6cdc49c17b7a39a Mon Sep 17 00:00:00 2001 From: atm-adrien <67913809+atm-adrien@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:21:22 +0200 Subject: [PATCH 03/17] FIX : Scale for the "second" unit (#29327) * FIX : Update of the second unit scale * FIX : Pr returns --- htdocs/install/mysql/data/llx_c_units.sql | 2 +- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/migration/19.0.0-20.0.0.sql diff --git a/htdocs/install/mysql/data/llx_c_units.sql b/htdocs/install/mysql/data/llx_c_units.sql index 475020aabaf..523e1a9ebc4 100644 --- a/htdocs/install/mysql/data/llx_c_units.sql +++ b/htdocs/install/mysql/data/llx_c_units.sql @@ -54,7 +54,7 @@ INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('P', '500', '0','Piece','p', 'qty', 1); INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('SET','510', '0','Set','set', 'qty', 1); -INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('S', '600', '0','second','s', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('S', '600', '1','second','s', 'time', 1); INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MI','610', '60','minute','i', 'time', 1); INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('H', '620', '3600','hour','h', 'time', 1); INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('D', '630', '86400','day','d', 'time', 1); diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql new file mode 100644 index 00000000000..e1f606be046 --- /dev/null +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -0,0 +1 @@ +UPDATE llx_c_units SET scale = 1 WHERE code = 'S'; From 95aa03e3b0f3c8b5b2920529d9ef27143806feb5 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:53:03 +0300 Subject: [PATCH 04/17] FIX #28347 FIX #28962 FIX #29224 FIX #29035 (#29303) * FIX #28347 FIX #28962 FIX #29224 * fix empty line * Update card.php * FIX #29035 * add multicompany support in creation of supplier order from client order * Update card.php Assign a subprice value of 0 to user selected lines without a vendor product price when creating a supplier order from a client order --- htdocs/fourn/commande/card.php | 97 ++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 985d5d114f4..849a7c9fefa 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -12,6 +12,7 @@ * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2022 Charlene Benke * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2024 Nick Fragoulis * * 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 @@ -1333,10 +1334,35 @@ if (empty($reshook)) { $product_fourn_price_id = 0; if ($origin == "commande") { $productsupplier = new ProductFournisseur($db); - $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid); + $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $object->socid); + $lines[$i]->subprice = 0; if ($result > 0) { $ref_supplier = $productsupplier->ref_supplier; $product_fourn_price_id = $productsupplier->product_fourn_price_id; + // we need supplier subprice + foreach ($srcobject->lines as $li) { + $sql = 'SELECT price, unitprice, tva_tx, remise_percent, entity, ref_fourn'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql .= ' WHERE fk_product = '.((int) $li->fk_product); + $sql .= ' AND entity IN ('.getEntity('product_fournisseur_price').')'; + $sql .= ' AND fk_soc = '.((int) $object->socid); + $sql .= ' ORDER BY unitprice ASC'; + + $resql = $db->query($sql); + if ($resql) { + $num_row = $db->num_rows($resql); + if (empty($num_row)) { + $li->remise_percent = 0; + } else { + $obj = $db->fetch_object($resql); + $li->subprice = $obj->unitprice; + $li->remise_percent = $obj->remise_percent; + } + } else { + dol_print_error($db); + } + $db->free($resql); + } } } else { $ref_supplier = $lines[$i]->ref_fourn; @@ -1626,35 +1652,52 @@ if ($action == 'create') { $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - - $soc = $objectsrc->thirdparty; - - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); - $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); - //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); - //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateinvoice = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : ''; - - $datedelivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); - - if (isModEnabled("multicurrency")) { - if (!empty($objectsrc->multicurrency_code)) { - $currency_code = $objectsrc->multicurrency_code; + if ($origin == "commande") { + $cond_reglement_id = 0; + $mode_reglement_id = 0; + $delivery_date = ''; + $objectsrc->note_private = ''; + $objectsrc->note_public = ''; + if ($societe = $object->thirdparty) { + $cond_reglement_id = $societe->cond_reglement_supplier_id; + $mode_reglement_id = $societe->mode_reglement_supplier_id; + if (isModEnabled("multicurrency")) { + $currency_code = $societe->multicurrency_code; + if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX')) { + $currency_tx = $societe->multicurrency_tx; + } + } } - if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) { - $currency_tx = $objectsrc->multicurrency_tx; + } else { + $soc = $objectsrc->thirdparty; + + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : ''; + + $datedelivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); + + if (isModEnabled("multicurrency")) { + if (!empty($objectsrc->multicurrency_code)) { + $currency_code = $objectsrc->multicurrency_code; + } + if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) { + $currency_tx = $objectsrc->multicurrency_tx; + } } + + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } - - $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); - - // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } else { $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0; $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0; From 3076b6ad4071f5323158af52368bcb6693d4d1bf Mon Sep 17 00:00:00 2001 From: boudet jean pascal <68547382+atm-jpb@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:44:54 +0200 Subject: [PATCH 05/17] fix 500 error count array (#29337) * fix error 500 on array count * fix pre-commit error * Update html.form.class.php --------- Co-authored-by: jpb Co-authored-by: Laurent Destailleur --- htdocs/core/class/html.form.class.php | 9 ++++++--- htdocs/core/lib/company.lib.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2dd23ab1e95..958375cd0c7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -830,13 +830,16 @@ class Form $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook // check if there is a mass action - if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) { + + if (is_array($arrayofaction) && count($arrayofaction) == 0 && empty($hookmanager->resPrint)) { return; } if (empty($reshook)) { $ret .= ''; - foreach ($arrayofaction as $code => $label) { - $ret .= ''; + if (is_array($arrayofaction)) { + foreach ($arrayofaction as $code => $label) { + $ret .= ''; + } } } $ret .= $hookmanager->resPrint; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index dcd70604fc6..b949c2df58b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -874,7 +874,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print ''.$langs->trans("Status").''; if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; - $selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + $selectedfields = (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print $selectedfields; print ''; } From 99e85334b5061e2803871bfbf2fde9589488a799 Mon Sep 17 00:00:00 2001 From: atm-adrien <67913809+atm-adrien@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:31:25 +0200 Subject: [PATCH 06/17] FIX : Error when updating user (#29304) * FIX : Error management * FIW : PR returns * FIX : PR returns error --- htdocs/langs/en_US/users.lang | 1 + htdocs/user/card.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index c4695d86791..e7d0395e661 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -134,3 +134,4 @@ UserPublicPageDesc=You can enable a virtual card for this user. An url with the EnablePublicVirtualCard=Enable the user's virtual business card UserEnabledDisabled=User status changed: %s AlternativeEmailForOAuth2=Alternative Email for OAuth2 login +ErrorUpdateCanceledDueToDuplicatedUniqueValue=Error, The update was canceled because one of the pieces of data, that should be unique, already exists diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 521523f5ace..fe308317daf 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -550,7 +550,7 @@ if (empty($reshook)) { $error++; if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors'); + setEventMessages($langs->trans("ErrorUpdateCanceledDueToDuplicatedUniqueValue", $object->login), null, 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; From 5cec87a80e2212ebd884fa7f8ae598221eae62f5 Mon Sep 17 00:00:00 2001 From: IC-Ilies <86972374+IC-Ilies@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:56:02 +0200 Subject: [PATCH 07/17] FIX link type extrafield on warehouse not working (#29339) --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b22c23c8699..bf0bff6b4b1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11923,7 +11923,8 @@ function getElementProperties($element_type) } elseif ($element_type == 'inventory') { $module = 'product'; $classpath = 'product/inventory/class'; - } elseif ($element_type == 'stock') { + } elseif ($element_type == 'stock' || $element_type == 'entrepot') { + $module = 'stock'; $classpath = 'product/stock/class'; $classfile = 'entrepot'; $classname = 'Entrepot'; From 028a099e130aa03638e8960ab2cf966181b5d2fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Apr 2024 03:07:02 +0200 Subject: [PATCH 08/17] Fix warnings --- htdocs/takepos/invoice.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4c484b76585..e02abdb7458 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1564,7 +1564,7 @@ if (empty($_SESSION["basiclayout"]) || $_SESSION["basiclayout"] != 1) { // In phone version only show when it is invoice page if (empty($mobilepage) || $mobilepage == "invoice") { print '' . price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency) . ''; - if (isModEnabled('multicurrency') && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) { + if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"]) && $conf->currency != $_SESSION["takeposcustomercurrency"]) { //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; $multicurrency = new MultiCurrency($db); @@ -1829,7 +1829,11 @@ if ($placeid > 0) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $stock_real = price2num($obj->reel, 'MS'); + if ($obj) { + $stock_real = price2num($obj->reel, 'MS'); + } else { + $stock_real = 0; + } $htmlforlines .= $line->qty; if ($line->qty && $line->qty > $stock_real) { $htmlforlines .= ''; From 26a750ee0a64f283f17ace7a54a673481ca1c16d Mon Sep 17 00:00:00 2001 From: MaximilienR-easya <122890855+MaximilienR-easya@users.noreply.github.com> Date: Tue, 16 Apr 2024 10:28:47 +0200 Subject: [PATCH 09/17] 17.0 Backport autocomplete in dialog box (#29307) * Fix autocomplete list showing in the background of the dialog box and was unusable * Fix permit to adjust dialog box size in case of the autocomplete list is cut by the dialog box * adjust dialog box size to be more fitting to the content * rollback * Backport Fix --- htdocs/theme/eldy/global.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5a68987162c..f18c09ba96c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4995,7 +4995,9 @@ div#card-errors { .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable { z-index: 1002 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ } - +.ui-menu.ui-widget.ui-widget-content.ui-autocomplete.ui-front { + z-index:1006 !important; /* To always be over the dialog box */ +} /* ============================================================================== */ /* For content of image preview */ From 5278cb07a834a1cc628b8fe184ecd37a0f4d26fa Mon Sep 17 00:00:00 2001 From: atm-adrien <67913809+atm-adrien@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:36:35 +0200 Subject: [PATCH 10/17] FIX : We should be able to remove wokstation from bom lines (#29360) --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 8ea8e3e3edd..b4b1f977414 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -792,7 +792,7 @@ class BOM extends CommonObject $line->array_options[$key] = $array_options[$key]; } } - if ($fk_default_workstation >= 0 && $line->fk_default_workstation != $fk_default_workstation) { + if ($line->fk_default_workstation != $fk_default_workstation) { $line->fk_default_workstation = $fk_default_workstation; } From 31ce8f826b4d58f76cf0e2db0943150f2c4d5bf2 Mon Sep 17 00:00:00 2001 From: atm-lucas <121817516+atm-lucasmantegari@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:00:23 +0200 Subject: [PATCH 11/17] FIX - Repair the replenishment list (#29336) * Repair the replenishment list * Warning and condition * pre-commit failling * Update replenish.php * Update replenish.php * Fixing list * pre-commit error * pre-commit error 2 * Fonction bis --------- Co-authored-by: Laurent Destailleur --- htdocs/product/stock/replenish.php | 347 +++++++++++++++-------------- 1 file changed, 181 insertions(+), 166 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 71040557537..8f464034fee 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -30,11 +30,11 @@ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; require_once './lib/replenishment.lib.php'; // Load translation files required by the page @@ -54,7 +54,7 @@ $hookmanager->initHooks(array('stockreplenishlist')); $action = GETPOST('action', 'aZ09'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $type = GETPOST('type', 'int'); $tobuy = GETPOST('tobuy', 'int'); $salert = GETPOST('salert', 'alpha'); @@ -68,7 +68,7 @@ $fk_supplier = GETPOST('fk_supplier', 'int'); $fk_entrepot = GETPOST('fk_entrepot', 'int'); // List all visible warehouses -$resWar = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "entrepot WHERE entity IN (" . $db->sanitize(getEntity('stock')) .")"); +$resWar = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "entrepot WHERE entity IN (" . $db->sanitize(getEntity('stock')) . ")"); $listofqualifiedwarehousesid = ""; $count = 0; while ($tmpobj = $db->fetch_object($resWar)) { @@ -93,7 +93,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; if (!$sortfield) { @@ -161,15 +161,15 @@ if ($action == 'order' && GETPOST('valid')) { $db->begin(); $suppliers = array(); - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; $productsupplier = new ProductFournisseur($db); for ($i = 0; $i < $linecount; $i++) { - if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) { + if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) { //one line $box = $i; - $supplierpriceid = GETPOST('fourn'.$i, 'int'); + $supplierpriceid = GETPOST('fourn' . $i, 'int'); //get all the parameters needed to create a line - $qty = GETPOST('tobuy'.$i, 'int'); + $qty = GETPOST('tobuy' . $i, 'int'); $idprod = $productsupplier->get_buyprice($supplierpriceid, $qty); $res = $productsupplier->fetch($idprod); if ($res && $idprod > 0) { @@ -215,7 +215,7 @@ if ($action == 'order' && GETPOST('valid')) { dol_print_error($db); } - unset($_POST['fourn'.$i]); + unset($_POST['fourn' . $i]); } unset($_POST[$i]); } @@ -229,10 +229,10 @@ if ($action == 'order' && GETPOST('valid')) { $order = new CommandeFournisseur($db); // Check if an order for the supplier exists - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql .= " WHERE fk_soc = ".((int) $suppliersid[$i]); - $sql .= " AND source = ".((int) $order::SOURCE_ID_REPLENISHMENT)." AND fk_statut = ".((int) $order::STATUS_DRAFT); - $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande_fournisseur"; + $sql .= " WHERE fk_soc = " . ((int) $suppliersid[$i]); + $sql .= " AND source = " . ((int) $order::SOURCE_ID_REPLENISHMENT) . " AND fk_statut = " . ((int) $order::STATUS_DRAFT); + $sql .= " AND entity IN (" . getEntity('commande_fournisseur') . ")"; $sql .= " ORDER BY date_creation DESC"; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) > 0) { @@ -269,7 +269,7 @@ if ($action == 'order' && GETPOST('valid')) { } if ($result < 0) { $fail++; - $msg = $langs->trans('OrderFail')." : "; + $msg = $langs->trans('OrderFail') . " : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } else { @@ -294,7 +294,7 @@ if ($action == 'order' && GETPOST('valid')) { $id = $order->create($user); if ($id < 0) { $fail++; - $msg = $langs->trans('OrderFail')." : "; + $msg = $langs->trans('OrderFail') . " : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } @@ -347,11 +347,11 @@ $sql .= ' p.desiredstock, p.seuil_stock_alerte,'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $sql .= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; } -$sql .= " ".$sqldesiredtock." as desiredstockcombined, ".$sqlalertstock." as seuil_stock_alertecombined,"; +$sql .= " " . $sqldesiredtock . " as desiredstockcombined, " . $sqlalertstock . " as seuil_stock_alertecombined,"; $sql .= ' s.fk_product,'; -$sql .= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; +$sql .= " SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ') as stock_physique'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql .= ", SUM(".$db->ifsql("s.reel IS NULL OR s.fk_entrepot <> ".$fk_entrepot, "0", "s.reel").') as stock_real_warehouse'; + $sql .= ", SUM(" . $db->ifsql("s.reel IS NULL OR s.fk_entrepot <> " . $fk_entrepot, "0", "s.reel") . ') as stock_real_warehouse'; } // Add fields from hooks @@ -359,21 +359,26 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; $list_warehouse = (empty($listofqualifiedwarehousesid) ? '0' : $listofqualifiedwarehousesid); -$sql .= ' AND s.fk_entrepot IN ('.$db->sanitize($list_warehouse) .')'; + +$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; +$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s ON p.rowid = s.fk_product'; +$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse) . ')'; + +$list_warehouse_selected = ($fk_entrepot < 0) ? '0' : $fk_entrepot; +$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse_selected) . ')'; + //$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.((int) $fk_entrepot).')'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = ' . ((int) $fk_entrepot) . ')'; } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; +$sql .= ' WHERE p.entity IN (' . getEntity('product') . ')'; if ($sall) { $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); } @@ -392,11 +397,11 @@ if ($search_label) { $sql .= natural_search('p.label', $search_label); } $sql .= ' AND p.tobuy = 1'; -if (!empty($conf->variants->eabled) && empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { // Add test to exclude products that has variants - $sql .= ' AND p.rowid NOT IN (SELECT pac.fk_product_parent FROM '.MAIN_DB_PREFIX.'product_attribute_combination as pac WHERE pac.entity IN ('.getEntity('product').'))'; +if (isModEnabled('variants') && !getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) { // Add test to exclude products that has variants + $sql .= ' AND p.rowid NOT IN (SELECT pac.fk_product_parent FROM ' . MAIN_DB_PREFIX . 'product_attribute_combination as pac WHERE pac.entity IN (' . getEntity('product') . '))'; } if ($fk_supplier > 0) { - $sql .= ' AND EXISTS (SELECT pfp.rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid AND pfp.fk_soc = '.((int) $fk_supplier).' AND pfp.entity IN ('.getEntity('product_fournisseur_price').'))'; + $sql .= ' AND EXISTS (SELECT pfp.rowid FROM ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid AND pfp.fk_soc = ' . ((int) $fk_supplier) . ' AND pfp.entity IN (' . getEntity('product_fournisseur_price') . '))'; } // Add where from hooks $parameters = array(); @@ -416,9 +421,9 @@ $sql .= ', s.fk_product'; if ($usevirtualstock) { if (isModEnabled('commande')) { - $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd1, ".MAIN_DB_PREFIX."commande as c1"; - $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'commande').")"; + $sqlCommandesCli = "(SELECT " . $db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)") . " as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlCommandesCli .= " FROM " . MAIN_DB_PREFIX . "commandedet as cd1, " . MAIN_DB_PREFIX . "commande as c1"; + $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'commande') . ")"; $sqlCommandesCli .= " AND cd1.fk_product = p.rowid"; $sqlCommandesCli .= " AND c1.fk_statut IN (1,2))"; } else { @@ -426,14 +431,14 @@ if ($usevirtualstock) { } if (isModEnabled("expedition")) { - $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e2,"; - $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."expeditiondet as ed2,"; - $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commande as c2,"; - $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commandedet as cd2"; - $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'expedition').")"; - $sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid"; - $sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)"; + $sqlExpeditionsCli = "(SELECT " . $db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)") . " as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlExpeditionsCli .= " FROM " . MAIN_DB_PREFIX . "expedition as e2,"; + $sqlExpeditionsCli .= " " . MAIN_DB_PREFIX . "expeditiondet as ed2,"; + $sqlExpeditionsCli .= " " . MAIN_DB_PREFIX . "commande as c2,"; + $sqlExpeditionsCli .= " " . MAIN_DB_PREFIX . "commandedet as cd2"; + $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'expedition') . ")"; + $sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid"; + $sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)"; $sqlExpeditionsCli .= " AND cd2.fk_product = p.rowid"; $sqlExpeditionsCli .= " AND e2.fk_statut IN (1,2))"; } else { @@ -441,18 +446,18 @@ if ($usevirtualstock) { } if (isModEnabled("supplier_order")) { - $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; - $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; + $sqlCommandesFourn = "(SELECT " . $db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)") . " as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlCommandesFourn .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd3,"; + $sqlCommandesFourn .= " " . MAIN_DB_PREFIX . "commande_fournisseur as c3"; $sqlCommandesFourn .= " WHERE c3.rowid = cd3.fk_commande"; - $sqlCommandesFourn .= " AND c3.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; + $sqlCommandesFourn .= " AND c3.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order') . ")"; $sqlCommandesFourn .= " AND cd3.fk_product = p.rowid"; $sqlCommandesFourn .= " AND c3.fk_statut IN (3,4))"; - $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf4,"; - $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd4"; - $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")"; + $sqlReceptionFourn = "(SELECT " . $db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)") . " as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlReceptionFourn .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as cf4,"; + $sqlReceptionFourn .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as fd4"; + $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order') . ")"; $sqlReceptionFourn .= " AND fd4.fk_product = p.rowid"; $sqlReceptionFourn .= " AND cf4.fk_statut IN (3,4))"; } else { @@ -461,18 +466,18 @@ if ($usevirtualstock) { } if (isModEnabled('mrp')) { - $sqlProductionToConsume = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlProductionToConsume .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; - $sqlProductionToConsume .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; - $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo').")"; + $sqlProductionToConsume = "(SELECT GREATEST(0, " . $db->ifsql("SUM(" . $db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty') . ") IS NULL", "0", "SUM(" . $db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty') . ")") . ") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlProductionToConsume .= " FROM " . MAIN_DB_PREFIX . "mrp_mo as mm5,"; + $sqlProductionToConsume .= " " . MAIN_DB_PREFIX . "mrp_production as mp5"; + $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo') . ")"; $sqlProductionToConsume .= " AND mp5.fk_product = p.rowid"; $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consumed')"; $sqlProductionToConsume .= " AND mm5.status IN (1,2))"; - $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlProductionToProduce .= " FROM ".MAIN_DB_PREFIX."mrp_mo as mm5,"; - $sqlProductionToProduce .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; - $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo').")"; + $sqlProductionToProduce = "(SELECT GREATEST(0, " . $db->ifsql("SUM(" . $db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty') . ") IS NULL", "0", "SUM(" . $db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty') . ")") . ") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlProductionToProduce .= " FROM " . MAIN_DB_PREFIX . "mrp_mo as mm5,"; + $sqlProductionToProduce .= " " . MAIN_DB_PREFIX . "mrp_production as mp5"; + $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (" . getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo') . ")"; $sqlProductionToProduce .= " AND mp5.fk_product = p.rowid"; $sqlProductionToProduce .= " AND mp5.role IN ('toproduce', 'produced')"; $sqlProductionToProduce .= " AND mm5.status IN (1,2))"; @@ -482,45 +487,53 @@ if ($usevirtualstock) { } $sql .= ' HAVING ('; - $sql .= " (".$sqldesiredtock." >= 0 AND (".$sqldesiredtock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql .= " - (".$sqlCommandesCli." - ".$sqlExpeditionsCli.") + (".$sqlCommandesFourn." - ".$sqlReceptionFourn.") + (".$sqlProductionToProduce." - ".$sqlProductionToConsume.")))"; + $sql .= " (" . $sqldesiredtock . " >= 0 AND (" . $sqldesiredtock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')'; + $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))"; $sql .= ' OR'; if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " ((".$sqlalertstock." >= 0 OR ".$sqlalertstock." IS NULL) AND (".$db->ifsql($sqlalertstock." IS NULL", "0", $sqlalertstock)." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").")"; + $sql .= " ((" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; } else { - $sql .= " (".$sqlalertstock." >= 0 AND (".$sqlalertstock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= " (" . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')'; } - $sql .= " - (".$sqlCommandesCli." - ".$sqlExpeditionsCli.") + (".$sqlCommandesFourn." - ".$sqlReceptionFourn.") + (".$sqlProductionToProduce." - ".$sqlProductionToConsume.")))"; + $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))"; $sql .= ")"; + if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql .= " AND ("; + $sql .= " pse.desiredstock > 0)"; + } - if ($salert == 'on') { // Option to see when stock is lower than alert + if ($salert == 'on') { // Option to see when stock is lower than alert $sql .= ' AND ('; if ($includeproductswithoutdesiredqty == 'on') { - $sql .= "(".$sqlalertstock." >= 0 OR ".$sqlalertstock." IS NULL) AND (".$db->ifsql($sqlalertstock." IS NULL", "0", $sqlalertstock)." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").")"; + $sql .= "(" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; } else { - $sql .= $sqlalertstock." >= 0 AND (".$sqlalertstock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").")"; + $sql .= $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; } - $sql .= " - (".$sqlCommandesCli." - ".$sqlExpeditionsCli.") + (".$sqlCommandesFourn." - ".$sqlReceptionFourn.") + (".$sqlProductionToProduce." - ".$sqlProductionToConsume."))"; + $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . "))"; $sql .= ")"; $alertchecked = 'checked'; } } else { $sql .= ' HAVING ('; - $sql .= "(".$sqldesiredtock." >= 0 AND (".$sqldesiredtock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").")))"; + $sql .= "(" . $sqldesiredtock . " >= 0 AND (" . $sqldesiredtock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")))"; $sql .= ' OR'; if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " ((".$sqlalertstock." >= 0 OR ".$sqlalertstock." IS NULL) AND (".$db->ifsql($sqlalertstock." IS NULL", "0", $sqlalertstock)." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= " ((" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')))'; } else { - $sql .= " (".$sqlalertstock." >= 0 AND (".$sqlalertstock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= " (" . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')))'; } $sql .= ')'; + if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql .= " AND ("; + $sql .= " pse.desiredstock > 0)"; + } - if ($salert == 'on') { // Option to see when stock is lower than alert + if ($salert == 'on') { // Option to see when stock is lower than alert $sql .= " AND ("; if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " (".$sqlalertstock." >= 0 OR ".$sqlalertstock." IS NULL) AND (".$db->ifsql($sqlalertstock." IS NULL", "0", $sqlalertstock)." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel")."))"; + $sql .= " (" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . "))"; } else { - $sql .= " ".$sqlalertstock." >= 0 AND (".$sqlalertstock." > SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").'))'; + $sql .= " " . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . '))'; } $sql .= ')'; $alertchecked = 'checked'; @@ -562,11 +575,11 @@ llxHeader('', $title, $helpurl, ''); $head = array(); -$head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; +$head[0][0] = DOL_URL_ROOT . '/product/stock/replenish.php'; $head[0][1] = $title; $head[0][2] = 'replenish'; -$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; +$head[1][0] = DOL_URL_ROOT . '/product/stock/replenishorders.php'; $head[1][1] = $langs->trans("ReplenishmentOrders"); $head[1][2] = 'replenishorders'; @@ -575,48 +588,48 @@ print load_fiche_titre($langs->trans('Replenishment'), '', 'stock'); print dol_get_fiche_head($head, 'replenish', '', -1, ''); -print ''.$langs->trans("ReplenishmentStatusDesc").''."\n"; +print '' . $langs->trans("ReplenishmentStatusDesc") . '' . "\n"; //$link = ''.$langs->trans("MenuNewWarehouse").''; if (empty($fk_entrepot) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { - print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; + print '' . $langs->trans("ReplenishmentStatusDescPerWarehouse") . '' . "\n"; } print '

'; if ($usevirtualstock == 1) { - print $langs->trans("CurentSelectionMode").': '; - print ''.$langs->trans("UseVirtualStock").''; - print ' 0 ? '&fk_supplier='.$fk_supplier : '').($fk_entrepot > 0 ? '&fk_entrepot='.$fk_entrepot : '').'">'.$langs->trans("UsePhysicalStock").''; + print $langs->trans("CurentSelectionMode") . ': '; + print '' . $langs->trans("UseVirtualStock") . ''; + print ' 0 ? '&fk_supplier=' . $fk_supplier : '') . ($fk_entrepot > 0 ? '&fk_entrepot=' . $fk_entrepot : '') . '">' . $langs->trans("UsePhysicalStock") . ''; print '
'; } if ($usevirtualstock == 0) { - print $langs->trans("CurentSelectionMode").': '; - print ' 0 ? '&fk_supplier='.$fk_supplier : '').($fk_entrepot > 0 ? '&fk_entrepot='.$fk_entrepot : '').'">'.$langs->trans("UseVirtualStock").''; - print ' '.$langs->trans("UsePhysicalStock").''; + print $langs->trans("CurentSelectionMode") . ': '; + print ' 0 ? '&fk_supplier=' . $fk_supplier : '') . ($fk_entrepot > 0 ? '&fk_entrepot=' . $fk_entrepot : '') . '">' . $langs->trans("UseVirtualStock") . ''; + print ' ' . $langs->trans("UsePhysicalStock") . ''; print '
'; } -print '
'."\n"; +print '
' . "\n"; -print '
'; -print ''; +print ''; +print ''; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; if ($limit > 0 && $limit != $conf->liste_limit) { - print ''; + print ''; } if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print '
'; - print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); + print $langs->trans('Warehouse') . ' ' . $formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); print '
'; } print '
'; $filter = '(fournisseur:=:1)'; -print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', $filter, 1); +print $langs->trans('Supplier') . ' ' . $form->select_company($fk_supplier, 'fk_supplier', $filter, 1); print '
'; $parameters = array(); @@ -626,63 +639,63 @@ if (empty($reshook)) { } print '
'; -print ''; +print ''; print '
'; print '
'; -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print ''; -print ''; +print ''; if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { - $filters = '&search_ref='.urlencode($search_ref).'&search_label='.urlencode($search_label); - $filters .= '&sall='.urlencode($sall); - $filters .= '&salert='.urlencode($salert); - $filters .= '&draftorder='.urlencode($draftorder); - $filters .= '&mode='.urlencode($mode); + $filters = '&search_ref=' . urlencode($search_ref) . '&search_label=' . urlencode($search_label); + $filters .= '&sall=' . urlencode($sall); + $filters .= '&salert=' . urlencode($salert); + $filters .= '&draftorder=' . urlencode($draftorder); + $filters .= '&mode=' . urlencode($mode); if ($fk_supplier > 0) { - $filters .= '&fk_supplier='.urlencode($fk_supplier); + $filters .= '&fk_supplier=' . urlencode($fk_supplier); } if ($fk_entrepot > 0) { - $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + $filters .= '&fk_entrepot=' . urlencode($fk_entrepot); } } else { - $filters = '&search_ref='.urlencode($search_ref).'&search_label='.urlencode($search_label); - $filters .= '&fourn_id='.urlencode($fourn_id); - $filters .= (isset($type) ? '&type='.urlencode($type) : ''); - $filters .= '&='.urlencode($salert); - $filters .= '&draftorder='.urlencode($draftorder); - $filters .= '&mode='.urlencode($mode); + $filters = '&search_ref=' . urlencode($search_ref) . '&search_label=' . urlencode($search_label); + $filters .= '&fourn_id=' . urlencode($fourn_id); + $filters .= (isset($type) ? '&type=' . urlencode($type) : ''); + $filters .= '&=' . urlencode($salert); + $filters .= '&draftorder=' . urlencode($draftorder); + $filters .= '&mode=' . urlencode($mode); if ($fk_supplier > 0) { - $filters .= '&fk_supplier='.urlencode($fk_supplier); + $filters .= '&fk_supplier=' . urlencode($fk_supplier); } if ($fk_entrepot > 0) { - $filters .= '&fk_entrepot='.urlencode($fk_entrepot); + $filters .= '&fk_entrepot=' . urlencode($fk_entrepot); } } if ($limit > 0 && $limit != $conf->liste_limit) { - $filters .= '&limit='.((int) $limit); + $filters .= '&limit=' . ((int) $limit); } -if (!empty($includeproductswithoutdesiredqty)) $filters .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); -if (!empty($salert)) $filters .= '&salert='.urlencode($salert); +if (!empty($includeproductswithoutdesiredqty)) $filters .= '&includeproductswithoutdesiredqty=' . urlencode($includeproductswithoutdesiredqty); +if (!empty($salert)) $filters .= '&salert=' . urlencode($salert); -$param = (isset($type) ? '&type='.urlencode($type) : ''); -$param .= '&fourn_id='.urlencode($fourn_id).'&search_label='.urlencode($search_label).'&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty).'&salert='.urlencode($salert).'&draftorder='.urlencode($draftorder); -$param .= '&search_ref='.urlencode($search_ref); -$param .= '&mode='.urlencode($mode); -$param .= '&fk_supplier='.urlencode($fk_supplier); -$param .= '&fk_entrepot='.urlencode($fk_entrepot); -if (!empty($includeproductswithoutdesiredqty)) $param .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); -if (!empty($salert)) $param .= '&salert='.urlencode($salert); +$param = (isset($type) ? '&type=' . urlencode($type) : ''); +$param .= '&fourn_id=' . urlencode($fourn_id) . '&search_label=' . urlencode($search_label) . '&includeproductswithoutdesiredqty=' . urlencode($includeproductswithoutdesiredqty) . '&salert=' . urlencode($salert) . '&draftorder=' . urlencode($draftorder); +$param .= '&search_ref=' . urlencode($search_ref); +$param .= '&mode=' . urlencode($mode); +$param .= '&fk_supplier=' . urlencode($fk_supplier); +$param .= '&fk_entrepot=' . urlencode($fk_entrepot); +if (!empty($includeproductswithoutdesiredqty)) $param .= '&includeproductswithoutdesiredqty=' . urlencode($includeproductswithoutdesiredqty); +if (!empty($salert)) $param .= '&salert=' . urlencode($salert); $stocklabel = $langs->trans('Stock'); $stocklabelbis = $langs->trans('Stock'); @@ -695,8 +708,8 @@ if ($usevirtualstock == 0) { $stocklabel = $langs->trans('PhysicalStock'); } if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $stocklabelbis = $stocklabel.' (Selected warehouse)'; - $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; + $stocklabelbis = $stocklabel . ' (Selected warehouse)'; + $stocklabel .= ' (' . $langs->trans("AllWarehouses") . ')'; } $texte = $langs->trans('Replenishment'); @@ -742,25 +755,25 @@ print ''; // Fields title search print ''; print ''; -print ''; -print ''; +print ''; +print ''; if (isModEnabled("service") && $type == 1) { print ''; } -print ''; +print ''; print ''; -print ''; +print ''; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { print ''; } print ''; print ''; // Fields from hook -$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -789,7 +802,7 @@ print_liste_field_titre('StockToBuy', $_SERVER["PHP_SELF"], '', $param, '', '', print_liste_field_titre('SupplierRef', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right '); // Hook fields -$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -805,14 +818,14 @@ while ($i < ($limit ? min($num, $limit) : $num)) { exit; } - $prod->load_stock('warehouseopen, warehouseinternal'.(!$usevirtualstock?', novirtual':''), $draftchecked); + $prod->load_stock('warehouseopen, warehouseinternal' . (!$usevirtualstock ? ', novirtual' : ''), $draftchecked); // Multilangs if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql = 'SELECT label,description'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; - $sql .= ' WHERE fk_product = '.((int) $objp->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; + $sql .= ' WHERE fk_product = ' . ((int) $objp->rowid); + $sql .= " AND lang = '" . $db->escape($langs->getDefaultLang()) . "'"; $sql .= ' LIMIT 1'; $resqlm = $db->query($sql); @@ -834,7 +847,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; } else { $stock = $prod->stock_reel; - $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real; + if (!empty($prod->stock_warehouse[$fk_entrepot])) { + $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real; + } } // Force call prod->load_stats_xxx to choose status to count (otherwise it is loaded by load_stock function) @@ -859,11 +874,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $warning = ''; if ($alertstock && ($stock < $alertstock)) { - $warning = img_warning($langs->trans('StockTooLow')).' '; + $warning = img_warning($langs->trans('StockTooLow')) . ' '; } $warningwarehouse = ''; if ($alertstockwarehouse && ($stockwarehouse < $alertstockwarehouse)) { - $warningwarehouse = img_warning($langs->trans('StockTooLow')).' '; + $warningwarehouse = img_warning($langs->trans('StockTooLow')) . ' '; } //depending on conf, use either physical stock or @@ -896,59 +911,59 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; // Select field - print ''; + print ''; - print ''; + print ''; - print ''; if (isModEnabled("service") && $type == 1) { $regs = array(); if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - $duration = $regs[1].' '.$langs->trans('DurationYear'); + $duration = $regs[1] . ' ' . $langs->trans('DurationYear'); } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - $duration = $regs[1].' '.$langs->trans('DurationMonth'); + $duration = $regs[1] . ' ' . $langs->trans('DurationMonth'); } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - $duration = $regs[1].' '.$langs->trans('DurationDay'); + $duration = $regs[1] . ' ' . $langs->trans('DurationDay'); } else { $duration = $objp->duration; } - print ''; + print ''; } // Desired stock - print ''; + print ''; // Limit stock for alert - print ''; + print ''; // Current stock (all warehouses) - print ''; // Current stock (warehouse selected only) if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - print ''; + print ''; } // Already ordered - print ''; + print ''; // To order $tobuy = (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $stocktobuywarehouse : $stocktobuy; - print ''; + print ''; // Supplier print ''; // Fields from hook - $parameters = array('objp'=>$objp, 'i'=>$i, 'tobuy'=>$tobuy); + $parameters = array('objp' => $objp, 'i' => $i, 'tobuy' => $tobuy); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -965,14 +980,14 @@ if ($num == 0) { if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $colspan++; } - print ''; } -$parameters = array('sql'=>$sql); +$parameters = array('sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -985,7 +1000,7 @@ print dol_get_fiche_end(); $value = $langs->trans("CreateOrders"); -print '
'; +print '
'; print ''; From 0d5d0d6ae8e8a1e1630b20b1c4687020edb136b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 Apr 2024 17:33:28 +0200 Subject: [PATCH 12/17] More complete log --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 958375cd0c7..32b74cf241e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8112,8 +8112,8 @@ class Form ); if (!is_object($objecttmp)) { - dol_syslog('selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.', objectfield='.$objectfield, LOG_WARNING); - return 'selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.', objectfield='.$objectfield; + dol_syslog('selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.', objectfield='.$objectfield.', objectdesc='.$objectdesc, LOG_WARNING); + return 'selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.', objectfield='.$objectfield.', objectdesc='.$objectdesc; } //var_dump($filter); From 94cc9c2e28b9b9f9887a5c09c4399a7f7810c5f9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 17 Apr 2024 17:56:39 +0200 Subject: [PATCH 13/17] Fix ergo fail (#29370) --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bf0bff6b4b1..4efa1c98b1b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13338,8 +13338,8 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n && $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_MODIFY' ) { - $out .= '
'; - $out .= dolGetFirstLineOfText($histo[$key]['message'], 3); + $out .= '
'; + $out .= $histo[$key]['message']; $out .= '
'; } From eea2201472d102d3f7f5717094da2e61b434079c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 17 Apr 2024 18:02:03 +0200 Subject: [PATCH 14/17] do not add tooltip in tooltip in object lines view (#29368) --- htdocs/core/tpl/objectline_view.tpl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index ef78b72ce1c..a60e0fe48d1 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -137,7 +137,11 @@ if (($line->info_bits & 2) == 2) { $format = (getDolGlobalString('MAIN_USE_HOURMIN_IN_DATE_RANGE') ? 'dayhour' : 'day'); if ($line->fk_product > 0) { - print $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '')); + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + print (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '') . $text; + } else { + print $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '')); + } } else { $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); if ($type == 1) { From 8e23600ee0764c0fee770329e0d70dd8060a3d35 Mon Sep 17 00:00:00 2001 From: Eric <1468823+rycks@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:25:13 +0200 Subject: [PATCH 15/17] fix start amount, '' is less than first releve.... (#29366) --- htdocs/compta/bank/releve.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 38a8fb1013b..d20666c224e 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -125,6 +125,7 @@ $foundnext = ''; $sql = "SELECT b.num_releve as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; +$sql .= " AND b.num_releve <> ''"; $sql .= " AND b.fk_account = ".((int) $object->id); $sql .= " ORDER BY b.num_releve DESC"; $sql .= $db->plimit(1); @@ -380,6 +381,7 @@ if (empty($numref)) { $sql = "SELECT sum(b.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'"; + $sql .= " AND b.num_releve <> ''"; $sql .= " AND b.fk_account = ".((int) $object->id); $resql = $db->query($sql); if ($resql) { @@ -464,6 +466,7 @@ if (empty($numref)) { $sql = "SELECT sum(b.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql .= " AND b.num_releve <> ''"; $sql .= " AND b.fk_account = ".((int) $object->id); $resql = $db->query($sql); From db74893f3f1a4111d2485bf6778dac807d83e6e8 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 17 Apr 2024 19:03:18 +0200 Subject: [PATCH 16/17] Fix extrafields origins rights (#29376) --- htdocs/comm/action/card.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 48fc2083e5d..1dfd9dff3cb 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -361,7 +361,8 @@ if (empty($reshook) && $action == 'add') { $object->label = GETPOST('label', 'alphanohtml'); if (GETPOST("elementtype", 'alpha')) { - $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha'); + $elProp = getElementProperties(GETPOST("elementtype", 'alpha')); + $modulecodetouseforpermissioncheck = $elProp['module']; $hasPermissionOnLinkedObject = 0; if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { @@ -822,7 +823,8 @@ if (empty($reshook) && $action == 'update') { $object->note_private = trim(GETPOST("note", "restricthtml")); if (GETPOST("elementtype", 'alpha')) { - $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha'); + $elProp = getElementProperties(GETPOST("elementtype", 'alpha')); + $modulecodetouseforpermissioncheck = $elProp['module']; $hasPermissionOnLinkedObject = 0; if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { @@ -1606,7 +1608,9 @@ if ($action == 'create') { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $hasPermissionOnLinkedObject = 0; - if ($user->hasRight($origin, 'read')) { + + $elProp = getElementProperties($origin); + if ($user->hasRight($elProp['module'], 'read')) { $hasPermissionOnLinkedObject = 1; } //var_dump('origin='.$origin.' originid='.$originid.' hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject); From fdebfdb8c68982b95ffa192ec8ad37ca0c469ff9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 Apr 2024 23:30:07 +0200 Subject: [PATCH 17/17] Fix warning --- htdocs/core/modules/facture/mod_facture_terre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index f53528f2d95..72473e854d1 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -73,7 +73,7 @@ class mod_facture_terre extends ModeleNumRefFactures { global $conf, $mysoc; - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code != 'FR') { + if (((float) getDolGlobalString('MAIN_VERSION_LAST_INSTALL')) >= 16.0 && $mysoc->country_code != 'FR') { $this->prefixinvoice = 'IN'; // We use correct standard code "IN = Invoice" $this->prefixreplacement = 'IR'; $this->prefixdeposit = 'ID';
  '.$form->textwithpicto($langs->trans('IncludeEmptyDesiredStock'), $langs->trans('IncludeProductWithUndefinedAlerts')).' ' . $form->textwithpicto($langs->trans('IncludeEmptyDesiredStock'), $langs->trans('IncludeProductWithUndefinedAlerts')) . ' '.$langs->trans('AlertOnly').' ' . $langs->trans('AlertOnly') . '  '; if (!empty($conf->global->STOCK_REPLENISH_ADD_CHECKBOX_INCLUDE_DRAFT_ORDER)) { - print $langs->trans('IncludeAlsoDraftOrders').' '; + print $langs->trans('IncludeAlsoDraftOrders') . ' '; } print ' 
'.$prod->getNomUrl(1, 'stock').'' . $prod->getNomUrl(1, 'stock') . ''; + print ''; print dol_escape_htmltag($objp->label); - print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST + print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST print ''.$duration.'' . $duration . ''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock).'' . ((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock) . ''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock).'' . ((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock) . ''.$warning.$stock; - print ''; + print '' . $warning . $stock; + print ''; print ''.$warningwarehouse.$stockwarehouse.'' . $warningwarehouse . $stockwarehouse . ''.$ordered.' '.$picto.'' . $ordered . ' ' . $picto . ''; - print $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier); + print $form->select_product_fourn_price($prod->id, 'fourn' . $i, $fk_supplier); print '
'; + print '
'; print ''; print $langs->trans("None"); print ''; print '