From 5401791247322cd9ea17af8ffa7e95fc2bd81dfa Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 11 Feb 2025 15:40:47 +0100 Subject: [PATCH] Debug v21 --- htdocs/core/lib/product.lib.php | 37 +++++++++++++++++++------------- htdocs/product/admin/product.php | 4 +++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index f13d2df07b8..1c9b0910bc0 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -328,7 +328,7 @@ function productlot_prepare_head($object) */ function product_admin_prepare_head() { - global $langs, $conf, $user, $db; + global $langs, $conf, $db; $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('product'); @@ -368,24 +368,31 @@ function product_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_price_extrafields.php'; - $head[$h][1] = $langs->trans("ProductLevelExtraFields"); - $nbExtrafields = $extrafields->attributes['product_price']['count']; - if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + // Extrafields for price levels + if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_price_extrafields.php'; + $head[$h][1] = $langs->trans("ProductLevelExtraFields"); + $nbExtrafields = $extrafields->attributes['product_price']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'levelAttributes'; + $h++; } - $head[$h][2] = 'levelAttributes'; - $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_customer_extrafields.php'; - $head[$h][1] = $langs->trans("ProductCustomerExtraFields"); - $nbExtrafields = $extrafields->attributes['product_customer_price']['count']; - if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + //Extrafields for price per customer + if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_customer_extrafields.php'; + $head[$h][1] = $langs->trans("ProductCustomerExtraFields"); + $nbExtrafields = $extrafields->attributes['product_customer_price']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'customerAttributes'; + $h++; } - $head[$h][2] = 'customerAttributes'; - $h++; + // Supplier prices $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php'; $head[$h][1] = $langs->trans("ProductSupplierExtraFields"); $nbExtrafields = $extrafields->attributes['product_fournisseur_price']['count']; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index d38409f9eaa..742e4a8de52 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -122,9 +122,11 @@ if ($action == 'other') { if ($tmprule == $princingrules) { // We are on selected rule, we enable it if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'PRODUCT_PRICE_UNIQ', 1, 'chaine', 0, '', $conf->entity); } else { $multirule = explode('&', $princingrules);