diff --git a/ChangeLog b/ChangeLog index c246f9528e5..07aa6da5208 100644 --- a/ChangeLog +++ b/ChangeLog @@ -229,16 +229,16 @@ The following changes may create regressions for some external modules, but were * More class properties (with old name in french) are now deprecated in favor of the property name in english. * The json emulator dol_json_encode/decode() is removed. The native json PHP module must be enabled/available (this is the case by default with most PHP installation). * The deprecated GET parameter "&sall=" has been removed, use now the "&search_all=". -* The experimental and deprecated module WebserviceClient is completely removed (was never released and use deprecated architecture). May be replaced with the stable module Webhook. -* The dynamic properties ->no_button_delete, ->no_button_edit, ->no_button_copy for $object Product that could be set by an external module must no more - be set (not allowed by PHP 8.2). A module can already return an array with key 'no_button_delete', 'no_button_edit', 'no_button_copy' for same purpose. -* The old function dol_bc($var, $moreclass = '') has been removed. If you called it, just stop to call it. -* The trigger code CATEGORY_LINK and CATEGORY_UNLINK has been replaced with code CATEGORY_MODIFY. You can read ->context['linkto'] or ->context['unlinkoff' to detect if we want to make a link or unlink. +* The experimental and deprecated module WebserviceClient is completely removed (was never released and use deprecated architecture). It may be replaced with the stable module Webhook. +* The dynamic properties ->no_button_delete, ->no_button_edit, ->no_button_copy for $object Product that could be set by an external module must no more be + set (not allowed by PHP 8.2). A module can already return an array with key 'no_button_delete', 'no_button_edit', 'no_button_copy' for the same purpose. +* The old function dol_bc($var, $moreclass = '') has been removed. If you called it, just stop to call it (the function has no effect since a long time). +* The trigger code CATEGORY_LINK and CATEGORY_UNLINK have been replaced with code CATEGORY_MODIFY. You can read ->context['linkto'] or ->context['unlinkoff'] to detect if we want to make a link or unlink. * The property ->domiciliation and ->propio on bank accounts has been deprecated and replaced with property ->address and ->owner_name everywhere. * If you were using the substitution key __MEMBER_CIVILITY__, you must now use __MEMBER_TITLE__ -***** ChangeLog for 20.0.4 compared to 20.0.2 ***** +***** ChangeLog for 20.0.4 compared to 20.0.3 ***** FIX: $this->origin_object can not be instance of CommandeFournisseur if it is already an instanceof CommonObject FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 FIX: 17.0 - collisions in cache for dol_getIdFromCode diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 98a307425c1..2f61bcd8349 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -14262,18 +14262,6 @@ parameters: count: 1 path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - message: '#^Variable \$showlinktoai might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/formlayoutai.tpl.php - - - - message: '#^Variable \$showlinktoailabel might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/core/tpl/formlayoutai.tpl.php - - message: '#^Variable \$limit might not be defined\.$#' identifier: variable.undefined diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index e4bac1868cc..be05dc5d762 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,22 +9,22 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1690+ occurrences + // PhanTypeMismatchArgument : 1580+ occurrences // PhanUndeclaredProperty : 500+ occurrences - // PhanTypeMismatchArgumentNullable : 350+ occurrences + // PhanTypeMismatchArgumentNullable : 330+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 75+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 65+ occurrences - // PhanTypeExpectedObjectPropAccess : 40+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences + // PhanTypeExpectedObjectPropAccess : 35+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences - // PhanUndeclaredMethod : 10+ occurrences + // PhanUndeclaredMethod : 9 occurrences // PhanTypeComparisonFromArray : 8 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences @@ -101,7 +101,6 @@ return [ 'htdocs/admin/eventorganization.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/expensereport_rules.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/external_rss.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/hrm.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/knowledgemanagement.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/mails.php' => ['PhanTypeMismatchArgument'], @@ -609,7 +608,6 @@ return [ 'htdocs/projet/class/api_tasks.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/projet/tasks/time.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/projet/tasks/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/public/company/new.php' => ['PhanTypeMismatchArgument'], 'htdocs/public/eventorganization/subscriptionok.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/members/new.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/public/payment/newpayment.php' => ['PhanUndeclaredProperty'], @@ -636,26 +634,13 @@ return [ 'htdocs/recruitment/recruitmentjobposition_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_note.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/resource/class/dolresource.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/salaries/paiement_salary.php' => ['PhanUndeclaredProperty'], 'htdocs/salaries/virement_request.php' => ['PhanUndeclaredProperty'], - 'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], - 'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/societe/canvas/actions_card_common.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/canvas/company/actions_card_company.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/checkvat/checkVatPopup.php' => ['PhanPossiblyUndeclaredGlobalVariable'], + 'htdocs/societe/ajax/company.php' => ['PhanUndeclaredProperty'], 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/societe/class/companybankaccount.class.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], - 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/societe/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/societe/price.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/tpl/linesalesrepresentative.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/societe/website.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], + 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'], 'htdocs/stripe/admin/stripe.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/charge.php' => ['PhanTypeMismatchArgument'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'], @@ -714,7 +699,6 @@ return [ 'htdocs/user/group/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/user/param_ihm.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/user/virtualcard.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'], 'htdocs/variants/card.php' => ['PhanTypeMismatchArgument'], 'htdocs/variants/class/ProductAttribute.class.php' => ['PhanTypeMismatchArgumentNullable'], diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 1355261d0ef..f01a6d56538 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -92,7 +92,7 @@ class DolibarrApiAccess implements iAuthenticate public function __isAllowed() { // phpcs:enable - global $conf, $db, $user; + global $conf, $user; $login = ''; $stored_key = ''; @@ -114,9 +114,16 @@ class DolibarrApiAccess implements iAuthenticate // TODO Add option to disable use of api key on url. Return errors if used. $api_key = $_GET['DOLAPIKEY']; // With GET method } - if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY - $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) - } + + // TODO Can filter on user agent. + //$api_useragent = $_SERVER['HTTP_USER_AGENT']; + + if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // HTTP Header entry "DOLAPIKEY: ..." can be read with $_SERVER["HTTP_DOLAPIKEY"] + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommended) + } 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']); + }; $api_key = dol_string_nounprintableascii($api_key); @@ -216,7 +223,7 @@ class DolibarrApiAccess implements iAuthenticate static::$role = 'admin'; } } else { - throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); + throw new RestException(401, "Failed to login to API. Neither parameter 'HTTP_DOLAPIKEY' nor 'Authentication: Bearer' found on HTTP header (and no parameter DOLAPIKEY in URL)."); } $userClass::setCacheIdentifier(static::$role); diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5082bda1b15..aad4da2447a 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 10e327a0420..c9d333ba56c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,21 +48,22 @@ require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class class Categorie extends CommonObject { // Categories types (we use string because we want to accept any modules/types in a future) - const TYPE_PRODUCT = 'product'; - const TYPE_SUPPLIER = 'supplier'; - const TYPE_CUSTOMER = 'customer'; - const TYPE_MEMBER = 'member'; - const TYPE_CONTACT = 'contact'; - const TYPE_USER = 'user'; - const TYPE_PROJECT = 'project'; - const TYPE_ACCOUNT = 'bank_account'; - const TYPE_BANK_LINE = 'bank_line'; - const TYPE_WAREHOUSE = 'warehouse'; - const TYPE_ACTIONCOMM = 'actioncomm'; - const TYPE_WEBSITE_PAGE = 'website_page'; - const TYPE_TICKET = 'ticket'; + const TYPE_PRODUCT = 'product'; + const TYPE_SUPPLIER = 'supplier'; + const TYPE_CUSTOMER = 'customer'; + const TYPE_MEMBER = 'member'; + const TYPE_CONTACT = 'contact'; + const TYPE_USER = 'user'; + const TYPE_PROJECT = 'project'; + const TYPE_ACCOUNT = 'bank_account'; + const TYPE_BANK_LINE = 'bank_line'; + const TYPE_WAREHOUSE = 'warehouse'; + const TYPE_ACTIONCOMM = 'actioncomm'; + const TYPE_WEBSITE_PAGE = 'website_page'; + const TYPE_TICKET = 'ticket'; const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement'; - const TYPE_FICHINTER = 'fichinter'; + const TYPE_FICHINTER = 'fichinter'; + const TYPE_ORDER = 'order'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -74,21 +75,22 @@ class Categorie extends CommonObject * @var array Table of mapping between type string and ID used for field 'type' in table llx_categories */ protected $MAP_ID = array( - 'product' => 0, - 'supplier' => 1, - 'customer' => 2, - 'member' => 3, - 'contact' => 4, - 'bank_account' => 5, - 'project' => 6, - 'user' => 7, - 'bank_line' => 8, - 'warehouse' => 9, - 'actioncomm' => 10, - 'website_page' => 11, - 'ticket' => 12, + 'product' => 0, + 'supplier' => 1, + 'customer' => 2, + 'member' => 3, + 'contact' => 4, + 'bank_account' => 5, + 'project' => 6, + 'user' => 7, + 'bank_line' => 8, + 'warehouse' => 9, + 'actioncomm' => 10, + 'website_page' => 11, + 'ticket' => 12, 'knowledgemanagement' => 13, - 'fichinter' => 14, + 'fichinter' => 14, + 'order' => 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 fcef409cc55..d9ebac1a4f8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -171,6 +171,11 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission n $tmpobject = new Fichinter($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'fichinter'; + } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $tmpobject = new Commande($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'order'; } else { dol_print_error(null, "Not supported value of type = ".$type); } @@ -238,6 +243,10 @@ if ($elemid && $action == 'addintocategory') { // Test on permission not require require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $newobject = new Account($db); $elementtype = 'bank_account'; + } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $newobject = new Commande($db); + $elementtype = 'order'; } else { dol_print_error(null, "Not supported value of type = ".$type); } @@ -1411,6 +1420,84 @@ if ($type == Categorie::TYPE_FICHINTER) { } } +// List of Orders +if ($type == Categorie::TYPE_ORDER) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $permission = $user->rights->commande->creer; + + $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($objects < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = $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 8ae504de154..57ccf008ac5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -42,6 +42,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; @@ -564,6 +565,13 @@ if (empty($reshook)) { $action = ''; } + if (isModEnabled('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 @@ if (empty($reshook)) { // $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); //} elseif ($action == 'setremiseabsolue' && $usercancreate) { // $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); + } elseif ($action == 'settags' && isModEnabled('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 @@ if ($action == 'create' && $usercancreate) { print ''; } + // Categories + if (!empty($conf->categorie->enabled)) { + print ''.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ORDER, '', 'parent', 64, 0, 1); + $arrayselected = GETPOST('categories', 'array'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; + } + // Note public print ''; print ''.$langs->trans('NotePublic').''; @@ -2841,6 +2863,40 @@ if ($action == 'create' && $usercancreate) { print ''; } + // Tags-Categories + if (isModEnabled('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 aada73c641f..0f3df74824f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -119,7 +119,7 @@ class Commande extends CommonOrder /** * Status of the order - * @var int + * @var int|null */ public $status; @@ -853,6 +853,23 @@ class Commande extends CommonOrder 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 @@ class Commande extends CommonOrder $error++; } + // Remove linked categories. + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_order"; + $sql .= " WHERE fk_order = ".((int) $this->id); + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete extrafields of lines and lines if (!$error && !empty($this->table_element_line)) { $tabletodelete = $this->table_element_line; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9e9ba12eda0..10db3c8d9b1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2740,7 +2740,7 @@ while ($i < $imaxinloop) { // Date creation if (!empty($arrayfields['c.datec']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; @@ -2750,7 +2750,7 @@ while ($i < $imaxinloop) { // Date modification if (!empty($arrayfields['c.tms']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; @@ -2760,7 +2760,7 @@ while ($i < $imaxinloop) { // Date cloture if (!empty($arrayfields['c.date_cloture']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 050e4267f95..994a47ccd73 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1206,11 +1206,11 @@ class Account extends CommonObject /** * Delete bank account from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index f6e8fd6ce24..1df290cd960 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -767,7 +767,7 @@ class PaymentVarious extends CommonObject */ public function info($id) { - $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; + $sql = 'SELECT v.rowid, v.datec, v.fk_user_author, fk_user_modif, tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql .= ' WHERE v.rowid = '.((int) $id); @@ -780,6 +780,7 @@ class PaymentVarious extends CommonObject $this->id = $obj->rowid; $this->user_creation = $obj->fk_user_author; + $this->user_creation_id = $obj->fk_user_author; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 2bff92f4218..3672690a4b4 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -139,7 +139,7 @@ if ($object->id) { $morehtmlref .= ''; $linkback = ''.$langs->trans("BackToList").''; - $morehtmlstatus = $morehtmlright; + $morehtmlstatus = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 12cd7d8bbaf..0e6069c9368 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -482,7 +482,7 @@ class Facture extends CommonInvoice */ public function create(User $user, $notrigger = 0, $forceduedate = 0) { - global $langs, $conf, $mysoc, $hookmanager; + global $langs, $conf, $mysoc; $error = 0; $origin_user_author_id = ($user->id > 0 ? (int) $user->id : 0); // Clean parameters diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e2dff3c5387..0d0cf80fc5d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -130,30 +130,39 @@ $search_customer_code = GETPOST("search_customer_code", 'alphanohtml'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma'); $search_user = GETPOST('search_user', 'intcomma'); $search_sale = GETPOST('search_sale', 'intcomma'); + $search_date_startday = GETPOSTINT('search_date_startday'); $search_date_startmonth = GETPOSTINT('search_date_startmonth'); $search_date_startyear = GETPOSTINT('search_date_startyear'); $search_date_endday = GETPOSTINT('search_date_endday'); $search_date_endmonth = GETPOSTINT('search_date_endmonth'); $search_date_endyear = GETPOSTINT('search_date_endyear'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_date_start = GETPOSTDATE('search_date_valid_start', 'getpost'); // Use tzserver because date invoice is a date without hour +$search_date_end = GETPOSTDATE('search_date_valid_end', 'getpostend'); + $search_date_valid_startday = GETPOSTINT('search_date_valid_startday'); $search_date_valid_startmonth = GETPOSTINT('search_date_valid_startmonth'); $search_date_valid_startyear = GETPOSTINT('search_date_valid_startyear'); $search_date_valid_endday = GETPOSTINT('search_date_valid_endday'); $search_date_valid_endmonth = GETPOSTINT('search_date_valid_endmonth'); $search_date_valid_endyear = GETPOSTINT('search_date_valid_endyear'); -$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver -$search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); +$search_date_valid_start = GETPOSTDATE('search_date_valid_start', 'getpost'); +$search_date_valid_end = GETPOSTDATE('search_date_valid_end', 'getpostend'); + $search_datelimit_startday = GETPOSTINT('search_datelimit_startday'); $search_datelimit_startmonth = GETPOSTINT('search_datelimit_startmonth'); $search_datelimit_startyear = GETPOSTINT('search_datelimit_startyear'); $search_datelimit_endday = GETPOSTINT('search_datelimit_endday'); $search_datelimit_endmonth = GETPOSTINT('search_datelimit_endmonth'); $search_datelimit_endyear = GETPOSTINT('search_datelimit_endyear'); -$search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear); -$search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear); +$search_datelimit_start = GETPOSTDATE('search_datelimit_start', 'getpost'); // Use tzserver because date invoice is a date without hour +$search_datelimit_end = GETPOSTDATE('search_datelimit_end', 'getpostend'); + +$search_datec_start = GETPOSTDATE('search_datec_start', 'getpost', 'tzuserrel'); +$search_datec_end = GETPOSTDATE('search_datec_end', 'getpostend', 'tzuserrel'); +$search_datem_start = GETPOSTDATE('search_datem_start', 'getpost', 'tzuserrel'); +$search_datem_end = GETPOSTDATE('search_datem_end', 'getpostend', 'tzuserrel'); + $search_categ_cus = GETPOST("search_categ_cus", 'intcomma'); $search_product_category = GETPOST('search_product_category', 'intcomma'); $search_fac_rec_source_title = GETPOST("search_fac_rec_source_title", 'alpha'); @@ -185,7 +194,7 @@ if (!$sortfield) { $pageprev = $page - 1; $pagenext = $page + 1; -$diroutputmassaction = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->invoice->dir_output.'/temp/massgeneration/'.$user->id; $now = dol_now(); $error = 0; @@ -413,6 +422,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_datelimit_endyear = ''; $search_datelimit_start = ''; $search_datelimit_end = ''; + + $search_datec_start = ''; + $search_datec_end = ''; + + $search_datem_start = ''; + $search_datem_end = ''; + $search_fac_rec_source_title = ''; $search_option = ''; $search_import_key = ''; @@ -429,7 +445,7 @@ if (empty($reshook)) { $permissiontoread = $user->hasRight("facture", "lire"); $permissiontoadd = $user->hasRight("facture", "creer"); $permissiontodelete = $user->hasRight("facture", "supprimer"); - $uploaddir = $conf->facture->dir_output; + $uploaddir = $conf->invoice->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -886,8 +902,20 @@ if ($search_datelimit_start) { if ($search_datelimit_end) { $sql .= " AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end)."'"; } +if ($search_datec_start) { + $sql .= " AND f.datec >= '".$db->idate($search_datec_start)."'"; +} +if ($search_datec_end) { + $sql .= " AND f.datec <= '".$db->idate($search_datec_end)."'"; +} +if ($search_datem_start) { + $sql .= " AND f.tms >= '".$db->idate($search_datem_start)."'"; +} +if ($search_datem_end) { + $sql .= " AND f.tms <= '".$db->idate($search_datem_end)."'"; +} if ($search_option == 'late') { - $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->invoice->client->warning_delay)."'"; } /*if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); @@ -918,6 +946,7 @@ if ($search_sale && $search_sale != '-1') { $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; } } + // Search for tag/category ($searchCategoryProductList is an array of ID) $searchCategoryProductList = $search_product_category ? array($search_product_category) : array(); $searchCategoryProductOperator = 0; @@ -1677,12 +1706,24 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $obje print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['f.datec']['checked'])) { - print ''; + print ''; + print '
'; + print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); + print '
'; + print '
'; + print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel'); + print '
'; print ''; } // Date modification if (!empty($arrayfields['f.tms']['checked'])) { - print ''; + print ''; + print '
'; + print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); + print '
'; + print '
'; + print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel'); + print '
'; print ''; } // Date closing @@ -2718,7 +2759,7 @@ if ($num > 0) { // Date creation if (!empty($arrayfields['f.datec']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; @@ -2727,7 +2768,7 @@ if ($num > 0) { // Date modification if (!empty($arrayfields['f.tms']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; @@ -2736,7 +2777,7 @@ if ($num > 0) { // Date closing if (!empty($arrayfields['f.date_closing']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); + print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuserrel'); print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dee4f0b3b71..dd69f69f2e5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -412,13 +412,13 @@ class Form /** * Output edit in place form * - * @param string $fieldname Name of the field - * @param CommonObject $object Object - * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) - * @param string $check Same coe than $check parameter of GETPOST() - * @param string $morecss More CSS - * @return string HTML code for the edit of alternative language + * @param string $fieldname Name of the field + * @param CommonObject $object Object + * @param bool|int<0,1> $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $check Same coe than $check parameter of GETPOST() + * @param string $morecss More CSS + * @return string HTML code for the edit of alternative language */ public function widgetForTranslation($fieldname, $object, $perm, $typeofdata = 'string', $check = '', $morecss = '') { @@ -4616,7 +4616,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int $noprint if set to one we return the html to print, if 0 (default) we print it @@ -4646,7 +4646,7 @@ class Form * @param int $addempty Add an empty entry * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info * @param string $morecss Add more CSS on select tag - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @return string String for the HTML select component @@ -6153,7 +6153,7 @@ class Form * @param int<0,1> $addempty Add empty entry * @param ''|'direct-debit'|'bank-transfer' $type Type ('direct-debit' or 'bank-transfer') * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates) - * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) + * @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int<0,1> $nooutput No print is done. String is returned. @@ -11063,7 +11063,7 @@ class Form $out = ''; $hideunselectables = false; - if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES')) { + if (getDolGlobalString('INVOICE_HIDE_UNSELECTABLES')) { $hideunselectables = true; } @@ -11279,6 +11279,110 @@ class Form } } + + /** + * 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 @@ class Form * @param string $save_label Alternative label for save button * @param string $cancel_label Alternative label for cancel button * @param array $morebuttons Add additional buttons between save and cancel - * @param bool $withoutdiv Option to remove enclosing centered div + * @param bool|int<0,1> $withoutdiv Option to remove enclosing centered div * @param string $morecss More CSS * @param string $dol_openinpopup If the button are shown in a context of a page shown inside a popup, we put here the string name of popup. * @return string Html code with the buttons diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 800913719ee..cf42ba4b738 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -1052,7 +1052,7 @@ class FormCompany extends Form /** * Return a HTML select for thirdparty type * - * @param int $selected Selected value + * @param int<0,4>|'0'|'2,3'|'1,3'|'4' $selected Selected value * @param string $htmlname HTML select name * @param string $htmlidname HTML select id * @param string $typeinput HTML output @@ -1117,11 +1117,11 @@ class FormCompany extends Form /** * Output html select to select third-party type * - * @param string $page Page - * @param string $selected Id preselected - * @param string $htmlname Name of HTML select - * @param string $filter optional filters criteras - * @param int $nooutput No print output. Return it only. + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select + * @param string $filter optional filters criteras + * @param int<0,1> $nooutput No print output. Return it only. * @return void|string */ public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0) @@ -1158,11 +1158,11 @@ class FormCompany extends Form /** * Output html select to select prospect status * - * @param string $htmlname Name of HTML select - * @param Contact|null $prospectstatic Prospect object - * @param int $statusprospect status of prospect - * @param int $idprospect id of prospect - * @param string $mode select if we want activate de html part or js + * @param string $htmlname Name of HTML select + * @param Contact|Client|null $prospectstatic Prospect object + * @param int $statusprospect status of prospect + * @param int $idprospect id of prospect + * @param 'html'|'js' $mode select if we want activate de html part or js * @return void */ public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html") diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3cf1933fed9..94fd432f20c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2061,7 +2061,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr // Complete request and execute it with limit $sql .= $db->order($sortfield_new, $sortorder); - if ($limit) { + if ($limit) { // @phpstan-ignore-line $sql .= $db->plimit($limit + 1, $offset); } @@ -2708,16 +2708,14 @@ function htmlPrintOnlineHeader($mysoc, $langs) print '
'; // Output html code for logo - if ($urllogo) { - print '
'; - print '
'; - print ''; - print '
'; - if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { - print ''; - } - print '
'; + print '
'; + print '
'; + print ''; + print '
'; + if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { + print ''; } + print '
'; if (getDolGlobalString('MEMBER_IMAGE_PUBLIC_REGISTRATION')) { print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bf3965e9f3c..4da74eb109c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1157,11 +1157,12 @@ function GETPOSTFLOAT($paramname, $rounding = '') * Helper function that combines values of a dolibarr DatePicker (such as Form::selectDate) for year, month, day (and * optionally hour, minute, second) fields to return a timestamp. * - * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate) - * @param string $hourTime 'getpost' to include hour, minute, second values from the HTTP request, - * or 'XX:YY:ZZ' to set hour, minute, second respectively (for instance '23:59:59') + * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate). Example: 'select_datec' + * @param string $hourTime 'getpost' or 'getpostend' to include hour, minute, second values from the HTTP request, + * or 'XX:YY:ZZ' to set hour, minute, second respectively, for example '23:59:59' + * or 'end' means '23:59:59' * or '' means '00:00:00' (default) - * @param int|string $gm Passed to dol_mktime + * @param int|string $gm Passed to dol_mktime. If most cases, when used with 'getpost' or 'getpostend', it should be 'tzuserrel'. * @return int|string Date as a timestamp, '' or false if error * * @see dol_mktime() @@ -1169,14 +1170,16 @@ function GETPOSTFLOAT($paramname, $rounding = '') function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') { $m = array(); - if ($hourTime === 'getpost') { - $hour = GETPOSTINT($prefix . 'hour'); - $minute = GETPOSTINT($prefix . 'minute'); - $second = GETPOSTINT($prefix . 'second'); + if ($hourTime === 'getpost' || $hourTime === 'getpostend') { + $hour = (GETPOSTISSET($prefix . 'hour') && GETPOSTINT($prefix . 'hour') >= 0) ? GETPOSTINT($prefix . 'hour') : ($hourTime === 'getpostend' ? 23 : 0); + $minute = (GETPOSTISSET($prefix . 'min') && GETPOSTINT($prefix . 'min') >= 0) ? GETPOSTINT($prefix . 'min') : ($hourTime === 'getpostend' ? 59 : 0); + $second = (GETPOSTISSET($prefix . 'second') && GETPOSTINT($prefix . 'second') >= 0) ? GETPOSTINT($prefix . 'second') : ($hourTime === 'getpostend' ? 59 : 0); } elseif (preg_match('/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) { $hour = intval($m[1]); $minute = intval($m[2]); $second = intval($m[3]); + } elseif ($hourTime === 'end') { + $hour = 23; $minute = 59; $second = 59; } else { $hour = $minute = $second = 0; } @@ -1185,6 +1188,7 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') $minute = (int) min($minute, 59); $second = (int) min($second, 59); + //print "$hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm
"; return dol_mktime($hour, $minute, $second, GETPOSTINT($prefix . 'month'), GETPOSTINT($prefix . 'day'), GETPOSTINT($prefix . 'year'), $gm); } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3b3c57167ac..602fb1a9d39 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 87115221921..6dbf6510907 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 @@ class modCategorie extends DolibarrModules 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 @@ class modCategorie extends DolibarrModules // 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 @@ class modCategorie extends DolibarrModules 'ca.label' => "Label*", 'ca.type' => "Type*", 'ca.description' => "Description", 'ca.fk_parent' => 'ParentCategory' ); - $this->import_regex_array[$r] = array('ca.type' => '^(0|1|2|3|4|5|6|7|8|9|10|11)$'); + $this->import_regex_array[$r] = array('ca.type' => '^(0|1|2|3|4|5|6|7|8|9|10|11|16)$'); $this->import_convertvalue_array[$r] = array( 'ca.fk_parent' => array( 'rule' => 'fetchidfromcodeandlabel', @@ -628,8 +648,153 @@ class modCategorie extends DolibarrModules // 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 b01fcafb6db..ad558c7e950 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -5,7 +5,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -219,8 +219,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (0:customer, 1:supplier) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index e7509a07e3b..b5699c9440c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2006-2014 Laurent Destailleur * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,8 +90,8 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ public function getNextValue($objsoc = '', $type = -1) diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 159f9114faf..d12833d958d 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -3,7 +3,7 @@ * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,9 +96,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe|string $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) - * @return string|-1 Value if OK, '' if module not configured, -1 if KO + * @param Societe|string|null $objsoc Object third party + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = '', $type = -1) { diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index ce5cfb5466b..fd15395e2ec 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -3,7 +3,7 @@ /* Copyright (C) 2004-2007 Rodolphe Quiedeville * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -158,8 +158,8 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * Set accountancy account code for a third party into this->code * * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') @@ -213,7 +213,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param string $code Code of third party - * @param Societe $societe Object third party + * @param ?Societe $societe Object third party * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 4ccb0c151a4..87bb764a27d 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -4,7 +4,7 @@ * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2019 Alexandre Spangaro * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -201,10 +201,10 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' - * @return int >=0 if OK, <0 if KO + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' + * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') { diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 41c6a65a46f..adb2e3ce6e7 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,9 +91,9 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 82551e436ae..b4bb7bbdcf0 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,15 +93,15 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - //abstract public function getExample($langs = null, $objsoc = '', $type = -1); + abstract public function getExample($langs = null, $objsoc = '', $type = -1); /** * Return next value available * - * @param Societe|string $objsoc Object thirdparty - * @param int $type Type - * @return string Value + * @param Societe|string|null $objsoc Object thirdparty + * @param int<-1,2> $type Type + * @return string Value */ public function getNextValue($objsoc = '', $type = -1) { @@ -144,8 +144,8 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -212,7 +212,7 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator /** * Check if mask/numbering use prefix * - * @return int 0=no, 1=yes + * @return int<0,1> 0=no, 1=yes */ public function verif_prefixIsUsed() { @@ -253,8 +253,8 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @param ?Societe $soc Third party object + * @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ public function getToolTip($langs, $soc, $type) @@ -294,9 +294,9 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator /** * Set accountancy account code for a third party into this->code * - * @param DoliDB $db Database handler - * @param Societe $societe Third party object - * @param string $type 'customer' or 'supplier' + * @param DoliDB $db Database handler + * @param ?Societe $societe Third party object + * @param 'customer'|'supplier'|'' $type 'customer' or 'supplier' * @return int<-1,1> >=0 if success, -1 if failure */ public function get_code($db, $societe, $type = '') @@ -304,7 +304,17 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator // phpcs:enable global $langs; - dol_syslog(get_class($this)."::get_code".$langs->trans("NotAvailable"), LOG_ERR); + dol_syslog(__METHOD__." ".$langs->trans("NotAvailable"), LOG_ERR); return -1; } + + /** + * Return an example of result returned by getNextValue + * + * @param ?Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example + */ + abstract public function getExample($langs = null, $objsoc = '', $type = -1); } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 25f6d7e4f90..a5c6a8f75f9 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -235,14 +235,14 @@ if (isModEnabled("supplier_order")) { /* - * List of users allowed + * List of users allowed to approve */ $sql = "SELECT"; if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " DISTINCT"; } -$sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut"; +$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.photo, u.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; @@ -252,7 +252,7 @@ if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_ } else { $sql .= " WHERE (u.entity IN (".getEntity('user')."))"; } -$sql .= " AND u.fk_soc IS NULL"; // An external user can not approved +$sql .= " AND u.fk_soc IS NULL"; // An external user can not approve $resql = $db->query($sql); if ($resql) { @@ -264,6 +264,9 @@ if ($resql) { print ''.$langs->trans("UserWithApproveOrderGrant").''; print "\n"; + print ''; + print ''; + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -272,19 +275,29 @@ if ($resql) { $userstatic->loadRights('fournisseur'); if ($userstatic->hasRight('fournisseur', 'commande', 'approuver')) { - print ''; - print ''; + if ($i > 0) { + print ', '; + } + $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; $userstatic->status = $obj->statut; - print $userstatic->getNomUrl(1); - print ''; - print "\n"; + + print $userstatic->getNomUrl(-1); } $i++; } + if ($i == 0) { + print ''.$langs->trans("Nobody").''; + } + + print ''; + print "\n"; + print "

"; $db->free($resql); } else { diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 4cf68ce85ad..7b9c19450b4 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -58,3 +58,76 @@ ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (entity, name ALTER TABLE llx_societe_account ADD COLUMN ip varchar(250); ALTER TABLE llx_product ADD COLUMN packaging float(24,8) DEFAULT NULL; + + +ALTER TABLE llx_categorie_member ADD COLUMN import_key varchar(14); +ALTER TABLE llx_category_bankline ADD COLUMN import_key varchar(14); + + +create table llx_categorie_order +( + fk_categorie integer NOT NULL, + fk_order integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +--noqa:disable=PRS +ALTER TABLE llx_categorie_order ADD PRIMARY KEY pk_categorie_order(fk_categorie, fk_order); +--noqa:enable=PRS +ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_order ADD INDEX idx_categorie_order_fk_order (fk_order); + +ALTER TABLE llx_categorie_order ADD CONSTRAINT fk_categorie_order_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_order ADD CONSTRAINT fk_categorie_order_fk_order_rowid FOREIGN KEY (fk_order) REFERENCES llx_commande (rowid); + + +create table llx_categorie_invoice +( + fk_categorie integer NOT NULL, + fk_invoice integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +--noqa:disable=PRS +ALTER TABLE llx_categorie_invoice ADD PRIMARY KEY pk_categorie_invoice(fk_categorie, fk_invoice); +--noqa:enable=PRS +ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_invoice ADD INDEX idx_categorie_invoice_fk_invoice (fk_invoice); + +ALTER TABLE llx_categorie_invoice ADD CONSTRAINT fk_categorie_invoice_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_invoice ADD CONSTRAINT fk_categorie_invoice_fk_invoice_rowid FOREIGN KEY (fk_invoice) REFERENCES llx_facture (rowid); + + +create table llx_categorie_supplier_order +( + fk_categorie integer NOT NULL, + fk_supplier_order integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +--noqa:disable=PRS +ALTER TABLE llx_categorie_supplier_order ADD PRIMARY KEY pk_categorie_supplier_order(fk_categorie, fk_supplier_order); +--noqa:enable=PRS +ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_supplier_order ADD INDEX idx_categorie_supplier_order_fk_supplier_order (fk_supplier_order); + +ALTER TABLE llx_categorie_supplier_order ADD CONSTRAINT fk_categorie_supplier_order_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_supplier_order ADD CONSTRAINT fk_categorie_supplier_order_fk_supplier_order_rowid FOREIGN KEY (fk_supplier_order) REFERENCES llx_commande_fournisseur (rowid); + + +create table llx_categorie_supplier_invoice +( + fk_categorie integer NOT NULL, + fk_supplier_invoice integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +--noqa:disable=PRS +ALTER TABLE llx_categorie_supplier_invoice ADD PRIMARY KEY pk_categorie_supplier_invoice(fk_categorie, fk_supplier_invoice); +--noqa:enable=PRS + +ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invoice_fk_supplier_invoice (fk_supplier_invoice); + +ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_fk_supplier_invoice_rowid FOREIGN KEY (fk_supplier_invoice) REFERENCES llx_facture_fourn (rowid); diff --git a/htdocs/install/mysql/tables/llx_categorie_invoice.key.sql b/htdocs/install/mysql/tables/llx_categorie_invoice-facture.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_invoice.key.sql rename to htdocs/install/mysql/tables/llx_categorie_invoice-facture.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_invoice.sql b/htdocs/install/mysql/tables/llx_categorie_invoice-facture.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_invoice.sql rename to htdocs/install/mysql/tables/llx_categorie_invoice-facture.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_member.sql b/htdocs/install/mysql/tables/llx_categorie_member.sql index b8ffedffc1e..0d911afb671 100644 --- a/htdocs/install/mysql/tables/llx_categorie_member.sql +++ b/htdocs/install/mysql/tables/llx_categorie_member.sql @@ -1,6 +1,6 @@ -- ============================================================================ -- Copyright (C) 2005 Brice Davoleau --- Copyright (C) 2005-2010 Matthieu Valleton +-- Copyright (C) 2005-2010 Matthieu Valleton -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -20,5 +20,6 @@ create table llx_categorie_member ( fk_categorie integer NOT NULL, - fk_member integer NOT NULL + fk_member integer NOT NULL, + import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_categorie_order.key.sql b/htdocs/install/mysql/tables/llx_categorie_order-commande.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_order.key.sql rename to htdocs/install/mysql/tables/llx_categorie_order-commande.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_order.sql b/htdocs/install/mysql/tables/llx_categorie_order-commande.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_order.sql rename to htdocs/install/mysql/tables/llx_categorie_order-commande.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse-stock.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_warehouse.key.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse-stock.key.sql diff --git a/htdocs/install/mysql/tables/llx_categorie_warehouse.sql b/htdocs/install/mysql/tables/llx_categorie_warehouse-stock.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_categorie_warehouse.sql rename to htdocs/install/mysql/tables/llx_categorie_warehouse-stock.sql diff --git a/htdocs/install/mysql/tables/llx_category_bank.sql b/htdocs/install/mysql/tables/llx_category_bank.sql deleted file mode 100644 index 10ed331b069..00000000000 --- a/htdocs/install/mysql/tables/llx_category_bank.sql +++ /dev/null @@ -1,27 +0,0 @@ --- =================================================================== --- Copyright (C) 2004-2007 Laurent Destailleur --- Copyright (C) 2005-2009 Regis Houssin --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- =================================================================== - --- TODO : Remove this file, content of this table has been moved into llx_categories table - -create table llx_category_bank -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - label varchar(255), - entity integer DEFAULT 1 NOT NULL -- multi company id -)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_category_bankline.sql b/htdocs/install/mysql/tables/llx_category_bankline.sql index 61112c3bec8..65d54e4e029 100644 --- a/htdocs/install/mysql/tables/llx_category_bankline.sql +++ b/htdocs/install/mysql/tables/llx_category_bankline.sql @@ -20,5 +20,6 @@ create table llx_category_bankline ( lineid integer NOT NULL, - fk_categ integer NOT NULL + fk_categ integer NOT NULL, + import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 65a964564c7..bb369a1dea8 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/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 65ff3c054bb..2f3cc694c4e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1351,3 +1351,4 @@ AllTime=From start Transferred=Transferred Anonymous=Anonymous Automatic=Automatic +Nobody=Nobody diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0f19a6534e7..f1d96e49120 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -736,15 +736,20 @@ if (!empty($_SESSION["disablemodules"])) { foreach ($disabled_modules as $module) { if ($module) { if (empty($conf->$module)) { - $conf->$module = new stdClass(); // To avoid warnings + $conf->$module = new stdClass(); // To avoid warnings } - $conf->$module->enabled = false; + + $conf->$module->enabled = false; // Old usage + unset($conf->modules[$module]); + foreach ($modulepartkeys as $modulepartkey) { unset($conf->modules_parts[$modulepartkey][$module]); } if ($module == 'fournisseur') { // Special case - $conf->supplier_order->enabled = 0; - $conf->supplier_invoice->enabled = 0; + $conf->supplier_order->enabled = 0; // Old usage + $conf->supplier_invoice->enabled = 0; // Old usage + unset($conf->modules['supplier_order']); + unset($conf->modules['supplier_invoice']); } } } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e4e0925f5b1..d36aeb1222e 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -440,7 +440,7 @@ foreach ($dirsociete as $dirroot) { } $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -'@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array +// '@phan-var-force array $arrayofmodules'; // Repeat type because of dol_sort_array foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; @@ -448,7 +448,7 @@ foreach ($arrayofmodules as $file => $modCodeTiers) { print ''.$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 @@ if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) { 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 51f33f87f6f..fc1ef0621bc 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2019 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; * @var User $user */ -$htmlname = GETPOST('htmlname', 'aZ09'); +$htmlname = (string) GETPOST('htmlname', 'aZ09'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOSTINT('outjson') ? GETPOSTINT('outjson') : 0); $action = GETPOST('action', 'aZ09'); @@ -102,7 +102,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - if (empty($htmlname)) { + if ($htmlname === '') { return; } @@ -115,7 +115,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param $htmlname. - $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? (string) GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; } @@ -134,7 +134,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id) && $user->hasRight('soc // If SOCIETE_USE_SEARCH_TO_SELECT is set, check that nb of chars in $filter is >= to avoid DOS attack - $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); + $arrayresult = $form->select_thirdparty_list('0', (string) $htmlname, $filter, 1, $showtype, 0, array(), $searchkey, $outjson, 0, 'minwidth100', '', false, $excludeids, $showcode); if ($outjson) { print json_encode($arrayresult); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index ef113ba10da..860c3e071f6 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -258,7 +258,7 @@ abstract class ActionsCardCommon // Country $this->object->country_id = ($this->object->country_id ? $this->object->country_id : $mysoc->country_id); $this->object->country_code = ($this->object->country_code ? $this->object->country_code : $mysoc->country_code); - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $this->tpl['select_country'] = $form->select_country((string) $this->object->country_id, 'country_id'); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($user->admin) { @@ -281,7 +281,7 @@ abstract class ActionsCardCommon $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par default en creation // Select users - $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth300'); // Local Tax // TODO Implement country specific action in country specific class diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index f5d533ceeab..955f6faa638 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,7 +123,7 @@ class ActionsCardCompany extends ActionsCardCommon $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id); // Juridical Status - $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_code); + $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_id); // Workforce $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id); @@ -136,7 +137,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; @@ -164,7 +165,7 @@ class ActionsCardCompany extends ActionsCardCommon $s .= ''.$langs->trans("VATIntraCheck").''; $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $this->tpl['tva_intra'] = $s.'object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } else { $this->tpl['tva_intra'] = $s; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b2fee95952e..4c45dc785c3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2022-2023 George Gkantinas * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Alexandre Janniaux - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Charlene Benke * * This program is free software; you can redistribute it and/or modify @@ -1677,7 +1677,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2); $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6); while ($i <= $NBPROFIDMAX) { - $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + $idprof = $langs->transcountry('ProfId'.$i, (string) $object->country_code); if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) { $key = 'idprof'.$i; @@ -1799,7 +1799,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -1861,7 +1861,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''.$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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } $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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2616,7 +2616,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2625,7 +2625,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + $formcompany->select_localtax(1, (float) $object->localtax1_value, "lt1"); print ''; } print ''; @@ -2634,7 +2634,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + $formcompany->select_localtax(2, (float) $object->localtax2_value, "lt2"); print ''; } print ''; @@ -2675,7 +2675,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2705,7 +2705,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Juridical type print ''.$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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio 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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -3227,7 +3227,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; $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 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; print ''; $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id)); print ''; } @@ -3486,7 +3486,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->hasRight('societe', 'creer'); - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); } // Subsidiaries list diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 5abc5048814..451f77fa51e 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,6 +55,8 @@ print '
'; print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup'); +$messagetoshow = ''; + $vatNumber = GETPOST("vatNumber", 'alpha'); if (!$vatNumber) { @@ -96,7 +99,6 @@ if (!$vatNumber) { dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD, $parameters); - $messagetoshow = ''; print ''.$langs->trans("Response").':
'; $faultstring = $result['faultstring'] ?? ''; // Service indisponible diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index bfdbf8c7920..c6832d92084 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2016 Marcos García * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -212,7 +212,7 @@ class CompanyBankAccount extends Account public $country_code; /** - * @var int $default_rib 1 = this object is the third party's default bank information, 0 if not + * @var int 1 = this object is the third party's default bank information, 0 if not */ public $default_rib; @@ -356,11 +356,11 @@ class CompanyBankAccount extends Account /** * Create bank information record. * - * @param ?User $user User + * @param User $user User * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, > 0 if OK (ID of newly created company bank account information) */ - public function create($user = null, $notrigger = 0) + public function create($user, $notrigger = 0) { $now = dol_now(); @@ -431,11 +431,11 @@ class CompanyBankAccount extends Account /** * Update bank account * - * @param ?User $user Object user + * @param User $user Object user * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <=0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs; @@ -599,11 +599,11 @@ class CompanyBankAccount extends Account /** * Delete a rib from database * - * @param ?User $user User deleting + * @param User $user User deleting * @param int<0,1> $notrigger 1=Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($user = null, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f734c3b7612..840971fea12 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1644,16 +1644,16 @@ class Societe extends CommonObject $sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'"; $sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null"); + $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape((string) $this->tva_assuj)."'" : "null"); $sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'"; if (!getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape($this->vat_reverse_charge) . "'" : 0); + $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape((string) $this->vat_reverse_charge) . "'" : 0); } $sql .= ",status = ".((int) $this->status); // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null"); + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape((string) $this->localtax1_assuj)."'" : "null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape((string) $this->localtax2_assuj)."'" : "null"); if ($this->localtax1_assuj == 1) { if ($this->localtax1_value != '') { $sql .= ",localtax1_value =".$this->localtax1_value; @@ -1686,16 +1686,16 @@ class Societe extends CommonObject $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); } - $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); + $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape((string) $this->forme_juridique_code)."'" : "null"); - $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); - $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); - $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null"); - $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); - $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); - $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); - $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape($this->transport_mode_supplier_id)."'" : "null"); - $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); + $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape((string) $this->mode_reglement_id)."'" : "null"); + $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape((string) $this->cond_reglement_id)."'" : "null"); + $sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape((string) $this->deposit_percent)."'" : "null"); + $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape((string) $this->transport_mode_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape((string) $this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape((string) $this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",transport_mode_supplier = ".(!empty($this->transport_mode_supplier_id) ? "'".$this->db->escape((string) $this->transport_mode_supplier_id)."'" : "null"); + $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape((string) $this->shipping_method_id)."'" : "null"); $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); $sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0); @@ -1768,7 +1768,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::update update linked member"); $lmember = new Adherent($this->db); - $result = $lmember->fetch(0, 0, $this->id); + $result = $lmember->fetch(0, '0', $this->id); if ($result > 0) { $lmember->company = $this->name; @@ -2469,7 +2469,7 @@ class Societe extends CommonObject // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql .= " SET remise_client = '".$this->db->escape((string) $remise)."'"; $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -2481,7 +2481,7 @@ class Societe extends CommonObject // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape($remise)."',"; + $sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($now)."', ".((int) $this->id).", '".$this->db->escape((string) $remise)."',"; $sql .= " '".$this->db->escape($note)."',"; $sql .= " ".((int) $user->id); $sql .= ")"; @@ -2627,7 +2627,7 @@ class Societe extends CommonObject $discount->multicurrency_amount_ht = price2num($remise * (float) $discount->multicurrency_tx, 'MT'); $discount->multicurrency_amount_tva = price2num(((float) $remise * (float) $vatrate / 100) * (float) $discount->multicurrency_tx, 'MT'); - $discount->multicurrency_amount_ttc= price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); + $discount->multicurrency_amount_ttc = price2num(((float) $discount->amount_ht + (float) $discount->amount_tva) * (float) $discount->multicurrency_tx, 'MT'); } $discount->tva_tx = (float) price2num($vatrate); @@ -2692,13 +2692,15 @@ class Societe extends CommonObject if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix()."usergroup_user as ug WHERE ug.entity IN (".getEntity('usergroup')."))"; } else { - $sql .= " WHERE entity IN (0, ".$this->db->sanitize($conf->entity).")"; + $sql .= " WHERE entity IN (0, ".$this->db->sanitize((string) $conf->entity).")"; } $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".((int) $this->id); - if (empty($sortfield) && empty($sortorder)) { + if (empty($sortfield)) { $sortfield = 'u.lastname,u.firstname'; - $sortorder = 'ASC,ASC'; + } + if (empty($sortorder)) { + $sortorder = str_repeat('ASC,', count(explode(',', $sortfield)) - 1) . 'ASC'; } $sql .= $this->db->order($sortfield, $sortorder); @@ -3161,7 +3163,7 @@ class Societe extends CommonObject $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (' class="'.(($withpicto != 2) ? 'paddingright' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { - $result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name); + $result .= dol_escape_htmltag($maxlen ? dol_trunc((string) $name, $maxlen) : $name); } $result .= $linkend; @@ -3512,7 +3514,7 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); - $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); + $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, (string) $bac->id); } return $bac->rum; } elseif ($mode == 'format') { @@ -4486,7 +4488,11 @@ class Societe extends CommonObject $this->entity = $member->entity; $this->client = 1; // A member is a customer by default - $this->code_client = ($customercode ? $customercode : -1); + if (getDolGlobalString('THIRDPARTY_CUSTOMERCODE_EQUALS_MEMBERREF')) { + $this->code_client = $member->ref; // set Customer Code equal to existing Member Reference + } else { + $this->code_client = ($customercode ? $customercode : -1); // set new auto-incremented Customer Code + } $this->code_fournisseur = '-1'; $this->typent_code = ($member->morphy == 'phy' ? 'TE_PRIVATE' : 0); $this->typent_id = $this->typent_code ? dol_getIdFromCode($this->db, $this->typent_code, 'c_typent', 'id', 'code') : 0; @@ -4969,7 +4975,7 @@ class Societe extends CommonObject /** * Return amount of order not yet paid and total and list of all orders * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') @@ -5012,7 +5018,7 @@ class Societe extends CommonObject /** * Return amount of bill not yet paid and total of all invoices * - * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param 'customer'|'supplier'|'' $mode 'customer' or 'supplier' * @param int<0,1> $late 0 => all invoice, 1=> only late * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index a84b221ab06..e3570e90aa1 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -244,6 +244,9 @@ print ''; $sql_select = ''; $documentstaticline = ''; +$tables_from = ''; +$dateprint = ''; +$doc_number = ''; /*if ($type_element == 'action') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -254,6 +257,7 @@ $documentstaticline = ''; $dateprint = 'f.datep'; $doc_number='f.id'; }*/ +$documentstatic = null; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); @@ -382,6 +386,7 @@ if ($type_element == 'contract') { // Order } $parameters = array(); +$totalnboflines = 0; $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook if (!empty($sql_select)) { @@ -453,6 +458,7 @@ $total_qty = 0; $total_ht = 0; $param = ''; +$num = 0; if ($sql_select) { $resql = $db->query($sql); @@ -496,8 +502,8 @@ if ($sql_select) { print ''; print ''; print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); + print $formother->select_month($month ? (string) $month : '-1', 'month', 1, 0, 'valignmiddle'); + print $formother->selectyear($year ? (string) $year : '-1', 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); print ''; // delivery planned date if ($type_element == 'order' || $type_element == 'supplier_order' || $type_element == 'shipment') { @@ -565,6 +571,8 @@ if ($sql_select) { print ''; if ($type_element == 'contract') { print $documentstaticline->getLibStatut(5); + } elseif ($documentstatic == null) { + // Do noting - for static analysis } elseif ($type_element == 'invoice') { // @phan-suppress-next-line PhanParamTooMany print $documentstatic->getLibStatut(5, $objp->paid); @@ -670,7 +678,7 @@ if ($sql_select) { } } else { if ($objp->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, $description, 3, 0, '', (string) $i, 0, ''); // Show range echo get_date_range($objp->date_start, $objp->date_end); @@ -689,7 +697,7 @@ if ($sql_select) { if (!empty($objp->label)) { $text .= ' '.$objp->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, 0, '', (string) $i, 0, ''); } else { echo $text.' '.dol_htmlentitiesbr($objp->description); } @@ -755,7 +763,7 @@ if ($sql_select) { } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); print ''."\n"; // Titles with sort buttons diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 990c6730061..98e814ea288 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -146,8 +146,8 @@ if (empty($reshook)) { } if ($action == 'confirm_delete' && $user->hasRight('societe', 'contact', 'delete')) { - $id = GETPOST('id', 'int'); - if (!empty($id) && $socid > 0) { + $id = GETPOSTINT('id'); + if ($id > 0 && $socid > 0) { $contact = new Contact($db); $ret = $contact->fetch($id); if ($ret > 0) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 449a7b02a9b..1bb811ceb8e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -208,6 +208,7 @@ if ($type == 't') { $contextpage = 'poslist'; } if ($search_type == '') { + // TODO: This case does not seem to be handled by FormCompany::selectProspectCustomerType. $search_type = '1,2,3'; } } @@ -268,78 +269,77 @@ if (getDolGlobalString('THIRDPARTY_QUICKSEARCH_ON_FIELDS')) { // Define list of fields to show into list -$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); -$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); -$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedtypetiers = 1; -$checkedprofid1 = 0; -$checkedprofid2 = 0; -$checkedprofid3 = 0; -$checkedprofid4 = 0; -$checkedprofid5 = 0; -$checkedprofid6 = 0; -//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); -//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); -$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); -$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? '1' : '0'); +$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? '1' : '0'); +$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? '1' : '0'); +$checkedtypetiers = '1'; +$checkedprofid1 = '0'; +$checkedprofid2 = '0'; +$checkedprofid3 = '0'; +$checkedprofid4 = '0'; +$checkedprofid5 = '0'; +$checkedprofid6 = '0'; +//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? '1' : '0'); +$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); +$checkstcomm = (in_array($contextpage, array('prospectlist')) ? '1' : '0'); $arrayfields = array( - 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => -1, 'enabled' => 1), - 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => 1), - 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => 1), - 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => -1, 'enabled' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), - 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => isModEnabled('barcode')), + 's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => '-1', 'enabled' => '1'), + 's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => '1'), + 's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => '1'), + 's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => '-1', 'enabled' => (string) getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')), + 's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => '1', 'enabled' => (string) (int) isModEnabled('barcode')), 's.code_client' => array('label' => "CustomerCodeShort", 'position' => 10, 'checked' => $checkedcustomercode), - 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.code_compta' => array('label' => "CustomerAccountancyCodeShort", 'position' => 13, 'checked' => $checkedcustomeraccountcode), - 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), - 's.address' => array('label' => "Address", 'position' => 19, 'checked' => 0), - 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => 1), - 's.town' => array('label' => "Town", 'position' => 21, 'checked' => 0), - 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => 0), - 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => 0), - 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => 0), - 's.email' => array('label' => "Email", 'position' => 25, 'checked' => 0), - 's.url' => array('label' => "Url", 'position' => 26, 'checked' => 0), - 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => 1), - 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => 0), + 's.code_compta_fournisseur' => array('label' => "SupplierAccountancyCodeShort", 'position' => 14, 'checked' => $checkedsupplieraccountcode, 'enabled' => (string) (int) (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.address' => array('label' => "Address", 'position' => 19, 'checked' => '0'), + 's.zip' => array('label' => "Zip", 'position' => 20, 'checked' => '1'), + 's.town' => array('label' => "Town", 'position' => 21, 'checked' => '0'), + 'state.nom' => array('label' => "State", 'position' => 22, 'checked' => '0'), + 'region.nom' => array('label' => "Region", 'position' => 23, 'checked' => '0'), + 'country.code_iso' => array('label' => "Country", 'position' => 24, 'checked' => '0'), + 's.email' => array('label' => "Email", 'position' => 25, 'checked' => '0'), + 's.url' => array('label' => "Url", 'position' => 26, 'checked' => '0'), + 's.phone' => array('label' => "Phone", 'position' => 27, 'checked' => '1'), + 's.fax' => array('label' => "Fax", 'position' => 28, 'checked' => '0'), 'typent.code' => array('label' => "ThirdPartyType", 'position' => 29, 'checked' => $checkedtypetiers), - 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => 0), - 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => 0), - 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => 0), + 'staff.code' => array('label' => "Workforce", 'position' => 31, 'checked' => '0'), + 'legalform.code' => array('label' => 'JuridicalStatus', 'position' => 32, 'checked' => '0'), + 's.phone_mobile' => array('label' => "PhoneMobile", 'position' => 35, 'checked' => '0'), 's.siren' => array('label' => "ProfId1Short", 'position' => 40, 'checked' => $checkedprofid1), 's.siret' => array('label' => "ProfId2Short", 'position' => 41, 'checked' => $checkedprofid2), 's.ape' => array('label' => "ProfId3Short", 'position' => 42, 'checked' => $checkedprofid3), 's.idprof4' => array('label' => "ProfId4Short", 'position' => 43, 'checked' => $checkedprofid4), 's.idprof5' => array('label' => "ProfId5Short", 'position' => 44, 'checked' => $checkedprofid5), 's.idprof6' => array('label' => "ProfId6Short", 'position' => 45, 'checked' => $checkedprofid6), - 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => 0), - 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => 1), + 's.tva_intra' => array('label' => "VATIntraShort", 'position' => 50, 'checked' => '0'), + 'customerorsupplier' => array('label' => 'NatureOfThirdParty', 'position' => 61, 'checked' => '1'), 's.fk_prospectlevel' => array('label' => "ProspectLevel", 'position' => 62, 'checked' => $checkprospectlevel), 's.fk_stcomm' => array('label' => "StatusProsp", 'position' => 63, 'checked' => $checkstcomm), - 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => 0), - 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => -2, 'position' => 500), - 's.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 501), - 's.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 505), - 's.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'position' => 520, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), - 's.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position' => 521, 'enabled' => (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), - 's.status' => array('label' => "Status", 'checked' => 1, 'position' => 1000), - 's.import_key' => array('label' => "ImportId", 'checked' => 0, 'position' => 1100), + 's2.nom' => array('label' => 'ParentCompany', 'position' => 64, 'checked' => '0'), + 's.ip' => array('type' => 'ip', 'label' => "IPAddress", 'checked' => '-2', 'position' => 500), + 's.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 501), + 's.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 505), + 's.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))), + 's.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))), + 's.status' => array('label' => "Status", 'checked' => '1', 'position' => 1000), + 's.import_key' => array('label' => "ImportId", 'checked' => '0', 'position' => 1100), ); if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) { - $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => 0); + $arrayfields['s.price_level'] = array('label' => "PriceLevel", 'position' => 30, 'checked' => '0'); } // Add non object fields to fields for list -$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => 1, 'position' => 12); +$arrayfields['sales.representative'] = array('label' => $langs->trans("SalesRepresentatives"), 'checked' => '1', 'position' => 12); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT('socid'); @@ -490,7 +490,7 @@ if (empty($reshook)) { if (!$error && $action == 'setstcomm' && $permissiontoadd) { $object = new Client($db); - $result = $object->fetch(GETPOST('stcommsocid')); + $result = $object->fetch(GETPOSTINT('stcommsocid')); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); $result = $object->update($object->id, $user); if ($result < 0) { @@ -1189,6 +1189,8 @@ if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MU print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), [], 'warning', 1); } +$newcardbutton = ''; + // Show the new button only when this page is not opened from the Extended POS (pop-up window) // but allow it too, when a user has the rights to create a new customer if ($contextpage != 'poslist') { @@ -1196,7 +1198,6 @@ if ($contextpage != 'poslist') { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer')); @@ -1291,7 +1292,7 @@ if (empty($type) || $type == 'f') { } // If the user can view prospects other than his' -$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); +$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 1); $userlist[-2] = $langs->trans("NoSalesRepresentativeAffected"); if ($user->hasRight("societe", "client", "voir") || $socid) { $moreforfilter .= '
'; @@ -2064,9 +2065,7 @@ while ($i < $imaxinloop) { } // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } + $typenArray = $formcompany->typent_array(1); $labeltypeofcompany = empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; print '
'; @@ -2348,7 +2347,7 @@ print '
'."\n"; print '
'."\n"; // Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script -$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js"); +$formcompany->selectProspectStatus('status_prospect', $prospectstatic, 0, 0, "js"); print ''."\n"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index acf931e6d84..c8d00a1559f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -8,7 +8,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2023 Thibault FOUCART * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -201,7 +201,7 @@ if (empty($reshook)) { $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = GETPOSTDATE('date_rum', '00:00:00'); if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { @@ -370,7 +370,7 @@ if (empty($reshook)) { } if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } } @@ -581,7 +581,7 @@ if (empty($reshook)) { } } } - if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the credit card on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); $companypaymentmode->fetch($id); @@ -598,6 +598,7 @@ if (empty($reshook)) { } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe card + update of llx_societe_rib // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to // ask to create the crdit card from Stripe backoffice. @@ -609,7 +610,7 @@ if (empty($reshook)) { } } } - if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation) { + if ($action == 'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Create the bank account on current Stripe env $companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib $companypaymentmode->fetch($id); @@ -628,6 +629,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorStripeCustomerNotFoundCreateFirst"), null, 'errors'); } if (!$error) { + '@phan-var-force \Stripe\Customer $cu'; // Creation of Stripe SEPA + update of llx_societe_rib $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { @@ -791,7 +793,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation) { // Set as default when payment mode defined remotely only + } elseif ($action == 'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Set as default when payment mode defined remotely only try { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_|src_/', $source)) { @@ -809,7 +811,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the credit card on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -842,7 +844,7 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation) { + } elseif ($action == 'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !== null) { // Delete the bank account on Stripe side try { if (preg_match('/pm_/', $source)) { @@ -852,7 +854,7 @@ if (empty($reshook)) { } } else { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - $card = $cu->sources->retrieve("$source"); + $card = $cu->sources->retrieve((string) $source); if ($card) { // $card->detach(); Does not work with card_, only with src_ if (method_exists($card, 'detach')) { @@ -1017,12 +1019,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 0; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_accounttest') { @@ -1047,12 +1049,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $tmpservice = 1; $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) + $tmpstripeacc = $stripe->getStripeAccount((string) $tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if ($tmpstripecu && $action != 'editkey_account') { @@ -1109,12 +1111,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Stripe connect - if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 && $service !== null) { $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, (int) $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') { @@ -1132,7 +1134,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; print ''; - print ''; + print ''; //print ''; print ''; } @@ -1155,7 +1157,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $listofsources = array(); $customerstripe = null; - if (isset($stripe) && is_object($stripe)) { + if (isset($stripe) && is_object($stripe) && $stripeacc !== null) { try { $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (!empty($customerstripe->id)) { @@ -1545,8 +1547,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } if (is_array($currencybalance)) { - foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price(isset($cpt->pending) ? $cpt->pending : 0, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + (isset($cpt->pending) ? $cpt->pending : 0), 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + foreach ($currencybalance as $cpt_arr) { + print ''.$langs->trans("Currency".strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'], 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price(isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0, 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''.price($cpt_arr['available'] + (isset($cpt_arr['pending']) ? $cpt_arr['pending'] : 0), 0, '', 1, - 1, - 1, strtoupper($cpt_arr['currency'])).''; } } @@ -1882,6 +1884,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Fields from hook + // TODO: No longer in foreach -> using last rib of for each which may be undeclared! $parameters = array('arrayfields' => array(), 'stripe_card_ref' => $rib->stripe_card_ref, 'stripe_account' => $rib->stripe_account, 'linetype' => 'stripebanremoteonly'); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1932,7 +1935,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', (string) $object->id, $filedir, $urlsource, $permissiontoread, (int) $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, '', '', $object->default_lang); // Show direct download link if (getDolGlobalString('BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD')) { @@ -2082,7 +2085,7 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print ''; if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, (string) $companybankaccount->id); } // RUM @@ -2140,8 +2143,8 @@ if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) print ''; print ''; print ''; @@ -2317,8 +2320,8 @@ if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformatio print ''; print ''; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index e06605e8a66..1e89a156e66 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -106,7 +106,7 @@ if (empty($reshook)) { } if (!$error) { - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // add price by customer $prodcustprice->fk_soc = $socid; @@ -204,7 +204,7 @@ if (empty($reshook)) { if ($action == 'update_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $prodcustprice->fetch(GETPOSTINT('lineid')); - $update_child_soc = GETPOST('updatechildprice'); + $update_child_soc = GETPOSTINT('updatechildprice'); // update price by customer $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); @@ -329,25 +329,25 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT $sortfield = "soc.nom"; } - // Build filter to display only concerned lines + // Build filter to display only related lines $filter = array( - 't.fk_soc' => $object->id + 't.fk_soc' => (string) $object->id ); if (!empty($search_prod)) { - $filter ['prod.ref'] = $search_prod; + $filter ['prod.ref'] = (string) $search_prod; } if (!empty($search_label)) { - $filter ['prod.label'] = $search_label; + $filter ['prod.label'] = (string) $search_label; } if (!empty($search_price)) { - $filter ['t.price'] = $search_price; + $filter ['t.price'] = (string) $search_price; } if (!empty($search_price_ttc)) { - $filter ['t.price_ttc'] = $search_price_ttc; + $filter ['t.price_ttc'] = (string) $search_price_ttc; } if ($action == 'add_customer_price') { @@ -368,7 +368,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''; print ''; print ''; print ''; @@ -378,7 +378,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -471,7 +471,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT // VAT print ''; // Price base @@ -581,8 +581,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT print ''."\n"; $filter = array( - 't.fk_product' => GETPOSTINT('prodid'), - 't.fk_soc' => $socid + 't.fk_product' => (string) GETPOSTINT('prodid'), + 't.fk_soc' => (string) $socid ); // Count total nb of records diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 66412a151cd..1da3c51d555 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,14 +56,14 @@ if ($action == 'editsalesrepresentatives') { if (empty($arrayselected)) { $arrayselected = $object->getSalesRepresentatives($user, 1); } - print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print $form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, '', 0, "90%"); print ''; print ''; } else { $listsalesrepresentatives = $object->getSalesRepresentatives($user); - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 0 && is_array($listsalesrepresentatives)) { + $nbofsalesrepresentative = is_array($listsalesrepresentatives) ? count($listsalesrepresentatives) : 0; + if ($nbofsalesrepresentative > 0) { $userstatic = new User($db); foreach ($listsalesrepresentatives as $val) { $userstatic->id = $val['id']; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e245f49d91b..00a5624dc94 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -272,10 +273,10 @@ foreach ($search as $key => $val) { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $objectwebsiteaccount->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate((int) $search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate((int) $search[$key])."'"; } } } @@ -547,7 +548,7 @@ foreach ($objectwebsiteaccount->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -682,7 +683,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'login') { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 84d5297f4c0..b30c1c9bdd5 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -766,7 +766,7 @@ if ($action == 'create' || $action == 'presend') { $formticket->showForm(0, 'edit', 0, null, $action, $object); print dol_get_fiche_end(); -} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status', 'dellink'])) { +} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'addlinkbyref', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status'])) { if (!empty($res) && $res > 0) { // or for unauthorized internals users if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3f86b929e99..3ed9c35afa7 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -4783,7 +4783,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); } if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) { - $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09') ? 1 : 0; + $pageallowedinframes = 1; } if (GETPOST('htmlheader', 'none')) { // Must accept tags like '
'.$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 '