From bfed762fe9b8a4897fe5ee4bf3db2cd7459a9158 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Fri, 14 Feb 2025 14:29:49 +0100 Subject: [PATCH 01/40] NEW Dolibarr#22848 Add order tags --- .../categories/class/api_categories.class.php | 23 +-- htdocs/categories/class/categorie.class.php | 165 +++++++++--------- htdocs/categories/viewcat.php | 86 +++++++++ htdocs/commande/card.php | 56 ++++++ htdocs/commande/class/commande.class.php | 16 ++ htdocs/core/class/html.form.class.php | 103 +++++++++++ htdocs/core/menus/standard/eldy.lib.php | 6 + 7 files changed, 365 insertions(+), 90 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5082bda1b15..aed702aebac 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -49,20 +49,21 @@ class Categories extends DolibarrApi * @var array Code mapping from ID */ public static $TYPES = array( - 0 => 'product', - 1 => 'supplier', - 2 => 'customer', - 3 => 'member', - 4 => 'contact', - 5 => 'account', - 6 => 'project', - 7 => 'user', - 8 => 'bank_line', - 9 => 'warehouse', + 0 => 'product', + 1 => 'supplier', + 2 => 'customer', + 3 => 'member', + 4 => 'contact', + 5 => 'account', + 6 => 'project', + 7 => 'user', + 8 => 'bank_line', + 9 => 'warehouse', 10 => 'actioncomm', 11 => 'website_page', 12 => 'ticket', - 13 => 'knowledgemanagement' + 13 => 'knowledgemanagement', + 14 => 'order', ); /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 10e327a0420..5d7d7b78ca4 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,21 +48,22 @@ require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class class Categorie extends CommonObject { // Categories types (we use string because we want to accept any modules/types in a future) - const TYPE_PRODUCT = 'product'; - const TYPE_SUPPLIER = 'supplier'; - const TYPE_CUSTOMER = 'customer'; - const TYPE_MEMBER = 'member'; - const TYPE_CONTACT = 'contact'; - const TYPE_USER = 'user'; - const TYPE_PROJECT = 'project'; - const TYPE_ACCOUNT = 'bank_account'; - const TYPE_BANK_LINE = 'bank_line'; - const TYPE_WAREHOUSE = 'warehouse'; - const TYPE_ACTIONCOMM = 'actioncomm'; - const TYPE_WEBSITE_PAGE = 'website_page'; - const TYPE_TICKET = 'ticket'; + const TYPE_PRODUCT = 'product'; + const TYPE_SUPPLIER = 'supplier'; + const TYPE_CUSTOMER = 'customer'; + const TYPE_MEMBER = 'member'; + const TYPE_CONTACT = 'contact'; + const TYPE_USER = 'user'; + const TYPE_PROJECT = 'project'; + const TYPE_ACCOUNT = 'bank_account'; + const TYPE_BANK_LINE = 'bank_line'; + const TYPE_WAREHOUSE = 'warehouse'; + const TYPE_ACTIONCOMM = 'actioncomm'; + const TYPE_WEBSITE_PAGE = 'website_page'; + const TYPE_TICKET = 'ticket'; const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement'; - const TYPE_FICHINTER = 'fichinter'; + const TYPE_FICHINTER = 'fichinter'; + const TYPE_ORDER = 'order'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -74,21 +75,22 @@ class Categorie extends CommonObject * @var array Table of mapping between type string and ID used for field 'type' in table llx_categories */ protected $MAP_ID = array( - 'product' => 0, - 'supplier' => 1, - 'customer' => 2, - 'member' => 3, - 'contact' => 4, - 'bank_account' => 5, - 'project' => 6, - 'user' => 7, - 'bank_line' => 8, - 'warehouse' => 9, - 'actioncomm' => 10, - 'website_page' => 11, - 'ticket' => 12, + 'product' => 0, + 'supplier' => 1, + 'customer' => 2, + 'member' => 3, + 'contact' => 4, + 'bank_account' => 5, + 'project' => 6, + 'user' => 7, + 'bank_line' => 8, + 'warehouse' => 9, + 'actioncomm' => 10, + 'website_page' => 11, + 'ticket' => 12, 'knowledgemanagement' => 13, - 'fichinter' => 14, + 'fichinter' => 14, + 'order' => 14, ); /** @@ -97,21 +99,22 @@ class Categorie extends CommonObject * @note This array should be removed in future, once previous constants are moved to the string value. Deprecated */ public static $MAP_ID_TO_CODE = array( - 0 => 'product', - 1 => 'supplier', - 2 => 'customer', - 3 => 'member', - 4 => 'contact', - 5 => 'bank_account', - 6 => 'project', - 7 => 'user', - 8 => 'bank_line', - 9 => 'warehouse', + 0 => 'product', + 1 => 'supplier', + 2 => 'customer', + 3 => 'member', + 4 => 'contact', + 5 => 'bank_account', + 6 => 'project', + 7 => 'user', + 8 => 'bank_line', + 9 => 'warehouse', 10 => 'actioncomm', 11 => 'website_page', 12 => 'ticket', 13 => 'knowledgemanagement', 14 => 'fichinter', + 14 => 'order', ); /** @@ -120,9 +123,9 @@ class Categorie extends CommonObject * @todo Move to const array when PHP 5.6 will be our minimum target */ public $MAP_CAT_FK = array( - 'customer' => 'soc', - 'supplier' => 'soc', - 'contact' => 'socpeople', + 'customer' => 'soc', + 'supplier' => 'soc', + 'contact' => 'socpeople', 'bank_account' => 'account', ); @@ -132,8 +135,8 @@ class Categorie extends CommonObject * @note Move to const array when PHP 5.6 will be our minimum target */ public $MAP_CAT_TABLE = array( - 'customer' => 'societe', - 'supplier' => 'fournisseur', + 'customer' => 'societe', + 'supplier' => 'fournisseur', 'bank_account' => 'account', ); @@ -143,21 +146,22 @@ class Categorie extends CommonObject * @note Move to const array when PHP 5.6 will be our minimum target */ public $MAP_OBJ_CLASS = array( - 'product' => 'Product', - 'customer' => 'Societe', - 'supplier' => 'Fournisseur', - 'member' => 'Adherent', - 'contact' => 'Contact', - 'user' => 'User', - 'account' => 'Account', // old for bank account - 'bank_account' => 'Account', - 'project' => 'Project', - 'warehouse' => 'Entrepot', - 'actioncomm' => 'ActionComm', - 'website_page' => 'WebsitePage', - 'ticket' => 'Ticket', + 'product' => 'Product', + 'customer' => 'Societe', + 'supplier' => 'Fournisseur', + 'member' => 'Adherent', + 'contact' => 'Contact', + 'user' => 'User', + 'account' => 'Account', // old for bank account + 'bank_account' => 'Account', + 'project' => 'Project', + 'warehouse' => 'Entrepot', + 'actioncomm' => 'ActionComm', + 'website_page' => 'WebsitePage', + 'ticket' => 'Ticket', 'knowledgemanagement' => 'KnowledgeRecord', - 'fichinter' => 'Fichinter', + 'fichinter' => 'Fichinter', + 'order' => 'Commande', ); /** @@ -166,21 +170,22 @@ class Categorie extends CommonObject * @note Move to const array when PHP 5.6 will be our minimum target */ public static $MAP_TYPE_TITLE_AREA = array( - 'product' => 'ProductsCategoriesArea', - 'customer' => 'CustomersCategoriesArea', - 'supplier' => 'SuppliersCategoriesArea', - 'member' => 'MembersCategoriesArea', - 'contact' => 'ContactsCategoriesArea', - 'user' => 'UsersCategoriesArea', - 'account' => 'AccountsCategoriesArea', // old for bank account - 'bank_account' => 'AccountsCategoriesArea', - 'project' => 'ProjectsCategoriesArea', - 'warehouse' => 'StocksCategoriesArea', - 'actioncomm' => 'ActioncommCategoriesArea', - 'website_page' => 'WebsitePagesCategoriesArea', - 'ticket' => 'TicketsCategoriesArea', + 'product' => 'ProductsCategoriesArea', + 'customer' => 'CustomersCategoriesArea', + 'supplier' => 'SuppliersCategoriesArea', + 'member' => 'MembersCategoriesArea', + 'contact' => 'ContactsCategoriesArea', + 'user' => 'UsersCategoriesArea', + 'account' => 'AccountsCategoriesArea', // old for bank account + 'bank_account' => 'AccountsCategoriesArea', + 'project' => 'ProjectsCategoriesArea', + 'warehouse' => 'StocksCategoriesArea', + 'actioncomm' => 'ActioncommCategoriesArea', + 'website_page' => 'WebsitePagesCategoriesArea', + 'ticket' => 'TicketsCategoriesArea', 'knowledgemanagement' => 'KnowledgemanagementsCategoriesArea', - 'fichinter' => 'FichintersCategoriesArea', + 'fichinter' => 'FichintersCategoriesArea', + 'order' => 'OrderCategoriesArea', ); /** @@ -188,15 +193,16 @@ class Categorie extends CommonObject * This array may be completed by external modules with hook "constructCategory" */ public $MAP_OBJ_TABLE = array( - 'customer' => 'societe', - 'supplier' => 'societe', - 'member' => 'adherent', - 'contact' => 'socpeople', - 'account' => 'bank_account', // old for bank account - 'project' => 'projet', - 'warehouse' => 'entrepot', + 'customer' => 'societe', + 'supplier' => 'societe', + 'member' => 'adherent', + 'contact' => 'socpeople', + 'account' => 'bank_account', // old for bank account + 'project' => 'projet', + 'warehouse' => 'entrepot', 'knowledgemanagement' => 'knowledgemanagement_knowledgerecord', - 'fichinter' => 'fichinter', + 'fichinter' => 'fichinter', + 'order' => 'commande', ); /** @@ -261,6 +267,7 @@ class Categorie extends CommonObject * @see Categorie::TYPE_WEBSITE_PAGE * @see Categorie::TYPE_TICKET * @see Categorie::TYPE_FICHINTER + * @see Categorie::TYPE_ORDER */ public $type; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index fcef409cc55..2d59a6a26e4 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -171,6 +171,11 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission n $tmpobject = new Fichinter($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'fichinter'; + } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $tmpobject = new Commande($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'order'; } else { dol_print_error(null, "Not supported value of type = ".$type); } @@ -238,6 +243,10 @@ if ($elemid && $action == 'addintocategory') { // Test on permission not require require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $newobject = new Account($db); $elementtype = 'bank_account'; + } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $newobject = new Commande($db); + $elementtype = 'order'; } else { dol_print_error(null, "Not supported value of type = ".$type); } @@ -1411,6 +1420,83 @@ if ($type == Categorie::TYPE_FICHINTER) { } } +// List of Orders +if ($type == Categorie::TYPE_ORDER) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $permission = $user->rights->commande->creer; + + $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($objects < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddOrderIntoCategory").'  '; + $form->selectOrder('', 'elemid'); + print '
'; + print '
'; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; + + print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit); + + print "\n"; + print ''."\n"; + + if (count($objects) > 0) { + $i = 0; + foreach ($objects as $key => $rder) { + $i++; + if ($i > $limit) { + break; + } + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; + } + } else { + print ''; + } + print "
'.$langs->trans("Ref").'
'; + print $order->getNomUrl(1); + print "'.$order->ref."'; + if ($permission) { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } +} + // Note that $action and $object may have been modified by some hooks $parameters = array('type' => $type, 'id' => $id, 'label' => $label); $reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8ae504de154..b557bb7b06b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -42,6 +42,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; @@ -564,6 +565,13 @@ if (empty($reshook)) { $action = ''; } + if (isModEnabled('categorie')) { + $categories = GETPOST('categories', 'array'); + if (method_exists($object, 'setCategories')) { + $object->setCategories($categories); + } + } + // End of object creation, we show it if ($object_id > 0 && !$error) { $db->commit(); @@ -690,6 +698,11 @@ if (empty($reshook)) { // $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); //} elseif ($action == 'setremiseabsolue' && $usercancreate) { // $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); + } elseif ($action == 'settags' && isModEnabled('categorie') && $usercancreate) { + $result = $object->setCategories(GETPOST('categories', 'array')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && (GETPOST('alldate_start', 'alpha') || GETPOST('alldate_end', 'alpha')) && $usercancreate) { // Define date start and date end for all line $alldate_start = dol_mktime(GETPOSTINT('alldate_starthour'), GETPOSTINT('alldate_startmin'), 0, GETPOSTINT('alldate_startmonth'), GETPOSTINT('alldate_startday'), GETPOSTINT('alldate_startyear')); @@ -2155,6 +2168,15 @@ if ($action == 'create' && $usercancreate) { print ''; } + // Categories + if (!empty($conf->categorie->enabled)) { + print ''.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ORDER, '', 'parent', 64, 0, 1); + $arrayselected = GETPOST('categories', 'array'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; + } + // Note public print ''; print ''.$langs->trans('NotePublic').''; @@ -2841,6 +2863,40 @@ if ($action == 'create' && $usercancreate) { print ''; } + // Tags-Categories + if (isModEnabled('categorie')) { + print ''; + print '
'; + print $langs->trans("Categories"); + print ''; + if ($usercancreate) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print ''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ORDER, '', 'parent', 64, 0, 1); + if ($action == 'edittags') { + print '
'; + print ''; + print ''; + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_ORDER); + $arrayselected=[]; + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, '0'); + print ''; + print '
'; + } else { + print $form->showCategories($object->id, Categorie::TYPE_ORDER, 1); + } + print ""; + } + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index aada73c641f..86bcf23fd29 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -853,6 +853,22 @@ class Commande extends CommonOrder return 0; } + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + * @return void + */ + public function setCategories($categories) + { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + return parent::setCategoriesCommon($categories, Categorie::TYPE_ORDER); + } + /** * Cancel an order * If stock is decremented on order validation, we must reincrement it diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dee4f0b3b71..269151b89cf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -11279,6 +11279,109 @@ class Form } } + + /** + * Output a combo list with orders qualified for a third party + * + * @param int $selected Id order preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @return int Nbr of project if OK, <0 if KO + */ + public function selectOrder($selected = '', $htmlname = 'orderid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500') + { + global $user, $conf, $langs; + + $out = ''; + + $hideunselectables = false; + if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) { + $hideunselectables = true; + } + + // Search all orders + $sql = "SELECT c.rowid, c.ref"; + $sql .= ' FROM '.$this->db->prefix().'commande as c'; + $sql .= " ORDER BY c.ref ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + // Use select2 selector + if (!empty($conf->use_javascript_ajax)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $out .= $comboenhancement; + $morecss = 'minwidth200imp maxwidth500'; + } + + if (empty($option_only)) { + $out .= ''; + } + + print $out; + + $this->db->free($resql); + return $num; + } else { + dol_print_error($this->db); + return -1; + } + } + /** * Output the component to make advanced search criteries * diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3b3c57167ac..c4f0e92dea5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1398,6 +1398,12 @@ function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $left } else { $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->hasRight('commande', 'lire')); } + + // Categories + if (isModEnabled('categorie')) { + $langs->load("categories"); + $newmenu->add("/categories/index.php?leftmenu=cat&type=14", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); + } } // Supplier proposal From ba78df46bda2c7000155060a9586c79dee021812 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:36:11 +0100 Subject: [PATCH 02/40] NEW #22848 Fix Typo --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 2d59a6a26e4..7901570c4a0 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1467,7 +1467,7 @@ if ($type == Categorie::TYPE_ORDER) { if (count($objects) > 0) { $i = 0; - foreach ($objects as $key => $rder) { + foreach ($objects as $key => $order) { $i++; if ($i > $limit) { break; From 8152d88b00da3813f7abadaf091808ac84a8f33b Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Thu, 15 Dec 2022 15:03:59 +0000 Subject: [PATCH 03/40] NEW #22848 Add import and export functions --- htdocs/core/modules/modCategorie.class.php | 163 ++++++++++++++++++++- 1 file changed, 162 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 87115221921..721dbae84de 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -166,6 +166,9 @@ class modCategorie extends DolibarrModules if (isModEnabled('website')) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } + if (!empty($conf->commande->enabled)) { + $typeexample .= ($typeexample ? " / " : "")."16=Order"; + } // Definition of vars $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.type' => "Type", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel", 'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification"); @@ -449,6 +452,21 @@ class modCategorie extends DolibarrModules // 11 Website Pages, TODO ? + // 16 Order + ++$r; + $this->exportTagLinks( + $r, + 16, + 'commande', + ['commande', 'commande', 'export'], + [ + 'rowid' => [ + 'name' => 'OrderID', + 'type' => 'Numeric' + ] + ] + ); + // Imports //-------- @@ -465,7 +483,7 @@ class modCategorie extends DolibarrModules 'ca.label' => "Label*", 'ca.type' => "Type*", 'ca.description' => "Description", 'ca.fk_parent' => 'ParentCategory' ); - $this->import_regex_array[$r] = array('ca.type' => '^(0|1|2|3|4|5|6|7|8|9|10|11)$'); + $this->import_regex_array[$r] = array('ca.type' => '^(0|1|2|3|4|5|6|7|8|9|10|11|16)$'); $this->import_convertvalue_array[$r] = array( 'ca.fk_parent' => array( 'rule' => 'fetchidfromcodeandlabel', @@ -628,8 +646,151 @@ class modCategorie extends DolibarrModules // 10 Agenda Events, TODO ? // 11 Website Pages, TODO ? + + // 16 Order + if (!empty($conf->commande->enabled)) { + ++$r; + $this->importTagLinks( + $r, + 16, + '/commande/class/commande.class.php', + 'Commande', + 'Commande' + ); + } } + /** + * Configure a tag link export + * + * @param int $r Index of import tables + * @param int $cat_id Categorie id + * @param string $class Class of the linked object + * @param string $permission Permission to export the linked object + * @param array $fields_list Additionnal fields of the linked object to export + * + * @return void + */ + protected function exportTagLinks( + int $r, + int $cat_id, + string $class, + array $permission, + array $fields_list + ) { + global $conf; + + $cat_type = Categorie::$MAP_ID_TO_CODE[$cat_id]; + + $this->export_code[$r] = $this->rights_class.'_'.$cat_id.'_'.$cat_type; + $this->export_label[$r] = 'Cat'.ucfirst($cat_type).'sLinks'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->'.$class.'->enabled)'; + $this->export_permission[$r] = [ + ['categorie', 'lire'], + $permission + ]; + + $entities = []; + $names = []; + $types = []; + foreach ($fields_list as $field => $value) { + $key = 'p.'.$field; + $entities[$key] = $cat_type; + $names[$key] = $value['name']; + $types[$key] = $value['type']; + } + $this->export_fields_array[$r] = array_merge( + [ + 'cat.rowid' => 'CategId', + 'cat.label' => 'Label', + 'cat.description' => 'Description', + 'cat.fk_parent' => 'ParentCategory', + 'pcat.label' => 'ParentCategoryLabel' + ], + $names + ); + $this->export_TypeFields_array[$r] = array_merge( + [ + 'cat.rowid' => 'Numeric', + 'cat.label' => 'Text', + 'cat.description' => 'Text', + 'cat.fk_parent' => 'Numeric', + 'pcat.label' => 'Text' + ], + $names + ); + $this->export_entities_array[$r] = $entities; // We define here only fields that use another picto + + $keyforselect = $class; + $keyforelement = $class; + $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_'.$cat_type.' as cfk ON cfk.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.$class.' as p ON p.rowid = cfk.fk_'.$cat_type; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.$class.'_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = '.((int) $cat_id); + } + + /** + * Configure a tag link import + * + * @param int $r Index of import tables + * @param int $cat_id Categorie id + * @param string $class_file Class file of the linked object + * @param string $class Class of the linked object + * @param string $element Name of the linked object + * + * @return void + */ + protected function importTagLinks( + int $r, + int $cat_id, + string $class_file, + string $class, + string $element, + ) { + $cat_type = Categorie::$MAP_ID_TO_CODE[$cat_id]; + + $this->import_code[$r] = $this->rights_class.'_'.$cat_id.'_'.$cat_type; + $this->import_label[$r] = 'Cat'.ucfirst($cat_type).'sLinks'; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = ['ci' => MAIN_DB_PREFIX.'categorie_'.$cat_type]; + $this->import_fields_array[$r] = [ + 'ci.fk_categorie' => 'Category*', + 'ci.fk_'.$cat_type => ucfirst($cat_type).'*' + ]; + $this->import_regex_array[$r] = ['ci.fk_categorie' => 'rowid@'.MAIN_DB_PREFIX.'categorie:type='.$cat_id]; + + $this->import_convertvalue_array[$r] = [ + 'ci.fk_categorie' => + [ + 'rule' => 'fetchidfromcodeorlabel', + 'classfile' => '/categories/class/categorie.class.php', + 'class' => 'Categorie', + 'method' => 'fetch', + 'element' => 'category' + ], + 'ci.fk_'.$cat_type => + [ + 'rule' => 'fetchidfromref', + 'classfile' => $class_file, + 'class' => $class, + 'method' => 'fetch', + 'element' => $element + ] + ]; + $this->import_examplevalues_array[$r] = [ + 'ci.fk_categorie' => 'rowid or label', + 'ci.fk_'.$cat_type => 'rowid or ref' + ]; + } /** * Function called when module is enabled. From 0c6ee5d47dd4f9a4823de378c5264ca9cb675af5 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Thu, 15 Dec 2022 20:27:03 +0000 Subject: [PATCH 04/40] NEW #22848 Use the right tag id --- htdocs/categories/class/api_categories.class.php | 2 +- htdocs/categories/class/categorie.class.php | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index aed702aebac..aad4da2447a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -63,7 +63,7 @@ class Categories extends DolibarrApi 11 => 'website_page', 12 => 'ticket', 13 => 'knowledgemanagement', - 14 => 'order', + 16 => 'order' ); /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5d7d7b78ca4..c9d333ba56c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -90,7 +90,7 @@ class Categorie extends CommonObject 'ticket' => 12, 'knowledgemanagement' => 13, 'fichinter' => 14, - 'order' => 14, + 'order' => 16, ); /** @@ -114,7 +114,7 @@ class Categorie extends CommonObject 12 => 'ticket', 13 => 'knowledgemanagement', 14 => 'fichinter', - 14 => 'order', + 16 => 'order', ); /** diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c4f0e92dea5..d4560cba34f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1402,7 +1402,7 @@ function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $left // Categories if (isModEnabled('categorie')) { $langs->load("categories"); - $newmenu->add("/categories/index.php?leftmenu=cat&type=14", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); + $newmenu->add("/categories/index.php?leftmenu=cat&type=16", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } } From ee8791666c290a2de1242142735665f9c235954e Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Mon, 24 Jul 2023 09:42:21 +0200 Subject: [PATCH 05/40] NEW #22848 Remove linked categories --- htdocs/commande/class/commande.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 86bcf23fd29..5acae07046c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3429,6 +3429,18 @@ class Commande extends CommonOrder $error++; } + // Remove linked categories. + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_order"; + $sql .= " WHERE fk_order = ".((int) $this->id); + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete extrafields of lines and lines if (!$error && !empty($this->table_element_line)) { $tabletodelete = $this->table_element_line; From 6dcb53f4c341ca10dbf6c3c67eea53018d860ba2 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 17 Oct 2023 14:45:33 +0200 Subject: [PATCH 06/40] NEW #22848 Fix link between invoice and order and tags export / import --- htdocs/core/modules/modCategorie.class.php | 40 ++++++++++++---------- htdocs/langs/en_US/categories.lang | 1 + 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 721dbae84de..55333978af5 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -1,10 +1,11 @@ - * Copyright (C) 2005-2014 Laurent Destailleur - * Copyright (C) 2012-2016 Juanjo Menent - * Copyright (C) 2020 Stéphane Lesage - * Copyright (C) 2024 MDW - * Copyright (C) 2025 Frédéric France +/* Copyright (C) 2005 Matthieu Valleton + * Copyright (C) 2005-2014 Laurent Destailleur + * Copyright (C) 2012-2016 Juanjo Menent + * Copyright (C) 2020 Stéphane Lesage + * Copyright (C) 2024 MDW + * Copyright (C) 2025 Frédéric France + * Copyright (C) 2022-2023 Solution Libre SAS * * 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 @@ -457,7 +458,8 @@ class modCategorie extends DolibarrModules $this->exportTagLinks( $r, 16, - 'commande', + 'Commande', + '!empty($conf->commande->enabled)', ['commande', 'commande', 'export'], [ 'rowid' => [ @@ -663,11 +665,12 @@ class modCategorie extends DolibarrModules /** * Configure a tag link export * - * @param int $r Index of import tables - * @param int $cat_id Categorie id - * @param string $class Class of the linked object - * @param string $permission Permission to export the linked object - * @param array $fields_list Additionnal fields of the linked object to export + * @param int $r Index of import tables + * @param int $cat_id Categorie id + * @param string $enabled Condition to enable this export + * @param string $class Class of the linked object + * @param string $permission Permission to export the linked object + * @param array $fields_list Additionnal fields of the linked object to export * * @return void */ @@ -675,6 +678,7 @@ class modCategorie extends DolibarrModules int $r, int $cat_id, string $class, + string $enabled, array $permission, array $fields_list ) { @@ -685,7 +689,7 @@ class modCategorie extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_'.$cat_id.'_'.$cat_type; $this->export_label[$r] = 'Cat'.ucfirst($cat_type).'sLinks'; $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = '!empty($conf->'.$class.'->enabled)'; + $this->export_enabled[$r] = $enabled; $this->export_permission[$r] = [ ['categorie', 'lire'], $permission @@ -740,11 +744,11 @@ class modCategorie extends DolibarrModules /** * Configure a tag link import * - * @param int $r Index of import tables - * @param int $cat_id Categorie id - * @param string $class_file Class file of the linked object - * @param string $class Class of the linked object - * @param string $element Name of the linked object + * @param int $r Index of import tables + * @param int $cat_id Categorie id + * @param string $class_file Class file of the linked object + * @param string $class Class of the linked object + * @param string $element Name of the linked object * * @return void */ diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 65a964564c7..57ac47b39d8 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -78,6 +78,7 @@ CatMemberList=List of members tags/categories CatContactList=List of contacts tags/categories CatProjectsList=List of projects tags/categories CatUsersList=List of users tags/categories +CatOrdersLinks=Links between orders and tags/categories CatSupLinks=Links between vendors and tags/categories CatCusLinks=Links between customers/prospects and tags/categories CatContactsLinks=Links between contacts/addresses and tags/categories From 941e703e34e0e12499fd5cba07cd958225a32911 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Fri, 20 Oct 2023 10:39:14 +0200 Subject: [PATCH 07/40] NEW #22848 Fix doc --- htdocs/core/modules/modCategorie.class.php | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 55333978af5..ea9218e0980 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -667,20 +667,20 @@ class modCategorie extends DolibarrModules * * @param int $r Index of import tables * @param int $cat_id Categorie id - * @param string $enabled Condition to enable this export * @param string $class Class of the linked object + * @param string $enabled Condition to enable this export * @param string $permission Permission to export the linked object * @param array $fields_list Additionnal fields of the linked object to export * * @return void */ protected function exportTagLinks( - int $r, - int $cat_id, - string $class, - string $enabled, - array $permission, - array $fields_list + int $r, + int $cat_id, + string $class, + string $enabled, + array $permission, + array $fields_list ) { global $conf; @@ -753,11 +753,11 @@ class modCategorie extends DolibarrModules * @return void */ protected function importTagLinks( - int $r, - int $cat_id, - string $class_file, - string $class, - string $element, + int $r, + int $cat_id, + string $class_file, + string $class, + string $element, ) { $cat_type = Categorie::$MAP_ID_TO_CODE[$cat_id]; From 05a11b7cef8fc0317cb920b042bea84130c8d3cf Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Thu, 1 Aug 2024 17:38:45 +0200 Subject: [PATCH 08/40] NEW Dolibarr#22848 typo --- htdocs/core/modules/modCategorie.class.php | 2 +- htdocs/langs/en_US/categories.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ea9218e0980..a592d387047 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -670,7 +670,7 @@ class modCategorie extends DolibarrModules * @param string $class Class of the linked object * @param string $enabled Condition to enable this export * @param string $permission Permission to export the linked object - * @param array $fields_list Additionnal fields of the linked object to export + * @param array $fields_list Additional fields of the linked object to export * * @return void */ diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 57ac47b39d8..bb369a1dea8 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -95,6 +95,7 @@ AddProductServiceIntoCategory=Assign category to the product/service AddCustomerIntoCategory=Assign the category to the customer AddSupplierIntoCategory=Assign the category to the supplier AddFichinterIntoCategory=Assign the category to the intervention +AddOrderIntoCategory=Assign the category to the order AssignCategoryTo=Assign the category to ShowCategory=Show tag/category ByDefaultInList=By default in list From c8cc7884e46fbb90c7045f5ef19ba74f7aa49370 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Mon, 26 Aug 2024 15:45:38 +0200 Subject: [PATCH 09/40] NEW #22848 Fix CI --- htdocs/categories/viewcat.php | 1 + htdocs/commande/card.php | 6 +++--- htdocs/commande/class/commande.class.php | 9 ++++---- htdocs/core/class/html.form.class.php | 25 +++++++++++----------- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/modCategorie.class.php | 4 ++-- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 7901570c4a0..ed0593a13d9 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1460,6 +1460,7 @@ if ($type == Categorie::TYPE_ORDER) { print '
'; $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; + // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit); print "\n"; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b557bb7b06b..5c0c6f0dc50 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -565,7 +565,7 @@ if (empty($reshook)) { $action = ''; } - if (isModEnabled('categorie')) { + if (isModEnabled('category')) { $categories = GETPOST('categories', 'array'); if (method_exists($object, 'setCategories')) { $object->setCategories($categories); @@ -698,7 +698,7 @@ if (empty($reshook)) { // $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); //} elseif ($action == 'setremiseabsolue' && $usercancreate) { // $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); - } elseif ($action == 'settags' && isModEnabled('categorie') && $usercancreate) { + } elseif ($action == 'settags' && isModEnabled('category') && $usercancreate) { $result = $object->setCategories(GETPOST('categories', 'array')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -2864,7 +2864,7 @@ if ($action == 'create' && $usercancreate) { } // Tags-Categories - if (isModEnabled('categorie')) { + if (isModEnabled('category')) { print ''; // Workforce/Staff @@ -3358,7 +3358,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'; print '\n"; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 5c0c6f0dc50..57ccf008ac5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2173,7 +2173,7 @@ if ($action == 'create' && $usercancreate) { print '"; } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index f46d818989f..fd9dbce3233 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -665,12 +665,12 @@ class modCategorie extends DolibarrModules /** * Configure a tag link export * - * @param int $r Index of import tables - * @param int $cat_id Categorie id - * @param string $class Class of the linked object - * @param string $enabled Condition to enable this export - * @param array $permission Permission to export the linked object - * @param array $fields_list Additional fields of the linked object to export + * @param int $r Index of import tables + * @param int $cat_id Categorie id + * @param string $class Class of the linked object + * @param string $enabled Condition to enable this export + * @param array $permission Permission to export the linked object + * @param array> $fields_list Additional fields of the linked object to export * * @return void */ From c404b0702e81aabda19e45e9a90f9a664acfdd01 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 15:41:23 +0100 Subject: [PATCH 11/40] Prepare 20.0.5 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 4e38fe07568..388e1d7b5c5 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -35,7 +35,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '20.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '20.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { From 66b767d024cc35ed906ab98a38bee42ebd81d50e Mon Sep 17 00:00:00 2001 From: iLLixM <162678117+iLLixM@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:22:33 +0100 Subject: [PATCH 12/40] Typo in Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 823aa8cb42f..87f353f6cd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 20.0.4 compared to 20.0.2 ***** +***** ChangeLog for 20.0.4 compared to 20.0.3 ***** FIX: $this->origin_object can not be instance of CommandeFournisseur if it is already an instanceof CommonObject FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 FIX: 17.0 - collisions in cache for dol_getIdFromCode From 92a8fcccfee87b2524bdc25de0332546acd94bda Mon Sep 17 00:00:00 2001 From: iLLixM Date: Sun, 16 Feb 2025 18:54:51 +0100 Subject: [PATCH 13/40] New: Option to set Third Party Customer Code equal to Member Reference when using the function of creating third parties from members, you are able to set the customer code equal to the existing member reference by setting the parameter THIRDPARTY_CUSTOMERCODE_EQUALS_MEMBERREF --- htdocs/societe/class/societe.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f734c3b7612..c72e72af3b5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4486,7 +4486,11 @@ class Societe extends CommonObject $this->entity = $member->entity; $this->client = 1; // A member is a customer by default - $this->code_client = ($customercode ? $customercode : -1); + if (getDolGlobalString('THIRDPARTY_CUSTOMERCODE_EQUALS_MEMBERREF')) { + $this->code_client = $member->ref; // set Customer Code equal to existing Member Reference + } else { + $this->code_client = ($customercode ? $customercode : -1); // set new auto-incremented Customer Code + } $this->code_fournisseur = '-1'; $this->typent_code = ($member->morphy == 'phy' ? 'TE_PRIVATE' : 0); $this->typent_id = $this->typent_code ? dol_getIdFromCode($this->db, $this->typent_code, 'c_typent', 'id', 'code') : 0; From 5035580e56c0e062cdddeac2f5835bd47c064602 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 15 Feb 2025 17:44:33 +0100 Subject: [PATCH 14/40] Qual: Fix phan notices (societe) --- dev/tools/phan/baseline.txt | 34 ++---- htdocs/compta/bank/class/account.class.php | 4 +- htdocs/core/class/html.form.class.php | 22 ++-- htdocs/core/class/html.formcompany.class.php | 22 ++-- .../societe/mod_codeclient_elephant.php | 6 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 8 +- .../societe/mod_codecompta_aquarium.php | 8 +- .../societe/mod_codecompta_digitaria.php | 10 +- .../societe/mod_codecompta_panicum.php | 8 +- .../modules/societe/modules_societe.class.php | 38 +++--- htdocs/societe/admin/societe.php | 8 +- htdocs/societe/ajax/company.php | 10 +- .../canvas/actions_card_common.class.php | 4 +- .../company/actions_card_company.class.php | 7 +- htdocs/societe/card.php | 58 ++++----- htdocs/societe/checkvat/checkVatPopup.php | 4 +- .../class/companybankaccount.class.php | 16 +-- htdocs/societe/class/societe.class.php | 50 ++++---- htdocs/societe/consumption.php | 18 ++- htdocs/societe/contact.php | 6 +- htdocs/societe/list.php | 111 +++++++++--------- htdocs/societe/paymentmodes.php | 53 +++++---- htdocs/societe/price.php | 26 ++-- .../tpl/linesalesrepresentative.tpl.php | 7 +- htdocs/societe/website.php | 9 +- 26 files changed, 282 insertions(+), 271 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index e4bac1868cc..be05dc5d762 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,22 +9,22 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1690+ occurrences + // PhanTypeMismatchArgument : 1580+ occurrences // PhanUndeclaredProperty : 500+ occurrences - // PhanTypeMismatchArgumentNullable : 350+ occurrences + // PhanTypeMismatchArgumentNullable : 330+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 75+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 65+ occurrences - // PhanTypeExpectedObjectPropAccess : 40+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences + // PhanTypeExpectedObjectPropAccess : 35+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences - // PhanUndeclaredMethod : 10+ occurrences + // PhanUndeclaredMethod : 9 occurrences // PhanTypeComparisonFromArray : 8 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences @@ -101,7 +101,6 @@ return [ 'htdocs/admin/eventorganization.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/expensereport_rules.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/external_rss.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/hrm.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/knowledgemanagement.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/mails.php' => ['PhanTypeMismatchArgument'], @@ -609,7 +608,6 @@ return [ 'htdocs/projet/class/api_tasks.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/projet/tasks/time.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/projet/tasks/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/public/company/new.php' => ['PhanTypeMismatchArgument'], 'htdocs/public/eventorganization/subscriptionok.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/members/new.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/payment/newpayment.php' => ['PhanUndeclaredProperty'], @@ -636,26 +634,13 @@ return [ 'htdocs/recruitment/recruitmentjobposition_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_note.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/resource/class/dolresource.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/salaries/paiement_salary.php' => ['PhanUndeclaredProperty'], 'htdocs/salaries/virement_request.php' => ['PhanUndeclaredProperty'], - 'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], - 'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/societe/canvas/actions_card_common.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/canvas/company/actions_card_company.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/checkvat/checkVatPopup.php' => ['PhanPossiblyUndeclaredGlobalVariable'], + 'htdocs/societe/ajax/company.php' => ['PhanUndeclaredProperty'], 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/societe/class/companybankaccount.class.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], - 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/societe/price.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/tpl/linesalesrepresentative.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/website.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], + 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'], 'htdocs/stripe/admin/stripe.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/charge.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'], @@ -714,7 +699,6 @@ return [ 'htdocs/user/group/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/param_ihm.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/user/virtualcard.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'], 'htdocs/variants/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/class/ProductAttribute.class.php' => ['PhanTypeMismatchArgumentNullable'], diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 050e4267f95..994a47ccd73 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1206,11 +1206,11 @@ class Account extends CommonObject /** * Delete bank account from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dee4f0b3b71..79c10768e76 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -412,13 +412,13 @@ class Form /** * Output edit in place form * - * @param string $fieldname Name of the field - * @param CommonObject $object Object - * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) - * @param string $check Same coe than $check parameter of GETPOST() - * @param string $morecss More CSS - * @return string HTML code for the edit of alternative language + * @param string $fieldname Name of the field + * @param CommonObject $object Object + * @param bool|int<0,1> $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $check Same coe than $check parameter of GETPOST() + * @param string $morecss More CSS + * @return string HTML code for the edit of alternative language */ public function widgetForTranslation($fieldname, $object, $perm, $typeofdata = 'string', $check = '', $morecss = '') { @@ -4616,7 +4616,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int $noprint if set to one we return the html to print, if 0 (default) we print it @@ -4646,7 +4646,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @return string String for the HTML select component @@ -6153,7 +6153,7 @@ class Form * @param int<0,1> $addempty Add empty entry * @param ''|'direct-debit'|'bank-transfer' $type Type ('direct-debit' or 'bank-transfer') * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int<0,1> $nooutput No print is done. String is returned. @@ -11704,7 +11704,7 @@ class Form * @param string $save_label Alternative label for save button * @param string $cancel_label Alternative label for cancel button * @param array $morebuttons Add additional buttons between save and cancel - * @param bool $withoutdiv Option to remove enclosing centered div + * @param bool|int<0,1> $withoutdiv Option to remove enclosing centered div * @param string $morecss More CSS * @param string $dol_openinpopup If the button are shown in a context of a page shown inside a popup, we put here the string name of popup. * @return string Html code with the buttons diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 800913719ee..cf42ba4b738 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1052,7 +1052,7 @@ class FormCompany extends Form /** * Return a HTML select for thirdparty type * - * @param int $selected Selected value + * @param int<0,4>|'0'|'2,3'|'1,3'|'4' $selected Selected value * @param string $htmlname HTML select name * @param string $htmlidname HTML select id * @param string $typeinput HTML output @@ -1117,11 +1117,11 @@ class FormCompany extends Form /** * Output html select to select third-party type * - * @param string $page Page - * @param string $selected Id preselected - * @param string $htmlname Name of HTML select - * @param string $filter optional filters criteras - * @param int $nooutput No print output. Return it only. + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select + * @param string $filter optional filters criteras + * @param int<0,1> $nooutput No print output. Return it only. * @return void|string */ public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0) @@ -1158,11 +1158,11 @@ class FormCompany extends Form /** * Output html select to select prospect status * - * @param string $htmlname Name of HTML select - * @param Contact|null $prospectstatic Prospect object - * @param int $statusprospect status of prospect - * @param int $idprospect id of prospect - * @param string $mode select if we want activate de html part or js + * @param string $htmlname Name of HTML select + * @param Contact|Client|null $prospectstatic Prospect object + * @param int $statusprospect status of prospect + * @param int $idprospect id of prospect + * @param 'html'|'js' $mode select if we want activate de html part or js * @return void */ public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html") diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index b01fcafb6db..ad558c7e950 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -5,7 +5,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -219,8 +219,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (0:customer, 1:supplier) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index e7509a07e3b..b5699c9440c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2006-2014 Laurent Destailleur * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -90,8 +90,8 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 159f9114faf..d12833d958d 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -3,7 +3,7 @@ * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -96,9 +96,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) - * @return string|-1 Value if OK, '' if module not configured, -1 if KO + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) { diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index ce5cfb5466b..fd15395e2ec 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -3,7 +3,7 @@ /* Copyright (C) 2004-2007 Rodolphe Quiedeville * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -158,8 +158,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * Set accountancy account code for a third party into this->code * * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') @@ -213,7 +213,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param string $code Code of third party - * @param Societe $societe Object third party + * @param ?Societe $societe Object third party * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 4ccb0c151a4..87bb764a27d 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -4,7 +4,7 @@ * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2019 Alexandre Spangaro * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -201,10 +201,10 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' - * @return int >=0 if OK, <0 if KO + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' + * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') { diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 41c6a65a46f..adb2e3ce6e7 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -91,9 +91,9 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 82551e436ae..b4bb7bbdcf0 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -93,15 +93,15 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - //abstract public function getExample($langs = null, $objsoc = '', $type = -1); + abstract public function getExample($langs = null, $objsoc = '', $type = -1); /** * Return next value available * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type - * @return string Value + * @param Societe|string|null $objsoc Object thirdparty + * @param int<-1,2> $type Type + * @return string Value */ public function getNextValue($objsoc = '', $type = -1) { @@ -144,8 +144,8 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -212,7 +212,7 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator /** * Check if mask/numbering use prefix * - * @return int 0=no, 1=yes + * @return int<0,1> 0=no, 1=yes */ public function verif_prefixIsUsed() { @@ -253,8 +253,8 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -294,9 +294,9 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int<-1,1> >=0 if success, -1 if failure */ public function get_code($db, $societe, $type = '') @@ -304,7 +304,17 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator // phpcs:enable global $langs; - dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR); + dol_syslog(__METHOD__." ".$langs->trans("NotAvailable"), LOG_ERR); return -1; } + + /** + * Return an example of result returned by getNextValue + * + * @param ?Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example + */ + abstract public function getExample($langs = null, $objsoc = '', $type = -1); } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e4e0925f5b1..d36aeb1222e 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -440,7 +440,7 @@ foreach ($dirsociete as $dirroot) { } $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -'@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array +// '@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; @@ -448,7 +448,7 @@ foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; print ''."\n"; - if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") { + if ($conf->global->SOCIETE_CODECLIENT_ADDON == (string) $file) { print '\n"; @@ -988,7 +988,7 @@ if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) { print ''; print ''; print ''; print ''; // Email - print ''; + print ''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; // Unsubscribe @@ -1740,7 +1740,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2); $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6); while ($i <= $NBPROFIDMAX) { - $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + $idprof = $langs->transcountry('ProfId'.$i, (string) $object->country_code); if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) { $key = 'idprof'.$i; @@ -1799,7 +1799,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -1861,7 +1861,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; print ''; print ''; // Payment mode print ''; print ''; print ''; // Incoterms @@ -2292,7 +2292,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Name print ''; print ''; // Alias names (commercial, trademark or alias names) @@ -2456,7 +2456,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; // Zip / Town @@ -2468,7 +2468,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print $form->widgetForTranslation("town", $object, (int) $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); print ''; // Country @@ -2511,7 +2511,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; // EMail - print ''; + print ''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'; print img_picto('', 'object_email', 'class="pictofixedwidth"'); print ''; @@ -2549,8 +2549,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } print ''; print ''; } print ''; @@ -2581,7 +2581,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''; if (($j % $NBCOLS) == ($NBCOLS - 1)) { @@ -2607,7 +2607,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2616,7 +2616,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2625,7 +2625,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2634,7 +2634,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2675,7 +2675,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2705,7 +2705,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Juridical type print ''; // Capital @@ -2824,7 +2824,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; print ''; if ($action == 'editRE') { print ''; } else { print ''; @@ -3083,7 +3083,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; if ($action == 'editIRPF') { print ''; } else { print ''; @@ -3101,7 +3101,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; if ($action == 'editRE') { print ''; } else { print ''; @@ -3119,7 +3119,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; if ($action == 'editIRPF') { print ''; } else { print ''; @@ -3160,7 +3160,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -3227,7 +3227,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'; print $langs->trans("Categories"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5acae07046c..1332dff25d6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -854,14 +854,15 @@ class Commande extends CommonOrder } /** - * Sets object to supplied categories. + * Sets object to given categories. * - * Deletes object from existing categories not supplied. * Adds it to non existing supplied categories. + * Deletes object from existing categories not supplied. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category ID or array of Categories IDs + * + * @return int Return integer <0 if KO, >0 if OK */ public function setCategories($categories) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 269151b89cf..c9e5f0a2265 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -11281,18 +11281,19 @@ class Form /** - * Output a combo list with orders qualified for a third party + * Output a combo list with orders qualified for a third party * - * @param int $selected Id order preselected - * @param string $htmlname Name of HTML select - * @param int $maxlength Maximum length of label - * @param int $option_only Return only html options lines without the select tag - * @param string $show_empty Add an empty line ('1' or string to show for empty line) - * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) - * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $disabled Disabled - * @param string $morecss More css added to the select component - * @return int Nbr of project if OK, <0 if KO + * @param string $selected Id order preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * + * @return int Nbr of project if OK, <0 if KO */ public function selectOrder($selected = '', $htmlname = 'orderid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500') { @@ -11315,7 +11316,7 @@ class Form // Use select2 selector if (!empty($conf->use_javascript_ajax)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus); $out .= $comboenhancement; $morecss = 'minwidth200imp maxwidth500'; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d4560cba34f..602fb1a9d39 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1400,7 +1400,7 @@ function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $left } // Categories - if (isModEnabled('categorie')) { + if (isModEnabled('category')) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=16", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index a592d387047..f46d818989f 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -669,7 +669,7 @@ class modCategorie extends DolibarrModules * @param int $cat_id Categorie id * @param string $class Class of the linked object * @param string $enabled Condition to enable this export - * @param string $permission Permission to export the linked object + * @param array $permission Permission to export the linked object * @param array $fields_list Additional fields of the linked object to export * * @return void @@ -757,7 +757,7 @@ class modCategorie extends DolibarrModules int $cat_id, string $class_file, string $class, - string $element, + string $element ) { $cat_type = Categorie::$MAP_ID_TO_CODE[$cat_id]; From fa512af1809f107933333874980025398fc634a0 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Fri, 14 Feb 2025 15:46:40 +0100 Subject: [PATCH 10/40] NEW #22848 FIx phpstan alert --- htdocs/categories/viewcat.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/core/modules/modCategorie.class.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index ed0593a13d9..62d2d47d979 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1484,7 +1484,7 @@ if ($type == Categorie::TYPE_ORDER) { if ($permission) { print ""; print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft'); print ""; } print "
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ORDER, '', 'parent', 64, 0, 1); $arrayselected = GETPOST('categories', 'array'); - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$modCodeTiers->info($langs).''.$modCodeTiers->getExample($langs).''."\n"; print img_picto($langs->trans("Activated"), 'switch_on'); print "
'.$langs->trans("DefaultCustomerType").''; - print $formcompany->selectProspectCustomerType(getDolGlobalString('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); + print $formcompany->selectProspectCustomerType(getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); print ''; print ''; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 51f33f87f6f..fc1ef0621bc 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2019 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; * @var User $user */ -$htmlname = GETPOST('htmlname', 'aZ09'); +$htmlname = (string) GETPOST('htmlname', 'aZ09'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOSTINT('outjson') ? GETPOSTINT('outjson') : 0); $action = GETPOST('action', 'aZ09'); @@ -102,7 +102,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - if (empty($htmlname)) { + if ($htmlname === '') { return; } @@ -115,7 +115,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param $htmlname. - $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? (string) GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; } @@ -134,7 +134,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc // If SOCIETE_USE_SEARCH_TO_SELECT is set, check that nb of chars in $filter is >= to avoid DOS attack - $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); + $arrayresult = $form->select_thirdparty_list('0', (string) $htmlname, $filter, 1, $showtype, 0, array(), $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); if ($outjson) { print json_encode($arrayresult); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index ef113ba10da..860c3e071f6 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -258,7 +258,7 @@ abstract class ActionsCardCommon // Country $this->object->country_id = ($this->object->country_id ? $this->object->country_id : $mysoc->country_id); $this->object->country_code = ($this->object->country_code ? $this->object->country_code : $mysoc->country_code); - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $this->tpl['select_country'] = $form->select_country((string) $this->object->country_id, 'country_id'); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($user->admin) { @@ -281,7 +281,7 @@ abstract class ActionsCardCommon $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par default en creation // Select users - $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth300'); // Local Tax // TODO Implement country specific action in country specific class diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index f5d533ceeab..955f6faa638 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2025 MDW * * 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 @@ -122,7 +123,7 @@ class ActionsCardCompany extends ActionsCardCommon $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id); // Juridical Status - $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_code); + $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_id); // Workforce $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id); @@ -136,7 +137,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; @@ -164,7 +165,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b2fee95952e..4c45dc785c3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2022-2023 George Gkantinas * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Alexandre Janniaux - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Charlene Benke * * This program is free software; you can redistribute it and/or modify @@ -1677,7 +1677,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.img_picto('', 'globe', 'class="pictofixedwidth"').'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalString('SOCIETE_EMAIL_MANDATORY')).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalInt('SOCIETE_EMAIL_MANDATORY')).'
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; if ($object->country_id) { - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_id, '', 'forme_juridique_code'); } else { print $countrynotdefined; } @@ -1892,14 +1892,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'.$form->editfieldkey('PaymentConditions', 'cond_reglement_id', '', $object, 0).''; - print $form->getSelectConditionsPaiements($object->cond_reglement_id, 'cond_reglement_id', 1, 1, 1, '', $object->deposit_percent); + print $form->getSelectConditionsPaiements($object->cond_reglement_id, 'cond_reglement_id', 1, 1, 1, '', (float) $object->deposit_percent); print '
'.$form->editfieldkey('PaymentMode', 'mode_reglement_id', '', $object, 0).''; - print $form->select_types_paiements($object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 1, 0, 1); + print $form->select_types_paiements((string) $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 1, 0, 1); print '
'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); + print $form->widgetForTranslation("name", $object, (int) $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); print '
'; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print $form->widgetForTranslation("address", $object, (int) $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); print '
'.$form->editfieldkey('Town', 'town', '', $object, 0).'
'.img_picto('', 'globe', 'class="pictofixedwidth"').'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalInt('SOCIETE_EMAIL_MANDATORY'))).''; - $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2); - print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, false, $useempty); + $useempty = (int) (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2); + print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, 0, $useempty); print '
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; + print ''.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (int) !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); print '
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_id, '', 'forme_juridique_code'); print '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); $arrayselected = GETPOST('commercial', 'array'); if (empty($arrayselected)) { $arrayselected = $object->getSalesRepresentatives($user, 1); @@ -3069,7 +3069,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'.$langs->transcountry("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
'.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'.$langs->transcountry("Localtax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
'.$langs->transcountry("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'; print '
'; $html_name = ($action == 'editthirdpartytype') ? 'typent_id' : 'none'; - $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->typent_id, $html_name, ''); + $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->typent_id, $html_name, ''); print '
'; print ''; $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); print ''; } @@ -3486,7 +3486,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->hasRight('societe', 'creer'); - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); } // Subsidiaries list diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 5abc5048814..451f77fa51e 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -54,6 +55,8 @@ print '
'; print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup'); +$messagetoshow = ''; + $vatNumber = GETPOST("vatNumber", 'alpha'); if (!$vatNumber) { @@ -96,7 +99,6 @@ if (!$vatNumber) { dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD, $parameters); - $messagetoshow = ''; print ''.$langs->trans("Response").':
'; $faultstring = $result['faultstring'] ?? ''; // Service indisponible diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index bfdbf8c7920..c6832d92084 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2016 Marcos García * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -212,7 +212,7 @@ class CompanyBankAccount extends Account public $country_code; /** - * @var int $default_rib 1 = this object is the third party's default bank information, 0 if not + * @var int 1 = this object is the third party's default bank information, 0 if not */ public $default_rib; @@ -356,11 +356,11 @@ class CompanyBankAccount extends Account /** * Create bank information record. * - * @param ?User $user User + * @param User $user User * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, > 0 if OK (ID of newly created company bank account information) */ - public function create($user = null, $notrigger = 0) + public function create($user, $notrigger = 0) { $now = dol_now(); @@ -431,11 +431,11 @@ class CompanyBankAccount extends Account /** * Update bank account * - * @param ?User $user Object user + * @param User $user Object user * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <=0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs; @@ -599,11 +599,11 @@ class CompanyBankAccount extends Account /** * Delete a rib from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f734c3b7612..2a70b11d5d4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1644,16 +1644,16 @@ class Societe extends CommonObject $sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'"; $sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null"); + $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape((string) $this->tva_assuj)."'" : "null"); $sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'"; if (!getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape($this->vat_reverse_charge) . "'" : 0); + $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape((string) $this->vat_reverse_charge) . "'" : 0); } $sql .= ",status = ".((int) $this->status); // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null"); + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape((string) $this->localtax1_assuj)."'" : "null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape((string) $this->localtax2_assuj)."'" : "null"); if ($this->localtax1_assuj == 1) { if ($this->localtax1_value != '') { $sql .= ",localtax1_value =".$this->localtax1_value; @@ -1686,16 +1686,16 @@ class Societe extends CommonObject $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); } - $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); + $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape((string) $this->forme_juridique_code)."'" : "null"); - $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); - $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); - $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null"); - $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); - $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); - $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); - $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape($this->transport_mode_supplier_id)."'" : "null"); - $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); + $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape((string) $this->mode_reglement_id)."'" : "null"); + $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape((string) $this->cond_reglement_id)."'" : "null"); + $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape((string) $this->deposit_percent)."'" : "null"); + $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape((string) $this->transport_mode_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape((string) $this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape((string) $this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape((string) $this->transport_mode_supplier_id)."'" : "null"); + $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape((string) $this->shipping_method_id)."'" : "null"); $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); $sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0); @@ -1768,7 +1768,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::update update linked member"); $lmember = new Adherent($this->db); - $result = $lmember->fetch(0, 0, $this->id); + $result = $lmember->fetch(0, '0', $this->id); if ($result > 0) { $lmember->company = $this->name; @@ -2469,7 +2469,7 @@ class Societe extends CommonObject // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql .= " SET remise_client = '".$this->db->escape((string) $remise)."'"; $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -2481,7 +2481,7 @@ class Societe extends CommonObject // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape($remise)."',"; + $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape((string) $remise)."',"; $sql .= " '".$this->db->escape($note)."',"; $sql .= " ".((int) $user->id); $sql .= ")"; @@ -2627,7 +2627,7 @@ class Societe extends CommonObject $discount->multicurrency_amount_ht = price2num($remise * (float) $discount->multicurrency_tx, 'MT'); $discount->multicurrency_amount_tva = price2num(((float) $remise * (float) $vatrate / 100) * (float) $discount->multicurrency_tx, 'MT'); - $discount->multicurrency_amount_ttc= price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); + $discount->multicurrency_amount_ttc = price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); } $discount->tva_tx = (float) price2num($vatrate); @@ -2692,13 +2692,15 @@ class Societe extends CommonObject if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix()."usergroup_user as ug WHERE ug.entity IN (".getEntity('usergroup')."))"; } else { - $sql .= " WHERE entity IN (0, ".$this->db->sanitize($conf->entity).")"; + $sql .= " WHERE entity IN (0, ".$this->db->sanitize((string) $conf->entity).")"; } $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".((int) $this->id); - if (empty($sortfield) && empty($sortorder)) { + if (empty($sortfield)) { $sortfield = 'u.lastname,u.firstname'; - $sortorder = 'ASC,ASC'; + } + if (empty($sortorder)) { + $sortorder = str_repeat('ASC,', count(explode(',', $sortfield)) - 1) . 'ASC'; } $sql .= $this->db->order($sortfield, $sortorder); @@ -3161,7 +3163,7 @@ class Societe extends CommonObject $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (' class="'.(($withpicto != 2) ? 'paddingright' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { - $result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name); + $result .= dol_escape_htmltag($maxlen ? dol_trunc((string) $name, $maxlen) : $name); } $result .= $linkend; @@ -3512,7 +3514,7 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); - $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); + $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, (string) $bac->id); } return $bac->rum; } elseif ($mode == 'format') { @@ -4969,7 +4971,7 @@ class Societe extends CommonObject /** * Return amount of order not yet paid and total and list of all orders * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') @@ -5012,7 +5014,7 @@ class Societe extends CommonObject /** * Return amount of bill not yet paid and total of all invoices * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @param int<0,1> $late 0 => all invoice, 1=> only late * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index a84b221ab06..e3570e90aa1 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -244,6 +244,9 @@ print ''; $sql_select = ''; $documentstaticline = ''; +$tables_from = ''; +$dateprint = ''; +$doc_number = ''; /*if ($type_element == 'action') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -254,6 +257,7 @@ $documentstaticline = ''; $dateprint = 'f.datep'; $doc_number='f.id'; }*/ +$documentstatic = null; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); @@ -382,6 +386,7 @@ if ($type_element == 'contract') { // Order } $parameters = array(); +$totalnboflines = 0; $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook if (!empty($sql_select)) { @@ -453,6 +458,7 @@ $total_qty = 0; $total_ht = 0; $param = ''; +$num = 0; if ($sql_select) { $resql = $db->query($sql); @@ -496,8 +502,8 @@ if ($sql_select) { print ''; print ''; print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); + print $formother->select_month($month ? (string) $month : '-1', 'month', 1, 0, 'valignmiddle'); + print $formother->selectyear($year ? (string) $year : '-1', 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); print ''; // delivery planned date if ($type_element == 'order' || $type_element == 'supplier_order' || $type_element == 'shipment') { @@ -565,6 +571,8 @@ if ($sql_select) { print ''; if ($type_element == 'contract') { print $documentstaticline->getLibStatut(5); + } elseif ($documentstatic == null) { + // Do noting - for static analysis } elseif ($type_element == 'invoice') { // @phan-suppress-next-line PhanParamTooMany print $documentstatic->getLibStatut(5, $objp->paid); @@ -670,7 +678,7 @@ if ($sql_select) { } } else { if ($objp->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, $description, 3, 0, '', (string) $i, 0, ''); // Show range echo get_date_range($objp->date_start, $objp->date_end); @@ -689,7 +697,7 @@ if ($sql_select) { if (!empty($objp->label)) { $text .= ' '.$objp->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, 0, '', (string) $i, 0, ''); } else { echo $text.' '.dol_htmlentitiesbr($objp->description); } @@ -755,7 +763,7 @@ if ($sql_select) { } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); print ''."\n"; // Titles with sort buttons diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 990c6730061..98e814ea288 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -146,8 +146,8 @@ if (empty($reshook)) { } if ($action == 'confirm_delete' && $user->hasRight('societe', 'contact', 'delete')) { - $id = GETPOST('id', 'int'); - if (!empty($id) && $socid > 0) { + $id = GETPOSTINT('id'); + if ($id > 0 && $socid > 0) { $contact = new Contact($db); $ret = $contact->fetch($id); if ($ret > 0) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 449a7b02a9b..1bb811ceb8e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,6 +208,7 @@ if ($type == 't') { $contextpage = 'poslist'; } if ($search_type == '') { + // TODO: This case does not seem to be handled by FormCompany::selectProspectCustomerType. $search_type = '1,2,3'; } } @@ -268,78 +269,77 @@ if (getDolGlobalString('THIRDPARTY_QUICKSEARCH_ON_FIELDS')) { // Define list of fields to show into list -$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); -$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); -$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedtypetiers = 1; -$checkedprofid1 = 0; -$checkedprofid2 = 0; -$checkedprofid3 = 0; -$checkedprofid4 = 0; -$checkedprofid5 = 0; -$checkedprofid6 = 0; -//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); -$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); -$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? '1' : '0'); +$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? '1' : '0'); +$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedtypetiers = '1'; +$checkedprofid1 = '0'; +$checkedprofid2 = '0'; +$checkedprofid3 = '0'; +$checkedprofid4 = '0'; +$checkedprofid5 = '0'; +$checkedprofid6 = '0'; +//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); +$checkstcomm = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); $arrayfields = array( - 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => -1, 'enabled' => 1), - 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => 1), - 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => 1), - 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => -1, 'enabled' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), - 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => isModEnabled('barcode')), + 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => '-1', 'enabled' => '1'), + 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => '1'), + 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => '1'), + 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => '-1', 'enabled' => (string) getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), + 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => '1', 'enabled' => (string) (int) isModEnabled('barcode')), 's.code_client' => array('label' => "CustomerCodeShort", 'position' => 10, 'checked' => $checkedcustomercode), - 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.code_compta' => array('label' => "CustomerAccountancyCodeShort", 'position' => 13, 'checked' => $checkedcustomeraccountcode), - 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), - 's.address' => array('label' => "Address", 'position' => 19, 'checked' => 0), - 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => 1), - 's.town' => array('label' => "Town", 'position' => 21, 'checked' => 0), - 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => 0), - 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => 0), - 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => 0), - 's.email' => array('label' => "Email", 'position' => 25, 'checked' => 0), - 's.url' => array('label' => "Url", 'position' => 26, 'checked' => 0), - 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => 1), - 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => 0), + 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.address' => array('label' => "Address", 'position' => 19, 'checked' => '0'), + 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => '1'), + 's.town' => array('label' => "Town", 'position' => 21, 'checked' => '0'), + 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => '0'), + 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => '0'), + 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => '0'), + 's.email' => array('label' => "Email", 'position' => 25, 'checked' => '0'), + 's.url' => array('label' => "Url", 'position' => 26, 'checked' => '0'), + 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => '1'), + 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => '0'), 'typent.code' => array('label' => "ThirdPartyType", 'position' => 29, 'checked' => $checkedtypetiers), - 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => 0), - 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => 0), - 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => 0), + 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => '0'), + 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => '0'), + 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => '0'), 's.siren' => array('label' => "ProfId1Short", 'position' => 40, 'checked' => $checkedprofid1), 's.siret' => array('label' => "ProfId2Short", 'position' => 41, 'checked' => $checkedprofid2), 's.ape' => array('label' => "ProfId3Short", 'position' => 42, 'checked' => $checkedprofid3), 's.idprof4' => array('label' => "ProfId4Short", 'position' => 43, 'checked' => $checkedprofid4), 's.idprof5' => array('label' => "ProfId5Short", 'position' => 44, 'checked' => $checkedprofid5), 's.idprof6' => array('label' => "ProfId6Short", 'position' => 45, 'checked' => $checkedprofid6), - 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => 0), - 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => 1), + 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => '0'), + 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => '1'), 's.fk_prospectlevel' => array('label' => "ProspectLevel", 'position' => 62, 'checked' => $checkprospectlevel), 's.fk_stcomm' => array('label' => "StatusProsp", 'position' => 63, 'checked' => $checkstcomm), - 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => 0), - 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => -2, 'position' => 500), - 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 501), - 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 505), - 's.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), - 's.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), - 's.status' => array('label' => "Status", 'checked' => 1, 'position' => 1000), - 's.import_key' => array('label' => "ImportId", 'checked' => 0, 'position' => 1100), + 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => '0'), + 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => '-2', 'position' => 500), + 's.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 501), + 's.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 505), + 's.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), + 's.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), + 's.status' => array('label' => "Status", 'checked' => '1', 'position' => 1000), + 's.import_key' => array('label' => "ImportId", 'checked' => '0', 'position' => 1100), ); if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { - $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => 0); + $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => '0'); } // Add non object fields to fields for list -$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => 1, 'position' => 12); +$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => '1', 'position' => 12); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT('socid'); @@ -490,7 +490,7 @@ if (empty($reshook)) { if (!$error && $action == 'setstcomm' && $permissiontoadd) { $object = new Client($db); - $result = $object->fetch(GETPOST('stcommsocid')); + $result = $object->fetch(GETPOSTINT('stcommsocid')); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); $result = $object->update($object->id, $user); if ($result < 0) { @@ -1189,6 +1189,8 @@ if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MU print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), [], 'warning', 1); } +$newcardbutton = ''; + // Show the new button only when this page is not opened from the Extended POS (pop-up window) // but allow it too, when a user has the rights to create a new customer if ($contextpage != 'poslist') { @@ -1196,7 +1198,6 @@ if ($contextpage != 'poslist') { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer')); @@ -1291,7 +1292,7 @@ if (empty($type) || $type == 'f') { } // If the user can view prospects other than his' -$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); +$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); $userlist[-2] = $langs->trans("NoSalesRepresentativeAffected"); if ($user->hasRight("societe", "client", "voir") || $socid) { $moreforfilter .= '
'; @@ -2064,9 +2065,7 @@ while ($i < $imaxinloop) { } // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } + $typenArray = $formcompany->typent_array(1); $labeltypeofcompany = empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; print '
'; @@ -2348,7 +2347,7 @@ print '
'."\n"; print '
'."\n"; // Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script -$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js"); +$formcompany->selectProspectStatus('status_prospect', $prospectstatic, 0, 0, "js"); print ''."\n"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index acf931e6d84..c8d00a1559f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -8,7 +8,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2023 Thibault FOUCART * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -201,7 +201,7 @@ if (empty($reshook)) { $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = GETPOSTDATE('date_rum', '00:00:00'); if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { @@ -370,7 +370,7 @@ if (empty($reshook)) { } if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } } @@ -581,7 +581,7 @@ if (empty($reshook)) { } } } - if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the credit card on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); $companypaymentmode->fetch($id); @@ -598,6 +598,7 @@ if (empty($reshook)) { } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe card + update of llx_societe_rib // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to // ask to create the crdit card from Stripe backoffice. @@ -609,7 +610,7 @@ if (empty($reshook)) { } } } - if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the bank account on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib $companypaymentmode->fetch($id); @@ -628,6 +629,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorStripeCustomerNotFoundCreateFirst"), null, 'errors'); } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe SEPA + update of llx_societe_rib $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { @@ -791,7 +793,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation) { // Set as default when payment mode defined remotely only + } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Set as default when payment mode defined remotely only try { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_|src_/', $source)) { @@ -809,7 +811,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the credit card on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -842,7 +844,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the bank account on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -852,7 +854,7 @@ if (empty($reshook)) { } } else { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - $card = $cu->sources->retrieve("$source"); + $card = $cu->sources->retrieve((string) $source); if ($card) { // $card->detach(); Does not work with card_, only with src_ if (method_exists($card, 'detach')) { @@ -1017,12 +1019,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 0; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_accounttest') { @@ -1047,12 +1049,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 1; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_account') { @@ -1109,12 +1111,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Stripe connect - if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 && $service !== null) { $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') { @@ -1132,7 +1134,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; print ''; - print ''; + print ''; //print ''; print ''; } @@ -1155,7 +1157,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $listofsources = array(); $customerstripe = null; - if (isset($stripe) && is_object($stripe)) { + if (isset($stripe) && is_object($stripe) && $stripeacc !== null) { try { $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (!empty($customerstripe->id)) { @@ -1545,8 +1547,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } if (is_array($currencybalance)) { - foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price(isset($cpt->pending) ? $cpt->pending : 0, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + (isset($cpt->pending) ? $cpt->pending : 0), 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + foreach ($currencybalance as $cpt_arr) { + print ''.$langs->trans("Currency".strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'], 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price(isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0, 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'] + (isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0), 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''; } } @@ -1882,6 +1884,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Fields from hook + // TODO: No longer in foreach -> using last rib of for each which may be undeclared! $parameters = array('arrayfields' => array(), 'stripe_card_ref' => $rib->stripe_card_ref, 'stripe_account' => $rib->stripe_account, 'linetype' => 'stripebanremoteonly'); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1932,7 +1935,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $permissiontoread, (int) $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); // Show direct download link if (getDolGlobalString('BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD')) { @@ -2082,7 +2085,7 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print ''; if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } // RUM @@ -2140,8 +2143,8 @@ if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) print ''; print ''; print ''; @@ -2317,8 +2320,8 @@ if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformatio print ''; print ''; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index e06605e8a66..1e89a156e66 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -106,7 +106,7 @@ if (empty($reshook)) { } if (!$error) { - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // add price by customer $prodcustprice->fk_soc = $socid; @@ -204,7 +204,7 @@ if (empty($reshook)) { if ($action == 'update_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $prodcustprice->fetch(GETPOSTINT('lineid')); - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // update price by customer $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); @@ -329,25 +329,25 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT $sortfield = "soc.nom"; } - // Build filter to display only concerned lines + // Build filter to display only related lines $filter = array( - 't.fk_soc' => $object->id + 't.fk_soc' => (string) $object->id ); if (!empty($search_prod)) { - $filter ['prod.ref'] = $search_prod; + $filter ['prod.ref'] = (string) $search_prod; } if (!empty($search_label)) { - $filter ['prod.label'] = $search_label; + $filter ['prod.label'] = (string) $search_label; } if (!empty($search_price)) { - $filter ['t.price'] = $search_price; + $filter ['t.price'] = (string) $search_price; } if (!empty($search_price_ttc)) { - $filter ['t.price_ttc'] = $search_price_ttc; + $filter ['t.price_ttc'] = (string) $search_price_ttc; } if ($action == 'add_customer_price') { @@ -368,7 +368,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''; print ''; print ''; print ''; @@ -378,7 +378,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -471,7 +471,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -581,8 +581,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''."\n"; $filter = array( - 't.fk_product' => GETPOSTINT('prodid'), - 't.fk_soc' => $socid + 't.fk_product' => (string) GETPOSTINT('prodid'), + 't.fk_soc' => (string) $socid ); // Count total nb of records diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 66412a151cd..1da3c51d555 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -55,14 +56,14 @@ if ($action == 'editsalesrepresentatives') { if (empty($arrayselected)) { $arrayselected = $object->getSalesRepresentatives($user, 1); } - print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print $form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, '', 0, "90%"); print ''; print ''; } else { $listsalesrepresentatives = $object->getSalesRepresentatives($user); - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 0 && is_array($listsalesrepresentatives)) { + $nbofsalesrepresentative = is_array($listsalesrepresentatives) ? count($listsalesrepresentatives) : 0; + if ($nbofsalesrepresentative > 0) { $userstatic = new User($db); foreach ($listsalesrepresentatives as $val) { $userstatic->id = $val['id']; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e245f49d91b..00a5624dc94 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -272,10 +273,10 @@ foreach ($search as $key => $val) { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $objectwebsiteaccount->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate((int) $search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate((int) $search[$key])."'"; } } } @@ -547,7 +548,7 @@ foreach ($objectwebsiteaccount->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -682,7 +683,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'login') { From 8f58256ede26cbc0fafdc99a1e5b68788b7c0348 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Feb 2025 11:46:29 +0100 Subject: [PATCH 15/40] Update viewcat.php --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 62d2d47d979..d9ebac1a4f8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1431,7 +1431,7 @@ if ($type == Categorie::TYPE_ORDER) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category - $showclassifyform = 1; + $showclassifyform = $user->hasRight('order', 'write'); if ($showclassifyform) { print '
'; print '
'; From 868fc56312bc56d31497946f4076a6e3e5907c8f Mon Sep 17 00:00:00 2001 From: Dolibot Date: Mon, 17 Feb 2025 12:07:19 +0000 Subject: [PATCH 16/40] PHPStan > Update baseline --- dev/build/phpstan/phpstan-baseline.neon | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 98a307425c1..2f61bcd8349 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -14262,18 +14262,6 @@ parameters: count: 1 path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - message: '#^Variable \$showlinktoai might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/formlayoutai.tpl.php - - - - message: '#^Variable \$showlinktoailabel might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/core/tpl/formlayoutai.tpl.php - - message: '#^Variable \$limit might not be defined\.$#' identifier: variable.undefined From 33b915abbe1c6f378d7713b3c599cc9119a6b4b4 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 13:18:20 +0100 Subject: [PATCH 17/40] NEW Better presentation of list of user approver. --- htdocs/fourn/commande/index.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 25f6d7e4f90..a5c6a8f75f9 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -235,14 +235,14 @@ if (isModEnabled("supplier_order")) { /* - * List of users allowed + * List of users allowed to approve */ $sql = "SELECT"; if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " DISTINCT"; } -$sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut"; +$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.photo, u.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; @@ -252,7 +252,7 @@ if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_ } else { $sql .= " WHERE (u.entity IN (".getEntity('user')."))"; } -$sql .= " AND u.fk_soc IS NULL"; // An external user can not approved +$sql .= " AND u.fk_soc IS NULL"; // An external user can not approve $resql = $db->query($sql); if ($resql) { @@ -264,6 +264,9 @@ if ($resql) { print '
'; print "\n"; + print ''; + print ''; - print ''; - print "\n"; + + print $userstatic->getNomUrl(-1); } $i++; } + if ($i == 0) { + print ''.$langs->trans("Nobody").''; + } + + print ''; + print "\n"; + print "
'.$langs->trans("ExpiryDate").''; - print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); - print $formother->selectyear($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print $formother->select_month((string) $companypaymentmode->exp_date_month, 'exp_date_month', 1); + print $formother->selectyear((string) $companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print '
'.$langs->trans("CVN").'
'.$langs->trans("ExpiryDate").''; - print $formother->select_month(GETPOSTINT('exp_date_month'), 'exp_date_month', 1); - print $formother->selectyear(GETPOSTINT('exp_date_year'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print $formother->select_month((string) GETPOSTINT('exp_date_month'), 'exp_date_month', 1); + print $formother->selectyear((string) GETPOSTINT('exp_date_year'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print '
'.$langs->trans("CVN").'
'.$langs->trans('Product').''; - $form->select_produits('', 'prodid', '', 0); + $form->select_produits(0, 'prodid', '', 0); print '
'.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, '', $object->id, 0, '', false, 1); + print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, null, $object->id, 0, '', false, 1); print '
'.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); + print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, null, $staticprod->id, $prodcustprice->recuperableonly); print '
'.$langs->trans("UserWithApproveOrderGrant").'
'; + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -272,19 +275,29 @@ if ($resql) { $userstatic->loadRights('fournisseur'); if ($userstatic->hasRight('fournisseur', 'commande', 'approuver')) { - print '
'; + if ($i > 0) { + print ', '; + } + $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; $userstatic->status = $obj->statut; - print $userstatic->getNomUrl(1); - print '

"; $db->free($resql); } else { From 3339ca0ed7b10d18a6dee4a163062807bbbf62da Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 13:45:16 +0100 Subject: [PATCH 18/40] Standardize category tables --- .../install/mysql/migration/21.0.0-22.0.0.sql | 64 +++++++++++++++++++ ... => llx_categorie_invoice-facture.key.sql} | 0 ....sql => llx_categorie_invoice-facture.sql} | 0 .../mysql/tables/llx_categorie_member.sql | 5 +- ...l => llx_categorie_order-commande.key.sql} | 0 ...r.sql => llx_categorie_order-commande.sql} | 0 ... => llx_categorie_warehouse-stock.key.sql} | 0 ....sql => llx_categorie_warehouse-stock.sql} | 0 .../mysql/tables/llx_category_bank.sql | 27 -------- .../mysql/tables/llx_category_bankline.sql | 3 +- 10 files changed, 69 insertions(+), 30 deletions(-) rename htdocs/install/mysql/tables/{llx_categorie_invoice.key.sql => llx_categorie_invoice-facture.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_categorie_invoice.sql => llx_categorie_invoice-facture.sql} (100%) rename htdocs/install/mysql/tables/{llx_categorie_order.key.sql => llx_categorie_order-commande.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_categorie_order.sql => llx_categorie_order-commande.sql} (100%) rename htdocs/install/mysql/tables/{llx_categorie_warehouse.key.sql => llx_categorie_warehouse-stock.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_categorie_warehouse.sql => llx_categorie_warehouse-stock.sql} (100%) delete mode 100644 htdocs/install/mysql/tables/llx_category_bank.sql diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 4cf68ce85ad..f873d5e7a23 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -58,3 +58,67 @@ ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (entity, name ALTER TABLE llx_societe_account ADD COLUMN ip varchar(250); ALTER TABLE llx_product ADD COLUMN packaging float(24,8) DEFAULT NULL; + + +ALTER TABLE llx_categorie_member ADD COLUMN import_key varchar(14); +ALTER TABLE llx_category_bankline ADD COLUMN import_key varchar(14); + + +create table llx_categorie_order +( + fk_categorie integer NOT NULL, + fk_order integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +--ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order(fk_categorie, fk_order); +ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); + +ALTER TABLE llx_categorie_order ADD CONSTRAINT fk_categorie_order_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_order ADD CONSTRAINT fk_categorie_order_fk_order_rowid FOREIGN KEY (fk_order) REFERENCES llx_commande (rowid); + + +create table llx_categorie_invoice +( + fk_categorie integer NOT NULL, + fk_invoice integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_invoice ADD PRIMARY KEY pk_categorie_invoice (fk_categorie, fk_invoice); +ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_invoice (fk_invoice); + +ALTER TABLE llx_categorie_invoice ADD CONSTRAINT fk_categorie_invoice_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_invoice ADD CONSTRAINT fk_categorie_invoice_fk_invoice_rowid FOREIGN KEY (fk_invoice) REFERENCES llx_facture (rowid); + + +create table llx_categorie_supplier_order +( + fk_categorie integer NOT NULL, + fk_supplier_order integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_supplier_order ADD PRIMARY KEY pk_categorie_supplier_order (fk_categorie, fk_supplier_order); +ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_supplier_order (fk_supplier_order); + +ALTER TABLE llx_categorie_supplier_order ADD CONSTRAINT fk_categorie_supplier_order_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_supplier_order ADD CONSTRAINT fk_categorie_supplier_order_fk_supplier_order_rowid FOREIGN KEY (fk_supplier_order) REFERENCES llx_commande_fournisseur (rowid); + + +create table llx_categorie_supplier_invoice +( + fk_categorie integer NOT NULL, + fk_supplier_invoice integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_supplier_invoice ADD PRIMARY KEY pk_categorie_supplier_invoice (fk_categorie, fk_supplier_invoice); +ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_supplier_invoice (fk_supplier_invoice); + +ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_fk_supplier_invoice_rowid FOREIGN KEY (fk_supplier_invoice) REFERENCES llx_facture_fourn (rowid); diff --git a/htdocs/install/mysql/tables/llx_categorie_invoice.key.sql b/htdocs/install/mysql/tables/llx_categorie_invoice-facture.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_invoice.key.sql rename to htdocs/install/mysql/tables/llx_categorie_invoice-facture.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_invoice.sql b/htdocs/install/mysql/tables/llx_categorie_invoice-facture.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_invoice.sql rename to htdocs/install/mysql/tables/llx_categorie_invoice-facture.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_member.sql b/htdocs/install/mysql/tables/llx_categorie_member.sql index b8ffedffc1e..0d911afb671 100644 --- a/htdocs/install/mysql/tables/llx_categorie_member.sql +++ b/htdocs/install/mysql/tables/llx_categorie_member.sql @@ -1,6 +1,6 @@ -- ============================================================================ -- Copyright (C) 2005 Brice Davoleau --- Copyright (C) 2005-2010 Matthieu Valleton +-- Copyright (C) 2005-2010 Matthieu Valleton -- -- 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 @@ -20,5 +20,6 @@ create table llx_categorie_member ( fk_categorie integer NOT NULL, - fk_member integer NOT NULL + fk_member integer NOT NULL, + import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_categorie_order.key.sql b/htdocs/install/mysql/tables/llx_categorie_order-commande.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_order.key.sql rename to htdocs/install/mysql/tables/llx_categorie_order-commande.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_order.sql b/htdocs/install/mysql/tables/llx_categorie_order-commande.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_order.sql rename to htdocs/install/mysql/tables/llx_categorie_order-commande.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse-stock.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse-stock.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_warehouse.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse-stock.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_warehouse.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse-stock.sql diff --git a/htdocs/install/mysql/tables/llx_category_bank.sql b/htdocs/install/mysql/tables/llx_category_bank.sql deleted file mode 100644 index 10ed331b069..00000000000 --- a/htdocs/install/mysql/tables/llx_category_bank.sql +++ /dev/null @@ -1,27 +0,0 @@ --- =================================================================== --- Copyright (C) 2004-2007 Laurent Destailleur --- Copyright (C) 2005-2009 Regis Houssin --- --- 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 --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- =================================================================== - --- TODO : Remove this file, content of this table has been moved into llx_categories table - -create table llx_category_bank -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - label varchar(255), - entity integer DEFAULT 1 NOT NULL -- multi company id -)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_category_bankline.sql b/htdocs/install/mysql/tables/llx_category_bankline.sql index 61112c3bec8..65d54e4e029 100644 --- a/htdocs/install/mysql/tables/llx_category_bankline.sql +++ b/htdocs/install/mysql/tables/llx_category_bankline.sql @@ -20,5 +20,6 @@ create table llx_category_bankline ( lineid integer NOT NULL, - fk_categ integer NOT NULL + fk_categ integer NOT NULL, + import_key varchar(14) )ENGINE=innodb; From d800b721fd662b23dcc5d16425e40c4a09b72935 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 13:52:52 +0100 Subject: [PATCH 19/40] Standardize category tables --- htdocs/install/mysql/migration/21.0.0-22.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index f873d5e7a23..7764d425405 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -71,7 +71,7 @@ create table llx_categorie_order import_key varchar(14) )ENGINE=innodb; ---ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order(fk_categorie, fk_order); +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); From 9af5292cc3cb1eadea7f168709d48d396dbe4e01 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 13:58:47 +0100 Subject: [PATCH 20/40] Standardize category tables --- htdocs/install/mysql/migration/21.0.0-22.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 7764d425405..51cdda10be8 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -71,7 +71,8 @@ create table llx_categorie_order import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); -- noqa: PRS + ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); From 8e411b3ead63092a32805de28ce5741fea1a83d4 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 13:59:59 +0100 Subject: [PATCH 21/40] Standardize category tables --- htdocs/install/mysql/migration/21.0.0-22.0.0.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 51cdda10be8..4b6e2c10de7 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -71,8 +71,7 @@ create table llx_categorie_order import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); -- noqa: PRS - +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); -- noqa: PRS ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); From fc96a88bd93f7e3cb027dd485a42805de8ed7a88 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 14:01:16 +0100 Subject: [PATCH 22/40] Standardize category tables --- htdocs/install/mysql/migration/21.0.0-22.0.0.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 4b6e2c10de7..e497ac34a96 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -71,7 +71,9 @@ create table llx_categorie_order import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); -- noqa: PRS +--noqa:disable=PRS +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); +--noqa:enable=all ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); From 5de4d8a1668d2e95dca6be78a3bd6c0cd2935162 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 14:02:39 +0100 Subject: [PATCH 23/40] Standardize category tables --- .../install/mysql/migration/21.0.0-22.0.0.sql | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index e497ac34a96..7b9c19450b4 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -72,8 +72,8 @@ create table llx_categorie_order )ENGINE=innodb; --noqa:disable=PRS -ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order (fk_categorie, fk_order); ---noqa:enable=all +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order(fk_categorie, fk_order); +--noqa:enable=PRS ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); @@ -88,7 +88,9 @@ create table llx_categorie_invoice import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_invoice ADD PRIMARY KEY pk_categorie_invoice (fk_categorie, fk_invoice); +--noqa:disable=PRS +ALTER TABLE llx_categorie_invoice ADD PRIMARY KEY pk_categorie_invoice(fk_categorie, fk_invoice); +--noqa:enable=PRS ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_invoice (fk_invoice); @@ -103,7 +105,9 @@ create table llx_categorie_supplier_order import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_supplier_order ADD PRIMARY KEY pk_categorie_supplier_order (fk_categorie, fk_supplier_order); +--noqa:disable=PRS +ALTER TABLE llx_categorie_supplier_order ADD PRIMARY KEY pk_categorie_supplier_order(fk_categorie, fk_supplier_order); +--noqa:enable=PRS ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_supplier_order (fk_supplier_order); @@ -118,7 +122,10 @@ create table llx_categorie_supplier_invoice import_key varchar(14) )ENGINE=innodb; -ALTER TABLE llx_categorie_supplier_invoice ADD PRIMARY KEY pk_categorie_supplier_invoice (fk_categorie, fk_supplier_invoice); +--noqa:disable=PRS +ALTER TABLE llx_categorie_supplier_invoice ADD PRIMARY KEY pk_categorie_supplier_invoice(fk_categorie, fk_supplier_invoice); +--noqa:enable=PRS + ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_categorie (fk_categorie); ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_supplier_invoice (fk_supplier_invoice); From 730c6971da1a8adaf8ded6e8322abb5a7edddf7b Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 14:20:40 +0100 Subject: [PATCH 24/40] Debug v21 --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 0a83062a908..b3880b31f81 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -4774,7 +4774,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); } else { //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) - print $form->textwithpicto($langs->trans("PreviewPageContent").' '.img_help(2, $langs->trans("PreviewPageContent")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); + print $form->textwithpicto($showlinktolayout ? '' : ($langs->trans("PreviewPageContent").' '.img_help(2, $langs->trans("PreviewPageContent"))), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); } } print ''; From 1cad2a092e0fe90123107fbd230875aaaa504c37 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 14:29:44 +0100 Subject: [PATCH 25/40] Standardize the category tables. --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 65ff3c054bb..2f3cc694c4e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1351,3 +1351,4 @@ AllTime=From start Transferred=Transferred Anonymous=Anonymous Automatic=Automatic +Nobody=Nobody From 1e4a9bfe9b45ad14dc3a658c03521f504e4010d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Feb 2025 14:41:01 +0100 Subject: [PATCH 26/40] Update modCategorie.class.php --- htdocs/core/modules/modCategorie.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index fd9dbce3233..9539c14d71b 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -167,7 +167,7 @@ class modCategorie extends DolibarrModules if (isModEnabled('website')) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } - if (!empty($conf->commande->enabled)) { + if (isModEnabled('commande')) { $typeexample .= ($typeexample ? " / " : "")."16=Order"; } @@ -459,7 +459,7 @@ class modCategorie extends DolibarrModules $r, 16, 'Commande', - '!empty($conf->commande->enabled)', + 'isModEnabled("commande")', ['commande', 'commande', 'export'], [ 'rowid' => [ @@ -650,7 +650,7 @@ class modCategorie extends DolibarrModules // 11 Website Pages, TODO ? // 16 Order - if (!empty($conf->commande->enabled)) { + if (isModEnabled("commande")) { ++$r; $this->importTagLinks( $r, @@ -735,8 +735,8 @@ class modCategorie extends DolibarrModules $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent'; $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_'.$cat_type.' as cfk ON cfk.fk_categorie = cat.rowid'; - $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.$class.' as p ON p.rowid = cfk.fk_'.$cat_type; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.$class.'_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.strtolower($class).' as p ON p.rowid = cfk.fk_'.$cat_type; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.strtolower($class).'_extrafields as extra ON extra.fk_object = p.rowid'; $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .= ' AND cat.type = '.((int) $cat_id); } From 180013b1ed8d9c99da04285d1c590359b2341352 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 14:53:44 +0100 Subject: [PATCH 27/40] Debug v21 --- htdocs/main.inc.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 110780d1401..7ab727033ba 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -736,15 +736,20 @@ if (!empty($_SESSION["disablemodules"])) { foreach ($disabled_modules as $module) { if ($module) { if (empty($conf->$module)) { - $conf->$module = new stdClass(); // To avoid warnings + $conf->$module = new stdClass(); // To avoid warnings } - $conf->$module->enabled = false; + + $conf->$module->enabled = false; // Old usage + unset($conf->modules[$module]); + foreach ($modulepartkeys as $modulepartkey) { unset($conf->modules_parts[$modulepartkey][$module]); } if ($module == 'fournisseur') { // Special case - $conf->supplier_order->enabled = 0; - $conf->supplier_invoice->enabled = 0; + $conf->supplier_order->enabled = 0; // Old usage + $conf->supplier_invoice->enabled = 0; // Old usage + unset($conf->modules['supplier_order']); + unset($conf->modules['supplier_invoice']); } } } From eaf978cb1249c16cf0a8e76fb64d60ebcdf84941 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 17 Feb 2025 15:09:31 +0100 Subject: [PATCH 28/40] FIX #33101 white page on ticket card when adding a link by reference --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 84d5297f4c0..b30c1c9bdd5 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -766,7 +766,7 @@ if ($action == 'create' || $action == 'presend') { $formticket->showForm(0, 'edit', 0, null, $action, $object); print dol_get_fiche_end(); -} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status', 'dellink'])) { +} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'addlinkbyref', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status'])) { if (!empty($res) && $res > 0) { // or for unauthorized internals users if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { From 33d722c84f3717240e1f0ca9d0e2eabb9b121759 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 16:02:22 +0100 Subject: [PATCH 29/40] API use syntax "Authorization: Bearer ..." instead of "DOLAPIKEY: ..." --- htdocs/api/class/api_access.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 1355261d0ef..3e0d7549f7f 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -92,7 +92,7 @@ class DolibarrApiAccess implements iAuthenticate public function __isAllowed() { // phpcs:enable - global $conf, $db, $user; + global $conf, $user; $login = ''; $stored_key = ''; @@ -114,9 +114,16 @@ class DolibarrApiAccess implements iAuthenticate // TODO Add option to disable use of api key on url. Return errors if used. $api_key = $_GET['DOLAPIKEY']; // With GET method } - if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY - $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) - } + + // TODO Can filter on user agent. + //$api_useragent = $_SERVER['HTTP_USER_AGENT']; + + if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // HTTP Header entry "DOLAPIKEY: ..." can be read with $_SERVER["HTTP_DOLAPIKEY"] + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) + } else { + $headers = getallheaders(); // HTTP Header entry "Authorization: Bearer ..." can be read with getallheaders + $api_key = preg_replace('/^Bearer\s+/i', '', empty($headers['Authorization']) ? '' : $headers['Authorization']); + }; $api_key = dol_string_nounprintableascii($api_key); @@ -216,7 +223,7 @@ class DolibarrApiAccess implements iAuthenticate static::$role = 'admin'; } } else { - throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); + throw new RestException(401, "Failed to login to API. Neither parameter 'HTTP_DOLAPIKEY' nor 'Authentication: Bearer' found on HTTP header (and no parameter DOLAPIKEY in URL)."); } $userClass::setCacheIdentifier(static::$role); From 417f10c99d25848381b7d245f3e68f4f0da1ed1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Feb 2025 16:08:20 +0100 Subject: [PATCH 30/40] Update modCategorie.class.php --- htdocs/core/modules/modCategorie.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 9539c14d71b..6dbf6510907 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -167,7 +167,7 @@ class modCategorie extends DolibarrModules if (isModEnabled('website')) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } - if (isModEnabled('commande')) { + if (isModEnabled('order')) { $typeexample .= ($typeexample ? " / " : "")."16=Order"; } @@ -459,7 +459,7 @@ class modCategorie extends DolibarrModules $r, 16, 'Commande', - 'isModEnabled("commande")', + 'isModEnabled("order")', ['commande', 'commande', 'export'], [ 'rowid' => [ @@ -650,7 +650,7 @@ class modCategorie extends DolibarrModules // 11 Website Pages, TODO ? // 16 Order - if (isModEnabled("commande")) { + if (isModEnabled("order")) { ++$r; $this->importTagLinks( $r, From 1904d4da6e6918857d789ca5b11dc4168f55c86c Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 16:42:11 +0100 Subject: [PATCH 31/40] FIX harmless PHP warnings --- htdocs/compta/bank/class/paymentvarious.class.php | 3 ++- htdocs/compta/bank/various_payment/document.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index c42bc942479..1a2bfe8076e 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -767,7 +767,7 @@ class PaymentVarious extends CommonObject */ public function info($id) { - $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; + $sql = 'SELECT v.rowid, v.datec, v.fk_user_author, fk_user_modif, tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql .= ' WHERE v.rowid = '.((int) $id); @@ -780,6 +780,7 @@ class PaymentVarious extends CommonObject $this->id = $obj->rowid; $this->user_creation = $obj->fk_user_author; + $this->user_creation_id = $obj->fk_user_author; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 7c717d7ede0..3ee2fbd77e9 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -129,7 +129,7 @@ if ($object->id) { $morehtmlref .= ''; $linkback = ''.$langs->trans("BackToList").''; - $morehtmlstatus = $morehtmlright; + $morehtmlstatus = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; From 4d46197aedc1430e789a7194a1434992f2cc3ec0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Feb 2025 17:23:16 +0100 Subject: [PATCH 32/40] Update html.form.class.php --- 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 c9e5f0a2265..ea7f50f9f04 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -11063,7 +11063,7 @@ class Form $out = ''; $hideunselectables = false; - if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES')) { + if (getDolGlobalString('INVOICE_HIDE_UNSELECTABLES')) { $hideunselectables = true; } @@ -11302,7 +11302,7 @@ class Form $out = ''; $hideunselectables = false; - if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) { + if (getDolGlobalString('ORDER_HIDE_UNSELECTABLES')) { $hideunselectables = true; } From b65189f4e3dca3ec36265b98adf29e4246424ee2 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 18:18:57 +0100 Subject: [PATCH 33/40] Fix regression --- htdocs/api/class/api_access.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 3e0d7549f7f..f01a6d56538 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -120,7 +120,7 @@ class DolibarrApiAccess implements iAuthenticate if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // HTTP Header entry "DOLAPIKEY: ..." can be read with $_SERVER["HTTP_DOLAPIKEY"] $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) - } else { + } elseif (empty($api_key)) { $headers = getallheaders(); // HTTP Header entry "Authorization: Bearer ..." can be read with getallheaders $api_key = preg_replace('/^Bearer\s+/i', '', empty($headers['Authorization']) ? '' : $headers['Authorization']); }; From 612f34f719dfcdf494efeb1e6cd7e39b9bea8eb6 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 17 Feb 2025 15:09:31 +0100 Subject: [PATCH 34/40] FIX #33101 white page on ticket card when adding a link by reference --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5365b05435e..9a1299478d8 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -766,7 +766,7 @@ if ($action == 'create' || $action == 'presend') { $formticket->showForm(0, 'edit', 0, null, $action, $object); print dol_get_fiche_end(); -} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status', 'dellink'])) { +} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'addlinkbyref', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status'])) { if (!empty($res) && $res > 0) { // or for unauthorized internals users if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { From 54e52c38328a5b17384ad9178e61e0f7997134af Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 21:49:08 +0100 Subject: [PATCH 35/40] Fix phpstan pb --- phpstan.neon.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a21273cea08..91d20f78748 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,6 +21,7 @@ parameters: analyseAndScan: - htdocs/custom/* - htdocs/documents/* + - htdocs/install/* # We must exclude this dir to avoid to have DOL_DOCUMENT_ROOT defined to .. by inc.php before the bootstrap*.php file can load it. - htdocs/install/doctemplates/* - htdocs/langs/* - htdocs/modulebuilder/template/test/* From 58e243e5355698980b6ee3bd0d386969a740e5d6 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 22:02:14 +0100 Subject: [PATCH 36/40] Fix phpstan --- htdocs/core/lib/geturl.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index bc105b30330..20d22d47b7c 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -52,7 +52,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent postorget=".$postorget." URL=".$url." param=".$param); if (!function_exists('curl_init')) { - return array('curl_error_no' => 'PHP curl lib not available', 'curl_error_msg' => 'PHP curl library must be installed'); + return array('http_code' => 500, 'content' => '', 'curl_error_no' => 1, 'curl_error_msg' => 'PHP curl library must be installed'); } //setting the curl parameters. From 104f5a9dc82815e93a6dca63fe30de970a582062 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 22:02:14 +0100 Subject: [PATCH 37/40] Fix phpstan From 9d61b20ecd6f8cb3aab178f70b5f4e466af69d2a Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 18 Feb 2025 10:24:00 +0100 Subject: [PATCH 38/40] Fix php stan --- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/class/timespent.class.php | 2 +- htdocs/core/lib/company.lib.php | 18 ++++++++---------- htdocs/website/index.php | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b18bcac8aca..ec83f271881 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -119,7 +119,7 @@ class Commande extends CommonOrder /** * Status of the order - * @var int + * @var int|null */ public $status; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 494d9cff49c..7e89a2a2217 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -104,7 +104,7 @@ class Facture extends CommonInvoice protected $table_ref_field = 'ref'; /** - * @var int ID + * @var int|null ID * @deprecated Use $user_creation_id */ public $fk_user_author; diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index fdd8dd83bcd..e5f10fb3c8b 100644 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -184,7 +184,7 @@ class TimeSpent extends CommonObject */ public $intervention_line_id; /** - * @var string + * @var int */ public $datec; /** diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index eb1b72a3846..c91193ac55e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2037,7 +2037,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr // Complete request and execute it with limit $sql .= $db->order($sortfield_new, $sortorder); - if ($limit) { + if ($limit) { // @phpstan-ignore-line $sql .= $db->plimit($limit + 1, $offset); } @@ -2684,16 +2684,14 @@ function htmlPrintOnlineHeader($mysoc, $langs) print '
'; // Output html code for logo - if ($urllogo) { - print '
'; - print '
'; - print ''; - print '
'; - if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { - print ''; - } - print '
'; + print '
'; + print '
'; + print ''; + print '
'; + if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { + print ''; } + print '
'; if (getDolGlobalString('MEMBER_IMAGE_PUBLIC_REGISTRATION')) { print '
'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index b3880b31f81..5e376b7dafe 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -4442,7 +4442,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); } if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) { - $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09') ? 1 : 0; + $pageallowedinframes = 1; } if (GETPOST('htmlheader', 'none')) { // Must accept tags like '