diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 579e02ceacd..97e91d7bb07 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -69,6 +69,7 @@ return [ 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch', 'PhanParamSuspiciousOrder'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], + 'htdocs/core/triggers/interface_80_modStripe_Stripe.class.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], 'htdocs/fourn/class/api_supplier_invoices.class.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/intracommreport/list.php' => ['PhanAccessPropertyStaticAsNonStatic'], @@ -79,6 +80,7 @@ return [ 'htdocs/public/opensurvey/index.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/public/recruitment/index.php' => ['PhanPluginSuspiciousParamOrder'], + 'htdocs/societe/paymentmodes.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 650f4fbf9e2..5cb5b5b2f07 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -446,7 +446,7 @@ return [ 'PhanRedefinedClassReference', // 'PhanPluginNoCommentOnClass', // 'PhanPluginNotFullyQualifiedGlobalConstant', - 'PhanTypeMismatchDefault', + // 'PhanTypeMismatchDefault', // 'PhanPluginPHPDocHashComment', 'PhanPluginShortArrayList', 'PhanPluginUnknownArrayPropertyType', @@ -457,7 +457,7 @@ return [ 'PhanPluginUnknownClosureReturnType', // 'PhanPluginNoCommentOnProtectedMethod', // 'PhanTypeArraySuspicious', - 'PhanTypeMismatchPropertyProbablyReal', + // 'PhanTypeMismatchPropertyProbablyReal', // 'PhanPluginNoCommentOnPrivateMethod', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeInvalidLeftOperandOfAdd', @@ -495,7 +495,7 @@ return [ 'PhanTypeInvalidLeftOperandOfBitwiseOp', // 'PhanTypeMismatchDimAssignment', // 'PhanPluginDescriptionlessCommentOnProtectedMethod', - 'PhanPluginPrintfIncompatibleArgumentTypeWeak', + // 'PhanPluginPrintfIncompatibleArgumentTypeWeak', 'PhanUndeclaredVariableAssignOp', 'PhanTypeExpectedObjectOrClassName', 'PhanEmptyFQSENInClasslike', @@ -591,7 +591,7 @@ return [ // 'PhanPluginPossiblyStaticProtectedMethod', 'PhanTypeMismatchReturn', // 'PhanPluginMoreSpecificActualReturnType', - 'PhanTypeMismatchReturnProbablyReal', + // 'PhanTypeMismatchReturnProbablyReal', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', // 'PhanPluginUnreachableCode', diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index c995908532f..78c5449ccca 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -550,7 +550,11 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' //$param='month='.$monthshown.'&year='.$year; $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; + $urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; + $urltocreateaction .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); + + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', $urltocreateaction); } // Define the legend/list of calendard to show diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 217fca02d35..408b64c6fc9 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -730,7 +730,7 @@ $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam $newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); -$param .= '&mode='.$mode; +$param .= '&mode='.urlencode($mode); print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, is_numeric($nbtotalofrecords) ? -1 * $nbtotalofrecords : $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 7bb071f036c..990c9af705f 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -480,9 +480,11 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; + $urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; + $urltocreateaction .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); + + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', $urltocreateaction); } print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index c191a6c35be..97098383652 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -129,8 +129,8 @@ if ($dateselect > 0) { $tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS') ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); -$begin_h = GETPOSTINT('begin_h') != '' ? GETPOSTINT('begin_h') : ($tmparray[0] != '' ? $tmparray[0] : 9); -$end_h = GETPOSTINT('end_h') ? GETPOSTINT('end_h') : ($tmparray[1] != '' ? $tmparray[1] : 18); +$begin_h = GETPOSTISSET('begin_h') ? GETPOSTINT('begin_h') : ($tmparray[0] != '' ? $tmparray[0] : 9); +$end_h = GETPOSTISSET('end_h') ? GETPOSTINT('end_h') : ($tmparray[1] != '' ? $tmparray[1] : 18); if ($begin_h < 0 || $begin_h > 23) { $begin_h = 9; } @@ -144,8 +144,8 @@ if ($end_h <= $begin_h) { $tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS') ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); -$begin_d = GETPOSTINT('begin_d') ? GETPOSTINT('begin_d') : ($tmparray[0] != '' ? $tmparray[0] : 1); -$end_d = GETPOSTINT('end_d') ? GETPOSTINT('end_d') : ($tmparray[1] != '' ? $tmparray[1] : 5); +$begin_d = GETPOSTISSET('begin_d') ? GETPOSTINT('begin_d') : ($tmparray[0] != '' ? $tmparray[0] : 1); +$end_d = GETPOSTISSET('end_d') ? GETPOSTINT('end_d') : ($tmparray[1] != '' ? $tmparray[1] : 5); if ($begin_d < 1 || $begin_d > 7) { $begin_d = 1; } @@ -496,9 +496,11 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' $newparam .= '&end_d='.urlencode($end_d); } - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create'; + $urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes']; + $urltocreateaction .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); + + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', $urltocreateaction); } $num = ''; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 5978fcc75b8..ff8260fce9d 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013-2023 Charlene BENKE + * Copyright (C) 2024 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 @@ -205,7 +206,7 @@ for ($mois = 1; $mois < 13; $mois++) { print "".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B").""; for ($annee = $year_start; $annee <= $year_end; $annee++) { - $case = sprintf("%04s-%02s", $annee, $mois); + $case = sprintf("%04d-%02d", $annee, $mois); print ' '; if (isset($decaiss[$case]) && $decaiss[$case] > 0) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 94d4b4247b1..67a067854f1 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -93,8 +93,10 @@ class Account extends CommonObject public $bank; /** - * Status + * Status closed + * * @var int + * @deprecated Duplicate field. We already have the field $this->status */ public $clos = self::STATUS_OPEN; @@ -200,13 +202,6 @@ class Account extends CommonObject */ public $type_lib = array(); - /** - * Array listing all the potential status of an account. - * Defined in __construct - * @var array array: int of the status => translated label of the status - */ - public $status = array(); - /** * Accountancy code * @var string @@ -387,17 +382,17 @@ class Account extends CommonObject $this->db = $db; - $this->solde = 0; + $this->balance = 0; $this->type_lib = array( - self::TYPE_SAVINGS => $langs->trans("BankType0"), - self::TYPE_CURRENT => $langs->trans("BankType1"), - self::TYPE_CASH => $langs->trans("BankType2"), + self::TYPE_SAVINGS => $langs->transnoentitiesnoconv("BankType0"), + self::TYPE_CURRENT => $langs->transnoentitiesnoconv("BankType1"), + self::TYPE_CASH => $langs->transnoentitiesnoconv("BankType2"), ); - $this->status = array( - self::STATUS_OPEN => $langs->trans("StatusAccountOpened"), - self::STATUS_CLOSED => $langs->trans("StatusAccountClosed") + $this->labelStatus = array( + self::STATUS_OPEN => $langs->transnoentitiesnoconv("StatusAccountOpened"), + self::STATUS_CLOSED => $langs->transnoentitiesnoconv("StatusAccountClosed") ); } @@ -2744,41 +2739,6 @@ class AccountLine extends CommonObjectLine public function LibStatut($status, $mode = 0) { // phpcs:enable - //global $langs; - - //$langs->load('companies'); - /* - if ($mode == 0) - { - if ($status==0) return $langs->trans("ActivityCeased"); - if ($status==1) return $langs->trans("InActivity"); - } - if ($mode == 1) - { - if ($status==0) return $langs->trans("ActivityCeased"); - if ($status==1) return $langs->trans("InActivity"); - } - if ($mode == 2) - { - if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - if ($mode == 3) - { - if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); - } - if ($mode == 4) - { - if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - if ($mode == 5) - { - if ($status==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($status==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); - }*/ - return ''; } diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 21fa04cc931..daa017a0130 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -3,6 +3,7 @@ * Copyright (C) 2016-2022 Alexandre Spangaro * Copyright (C) 2018-2020 Laurent Destailleur * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 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 @@ -260,12 +261,12 @@ print ''.$langs->trans("PreviousPeriod").''; print ''.$langs->trans("SelectedPeriod").''; foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth && $k < $date_endmonth) { - print ''.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).''; + print ''.$langs->trans('MonthShort'.sprintf("%02d", ($k + 1))).''; } } foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { - print ''.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).''; + print ''.$langs->trans('MonthShort'.sprintf("%02d", ($k + 1))).''; } } print ''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 153cb7d53ff..d91ce98999e 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -406,8 +406,8 @@ class ChargeSociales extends CommonObject /** * Calculate amount remaining to pay by year * - * @param int $year Year - * @return int|float + * @param int $year Year + * @return int|float Returns -1 when error (Note: could be mistaken with an amount) */ public function solde($year = 0) { diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index c5fbf396667..1c72b1ff444 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -548,12 +548,12 @@ class PaymentVAT extends CommonObject $this->fk_tva = 0; $this->datec = dol_now(); $this->tms = dol_now(); - $this->datep = ''; - $this->amount = ''; + $this->datep = dol_now(); + $this->amount = 100; $this->fk_typepaiement = 0; - $this->num_payment = ''; - $this->note_private = ''; - $this->note_public = ''; + $this->num_payment = '123456'; + $this->note_private = 'Private note'; + $this->note_public = 'Public note'; $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 06644ff5a17..6c9fc066666 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1683,7 +1683,7 @@ class Contrat extends CommonObject $contractline->id = $contractlineid; $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[] = $contractline->error; + $this->errors[] = $contractline->error; $error++; } } @@ -1877,7 +1877,7 @@ class Contrat extends CommonObject $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[] = $contractline->error; + $this->errors[] = $contractline->error; $error++; } } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 2a5dc287f2b..58a877cca75 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -29,6 +30,10 @@ // $triggersendname must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined +' +@phan-var-force Societe $mysoc +@phan-var-force CommonObject $object +'; /* * Add file in email form @@ -357,7 +362,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; - $parameters = array('mode'=>'formemail'); + $parameters = array('mode' => 'formemail'); complete_substitutions_array($substitutionarray, $langs, $object, $parameters); $subject = make_substitutions($subject, $substitutionarray); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 985f23625e8..07dfa7db829 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -226,13 +226,13 @@ abstract class CommonObject /** * @var Project The related project object - * @deprecated - * @see project + * @deprecated Use $project instead + * @see $project */ public $projet; /** - * @deprecated + * @deprecated Use $fk_project instead * @see $fk_project */ public $fk_projet; @@ -274,13 +274,13 @@ abstract class CommonObject public $origin_id; /** - * @var Object Origin object. This is set by fetch_origin() from this->origin and this->origin_id. + * @var ?CommonObject Origin object. This is set by fetch_origin() from this->origin and this->origin_id. */ public $origin_object; /** - * @var string|CommonObject Sometime the type of the originating object ('commande', 'facture', ...), sometime the object (like onh MouvementStock) - * @deprecated Use now $origin_type and $origin_id; + * @var CommonObject|string|null Sometimes the type of the originating object ('commande', 'facture', ...), sometimes the object (as with MouvementStock) + * @deprecated Use now $origin_type and $origin_id; * @see fetch_origin() */ public $origin; @@ -322,7 +322,7 @@ abstract class CommonObject /** * @var int The object's status. Use status instead. - * @deprecated + * @deprecated Use $status instead * @see setStatut() */ public $statut; @@ -369,7 +369,7 @@ abstract class CommonObject /** * var int State ID - * @deprecated Use state_id. We can remove this property when the field 'fk_departement' have been renamed into 'state_id' in all tables + * @deprecated Use $state_id. We can remove this property when the field 'fk_departement' have been renamed into 'state_id' in all tables */ public $fk_departement; @@ -447,7 +447,7 @@ abstract class CommonObject /** * @var int Payment terms ID - * @deprecated Kept for compatibility + * @deprecated Use $cond_reglement_id instead - Kept for compatibility * @see cond_reglement_id; */ public $cond_reglement; @@ -730,13 +730,13 @@ abstract class CommonObject public $specimen = 0; /** - * @var int Id of contact to send object (used by the trigger of module Agenda) + * @var int[] Id of contacts to send objects (mails, etc.) */ public $sendtoid; /** * @var float Amount already paid from getSommePaiement() (used to show correct status) - * @deprecated Duplicate of $totalpaid + * @deprecated Use $totalpaid instead */ public $alreadypaid; /** @@ -792,8 +792,8 @@ abstract class CommonObject /** * @var string[] List of child tables. To know object to delete on cascade. - * If name is like '@ClassName:FilePathClass:ParentFkFieldName', it will - * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object. + * If name is like '@ClassName:FilePathClass:ParentFkFieldName', it will + * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object. */ protected $childtablesoncascade = array(); @@ -4205,98 +4205,20 @@ abstract class CommonObject if (!empty($this->linkedObjectsIds)) { $tmparray = $this->linkedObjectsIds; foreach ($tmparray as $objecttype => $objectids) { // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) - // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) - $module = $element = $subelement = $objecttype; - $regs = array(); - if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier' - && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) { - $module = $element = $regs[1]; - $subelement = $regs[2]; - } + $element_properties = getElementProperties($objecttype); + $element = $element_properties['element']; + $classPath = $element_properties['classpath']; + $classFile = $element_properties['classfile']; + $className = $element_properties['classname']; + $module = $element_properties['module']; - $classpath = $element.'/class'; - // To work with non standard classpath or module name - if ($objecttype == 'facture') { - $classpath = 'compta/facture/class'; - } elseif ($objecttype == 'facturerec') { - $classpath = 'compta/facture/class'; - $module = 'facture'; - } elseif ($objecttype == 'propal') { - $classpath = 'comm/propal/class'; - } elseif ($objecttype == 'supplier_proposal') { - $classpath = 'supplier_proposal/class'; - } elseif ($objecttype == 'shipping') { - $classpath = 'expedition/class'; - $subelement = 'expedition'; - $module = 'expedition'; - } elseif ($objecttype == 'delivery') { - $classpath = 'delivery/class'; - $subelement = 'delivery'; - $module = 'shipping'; - } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { - $classpath = 'fourn/class'; - $module = 'fournisseur'; - } elseif ($objecttype == 'fichinter') { - $classpath = 'fichinter/class'; - $subelement = 'fichinter'; - $module = 'ficheinter'; - } elseif ($objecttype == 'subscription') { - $classpath = 'adherents/class'; - $module = 'adherent'; - } elseif ($objecttype == 'contact') { - $module = 'societe'; - } - // Set classfile - $classfile = strtolower($subelement); - $classname = ucfirst($subelement); - - if ($objecttype == 'order') { - $classfile = 'commande'; - $classname = 'Commande'; - } elseif ($objecttype == 'invoice_supplier') { - $classfile = 'fournisseur.facture'; - $classname = 'FactureFournisseur'; - } elseif ($objecttype == 'order_supplier') { - $classfile = 'fournisseur.commande'; - $classname = 'CommandeFournisseur'; - } elseif ($objecttype == 'supplier_proposal') { - $classfile = 'supplier_proposal'; - $classname = 'SupplierProposal'; - } elseif ($objecttype == 'facturerec') { - $classfile = 'facture-rec'; - $classname = 'FactureRec'; - } elseif ($objecttype == 'subscription') { - $classfile = 'subscription'; - $classname = 'Subscription'; - } elseif ($objecttype == 'project' || $objecttype == 'projet') { - $classpath = 'projet/class'; - $classfile = 'project'; - $classname = 'Project'; - } elseif ($objecttype == 'conferenceorboothattendee') { - $classpath = 'eventorganization/class'; - $classfile = 'conferenceorboothattendee'; - $classname = 'ConferenceOrBoothAttendee'; - $module = 'eventorganization'; - } elseif ($objecttype == 'conferenceorbooth') { - $classpath = 'eventorganization/class'; - $classfile = 'conferenceorbooth'; - $classname = 'ConferenceOrBooth'; - $module = 'eventorganization'; - } elseif ($objecttype == 'mo') { - $classpath = 'mrp/class'; - $classfile = 'mo'; - $classname = 'Mo'; - $module = 'mrp'; - } - - // Here $module, $classfile and $classname are set, we can use them. + // Here $module, $classFile and $className are set, we can use them. if (isModEnabled($module) && (($element != $this->element) || $alsosametype)) { if ($loadalsoobjects && (is_numeric($loadalsoobjects) || ($loadalsoobjects === $objecttype))) { - dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); - if (class_exists($classname)) { + dol_include_once('/'.$classPath.'/'.$classFile.'.class.php'); + if (class_exists($className)) { foreach ($objectids as $i => $objectid) { // $i is rowid into llx_element_element - $object = new $classname($this->db); + $object = new $className($this->db); $ret = $object->fetch($objectid); if ($ret >= 0) { $this->linkedObjects[$objecttype][$i] = $object; @@ -8955,7 +8877,7 @@ abstract class CommonObject /** * Returns the rights used for this class * - * @return int|stdClass Object of permission for the module + * @return null|int|stdClass Object of permission for the module */ public function getRights() { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0e9927aad5d..df8fe37210d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -524,7 +524,7 @@ function societe_admin_prepare_head() * @param Translate $outputlangs Langs object for output translation * @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output * @param string $searchlabel Label of country to search (warning: searching on label is not reliable) - * @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' + * @return int|string|array{id:int,code:string,label:string} Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' */ function getCountry($searchkey, $withcode = '', $dbtouse = null, $outputlangs = null, $entconv = 1, $searchlabel = '') { @@ -1515,6 +1515,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; } + // Delete + if ($user->hasRight('societe', 'contact', 'delete')) { + print ''; + print img_delete(); + print ''; + } + print ''; } @@ -1611,6 +1618,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; } + // Delete + if ($user->hasRight('societe', 'contact', 'delete')) { + print ''; + print img_delete(); + print ''; + } + print ''; } @@ -2043,6 +2057,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr } } + '@phan-var-force array,datestart:int,dateend:int,fk_element:string,elementtype:string,contact_id:string,lastname:string,firstname:string,contact_photo:string,socpeaopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo'; + if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) { $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5b18aee94af..3d9117894a2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -57,7 +57,7 @@ function dol_basename($pathfile) * @param string $relativename For recursive purpose only. Must be "" at first call. * @param int $donotfollowsymlinks Do not follow symbolic links * @param int $nbsecondsold Only files older than $nbsecondsold - * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) + * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)> * @see dol_dir_list_in_database() */ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "", $donotfollowsymlinks = 0, $nbsecondsold = 0) @@ -2621,10 +2621,10 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = * * @param string $dir Directory to scan * @param string $regexfilter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function - * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function - * @param int $nohook Disable all hooks - * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only - * @return array Array with properties (full path, date, ...) of to most recent file + * @param string[] $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function + * @param int<0,1> $nohook Disable all hooks + * @param int<0,3> $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only + * @return null|array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string} null if none or Array with properties (full path, date, ...) of the most recent file */ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = 0, $mode = 0) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index da57c3863a8..4a6e3a42f01 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12176,6 +12176,10 @@ function getElementProperties($elementType) $module = 'facture'; $subelement = 'facture'; $table_element = 'facture'; + } elseif ($elementType == 'facturerec') { + $classpath = 'compta/facture/class'; + $module = 'facture'; + $classname = 'FactureRec'; } elseif ($elementType == 'commande' || $elementType == 'order') { $classpath = 'commande/class'; $module = 'commande'; @@ -12316,6 +12320,16 @@ function getElementProperties($elementType) $classname = 'EmailSenderProfile'; $table_element = 'c_email_senderprofile'; $subelement = ''; + } elseif ($elementType == 'conferenceorboothattendee') { + $classpath = 'eventorganization/class'; + $classfile = 'conferenceorboothattendee'; + $classname = 'ConferenceOrBoothAttendee'; + $module = 'eventorganization'; + } elseif ($elementType == 'conferenceorbooth') { + $classpath = 'eventorganization/class'; + $classfile = 'conferenceorbooth'; + $classname = 'ConferenceOrBooth'; + $module = 'eventorganization'; } if (empty($classfile)) { @@ -13866,9 +13880,9 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') * request. * * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate) - * @param int $timestamp If null, the timestamp will be created from request data - * @param bool $hourTime If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp - * @param bool $gm If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp + * @param ?int $timestamp If null, the timestamp will be created from request data + * @param string $hourTime If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp + * @param string $gm If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp * @return string Portion of URL with query parameters for the specified date */ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto') diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7fcb1c8f0d1..9c5d138dfc6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -639,7 +639,7 @@ function print_start_menu_entry($idsel, $classname, $showmode) * @param string $idsel Id sel * @param string $classname Class name * @param string $atarget Target - * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string} $menuval All the $menuval array + * @param array{}|array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string} $menuval All the $menuval array * @return void */ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array()) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 04081ba6a02..e0603034fbe 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -141,7 +141,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $menu = array(); /** - * @var array{triggers?:int<0,1>,login?:int<0,1>,substitutions?:int<0,1>,menus?:int<0,1>,theme?:int<0,1>,tpl?:int<0,1>,barcode?:int<0,1>,models?:int<0,1>,printing?:int<0,1>,css?:string[],js?:string[],hooks?:array{data:string[],entity:string},moduleforexternal?:int<0,1>,websitetemplates?:int<0,1>,contactelement?:int<0,1>} Module parts + * @var array{triggers?:int<0,1>,login?:int<0,1>,substitutions?:int<0,1>,menus?:int<0,1>,theme?:int<0,1>,tpl?:int<0,1>,barcode?:int<0,1>,models?:int<0,1>,printing?:int<0,1>,css?:string[],js?:string[],hooks?:array{data?:string[],entity?:string},moduleforexternal?:int<0,1>,websitetemplates?:int<0,1>,contactelement?:int<0,1>} Module parts * array( * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) * 'triggers' => 0, diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index bc0705840d3..d09748f158c 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -2,6 +2,8 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2022 Frédéric France + * Copyright (C) 2024 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 @@ -156,7 +158,7 @@ class mod_asset_standard extends ModeleNumRefAsset if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_asset_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 1e4c22fb754..69656164461 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -148,7 +149,7 @@ class mod_bom_standard extends ModeleNumRefBoms if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 8cf6c383e65..3f760794750 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -145,7 +146,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index 4bd0c9a9c33..71ccfb8915e 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -160,7 +161,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 4c7979728e4..e0ffb17003c 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -29,7 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; */ class mod_contract_serpis extends ModelNumRefContracts { - // variables inherited from ModelNumRefContracts class public $name = 'Serpis'; public $version = 'dolibarr'; @@ -145,7 +145,7 @@ class mod_contract_serpis extends ModelNumRefContracts if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_contract_serpis::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index df68b875e72..8cc8ec7f234 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -163,7 +164,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_delivery_jade::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index af10ae43e45..a96b405e694 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -151,7 +152,7 @@ class mod_expedition_safor extends ModelNumRefExpedition if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index e88aa5f6bf9..afbd1664e96 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -208,7 +209,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 2993ed9f37e..651181c8cfb 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -200,7 +201,7 @@ class mod_facture_mars extends ModeleNumRefFactures if ($max >= (pow(10, 4) - 1)) { $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max); + $num = sprintf("%04d", $max); } $ref = ''; @@ -229,7 +230,7 @@ class mod_facture_mars extends ModeleNumRefFactures if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index f29607e5cd1..eef74993761 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -240,7 +241,7 @@ class mod_facture_terre extends ModeleNumRefFactures if ($max >= (pow(10, 4) - 1)) { $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max); + $num = sprintf("%04d", $max); } $ref = ''; @@ -268,7 +269,7 @@ class mod_facture_terre extends ModeleNumRefFactures if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 0f780ee2bb6..f721029b132 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -156,7 +157,7 @@ class mod_pacific extends ModeleNumRefFicheinter if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 06e63f42af8..c084f48e46d 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011 Juanjo Menent * Copyright (C) 2018-2023 Charlene Benke * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -30,7 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/holiday/modules_holiday.php'; */ class mod_holiday_madonna extends ModelNumRefHolidays { - // variables inherited from ModelNumRefHolidays class public $name = 'Madonna'; public $version = 'dolibarr'; @@ -146,7 +146,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index eb69f3c0953..98fd02255c7 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -156,7 +157,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_evaluation_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 8585f4ee1b4..b8b8acbbec1 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -263,12 +263,12 @@ class pdf_standard extends CommonStickerGenerator /** * Function to build PDF on disk, then output on HTTP stream. * - * @param Adherent $object Member object. Old usage: Array of record information (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) - * @param Translate $outputlangs Lang object for output language - * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... - * @param string $mode Tell if doc module is called for 'member', ... - * @param int $nooutput 1=Generate only file on disk and do not return it on response - * @param string $filename Name of output file (without extension) + * @param Adherent|array $object Member object. Old usage: Array of record information (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) + * @param Translate $outputlangs Lang object for output language + * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... + * @param string $mode Tell if doc module is called for 'member', ... + * @param int $nooutput 1=Generate only file on disk and do not return it on response + * @param string $filename Name of output file (without extension) * @return int 1=OK, 0=KO */ public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0, $filename = 'tmp_cards') diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php index 0547350208e..2e1de7e6b1e 100644 --- a/htdocs/core/modules/member/mod_member_advanced.php +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -1,6 +1,7 @@ * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2024 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 @@ -31,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_member.class.php'; */ class mod_member_advanced extends ModeleNumRefMembers { - // variables inherited from ModeleNumRefMembers class public $name = 'Advanced'; public $version = 'dolibarr'; @@ -150,7 +150,7 @@ class mod_member_advanced extends ModeleNumRefMembers if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_member_advanced::getNextValue return ".$this->prefix.$yymm."-".$num, LOG_INFO); diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index 333491281cc..b835a07614f 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -148,7 +149,7 @@ class mod_mo_standard extends ModeleNumRefMos if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index 6c90fec350a..5991cc2be93 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 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 @@ -154,7 +155,7 @@ class mod_payment_cicada extends ModeleNumRefPayments if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index d3feb2e88c1..b09f6bc3ff5 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Christophe Battarel * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -150,7 +151,7 @@ class mod_lot_standard extends ModeleNumRefBatch if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; } else { // If counter > 9999, we do not format on 4 chars, we take number as it is - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_lot_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index ae4d4efa965..6f5f673562e 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Christophe Battarel * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -150,7 +151,7 @@ class mod_sn_standard extends ModeleNumRefBatch if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; } else { // If counter > 9999, we do not format on 4 chars, we take number as it is - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_sn_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 1ef51d36c95..a411154425c 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -159,7 +160,7 @@ class mod_project_simple extends ModeleNumRefProjects if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index e75fd1b5e8a..b523fefad8c 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -156,7 +157,7 @@ class mod_task_simple extends ModeleNumRefTask if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 0da17182404..b601a7b1217 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -157,7 +158,7 @@ class mod_propale_marbre extends ModeleNumRefPropales if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 1482d96f935..10b12439776 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -131,7 +132,7 @@ class mod_reception_beryl extends ModelNumRefReception if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index e46b5dc3f7a..9ddae66f284 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -137,7 +137,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode if ($max >= (pow(10, 5) - 1)) { $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is } else { - $num = sprintf("%05s", $max + 1); + $num = sprintf("%05d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index a270b7d8842..57e7f238fc2 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -157,7 +158,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; } else { // If counter > 9999, we do not format on 4 chars, we take number as it is - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 9a197b31aad..68b728b839c 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -4,6 +4,7 @@ * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2016 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -214,7 +215,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($max >= (pow(10, 4) - 1)) { $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max); + $num = sprintf("%04d", $max); } $ref = ''; @@ -242,7 +243,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index cd6d9f78d0e..3601f2cb1fc 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -135,7 +136,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param CommandeFournisseur $object Object * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc = '', $object = '') + public function getNextValue($objsoc, $object) { global $db, $conf; @@ -166,7 +167,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 03f948de1c1..025ee320d36 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -126,7 +127,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param CommandeFournisseur $object Object * @return string|0 Value if OK, 0 if KO */ - public function getNextValue($objsoc = '', $object = '') + public function getNextValue($objsoc, $object) { global $db, $conf; diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index dba6eefb6b4..30f323ecc81 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -155,7 +156,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index b71d9581a53..ad61e3a55b2 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -157,7 +158,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 1629d0e779d..7ac31b4929e 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -4,6 +4,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2020 Open-DSI * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -166,7 +167,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos if ($max >= (pow(10, 4) - 1)) { $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max); + $num = sprintf("%04d", $max); } $ref = ''; @@ -194,7 +195,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$pos_source.'-'.$yymm.'-'.$num); diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 3d0c057870d..8c476eb91a7 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -156,7 +157,7 @@ class mod_ticket_simple extends ModeleNumRefTicket $num = $max + 1; } else { // If counter > 9999, we do not format on 4 chars, we take number as it is - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_ticket_simple::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/core/modules/workstation/mod_workstation_standard.php b/htdocs/core/modules/workstation/mod_workstation_standard.php index d5d6c40e459..c68952f36a6 100644 --- a/htdocs/core/modules/workstation/mod_workstation_standard.php +++ b/htdocs/core/modules/workstation/mod_workstation_standard.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2020 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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,7 +147,7 @@ class mod_workstation_standard extends ModeleNumRefWorkstation if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_workstation_standard::getNextValue return ".$this->prefix."-".$num); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index b4d139a0120..d57a25e96ba 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2023-2024 Frédéric France + * Copyright (C) 2024 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 @@ -615,7 +616,7 @@ class Delivery extends CommonObject $result = $line->insertExtraFields(); if ($result < 0) { - $this->error[] = $line->error; + $this->errors[] = $line->error; $error++; } } @@ -826,7 +827,7 @@ class Delivery extends CommonObject global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 54c4a8b469a..a602edc810d 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -656,8 +656,6 @@ class ExpenseReport extends CommonObject */ public function fetch($id, $ref = '') { - global $conf; - $sql = "SELECT d.rowid, d.entity, d.ref, d.note_public, d.note_private,"; // DEFAULT $sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS $sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS @@ -885,6 +883,8 @@ class ExpenseReport extends CommonObject $sql .= " WHERE f.rowid = ".((int) $id); $sql .= " AND f.entity = ".$conf->entity; + + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -920,7 +920,7 @@ class ExpenseReport extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; + global $user, $langs; $now = dol_now(); @@ -983,10 +983,10 @@ class ExpenseReport extends CommonObject * @param User $user User * @return int Return integer <0 if KO, >0 if OK */ - public function fetch_line_by_project($projectid, $user = '') + public function fetch_line_by_project($projectid, $user) { // phpcs:enable - global $conf, $db, $langs; + global $langs; $langs->load('trips'); @@ -1086,8 +1086,6 @@ class ExpenseReport extends CommonObject public function fetch_lines() { // phpcs:enable - global $conf; - $this->lines = array(); $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; @@ -1792,7 +1790,7 @@ class ExpenseReport extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { - global $langs, $conf, $hookmanager; + global $langs, $hookmanager; $result = ''; @@ -1906,7 +1904,7 @@ class ExpenseReport extends CommonObject * @param float $qty Qty * @param double $up Unit price (price with tax) * @param int $fk_c_type_fees Type payment - * @param string $vatrate Vat rate (Can be '10' or '10 (ABC)') + * @param int<-1,0>|string $vatrate Vat rate (Can be '10' or '10 (ABC)') * @param string $date Date * @param string $comments Description * @param int $fk_project Project id @@ -1917,7 +1915,7 @@ class ExpenseReport extends CommonObject */ public function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0, $fk_ecm_files = 0) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG); @@ -2029,7 +2027,7 @@ class ExpenseReport extends CommonObject */ public function checkRules($type = 0, $seller = '') { - global $user, $conf, $db, $langs, $mysoc; + global $conf, $db, $langs, $mysoc; $langs->load('trips'); @@ -2105,7 +2103,7 @@ class ExpenseReport extends CommonObject */ public function applyOffset($type = 0, $seller = '') { - global $conf, $mysoc; + global $mysoc; if (!getDolGlobalString('MAIN_USE_EXPENSE_IK')) { return false; @@ -2327,10 +2325,10 @@ class ExpenseReport extends CommonObject /** * deleteline * - * @param int $rowid Row id - * @param User $fuser User - * @param int $notrigger 1=No trigger - * @return int Return integer <0 if KO, >0 if OK + * @param int $rowid Row id + * @param User|string $fuser User + * @param int<0,1> $notrigger 1=No trigger + * @return int<0,1> Return integer <0 if KO, >0 if OK */ public function deleteLine($rowid, $fuser = '', $notrigger = 0) { @@ -2473,8 +2471,6 @@ class ExpenseReport extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf; - $outputlangs->load("trips"); if (!dol_strlen($modele)) { @@ -2530,7 +2526,7 @@ class ExpenseReport extends CommonObject */ public function loadStateBoard() { - global $conf, $user; + global $user; $this->nb = array(); @@ -3040,7 +3036,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function insert($notrigger = 0, $fromaddline = false) { - global $user, $conf; + global $user; $error = 0; @@ -3182,7 +3178,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function update(User $user) { - global $langs, $conf; + global $langs; $error = 0; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 8763f965a90..5541cdc9ac3 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -307,7 +307,6 @@ class PaymentExpenseReport extends CommonObject public function update($user = null, $notrigger = 0) { // phpcs:enable - global $conf, $langs; $error = 0; // Clean parameters @@ -337,13 +336,8 @@ class PaymentExpenseReport extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; } - - // Check parameters - // Put here code to add control on parameters values - // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET"; - $sql .= " fk_expensereport=".(isset($this->fk_expensereport) ? $this->fk_expensereport : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; @@ -355,8 +349,6 @@ class PaymentExpenseReport extends CommonObject $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null"); - - $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -393,7 +385,6 @@ class PaymentExpenseReport extends CommonObject public function delete($user, $notrigger = 0) { // phpcs:enable - global $conf, $langs; $error = 0; $this->db->begin(); @@ -524,13 +515,14 @@ class PaymentExpenseReport extends CommonObject $this->id = 0; $this->fk_expensereport = 0; - $this->datec = ''; + $this->datec = dol_now(); $this->tms = dol_now(); - $this->datep = ''; - $this->amount = ''; + $this->datep = dol_now(); + $this->amount = 100; $this->fk_typepayment = 0; - $this->num_payment = ''; - $this->note = ''; + $this->num_payment = '123456'; + $this->note_public = 'Public note'; + $this->note_private = 'Private note'; $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; @@ -553,7 +545,7 @@ class PaymentExpenseReport extends CommonObject */ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { - global $langs, $conf; + global $langs; $error = 0; diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index bd3ba374d76..c1f474af0db 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Ferran Marcet + * Copyright (C) 2024 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 diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7f7511db38f..5c7fba47e8e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1929,7 +1929,7 @@ class CommandeFournisseur extends CommonOrder * @param int $date_end Date end of service * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param string $pu_ht_devise Amount in currency + * @param int|string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @param int $rang Rank @@ -2880,13 +2880,13 @@ class CommandeFournisseur extends CommonOrder * * @param int $rowid ID de la ligne de facture * @param string $desc Line description - * @param float $pu Unit price - * @param float $qty Quantity - * @param float $remise_percent Percent discount on line - * @param float $txtva VAT rate - * @param float $txlocaltax1 Localtax1 tax - * @param float $txlocaltax2 Localtax2 tax - * @param float $price_base_type Type of price base + * @param int|float $pu Unit price + * @param int|float $qty Quantity + * @param int|float $remise_percent Percent discount on line + * @param int|float $txtva VAT rate + * @param int|float $txlocaltax1 Localtax1 tax + * @param int|float $txlocaltax2 Localtax2 tax + * @param string $price_base_type Type of price base * @param int $info_bits Miscellaneous information * @param int $type Type of line (0=product, 1=service) * @param int $notrigger Disable triggers @@ -2894,11 +2894,11 @@ class CommandeFournisseur extends CommonOrder * @param integer $date_end Date end of service * @param array $array_options Extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param float $pu_ht_devise Unit price in currency + * @param int|float $pu_ht_devise Unit price in currency * @param string $ref_supplier Supplier ref * @return int Return integer < 0 if error, > 0 if ok */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = 0, $date_end = 0, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); @@ -3243,8 +3243,8 @@ class CommandeFournisseur extends CommonOrder /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Object user - * @param int $mode "opened", "awaiting" for orders awaiting reception + * @param User $user Object user + * @param string $mode "opened", "awaiting" for orders awaiting reception * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK */ public function load_board($user, $mode = 'opened') diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index cd90cf86179..c9b37398cae 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis + * Copyright (C) 2024 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 @@ -1196,9 +1197,9 @@ class FactureFournisseur extends CommonInvoice } if (isset($this->fk_project)) { if (empty($this->fk_project)) { - $this->fk_project = null; + $this->fk_project = 0; } else { - $this->fk_project = intval($this->fk_project); + $this->fk_project = (int) $this->fk_project; } } if (isset($this->cond_reglement_id)) { @@ -2064,7 +2065,7 @@ class FactureFournisseur extends CommonInvoice * @param int $fk_remise_except Id discount used * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $fk_code_ventilation = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = 0, $date_end = 0, $fk_code_ventilation = 0, $info_bits = 0, $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) { global $langs, $mysoc, $conf; diff --git a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php index 3d509d7d25c..c4652df83b1 100644 --- a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php +++ b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 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 @@ -154,7 +155,7 @@ class mod_knowledgerecord_standard extends ModeleNumRefKnowledgeRecord if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_knowledgerecord_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index c4695d86791..3cfa2ee7236 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -134,3 +134,5 @@ UserPublicPageDesc=You can enable a virtual card for this user. An url with the EnablePublicVirtualCard=Enable the user's virtual business card UserEnabledDisabled=User status changed: %s AlternativeEmailForOAuth2=Alternative Email for OAuth2 login +ConfirmDeleteContact= Are you sure that you want delete this contact ? +ContactDeleted= Contact has been delete successfully diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 6eb2db3db15..3c0d1e41776 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -4353,8 +4353,9 @@ if ($module == 'initmodule') { $mod = strtolower($module); $obj = strtolower($tabobj); $newproperty = dolGetButtonTitle($langs->trans('NewProperty'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.urlencode($module).'&tabobj=createproperty&obj='.urlencode($tabobj)); + $nbOfProperties = count($reflectorpropdefault['fields']); - print_barre_liste($langs->trans("ObjectProperties"), 0, $_SERVER["PHP_SELF"], '', '', '', '', '', 0, '', 0, $newproperty, '', '', 0, 0, 1); + print_barre_liste($langs->trans("ObjectProperties"), 0, $_SERVER["PHP_SELF"], '', '', '', '', '', $nbOfProperties, '', 0, $newproperty, '', '', 0, 0, 1); //var_dump($reflectorpropdefault);exit; print ''."\n"; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index f2ff645052c..ed4affb4e1a 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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,7 +91,7 @@ class MultiCurrency extends CommonObject public $fk_user; /** - * @var CurrencyRate|null The currency rate + * @var ?CurrencyRate The currency rate */ public $rate; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 51e44645703..b03747a8129 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -205,7 +205,7 @@ class Partnership extends CommonObject public function create(User $user, $notrigger = 0) { if ($this->fk_soc <= 0 && $this->fk_member <= 0) { - $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory"; + $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; return -1; } @@ -522,7 +522,7 @@ class Partnership extends CommonObject public function update(User $user, $notrigger = 0) { if ($this->fk_soc <= 0 && $this->fk_member <= 0) { - $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory"; + $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations return -1; } if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page). diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index 92c39356a7f..9dd883cd2fb 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 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 @@ -154,7 +155,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_partnership_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 086163975a3..0f37edaf398 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -807,7 +807,7 @@ if (empty($reshook)) { if ($fk_default_bom >= 0) { $object->fk_default_bom = $fk_default_bom; } else { - $object->fk_default_bom = null; + $object->fk_default_bom = 0; } $units = GETPOSTINT('units'); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c4b70c7a1f8..942a332d7a0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -311,7 +311,7 @@ class Product extends CommonObject /** * Status indicates whether the product is on sale '1' or not '0' * @var int - * @deprecated + * @deprecated Use $status instead * @see $status */ public $tosell; @@ -326,7 +326,7 @@ class Product extends CommonObject /** * Status indicate whether the product is available for purchase '1' or not '0' * @var int - * @deprecated + * @deprecated Use $status_buy instead * @see $status_buy */ public $tobuy; @@ -334,7 +334,7 @@ class Product extends CommonObject /** * Status indicates whether the product is a finished product '1' or a raw material '0' * - * @var int + * @var ?int */ public $finished; @@ -1971,7 +1971,7 @@ class Product extends CommonObject // Add new price $sql = "INSERT INTO ".$this->db->prefix()."product_price(price_level,date_price, fk_product, fk_user_author, price_label, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; - $sql .= " VALUES(".($level ? ((int) $level) : 1).", '".$this->db->idate($now)."', ".((int) $this->id).", ".((int) $user->id).", ".(empty($this->price_label)?"null":"'".$this->db->escape($this->price_label)."'").", ".((float) price2num($this->price)).", ".((float) price2num($this->price_ttc)).",'".$this->db->escape($this->price_base_type)."',".((int) $this->status).", ".((float) price2num($this->tva_tx)).", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").", ".((int) $this->tva_npr).","; + $sql .= " VALUES(".($level ? ((int) $level) : 1).", '".$this->db->idate($now)."', ".((int) $this->id).", ".((int) $user->id).", ".(empty($this->price_label) ? "null" : "'".$this->db->escape($this->price_label)."'").", ".((float) price2num($this->price)).", ".((float) price2num($this->price_ttc)).",'".$this->db->escape($this->price_base_type)."',".((int) $this->status).", ".((float) price2num($this->tva_tx)).", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").", ".((int) $this->tva_npr).","; $sql .= " ".price2num($this->localtax1_tx).", ".price2num($this->localtax2_tx).", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".price2num($this->price_min).", ".price2num($this->price_min_ttc).", ".price2num($this->price_by_qty).", ".((int) $conf->entity).",".($this->fk_price_expression > 0 ? ((int) $this->fk_price_expression) : 'null'); $sql .= ")"; @@ -2308,7 +2308,7 @@ class Product extends CommonObject * @param double $newprice New price * @param string $newpricebase HT or TTC * @param User $user Object user that make change - * @param double $newvat New VAT Rate (For example 8.5. Should not be a string) + * @param ?double $newvat New VAT Rate (For example 8.5. Should not be a string) * @param double $newminprice New price min * @param int $level 0=standard, >0 = level if multilevel prices * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT @@ -2320,7 +2320,7 @@ class Product extends CommonObject * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) + public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) { global $conf, $langs; @@ -2342,7 +2342,7 @@ class Product extends CommonObject } // Check parameters - if ($newvat == '') { + if ($newvat === null || $newvat == '') { // Maintain '' for backwards compatibility $newvat = $this->tva_tx; } diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index c0ec8226e3d..11b8b1db214 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ion Agorria * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 1fe8ae87fa5..7d387457b23 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -14,6 +14,7 @@ * Copyright (C) 2020-2021 Open-DSI * Copyright (C) 2022 Charlene Benke * Copyright (C) 2020-2023 Alexandre Spangaro + * Copyright (C) 2024 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 @@ -296,7 +297,7 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES')) { } else { $labelp = $langs->transnoentitiesnoconv("SellingPrice")." ".$i; } - $arrayfields['p.sellprice'.$i] = array('label' => $labelp, 'checked' => ($i == 1 ? 1 : 0), 'enabled' => getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => (float) ('40.'.sprintf('%03s', $i))); + $arrayfields['p.sellprice'.$i] = array('label' => $labelp, 'checked' => ($i == 1 ? 1 : 0), 'enabled' => getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => (float) ('40.'.sprintf('%03d', $i))); $arraypricelevel[$i] = array($i); } } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 754f465e574..260b922d5de 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -934,9 +934,9 @@ class Task extends CommonObjectLine * @param string $filteronproj Filter on project ref or label * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated only) * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @param string $filteronprojuser Filter on user that is a contact of project - * @param string $filterontaskuser Filter on user assigned to task - * @param Extrafields $extrafields Show additional column from project or task + * @param int $filteronprojuser Filter on user that is a contact of project + * @param int $filterontaskuser Filter on user assigned to task + * @param ?Extrafields $extrafields Show additional column from project or task * @param int $includebilltime Calculate also the time to bill and billed * @param array $search_array_options Array of search filters. Not Used yet. * @param int $loadextras Fetch all Extrafields on each project and task @@ -945,9 +945,9 @@ class Task extends CommonObjectLine * @param string $sortorder Sort order * @return array|string Array of tasks */ - public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '') + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = null, $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '') { - global $conf, $hookmanager; + global $hookmanager; $tasks = array(); @@ -1054,7 +1054,7 @@ class Task extends CommonObjectLine if ($filteronproj) { $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); } - if ($filteronprojstatus && $filteronprojstatus != '-1') { + if ($filteronprojstatus && (int) $filteronprojstatus != '-1') { $sql .= " AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).")"; } if ($morewherefilter) { diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 1cbedcc9342..0b78780cfe4 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -2,6 +2,7 @@ /* Copyright (C) 2018-2020 Thibault FOUCART * Copyright (C) 2018 Fédéric France * Copyright (C) 2023 Laurent Destailleur + * Copyright (C) 2024 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 @@ -689,7 +690,7 @@ if ($event->type == 'payout.created') { $companypaymentmode->stripe_card_ref = $db->escape($event->data->object->id); $companypaymentmode->fk_soc = $idthirdparty; $companypaymentmode->bank = null; - $companypaymentmode->label = null; + $companypaymentmode->label = ''; $companypaymentmode->number = $db->escape($event->data->object->id); $companypaymentmode->last_four = $db->escape($event->data->object->card->last4); $companypaymentmode->card_type = $db->escape($event->data->object->card->branding); @@ -725,7 +726,7 @@ if ($event->type == 'payout.created') { if ($companypaymentmode->id > 0) { // If we found a payment mode with the ID $companypaymentmode->bank = null; - $companypaymentmode->label = null; + $companypaymentmode->label = ''; $companypaymentmode->number = $db->escape($event->data->object->id); $companypaymentmode->last_four = $db->escape($event->data->object->card->last4); $companypaymentmode->proprio = $db->escape($event->data->object->billing_details->name); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 5d7b262f22e..67e29c85fc1 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Quentin Vial-Gouteyron * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2024 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 @@ -125,7 +126,7 @@ class Reception extends CommonObject public $listmeths; // List of carriers /** - * @var CommandeFournisseur + * @var ?CommandeFournisseur */ public $commandeFournisseur; @@ -731,7 +732,11 @@ class Reception extends CommonObject $this->fetch_origin(); if (empty($this->origin_object->lines)) { $res = $this->origin_object->fetch_lines(); - $this->commandeFournisseur = $this->origin_object; // deprecated + if ($this->origin_object instanceof CommandeFournisseur) { + $this->commandeFournisseur = $this->origin_object; // deprecated + } else { + $this->commandeFournisseur = null; // deprecated + } if ($res < 0) { return $res; } @@ -742,7 +747,7 @@ class Reception extends CommonObject $qty_wished = array(); $supplierorderdispatch = new CommandeFournisseurDispatch($this->db); - $filter = array('t.fk_commande'=>$this->origin_id); + $filter = array('t.fk_commande' => $this->origin_id); if (getDolGlobalInt('SUPPLIER_ORDER_USE_DISPATCH_STATUS')) { $filter['t.status'] = 1; // Restrict to lines with status validated } @@ -1305,7 +1310,7 @@ class Reception extends CommonObject global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php index 6a7b4d8c510..cb46d8323df 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -155,7 +156,7 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_recruitmentcandidature_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php index 50c2ab775e7..e95cfbb2ee8 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -155,7 +156,7 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is } else { - $num = sprintf("%04s", $max + 1); + $num = sprintf("%04d", $max + 1); } dol_syslog("mod_recruitmentjobposition_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 0159b9b93a9..4e7024d83c2 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -402,7 +402,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { if ($object->id > 0) { $object->paye = 0; - $object->id = $object->ref = null; + $object->id = 0; + $object->ref = ''; if (GETPOST('amount', 'alphanohtml')) { $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 8eda5988f80..52921b28c80 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -562,12 +562,12 @@ if (empty($reshook)) { } else { if ($result == -3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; - $object->code_client = null; + $object->code_client = ''; } if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; - $object->code_fournisseur = null; + $object->code_fournisseur = ''; } if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 7fd087024c3..db6e2158e1f 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Frédéric France + * Copyright (C) 2024 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 @@ -167,7 +168,7 @@ class Contacts extends DolibarrApi * @param int $includecount Count and return also number of elements the contact is used as a link for * @param int $includeroles Includes roles of the contact * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names - * @return array Array of contact objects + * @return Contact[] Array of contact objects * * @throws RestException */ @@ -273,6 +274,8 @@ class Contacts extends DolibarrApi * * @param array $request_data Request datas * @return int ID of contact + * + * @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation */ public function post($request_data = null) { @@ -311,7 +314,7 @@ class Contacts extends DolibarrApi * * @param int $id Id of contact to update * @param array $request_data Datas - * @return Object Updated object + * @return Object|false Updated object, false when issue toupdate */ public function put($id, $request_data = null) { @@ -389,6 +392,7 @@ class Contacts extends DolibarrApi * @return int ID of user * * @url POST {id}/createUser + * @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation */ public function createUser($id, $request_data = null) { @@ -573,8 +577,8 @@ class Contacts extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Data to validate - * @return array + * @param string[]|null $data Data to validate + * @return string[] * @throws RestException */ private function _validate($data) diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 86bbab8910c..a30927fafb3 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -94,43 +94,43 @@ class CompanyBankAccount extends Account 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => -1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150',), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 25, 'notnull' => 0, 'visible' => -1,), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => -1,), - 'label' => array('type' => 'varchar(200)', 'label' => 'Label', 'enabled' => 1, 'position' => 35, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1', 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'csslist' => 'tdoverflowmax150',), - 'bank' => array('type' => 'varchar(255)', 'label' => 'Bank', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'code_banque' => array('type' => 'varchar(128)', 'label' => 'Codebanque', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'code_guichet' => array('type' => 'varchar(6)', 'label' => 'Codeguichet', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'number' => array('type' => 'varchar(255)', 'label' => 'Number', 'enabled' => 1, 'position' => 55, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'cle_rib' => array('type' => 'varchar(5)', 'label' => 'Clerib', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'bic' => array('type' => 'varchar(20)', 'label' => 'Bic', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'iban_prefix' => array('type' => 'varchar(34)', 'label' => 'Ibanprefix', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'domiciliation' => array('type' => 'varchar(255)', 'label' => 'Domiciliation', 'enabled' => 1, 'position' => 75, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'proprio' => array('type' => 'varchar(60)', 'label' => 'Proprio', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'owner_address' => array('type' => 'varchar(255)', 'label' => 'Owneraddress', 'enabled' => 1, 'position' => 85, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'default_rib' => array('type' => 'smallint(6)', 'label' => 'Defaultrib', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => '1',), - 'state_id' => array('type' => 'integer', 'label' => 'Stateid', 'enabled' => 1, 'position' => 95, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'fk_country' => array('type' => 'integer', 'label' => 'Fkcountry', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1', 'css' => 'maxwidth500 widthcentpercentminusxx',), - 'currency_code' => array('type' => 'varchar(3)', 'label' => 'Currencycode', 'enabled' => 1, 'position' => 105, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'rum' => array('type' => 'varchar(32)', 'label' => 'Rum', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'date_rum' => array('type' => 'date', 'label' => 'Daterum', 'enabled' => 1, 'position' => 115, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'frstrecur' => array('type' => 'varchar(16)', 'label' => 'Frstrecur', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 900, 'notnull' => 0, 'visible' => -2, 'alwayseditable' => '1',), - 'last_four' => array('type' => 'varchar(4)', 'label' => 'Lastfour', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'card_type' => array('type' => 'varchar(255)', 'label' => 'Cardtype', 'enabled' => 1, 'position' => 135, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'cvn' => array('type' => 'varchar(255)', 'label' => 'Cvn', 'enabled' => 1, 'position' => 140, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'exp_date_month' => array('type' => 'integer', 'label' => 'Expdatemonth', 'enabled' => 1, 'position' => 145, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'exp_date_year' => array('type' => 'integer', 'label' => 'Expdateyear', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'country_code' => array('type' => 'varchar(10)', 'label' => 'Countrycode', 'enabled' => 1, 'position' => 155, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'approved' => array('type' => 'integer', 'label' => 'Approved', 'enabled' => 1, 'position' => 160, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'position' => 165, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'ending_date' => array('type' => 'date', 'label' => 'Endingdate', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'max_total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Maxtotalamountofallpayments', 'enabled' => 1, 'position' => 175, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'preapproval_key' => array('type' => 'varchar(255)', 'label' => 'Preapprovalkey', 'enabled' => 1, 'position' => 180, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'starting_date' => array('type' => 'date', 'label' => 'Startingdate', 'enabled' => 1, 'position' => 185, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Totalamountofallpayments', 'enabled' => 1, 'position' => 190, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'stripe_card_ref' => array('type' => 'varchar(128)', 'label' => 'Stripecardref', 'enabled' => 1, 'position' => 195, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => '1',), - 'comment' => array('type' => 'varchar(255)', 'label' => 'Comment', 'enabled' => 1, 'position' => 205, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'ipaddress' => array('type' => 'varchar(68)', 'label' => 'Ipaddress', 'enabled' => 1, 'position' => 210, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'stripe_account' => array('type' => 'varchar(128)', 'label' => 'Stripeaccount', 'enabled' => 1, 'position' => 215, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), + 'label' => array('type' => 'varchar(200)', 'label' => 'Label', 'enabled' => 1, 'position' => 35, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'csslist' => 'tdoverflowmax150',), + 'bank' => array('type' => 'varchar(255)', 'label' => 'Bank', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'code_banque' => array('type' => 'varchar(128)', 'label' => 'Codebanque', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'code_guichet' => array('type' => 'varchar(6)', 'label' => 'Codeguichet', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'number' => array('type' => 'varchar(255)', 'label' => 'Number', 'enabled' => 1, 'position' => 55, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'cle_rib' => array('type' => 'varchar(5)', 'label' => 'Clerib', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'bic' => array('type' => 'varchar(20)', 'label' => 'Bic', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'iban_prefix' => array('type' => 'varchar(34)', 'label' => 'Ibanprefix', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'domiciliation' => array('type' => 'varchar(255)', 'label' => 'Domiciliation', 'enabled' => 1, 'position' => 75, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'proprio' => array('type' => 'varchar(60)', 'label' => 'Proprio', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'owner_address' => array('type' => 'varchar(255)', 'label' => 'Owneraddress', 'enabled' => 1, 'position' => 85, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'default_rib' => array('type' => 'smallint(6)', 'label' => 'Defaultrib', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => 1,), + 'state_id' => array('type' => 'integer', 'label' => 'Stateid', 'enabled' => 1, 'position' => 95, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'fk_country' => array('type' => 'integer', 'label' => 'Fkcountry', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx',), + 'currency_code' => array('type' => 'varchar(3)', 'label' => 'Currencycode', 'enabled' => 1, 'position' => 105, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'rum' => array('type' => 'varchar(32)', 'label' => 'Rum', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'date_rum' => array('type' => 'date', 'label' => 'Daterum', 'enabled' => 1, 'position' => 115, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'frstrecur' => array('type' => 'varchar(16)', 'label' => 'Frstrecur', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 900, 'notnull' => 0, 'visible' => -2, 'alwayseditable' => 1,), + 'last_four' => array('type' => 'varchar(4)', 'label' => 'Lastfour', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'card_type' => array('type' => 'varchar(255)', 'label' => 'Cardtype', 'enabled' => 1, 'position' => 135, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'cvn' => array('type' => 'varchar(255)', 'label' => 'Cvn', 'enabled' => 1, 'position' => 140, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'exp_date_month' => array('type' => 'integer', 'label' => 'Expdatemonth', 'enabled' => 1, 'position' => 145, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'exp_date_year' => array('type' => 'integer', 'label' => 'Expdateyear', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'country_code' => array('type' => 'varchar(10)', 'label' => 'Countrycode', 'enabled' => 1, 'position' => 155, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'approved' => array('type' => 'integer', 'label' => 'Approved', 'enabled' => 1, 'position' => 160, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'position' => 165, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'ending_date' => array('type' => 'date', 'label' => 'Endingdate', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'max_total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Maxtotalamountofallpayments', 'enabled' => 1, 'position' => 175, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'preapproval_key' => array('type' => 'varchar(255)', 'label' => 'Preapprovalkey', 'enabled' => 1, 'position' => 180, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'starting_date' => array('type' => 'date', 'label' => 'Startingdate', 'enabled' => 1, 'position' => 185, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Totalamountofallpayments', 'enabled' => 1, 'position' => 190, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'stripe_card_ref' => array('type' => 'varchar(128)', 'label' => 'Stripecardref', 'enabled' => 1, 'position' => 195, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => 1,), + 'comment' => array('type' => 'varchar(255)', 'label' => 'Comment', 'enabled' => 1, 'position' => 205, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'ipaddress' => array('type' => 'varchar(68)', 'label' => 'Ipaddress', 'enabled' => 1, 'position' => 210, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'stripe_account' => array('type' => 'varchar(128)', 'label' => 'Stripeaccount', 'enabled' => 1, 'position' => 215, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => 0, 'position' => 230), ); diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 1fd810a9793..fd0109db515 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -133,6 +133,29 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; } +if ($action == 'confirm_delete' && $user->hasRight('societe', 'contact', 'delete')) { + $id = GETPOST('id', 'int'); + if (!empty($id) && $socid > 0) { + $db->begin(); + + $sql = "DELETE t, et FROM llx_socpeople AS t"; + $sql .= " LEFT JOIN llx_socpeople_extrafields AS et ON t.rowid = et.fk_object"; + $sql .= " WHERE t.fk_soc = ".((int) $socid); + $sql .= " AND t.rowid = ".((int) $id); + $sql .= " AND ((t.fk_user_creat = ".((int) $user->id)." AND t.priv = 1) OR t.priv = 0)"; + + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror(), null, 'errors'); + $db->rollback(); + } else { + $db->commit(); + setEventMessages('ContactDeleted', null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$socid); + exit(); + } + } +} /* * View @@ -184,6 +207,18 @@ if ($action != 'presend') { $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1); } } +if ($action == 'delete') { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?id='.GETPOST('id').'&socid='.$object->id, + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteContact', GETPOST('id', 'alpha')), + 'confirm_delete', + '', + 0, + 1 + ); + print $formconfirm; +} // End of page llxFooter(); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 778bd6ef730..cdfb8beef07 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -76,7 +76,7 @@ class Ticket extends CommonObject /** - * @var string Hash to identify ticket publicly + * @var ?string Hash to identify ticket publicly */ public $track_id; @@ -97,17 +97,17 @@ class Ticket extends CommonObject public $fk_contract; /** - * @var string Person email who have create ticket + * @var ?string Email of person who created the ticket */ public $origin_email; /** - * @var int User id who have create ticket + * @var int User id who created the ticket */ public $fk_user_create; /** - * @var int User id who have ticket assigned + * @var int User id who the ticket is assigned to */ public $fk_user_assign; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index ef23ce4857d..7e183f75362 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -884,7 +884,7 @@ class ProductCombination if ($result < 0) { //In case the error is not related with an already existing product if ($newproduct->error != 'ErrorProductAlreadyExists') { - $this->error[] = $newproduct->error; + $this->error = $newproduct->error; $this->errors = $newproduct->errors; $this->db->rollback(); return -1; diff --git a/test/phpunit/RestAPIContactTest.php b/test/phpunit/RestAPIContactTest.php index 4af37c718e0..dd4173ab6ff 100644 --- a/test/phpunit/RestAPIContactTest.php +++ b/test/phpunit/RestAPIContactTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 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 @@ -229,7 +230,7 @@ class RestAPIContactTest extends CommonClassTest print_r($updateResponse); // Check if the updated fields match the changes you made - $this->assertTrue($updateResponse['firstname'] === $updateBody['firstname'], 'Update might have failed'); + $this->assertEquals($updateBody['firstname'], $updateResponse['firstname'], 'Update failed for request body: '.$updateRequestBody); // Deleting the Contact /*