From fc78b2e882a48099174ee84ef8b3e218db517de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 May 2023 11:22:02 +0200 Subject: [PATCH 1/9] can use isModEnabled("module") in extrafield enabled --- htdocs/core/actions_extrafields.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 83fd8d47c4f..e8c4154c85b 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -367,7 +367,7 @@ if ($action == 'update') { $computedvalue, (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'restricthtml'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha'), array('css' => $css, 'cssview' => $cssview, 'csslist' => $csslist) From 69dcd9dfd098110414ea40dfe7b111e5705e10b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 May 2023 11:23:30 +0200 Subject: [PATCH 2/9] Update admin_extrafields_edit.tpl.php --- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 2e8511acf8e..e12c6c17ce6 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * 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 @@ -143,7 +143,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con - + From 2a9dbd357ee6305cdaf5e44eaf31b5dc3f81ad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 May 2023 11:59:14 +0200 Subject: [PATCH 3/9] Update admin_extrafields_edit.tpl.php --- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index e12c6c17ce6..093af43a635 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -143,7 +143,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con - + From ade94b8ab219f36fee566406bea17ed3ae0fa253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 May 2023 12:00:32 +0200 Subject: [PATCH 4/9] Update actions_extrafields.inc.php --- htdocs/core/actions_extrafields.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index e8c4154c85b..a74f9c4c5a8 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -367,7 +367,7 @@ if ($action == 'update') { $computedvalue, (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'restricthtml'), + GETPOST('enabled', 'nohtml'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha'), array('css' => $css, 'cssview' => $cssview, 'csslist' => $csslist) From a8cfea083e5ecf259e8473fa17c42d6fd291a76d Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 15 May 2023 11:09:35 +0200 Subject: [PATCH 5/9] add charchesociales in security.lib.php --- htdocs/core/lib/security.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index aeb58d34c0f..92b56ebdd2f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -811,10 +811,13 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $feature = 'projet_task'; } + if ($feature == 'payment_sc'){ + $feature = "chargesociales"; + } $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment','chargesociales'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe $checkother = array('contact', 'agenda', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object From 76e7195dd0d0af11842e6023df721430224e571e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 15 May 2023 09:16:23 +0000 Subject: [PATCH 6/9] Fixing style errors. --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 92b56ebdd2f..bdc20a6ddd1 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -811,7 +811,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $feature = 'projet_task'; } - if ($feature == 'payment_sc'){ + if ($feature == 'payment_sc') { $feature = "chargesociales"; } $checkonentitydone = 0; From 325c75db546e8b2d9f9d4fd29117311b12ba95c1 Mon Sep 17 00:00:00 2001 From: hystepik Date: Mon, 15 May 2023 14:03:37 +0200 Subject: [PATCH 7/9] Fix #24769 : External user cannot access card --- htdocs/core/lib/security.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index aeb58d34c0f..0ebfe480c14 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -431,6 +431,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($featureforlistofmodule == 'produit') { $featureforlistofmodule = 'product'; } + if ($featureforlistofmodule == 'supplier_proposal') { + $featureforlistofmodule = 'supplierproposal'; + } if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users $readok = 0; $nbko++; From c9eacc4928c71def0b07e4ab168c7c0505d68406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Mon, 15 May 2023 15:19:30 +0200 Subject: [PATCH 8/9] FIX: Warehouse total line --- htdocs/core/tpl/list_print_total.tpl.php | 29 +++++++--- htdocs/product/stock/card.php | 72 ++++++++++++++---------- 2 files changed, 64 insertions(+), 37 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 288f3b8f72e..44c1c9e34dc 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,13 +13,28 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''; - if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') { - print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); - } else { - print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); - } - print ''; + switch ($totalarray['type'][$i]) { + case 'duration'; + print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); + print ''; + break; + case 'string'; + print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : ''); + print ''; + break; + case 'stock'; + print ''; + print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS'); + print ''; + break; + default; + print ''; + print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); + print ''; + break; + } } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index ac740974d88..591d41c0ca3 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -595,35 +595,60 @@ if ($action == 'create') { print '
'; + $totalarray = array(); + $totalarray['val'] = array (); + $totalarray['pos'] = array (); + $totalarray['type'] = array (); + $totalarray['nbfield'] = 0; + // TODO Create $arrayfields with all fields to show print ''; print ""; - $parameters = array(); + $parameters = array('totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield'] += 3; + $totalarray['pos'][$totalarray['nbfield']] = 'totalunit'; + $totalarray['type'][$totalarray['nbfield']] = 'stock'; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); - } + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'units'; + $totalarray['type'][$totalarray['nbfield']] = 'string'; + } + print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; + print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue'; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; } if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - } + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell'; + } if ($user->rights->stock->mouvement->creer) { print_liste_field_titre(''); + $totalarray['nbfield']++; } if ($user->rights->stock->creer) { print_liste_field_titre(''); + $totalarray['nbfield']++; } // Hook fields - $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "\n"; @@ -708,7 +733,7 @@ if ($action == 'create') { //print ''; print ''; - $parameters = array('obj'=>$objp); + $parameters = array('obj'=>$objp, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -807,34 +832,21 @@ if ($action == 'create') { } $db->free($resql); - // Total - print ''; - print ''; - print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print ''; - print ''; - } + $totalarray['val']['totalunit'] = $totalunit; + $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT'); + $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT'); + $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit()); - if ($user->rights->stock->mouvement->creer) { - print ''; - } + $parameters = array('totalarray' => &$totalarray); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors); + } - if ($user->rights->stock->creer) { - print ''; - } + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - print ''; } else { dol_print_error($db); } From fd108f67a742e2b93e0f557ae736d83185c85edd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 15 May 2023 13:27:01 +0000 Subject: [PATCH 9/9] Fixing style errors. --- htdocs/core/tpl/list_print_total.tpl.php | 44 +++++++++--------- htdocs/product/stock/card.php | 59 ++++++++++++------------ 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 44c1c9e34dc..9b4fa75c751 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,28 +13,28 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - switch ($totalarray['type'][$i]) { - case 'duration'; - print ''; - break; - case 'string'; - print ''; - break; - case 'stock'; - print ''; - break; - default; - print ''; - break; - } + switch ($totalarray['type'][$i]) { + case 'duration'; + print ''; + break; + case 'string'; + print ''; + break; + case 'stock'; + print ''; + break; + default; + print ''; + break; + } } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 591d41c0ca3..1412ea2fcf5 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -595,12 +595,12 @@ if ($action == 'create') { print '
'; - $totalarray = array(); - $totalarray['val'] = array (); - $totalarray['pos'] = array (); - $totalarray['type'] = array (); - $totalarray['nbfield'] = 0; - + $totalarray = array(); + $totalarray['val'] = array (); + $totalarray['pos'] = array (); + $totalarray['type'] = array (); + $totalarray['nbfield'] = 0; + // TODO Create $arrayfields with all fields to show print '
'.dol_print_date($objp->datem).'
'.$langs->trans("Total").''; - $valtoshow = price2num($totalunit, 'MS'); - if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) { - print empty($valtoshow) ? '0' : $valtoshow; - } - print ''; - if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) { - print $langs->trans($productstatic->getLabelOfUnit()); - } - print ''.price(price2num($totalvalue, 'MT')).' '.price(price2num($totalvaluesell, 'MT')).'  
'; - print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); - print ''; - print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : ''); - print ''; - print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS'); - print ''; - print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); - print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); + print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : ''); + print ''; + print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS'); + print ''; + print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); + print '
'; @@ -612,40 +612,40 @@ if ($action == 'create') { print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield'] += 3; - $totalarray['pos'][$totalarray['nbfield']] = 'totalunit'; - $totalarray['type'][$totalarray['nbfield']] = 'stock'; + $totalarray['nbfield'] += 3; + $totalarray['pos'][$totalarray['nbfield']] = 'totalunit'; + $totalarray['type'][$totalarray['nbfield']] = 'stock'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'units'; - $totalarray['type'][$totalarray['nbfield']] = 'string'; - } + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'units'; + $totalarray['type'][$totalarray['nbfield']] = 'string'; + } print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; + $totalarray['nbfield']++; print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue'; + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue'; if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; + $totalarray['nbfield']++; } if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell'; - } + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell'; + } if ($user->rights->stock->mouvement->creer) { print_liste_field_titre(''); - $totalarray['nbfield']++; + $totalarray['nbfield']++; } if ($user->rights->stock->creer) { print_liste_field_titre(''); - $totalarray['nbfield']++; + $totalarray['nbfield']++; } // Hook fields $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray); @@ -832,21 +832,20 @@ if ($action == 'create') { } $db->free($resql); - $totalarray['val']['totalunit'] = $totalunit; - $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT'); - $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT'); - $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit()); + $totalarray['val']['totalunit'] = $totalunit; + $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT'); + $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT'); + $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit()); $parameters = array('totalarray' => &$totalarray); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors); - } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + } + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } else { dol_print_error($db); }