diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 98a307425c102..2f61bcd834900 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 diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index e4bac1868cc3b..be05dc5d76239 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/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 3e0d7549f7f6c..f01a6d56538b2 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -120,7 +120,7 @@ public function __isAllowed() 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']); }; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5082bda1b1515..aad4da2447a07 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', + 16 => 'order' ); /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 10e327a0420fa..c9d333ba56cbe 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,21 +48,22 @@ 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' => 16, ); /** @@ -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', + 16 => '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 fcef409cc55d5..d9ebac1a4f890 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -171,6 +171,11 @@ $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 @@ 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,84 @@ } } +// 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 = $user->hasRight('order', 'write'); + 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 = ''; + + // @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"; + print ''."\n"; + + if (count($objects) > 0) { + $i = 0; + foreach ($objects as $key => $order) { + $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', '', 0, 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 8ae504de1542f..57ccf008ac555 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 @@ $action = ''; } + if (isModEnabled('category')) { + $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 @@ // $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('category') && $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 @@ 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, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; + } + // Note public print ''; print ''.$langs->trans('NotePublic').''; @@ -2841,6 +2863,40 @@ print ''; } + // Tags-Categories + if (isModEnabled('category')) { + 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 aada73c641fa2..1332dff25d604 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -853,6 +853,23 @@ public function cloture($user, $notrigger = 0) return 0; } + /** + * Sets object to given categories. + * + * Adds it to non existing supplied categories. + * Deletes object from existing categories not supplied. + * Existing categories are left untouch. + * + * @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) + { + 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 @@ -3413,6 +3430,18 @@ public function delete($user, $notrigger = 0) $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; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 050e4267f95ce..994a47ccd732a 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1206,11 +1206,11 @@ public function setCategories($categories) /** * 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 dee4f0b3b717a..dd69f69f2e559 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -412,13 +412,13 @@ public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofda /** * 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 @@ public function load_cache_types_paiements() * @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 @@ public function select_conditions_paiements($selected = 0, $htmlname = 'condid', * @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 @@ public function form_project($page, $socid, $selected = '', $htmlname = 'project * @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. @@ -11063,7 +11063,7 @@ public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoicei $out = ''; $hideunselectables = false; - if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES')) { + if (getDolGlobalString('INVOICE_HIDE_UNSELECTABLES')) { $hideunselectables = true; } @@ -11279,6 +11279,110 @@ public function selectInvoiceRec($selected = '', $htmlname = 'facrecid', $maxlen } } + + /** + * Output a combo list with orders qualified for a third party + * + * @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') + { + global $user, $conf, $langs; + + $out = ''; + + $hideunselectables = false; + if (getDolGlobalString('ORDER_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, array(), 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 * @@ -11704,7 +11808,7 @@ public function selectModelMail($prefix, $modelType = '', $default = 0, $addjsco * @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 800913719eed5..cf42ba4b738ae 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1052,7 +1052,7 @@ public function select_localtax($local, $selected, $htmlname) /** * 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 @@ public function selectProspectCustomerType($selected, $htmlname = 'client', $htm /** * 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 @@ public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $ /** * 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/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3b3c57167ac32..602fb1a9d3994 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('category')) { + $langs->load("categories"); + $newmenu->add("/categories/index.php?leftmenu=cat&type=16", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); + } } // Supplier proposal diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 8711522192149..6dbf651090749 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 @@ -166,6 +167,9 @@ public function __construct($db) if (isModEnabled('website')) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } + if (isModEnabled('order')) { + $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 +453,22 @@ public function __construct($db) // 11 Website Pages, TODO ? + // 16 Order + ++$r; + $this->exportTagLinks( + $r, + 16, + 'Commande', + 'isModEnabled("order")', + ['commande', 'commande', 'export'], + [ + 'rowid' => [ + 'name' => 'OrderID', + 'type' => 'Numeric' + ] + ] + ); + // Imports //-------- @@ -465,7 +485,7 @@ public function __construct($db) '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 +648,153 @@ public function __construct($db) // 10 Agenda Events, TODO ? // 11 Website Pages, TODO ? + + // 16 Order + if (isModEnabled("order")) { + ++$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 $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 + */ + protected function exportTagLinks( + int $r, + int $cat_id, + string $class, + string $enabled, + 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] = $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.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); } + /** + * 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. diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index b01fcafb6db84..ad558c7e95049 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) /** * 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 e7509a07e3b3a..b5699c9440ce0 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) /** * 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 159f9114faf83..d12833d958d6b 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) /** * 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 ce5cfb5466b57..fd15395e2ec1d 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) * 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 @@ public function get_code($db, $societe, $type = '') * * @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 4ccb0c151a4e6..87bb764a27d68 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) /** * 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 41c6a65a46f20..adb2e3ce6e7d6 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 @@ public function getExample($langs = null, $objsoc = '', $type = -1) /** * 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 82551e436ae37..b4bb7bbdcf070 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 public function __construct($db); * @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 @@ public static function liste_modeles($dbs, $maxfilenamelength = 0) * 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 @@ public function getToolTip($langs, $soc, $type) /** * 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 @@ public function getToolTip($langs, $soc, $type) /** * 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 @@ public function get_code($db, $societe, $type = '') // 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/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 65a964564c768..bb369a1dea86b 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 @@ -94,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 diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e4e0925f5b1e2..d36aeb1222e17 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 @@ } $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 @@ print ''.$modCodeTiers->info($langs).''."\n"; print ''.$modCodeTiers->getExample($langs).''."\n"; - if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") { + if ($conf->global->SOCIETE_CODECLIENT_ADDON == (string) $file) { print ''."\n"; print img_picto($langs->trans("Activated"), 'switch_on'); print "\n"; @@ -988,7 +988,7 @@ print ''; print ''.$langs->trans("DefaultCustomerType").''; print ''; - print $formcompany->selectProspectCustomerType(getDolGlobalString('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); + print $formcompany->selectProspectCustomerType(getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin'); print ''; print ''; print ''; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 51f33f87f6fb7..fc1ef0621bcc0 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 @@ * @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 @@ } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - if (empty($htmlname)) { + if ($htmlname === '') { return; } @@ -115,7 +115,7 @@ $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 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 ef113ba10da6b..860c3e071f6a9 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -258,7 +258,7 @@ public function assign_values(&$action, $id = 0, $ref = '') // 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 @@ public function assign_values(&$action, $id = 0, $ref = '') $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 f5d533ceeab03..955f6faa63836 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 @@ public function assign_values(&$action, $id = 0, $ref = '') $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 @@ public function assign_values(&$action, $id = 0, $ref = '') $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 @@ public function assign_values(&$action, $id = 0, $ref = '') $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 b2fee95952e3a..4c45dc785c319 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 @@ function manageprospectcustomer(element) { print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // Email - print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalString('SOCIETE_EMAIL_MANDATORY')).''; + print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalInt('SOCIETE_EMAIL_MANDATORY')).''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; // Unsubscribe @@ -1740,7 +1740,7 @@ function manageprospectcustomer(element) { $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 @@ function manageprospectcustomer(element) { $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 @@ function manageprospectcustomer(element) { print ''.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; print ''; 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 @@ function manageprospectcustomer(element) { print ''; print ''.$form->editfieldkey('PaymentConditions', 'cond_reglement_id', '', $object, 0).''; print ''; - 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 ''; // Payment mode print ''; print ''.$form->editfieldkey('PaymentMode', 'mode_reglement_id', '', $object, 0).''; print ''; - 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 ''; // Incoterms @@ -2292,7 +2292,7 @@ function init_supplier_categ() { // Name print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).''; print ''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); + print $form->widgetForTranslation("name", $object, (int) $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); print ''; // Alias names (commercial, trademark or alias names) @@ -2456,7 +2456,7 @@ function manageprospectcustomer(element) { print ''; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print $form->widgetForTranslation("address", $object, (int) $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); print ''; // Zip / Town @@ -2468,7 +2468,7 @@ function manageprospectcustomer(element) { } print ''.$form->editfieldkey('Town', 'town', '', $object, 0).'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 @@ function manageprospectcustomer(element) { print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // EMail - print ''.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).''; + print ''.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalInt('SOCIETE_EMAIL_MANDATORY'))).''; print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'; print img_picto('', 'object_email', 'class="pictofixedwidth"'); print ''; @@ -2549,8 +2549,8 @@ function init_check_no_email(input) { } print ''; print ''; - $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 ''; } print ''; @@ -2581,7 +2581,7 @@ function init_check_no_email(input) { } $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; - 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 ''; if (($j % $NBCOLS) == ($NBCOLS - 1)) { @@ -2607,7 +2607,7 @@ function init_check_no_email(input) { 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 @@ function init_check_no_email(input) { 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 @@ function init_check_no_email(input) { 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 @@ function init_check_no_email(input) { 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 @@ function init_check_no_email(input) { $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 @@ function init_check_no_email(input) { // Juridical type 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 ''; // Capital @@ -2824,7 +2824,7 @@ function init_check_no_email(input) { print ''; print ''.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; print ''; - $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 @@ function init_check_no_email(input) { print ''.$langs->transcountry("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editRE') { print ''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } else { print ''.$object->localtax1_value.''; @@ -3083,7 +3083,7 @@ function init_check_no_email(input) { print ''.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editIRPF') { print ''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } else { print ''.$object->localtax2_value.''; @@ -3101,7 +3101,7 @@ function init_check_no_email(input) { print ' '.$langs->transcountry("Localtax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editRE') { print ''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } else { print ''.$object->localtax1_value.''; @@ -3119,7 +3119,7 @@ function init_check_no_email(input) { print ' '.$langs->transcountry("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; if ($action == 'editIRPF') { print ''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } else { print ''.$object->localtax2_value.''; @@ -3160,7 +3160,7 @@ function init_check_no_email(input) { $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 @@ function init_check_no_email(input) { print ''; 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 ''; // Workforce/Staff @@ -3358,7 +3358,7 @@ function init_check_no_email(input) { 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 @@ function init_check_no_email(input) { $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 5abc504881481..451f77fa51ef8 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 load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup'); +$messagetoshow = ''; + $vatNumber = GETPOST("vatNumber", 'alpha'); if (!$vatNumber) { @@ -96,7 +99,6 @@ 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 bfdbf8c7920c2..c6832d92084ab 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 @@ public function __construct(DoliDB $db) /** * 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 @@ public function create($user = null, $notrigger = 0) /** * 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 @@ public function fetch($id, $ref = '', $socid = 0, $default = 1, $type = 'ban') /** * 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 f734c3b7612fc..840971fea12e5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1644,16 +1644,16 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient = $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 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient = $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 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient = 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 @@ public function set_remise_client($remise, $note, User $user) // 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 @@ public function set_remise_client($remise, $note, User $user) // 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 @@ public function set_remise_except($remise, User $user, $desc, $vatrate = '', $di $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 @@ public function getSalesRepresentatives(User $user, $mode = 0, $sortfield = null 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 @@ public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip $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 @@ public function display_rib($mode = 'label') 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') { @@ -4486,7 +4488,11 @@ public function create_from_member(Adherent $member, $socname = '', $socalias = $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; @@ -4969,7 +4975,7 @@ public function getOutstandingProposals($mode = 'customer') /** * 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 +5018,7 @@ public function getOutstandingOrders($mode = 'customer') /** * 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 a84b221ab0645..e3570e90aa10e 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -244,6 +244,9 @@ $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 @@ $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 @@ } $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_ht = 0; $param = ''; +$num = 0; if ($sql_select) { $resql = $db->query($sql); @@ -496,8 +502,8 @@ 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 @@ 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 @@ } } 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 (!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 @@ } $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 990c67300610d..98e814ea2884b 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 ($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 449a7b02a9be5..1bb811ceb8e19 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,6 +208,7 @@ $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 @@ // 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 (!$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 @@ 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 (!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 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 @@ } // 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 '
'; + foreach ($currencybalance as $cpt_arr) { + print ''; } } @@ -1882,6 +1884,7 @@ } // 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 @@ $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 @@ print '
'; @@ -2348,7 +2347,7 @@ 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 acf931e6d8441..c8d00a1559f61 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 @@ $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($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 ($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 (!$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 ($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 @@ 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 @@ $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 @@ $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 @@ $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 @@ } } 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 @@ $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 @@ $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 @@ } // 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 @@ print ''; print ''; print ''; - print ''; + print ''; //print ''; print ''; } @@ -1155,7 +1157,7 @@ $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 (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'])).'
'.$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'])).'
'; 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 @@ print ''; print ''; print ''; @@ -2317,8 +2320,8 @@ print ''; print ''; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index e06605e8a6653..1e89a156e6609 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -106,7 +106,7 @@ } 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 ($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 @@ $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 @@ print ''; print ''; print ''; print ''; @@ -378,7 +378,7 @@ // VAT print ''; // Price base @@ -471,7 +471,7 @@ // VAT print ''; // Price base @@ -581,8 +581,8 @@ 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 66412a151cd9e..1da3c51d55554 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 (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 e245f49d91b12..00a5624dc94ed 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 @@ $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 @@ } 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 @@ 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') { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 84d5297f4c0e1..b30c1c9bdd572 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -766,7 +766,7 @@ $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')) {
'.$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 '