From a4a66e60f8dbdc4bccf37fcad14362e950940cfe Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 09:26:10 +0100 Subject: [PATCH 01/21] Add a substitution Category Of Operations into ODT generation for Invoices --- .../doc/doc_generic_invoice_odt.modules.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index f5dcfb86936..8a10f2d53b8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -338,6 +338,35 @@ class doc_generic_invoice_odt extends ModelePDFFactures $propal_object = $object->linkedObjects['propal'][0]; + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; + foreach ($object->lines as $line) { + + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $line->product_type; + if ($lineProductType == Product::TYPE_PRODUCT) { + $nbProduct++; + } elseif ($lineProductType == Product::TYPE_SERVICE) { + $nbService++; + } + if ($nbProduct > 0 && $nbService > 0) { + // mixed products and services + $categoryOfOperation = 2; + } + } + } + + // determine category of operation + if ($categoryOfOperation <= 0) { + // only services + if ($nbProduct == 0 && $nbService > 0) { + $categoryOfOperation = 1; + } + } + // Make substitution $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, @@ -420,6 +449,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); From 11da2351df75609d3c4b7139e6625a3f76525bd0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 08:32:22 +0000 Subject: [PATCH 02/21] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 8a10f2d53b8..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 0671ec697fda7ea6e6b1ee083370d4745d47cece Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 10:06:58 +0100 Subject: [PATCH 03/21] Add a substitution Category Of Operations into ODT generation for Invoices --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..907808f3479 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,6 +343,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { + // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 25bfd4d855fce4e754968e78ba34a602c784f128 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 09:08:32 +0000 Subject: [PATCH 04/21] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 907808f3479..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 78b383efa4b6257ec63df665ba12d99c8ef83fc2 Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Wed, 4 Jan 2023 08:59:34 +0100 Subject: [PATCH 05/21] Corrections added by Eldy --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..ba1a64f29f6 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -448,7 +448,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); From bcd5666e01c25350f14dc12590b21c20383e3db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Sun, 9 Jul 2023 12:16:05 +0200 Subject: [PATCH 06/21] Support extrafields in selectForForms --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39a0d9754e0..59b9c70dca2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8030,6 +8030,7 @@ class Form // Search data $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t"; + $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; if (isset($objecttmp->ismultientitymanaged)) { if (!is_numeric($objecttmp->ismultientitymanaged)) { $tmparray = explode('@', $objecttmp->ismultientitymanaged); From 7442a855146a7070a0b1ec904f797c3a170200b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 11 Jul 2023 06:40:33 +0200 Subject: [PATCH 07/21] check if object has extrafields --- htdocs/core/class/html.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 59b9c70dca2..4d7e41f6501 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8030,7 +8030,9 @@ class Form // Search data $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t"; - $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; + if (!empty($objecttmp->isextrafieldmanaged)) { + $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; + } if (isset($objecttmp->ismultientitymanaged)) { if (!is_numeric($objecttmp->ismultientitymanaged)) { $tmparray = explode('@', $objecttmp->ismultientitymanaged); From a73024bec87517dea55948c7b79f52774187dc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:54:58 +0200 Subject: [PATCH 08/21] add extrafieldmanaged in commande.class.php --- htdocs/commande/class/commande.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 64dd3ad564a..ec23a97acc5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -82,6 +82,11 @@ class Commande extends CommonOrder */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer From bb1aad54c0c3cb218699a064dc5a34d6d1587121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:56:25 +0200 Subject: [PATCH 09/21] add $isextrafieldmanaged to contact.class.php --- htdocs/contact/class/contact.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 3a4128f01cf..728efba79a1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -60,6 +60,11 @@ class Contact extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ From 38037089dd12b52299bb43523054a4f1b3248870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:57:50 +0200 Subject: [PATCH 10/21] add $isextrafieldmanaged to facture.class.php --- htdocs/compta/facture/class/facture.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 851fc3a08b1..5bbf4fadf98 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -90,6 +90,11 @@ class Facture extends CommonInvoice */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer From 6ec130d2e6d6be28c840037a100b9545d547682d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:58:55 +0200 Subject: [PATCH 11/21] add $isextrafieldmanaged to expedition.class.php --- htdocs/expedition/class/expedition.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b62a9a94a5b..dae0b9dc329 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -79,6 +79,11 @@ class Expedition extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ From 509384e319a64d27f9bdaef1f2b042dc0a4f2977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 00:28:47 +0200 Subject: [PATCH 12/21] remove duplicate line --- htdocs/core/class/conf.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index bb7ff52a9f9..bbaed873c6a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -287,7 +287,6 @@ class Conf $this->commande = new stdClass(); $this->propal = new stdClass(); $this->facture = new stdClass(); - $this->contrat = new stdClass(); $this->user = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); From 9132529b691d0f6f18c582743f3acae045365b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Fri, 1 Sep 2023 00:50:15 +0200 Subject: [PATCH 13/21] clean numbering module --- .../partnership/mod_partnership_advanced.php | 35 +++---- .../partnership/mod_partnership_standard.php | 8 +- .../partnership/modules_partnership.php | 91 +------------------ 3 files changed, 25 insertions(+), 109 deletions(-) diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php index 821a9e67303..c3b3a888b54 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * \brief File containing class for advanced numbering model of Partnership */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership /** * Returns the description of the numbering model * + * @param Translate $langs Lang object to use for output * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $db; $langs->load("bills"); $form = new Form($db); - $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte .= '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; + $text = $langs->trans('GenericNumRefModelDesc')."
\n"; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership")); $tooltip .= $langs->trans("GenericMaskCodes2"); @@ -78,17 +79,17 @@ class mod_partnership_advanced extends ModeleNumRefPartnership $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte .= ''; - $texte .= ''; + $text .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte .= '
'; + $text .= ''; + $text .= ''; - return $texte; + return $text; } /** diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index 5de4b07f215..c7409aba85e 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -22,7 +22,7 @@ * \ingroup partnership * \brief File of class to manage Partnership numbering rules standard */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Text with description */ - public function info() + public function info($langs) { - global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); } diff --git a/htdocs/partnership/core/modules/partnership/modules_partnership.php b/htdocs/partnership/core/modules/partnership/modules_partnership.php index 4d1f6c0b107..dafab0cc8ed 100644 --- a/htdocs/partnership/core/modules/partnership/modules_partnership.php +++ b/htdocs/partnership/core/modules/partnership/modules_partnership.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -66,93 +67,7 @@ abstract class ModelePDFPartnership extends CommonDocGenerator /** * Parent class to manage numbering of Partnership */ -abstract class ModeleNumRefPartnership +abstract class ModeleNumRefPartnership extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } From 69f070d8fdb4538db40069cbf1bcdeb861d2670d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 09:18:23 +0200 Subject: [PATCH 14/21] phpstan --- htdocs/paypal/lib/paypal.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 79003956f12..db949620440 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -145,7 +145,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); if ($ErrorCode == 10729) { - $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + $mesg = "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; } else { $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
\n"; $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n"; From eaf63b60c5e6e69a894de6ff95a689c3df6bfa33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 14:54:35 +0200 Subject: [PATCH 15/21] phpstan --- htdocs/reception/class/reception.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index c9cf763882c..9fb6a0cb6a9 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -93,6 +93,7 @@ class Reception extends CommonObject public $depth_units; // A denormalized value public $trueSize; + public $size_units; public $date_delivery; // Date delivery planed @@ -121,6 +122,11 @@ class Reception extends CommonObject public $meths; public $listmeths; // List of carriers + /** + * @var CommandeFournisseur + */ + public $commandeFournisseur; + /** * @var CommandeFournisseurDispatch[] */ From 022c7f0dc37caf33c1df63d4ad30a97a5ba1c7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 15:38:00 +0200 Subject: [PATCH 16/21] doc --- htdocs/core/class/html.form.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 13d5775196b..0169ea235b2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6606,7 +6606,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. - * @param datetime $adddateof Add a link "Date of invoice" using the following date. + * @param int|string $adddateof Add a link "Date of invoice" using the following date. * @return string '' or HTML component string if nooutput is 1 * @deprecated * @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek() @@ -6614,6 +6614,7 @@ class Form public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') { // phpcs:enable + dol_syslog(__METHOD__ . ': using select_date is deprecated. Use selectDate instead.', LOG_WARNING); $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); if (!empty($nooutput)) { return $retstring; @@ -6668,7 +6669,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. - * @param datetime|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) + * @param int|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) * @param string $openinghours Specify hour start and hour end for the select ex 8,20 * @param int $stepminutes Specify step for minutes between 1 and 30 * @param string $labeladddateof Label to use for the $adddateof parameter. Deprecated. Used only when $adddateof is not an array. From 725d870669c02df44044afbbe553e3257b9fa485 Mon Sep 17 00:00:00 2001 From: Roger Dueck Date: Fri, 1 Sep 2023 09:26:13 -0600 Subject: [PATCH 17/21] Fix attempt to access stdClass::$* on query result --- htdocs/core/class/commonobject.class.php | 31 ++++++++++++++++++++++++ htdocs/core/lib/project.lib.php | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2ee3fd3aa48..e220f5aa98d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4256,6 +4256,10 @@ abstract class CommonObject return -1; } + if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) { + error_log("ERROR: Invalid value '$field_select' for parameter \$field_select in call to getAllItemsLinkedByObjectID(). Must be a single field name."); + } + global $db; $sql = "SELECT ".$field_select." FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); @@ -4271,6 +4275,33 @@ abstract class CommonObject return $TRes; } + /** + * Count items linked to an object id in association table + * + * @param int $fk_object_where id of object we need to get linked items + * @param string $field_where name of field of object we need to get linked items + * @param string $table_element name of association table + * @return array|int Array of record, -1 if empty + */ + public static function getCountOfItemsLinkedByObjectID($fk_object_where, $field_where, $table_element) + { + if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { + return -1; + } + + global $db; + + $sql = "SELECT COUNT(*) n FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); + $resql = $db->query($sql); + $n = 0; + if ($resql) { + $res = $db->fetch_object($resql); + if ($res) $n = $res->n; + } + + return $n; + } + /** * Function used to remove all items linked to an object id in association table * diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 43b2c136044..07519ea55d2 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '') if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) { require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; $Tickettatic = new Ticket($db); - $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket')); + $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket'); $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); $head[$h][1] = $langs->trans("Ticket"); if ($nbTicket > 0) { From ca1e139c6a3856a3218c6ec84862fb2e707e1558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 20:28:42 +0200 Subject: [PATCH 18/21] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e220f5aa98d..c5d2c5f123b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4255,9 +4255,8 @@ abstract class CommonObject if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { return -1; } - if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) { - error_log("ERROR: Invalid value '$field_select' for parameter \$field_select in call to getAllItemsLinkedByObjectID(). Must be a single field name."); + dol_syslog('Invalid value $field_select for parameter '.$field_select.' in call to getAllItemsLinkedByObjectID(). Must be a single field name.', LOG_ERR); } global $db; From df4781a521f001ae8c3e72dd9c0f536a9ec465bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 20:30:43 +0200 Subject: [PATCH 19/21] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c5d2c5f123b..364de5092d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4290,12 +4290,14 @@ abstract class CommonObject global $db; - $sql = "SELECT COUNT(*) n FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); + $sql = "SELECT COUNT(*) as nb FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); $resql = $db->query($sql); $n = 0; if ($resql) { $res = $db->fetch_object($resql); - if ($res) $n = $res->n; + if ($res) { + $n = $res->nb; + } } return $n; From 0a3bb161f84bb419e955e6d0756788739ea996ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 2 Sep 2023 10:14:25 +0200 Subject: [PATCH 20/21] phpstan --- htdocs/core/class/html.formmail.class.php | 9 +++++++++ htdocs/core/class/html.formsms.class.php | 1 + 2 files changed, 10 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d117140e156..264ed21b512 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -134,6 +134,7 @@ class FormMail extends Form public $withtocc; public $withtoccc; public $withtopic; + public $witherrorsto; /** * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -150,13 +151,21 @@ class FormMail extends Form public $withreplytoreadonly; public $withtoreadonly; public $withtoccreadonly; + public $witherrorstoreadonly; public $withtocccreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withfilereadonly; public $withdeliveryreceipt; public $withcancel; + public $withdeliveryreceiptreadonly; public $withfckeditor; + /** + * @var string ckeditortoolbar + */ + public $ckeditortoolbar; + public $substit = array(); public $substit_lines = array(); public $param = array(); diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 940f76d0ae8..8e20cb8d33c 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -62,6 +62,7 @@ class FormSms public $withreplytoreadonly; public $withtoreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withcancel; public $substit = array(); From e0189c654c16749c0e46dbd183b50a3ffed5504d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 2 Sep 2023 10:18:46 +0200 Subject: [PATCH 21/21] phpcs --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index ec8d8b5f68d..aaa8bad5ee7 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -430,7 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding // property of object and use the xxxx to know how to format it. // Before that, we hard code this substitution as if we have found them into the template. - + $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m'); $tmparray['object_MONTH'] = dol_print_date($object->date, '%m'); $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m'); @@ -440,7 +440,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y'); - $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook