diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index bd8bb9a3462..889cbf81fb3 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -576,7 +576,10 @@ return [ 'htdocs/core/lib/intracommreport.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/invoice.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/invoice2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/lib/ldap.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], + 'htdocs/core/lib/ldap.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownArrayFunctionParamType'], + 'htdocs/core/lib/memory.lib.php' => ['PhanTypeMismatchDimFetch'], + 'htdocs/core/lib/multicurrency.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], + 'htdocs/core/lib/pdf.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/lib/loan.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/mailmanspip.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/memory.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchDimFetch'], @@ -598,7 +601,7 @@ return [ 'htdocs/core/lib/resource.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/salaries.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/security.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], - 'htdocs/core/lib/security2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable'], + 'htdocs/core/lib/security2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/lib/sendings.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/lib/signature.lib.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/lib/socialnetwork.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], @@ -975,7 +978,6 @@ return [ 'htdocs/margin/lib/margins.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/margin/productMargins.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/master.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/modulebuilder/index.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/mrp/class/api_mos.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/mrp/class/mo.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], 'htdocs/mrp/lib/mrp.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 22f33364671..989b37b0f80 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -323,12 +323,12 @@ return [ // mymodule seen in cti, but not in git. .'|htdocs/custom/mymodule/.*' // @phpstan-ignore-line .'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' // @phpstan-ignore-line - .'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line + //.'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line // Included as stub (better analysis) .'|htdocs/includes/nusoap/.*' // @phpstan-ignore-line // Included as stub (old version + incompatible typing hints) .'|htdocs/includes/restler/.*' // @phpstan-ignore-line - // Included as stub (did not seem properly analysed by phan without it) + // Included as stub (did not seem properly analyzed by phan without it) .'|htdocs/includes/stripe/.*' // @phpstan-ignore-line .'|htdocs/conf/conf.php' // @phpstan-ignore-line // .'|htdocs/[^h].*/.*' // For testing @phpstan-ignore-line diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index c3c74cd9e69..0882c22a97a 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -175,10 +175,14 @@ class DolibarrApi // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Clean sensible object datas + * Clean sensitive object data + * @phpstan-template T of Object * * @param Object $object Object to clean * @return Object Object with cleaned properties + * + * @phpstan-param T $object + * @phpstan-return T */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 14169dfe17c..bcac923ba58 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2019 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 @@ -133,7 +134,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedManualEntries").'' + 'text' => ''.$langs->trans("NoRecordedManualEntries").'' ); } @@ -141,7 +142,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -156,9 +157,9 @@ class box_accountancy_last_manual_entries extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 284d8ac13ed..bd35f9a302f 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2019 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 @@ -109,9 +110,9 @@ class box_accountancy_suspense_account extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 5bd9889e041..73f598a3ac6 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2014 Charles-Fr BENKE * Copyright (C) 2015 Frederic 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 @@ -142,7 +143,7 @@ class box_actions extends ModeleBoxes $this->info_box_contents[$line][0] = array( 'td' => 'class="tdoverflowmax200"', 'text' => $actionstatic->getNomUrl(1), - 'text2'=> $late, + 'text2' => $late, 'asis' => 1 ); @@ -176,7 +177,7 @@ class box_actions extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoActionsToDo").'' + 'text' => ''.$langs->trans("NoActionsToDo").'' ); } @@ -184,7 +185,7 @@ class box_actions extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql) ); } @@ -199,9 +200,9 @@ class box_actions extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_actions_future.php b/htdocs/core/boxes/box_actions_future.php index 0e5c57f2c04..8c1b19335a2 100644 --- a/htdocs/core/boxes/box_actions_future.php +++ b/htdocs/core/boxes/box_actions_future.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2014 Charles-Fr BENKE * Copyright (C) 2015 Frederic 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 box_actions_future extends ModeleBoxes $this->info_box_contents[$line][0] = array( 'td' => 'class="tdoverflowmax200"', 'text' => $actionstatic->getNomUrl(1), - 'text2'=> $late, + 'text2' => $late, 'asis' => 1 ); @@ -179,7 +180,7 @@ class box_actions_future extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoActionsToDo").'' + 'text' => ''.$langs->trans("NoActionsToDo").'' ); } @@ -187,7 +188,7 @@ class box_actions_future extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql) ); } @@ -202,9 +203,9 @@ class box_actions_future extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 88571ed872b..d637230d409 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012 Charles-François BENKE * Copyright (C) 2005-2015 Laurent Destailleur * Copyright (C) 2014-2021 Frederic 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 @@ -88,7 +89,7 @@ class box_activity extends ModeleBoxes $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); $this->info_box_head = array( 'text' => $textHead, - 'limit'=> dol_strlen($textHead), + 'limit' => dol_strlen($textHead), ); // compute the year limit to show @@ -175,7 +176,7 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>''.$langs->trans("NoRecordedProposals").'', + 'text' => ''.$langs->trans("NoRecordedProposals").'', ); $line++; } @@ -235,7 +236,7 @@ class box_activity extends ModeleBoxes $this->info_box_contents[$line][1] = array( 'td' => '', - 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), + 'text' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), ); $this->info_box_contents[$line][2] = array( @@ -261,7 +262,7 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedOrders"), + 'text' => $langs->trans("NoRecordedOrders"), ); $line++; } @@ -349,7 +350,7 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), + 'text' => $langs->trans("NoRecordedInvoices"), ); $line++; } @@ -418,7 +419,7 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedUnpaidInvoices"), + 'text' => $langs->trans("NoRecordedUnpaidInvoices"), ); $line++; } @@ -439,9 +440,9 @@ class box_activity extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index ffb16d94071..d7e30b83d0a 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -170,9 +170,9 @@ class box_birthdays extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 062eeb31506..0453d30ee01 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -162,9 +162,9 @@ class box_birthdays_members extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index 351d9372869..acd95fc5563 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic 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 box_boms extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedOrders").'' + 'text' => ''.$langs->trans("NoRecordedOrders").'' ); } @@ -159,7 +160,7 @@ class box_boms extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -174,9 +175,9 @@ class box_boms extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 8fbdfbabda6..dcbe2c7da41 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Frederic 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 @@ -116,7 +117,7 @@ class box_bookmarks extends ModeleBoxes $this->info_box_contents[$line][0] = array( 'td' => 'class="center" colspan="2"', 'tooltip' => $mytxt, - 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + 'url' => DOL_URL_ROOT.'/bookmarks/list.php', 'text' => $mytxt, ); } @@ -124,7 +125,7 @@ class box_bookmarks extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -139,9 +140,9 @@ class box_bookmarks extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 105b6b9f557..08e3c1af516 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2021 Frederic 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 @@ -149,7 +150,7 @@ class box_clients extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedCustomers").'' + 'text' => ''.$langs->trans("NoRecordedCustomers").'' ); } @@ -157,7 +158,7 @@ class box_clients extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql) ); } @@ -172,9 +173,9 @@ class box_clients extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index bb8364afe04..38a36a4175f 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic 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 @@ -188,7 +189,7 @@ class box_commandes extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedOrders").'' + 'text' => ''.$langs->trans("NoRecordedOrders").'' ); } @@ -196,7 +197,7 @@ class box_commandes extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -211,9 +212,9 @@ class box_commandes extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 046ce9034b0..7bdca79e5ac 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Frederic 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 @@ -165,7 +166,7 @@ class box_comptes extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -180,9 +181,9 @@ class box_comptes extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 162afd93db9..7cc479d7a8b 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2018 Josep Lluís Amador * Copyright (C) 2020 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 @@ -176,7 +177,7 @@ class box_contacts extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="nowrap right" width="18"', 'text' => $contactstatic->getLibStatut(3), - 'asis'=>1, + 'asis' => 1, ); $line++; @@ -185,8 +186,8 @@ class box_contacts extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedContacts").'', - 'asis'=> 1 + 'text' => ''.$langs->trans("NoRecordedContacts").'', + 'asis' => 1 ); } @@ -194,7 +195,7 @@ class box_contacts extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -209,9 +210,9 @@ class box_contacts extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index b6cbb4b8d8a..867651ae408 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Regis Houssin * Copyright (C) 2015 Frederic France * Copyright (C) 2016-2017 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 @@ -137,14 +138,14 @@ class box_contracts extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', 'text' => $contractstatic->getNomUrl(1), - 'text2'=> $late, - 'asis'=>1 + 'text2' => $late, + 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $thirdpartytmp->getNomUrl(1), - 'asis'=>1 + 'asis' => 1 ); $this->info_box_contents[$line][] = array( @@ -155,7 +156,7 @@ class box_contracts extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall right"', 'text' => $contractstatic->getLibStatut(7), - 'asis'=>1, + 'asis' => 1, ); $line++; @@ -164,7 +165,7 @@ class box_contracts extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedContracts").'' + 'text' => ''.$langs->trans("NoRecordedContracts").'' ); } @@ -172,7 +173,7 @@ class box_contracts extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -187,9 +188,9 @@ class box_contracts extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php index dba505e6c6f..76e6db5dddc 100644 --- a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic 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 @@ -149,7 +150,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes if ($num == 0 || $nboutstandingbillreachedcustomers == 0) { $this->info_box_contents[0][] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("None").'' + 'text' => ''.$langs->trans("None").'' ); } @@ -157,7 +158,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql) ); } @@ -172,9 +173,9 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 4de552b0b0d..1fbb3216444 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -315,9 +315,9 @@ class box_dolibarr_state_board extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d0bafc2cb95..1d3930a86f5 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Frederic 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 @@ -102,9 +103,9 @@ class box_external_rss extends ModeleBoxes $this->info_box_head = array( 'text' => $title, 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), - 'subpicto'=>'globe', - 'target'=>'_blank', + 'subtext' => $langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), + 'subpicto' => 'globe', + 'target' => '_blank', ); } @@ -206,9 +207,9 @@ class box_external_rss extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 78ea3e70df4..0fa3a0af7ab 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -223,9 +223,9 @@ class box_factures extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index cfaeddc5b0f..a52cec120bf 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -219,9 +219,9 @@ class box_factures_fourn extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index c75418ae958..09ac76fce4e 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -261,9 +261,9 @@ class box_factures_fourn_imp extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 664b32514a1..42e3e297c86 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -273,9 +273,9 @@ class box_factures_imp extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_fediverse.php b/htdocs/core/boxes/box_fediverse.php index 485b8e6ec27..479f47a2684 100644 --- a/htdocs/core/boxes/box_fediverse.php +++ b/htdocs/core/boxes/box_fediverse.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 @@ -150,9 +151,9 @@ class box_fediverse extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index d27b383d599..406a9c45305 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Frederic 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 @@ -153,7 +154,7 @@ class box_ficheinter extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$i][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedInterventions").'' + 'text' => ''.$langs->trans("NoRecordedInterventions").'' ); } @@ -161,7 +162,7 @@ class box_ficheinter extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -176,9 +177,9 @@ class box_ficheinter extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index ee5ae31472f..4f8b8211f33 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2019 Frederic France * Copyright (C) 2020 Pierre Ardoin + * 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 @@ -141,7 +142,7 @@ class box_fournisseurs extends ModeleBoxes $langs->load("suppliers"); $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedSuppliers").'' + 'text' => ''.$langs->trans("NoRecordedSuppliers").'' ); } @@ -149,7 +150,7 @@ class box_fournisseurs extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -164,9 +165,9 @@ class box_fournisseurs extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 7112538c9de..860ed045ecd 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -312,9 +312,9 @@ class box_funnel_of_prospection extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No $stringtoprint .=, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No $stringtoprint .=, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 8cdc6bcc708..eb71fb09538 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Charlie 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 @@ -137,7 +138,7 @@ class box_goodcustomers extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedCustomers").'' + 'text' => ''.$langs->trans("NoRecordedCustomers").'' ); } @@ -145,7 +146,7 @@ class box_goodcustomers extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -160,9 +161,9 @@ class box_goodcustomers extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 00e83f97f3e..17aae230954 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.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 @@ -77,13 +78,13 @@ class box_graph_invoices_permonth extends ModeleBoxes $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -260,9 +261,9 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow .= ''; $stringtoshow .= ''; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat' => $stringtoshow); } else { - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength' => 500, 'text' => $mesg); } } else { $this->info_box_contents[0][0] = array( @@ -275,9 +276,9 @@ class box_graph_invoices_permonth extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index f9c1638d02d..e4ea9a1cf3a 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.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 @@ -74,13 +75,13 @@ class box_graph_invoices_peryear extends ModeleBoxes $text = $langs->trans("Turnover", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -193,9 +194,9 @@ class box_graph_invoices_peryear extends ModeleBoxes $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= $px2->show(); - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat' => $stringtoshow); } else { - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength' => 500, 'text' => $mesg); } } else { $this->info_box_contents[0][0] = array( @@ -208,9 +209,9 @@ class box_graph_invoices_peryear extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 27e8d4e9205..2c0f4299a9e 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.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 @@ -75,13 +76,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -255,9 +256,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $stringtoshow .= ''; $stringtoshow .= ''; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat' => $stringtoshow); } else { - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); + $this->info_box_contents[0][0] = array('tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength' => 500, 'text' => $mesg); } } else { $this->info_box_contents[0][0] = array( @@ -270,9 +271,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index 9bd1b4ab034..c4ca39e598c 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel * Copyright (C) 2019-2021 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 @@ -203,9 +204,9 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 5dd1c32342d..334e747a8a4 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel * Copyright (C) 2019-2021 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 @@ -164,7 +165,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes $stringtoprint .= $px1->show($totalnb ? 0 : 1); } $stringtoprint .= ''; - $this->info_box_contents[][]=array( + $this->info_box_contents[][] = array( 'td' => 'class="center"', 'text' => $stringtoprint ); @@ -185,9 +186,9 @@ class box_graph_nb_tickets_type extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php index e9c92ba8666..271bf534cdb 100644 --- a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php +++ b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel * Copyright (C) 2019-2021 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,9 +167,9 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index e50cc71a1e7..faae74f9041 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.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 @@ -76,13 +77,13 @@ class box_graph_orders_permonth extends ModeleBoxes $text = $langs->trans("BoxCustomersOrdersPerMonth", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -260,15 +261,15 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, + 'textnoformat' => $stringtoshow, ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => $mesg, ); } @@ -283,9 +284,9 @@ class box_graph_orders_permonth extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index f9a5d0751a5..6b75fdf3368 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.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 @@ -75,13 +76,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -259,15 +260,15 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, + 'textnoformat' => $stringtoshow, ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => $mesg, ); } @@ -282,9 +283,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index f9e5d63ecf6..eeb4e2a4a29 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -1,6 +1,7 @@ * 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 @@ -125,13 +126,13 @@ class box_graph_product_distribution extends ModeleBoxes $text = $langs->trans("BoxProductDistribution", $max).' - '.$langs->trans("Year").': '.$year; $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); @@ -154,7 +155,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data2)) { $showpointvalue = 0; $nocolor = 1; - $data2 = array(array(0=>$langs->trans("None"), 1=>1)); + $data2 = array(array(0 => $langs->trans("None"), 1 => 1)); } $filenamenb = $dir."/prodserforpropal-".$year.".png"; @@ -217,7 +218,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data3)) { $showpointvalue = 0; $nocolor = 1; - $data3 = array(array(0=>$langs->trans("None"), 1=>1)); + $data3 = array(array(0 => $langs->trans("None"), 1 => 1)); } $filenamenb = $dir."/prodserfororder-".$year.".png"; @@ -282,7 +283,7 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($data1)) { $showpointvalue = 0; $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + $data1 = array(array(0 => $langs->trans("None"), 1 => 1)); } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; @@ -408,12 +409,12 @@ class box_graph_product_distribution extends ModeleBoxes $this->info_box_contents[0][0] = array( 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, + 'textnoformat' => $stringtoshow, ); } else { $this->info_box_contents[0][0] = array( 'td' => 'class="nohover left"', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ''.$mesg.'' ); } @@ -422,9 +423,9 @@ class box_graph_product_distribution extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index e153e4bbe92..52520e3cf14 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.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 @@ -78,13 +79,13 @@ class box_graph_propales_permonth extends ModeleBoxes $text = $langs->trans("BoxProposalsPerMonth", $max); $this->info_box_head = array( 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, // Set to 1 if it's a box graph - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($text), + 'graph' => 1, // Set to 1 if it's a box graph + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); $dir = ''; // We don't need a path because image file will not be saved into disk @@ -256,13 +257,13 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, + 'textnoformat' => $stringtoshow, ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', + 'tr' => 'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength' => 500, 'text' => $mesg, @@ -279,9 +280,9 @@ class box_graph_propales_permonth extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 54826b28378..e12fe6a6d6e 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel * Copyright (C) 2019-2021 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 @@ -180,7 +181,7 @@ class box_graph_ticket_by_severity extends ModeleBoxes $stringtoprint .= $px1->show($totalnb ? 0 : 1); } $stringtoprint .= ''; - $this->info_box_contents[][]=array( + $this->info_box_contents[][] = array( 'td' => 'class="center"', 'text' => $stringtoprint ); @@ -201,9 +202,9 @@ class box_graph_ticket_by_severity extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_last_knowledgerecord.php b/htdocs/core/boxes/box_last_knowledgerecord.php index 499b108ed0e..88a12929e0e 100644 --- a/htdocs/core/boxes/box_last_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_knowledgerecord.php @@ -186,9 +186,9 @@ class box_last_knowledgerecord extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_last_modified_knowledgerecord.php b/htdocs/core/boxes/box_last_modified_knowledgerecord.php index 8a574e2d237..ca121fc409c 100644 --- a/htdocs/core/boxes/box_last_modified_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_modified_knowledgerecord.php @@ -186,9 +186,9 @@ class box_last_modified_knowledgerecord extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 9958dcaf4f6..abdc6653331 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * 2016 Christophe Battarel * Copyright (C) 2019-2021 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 @@ -175,7 +176,7 @@ class box_last_modified_ticket extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$i][0] = array( 'td' => '', - 'text'=>''.$langs->trans("BoxLastModifiedTicketNoRecordedTickets").'' + 'text' => ''.$langs->trans("BoxLastModifiedTicketNoRecordedTickets").'' ); } } else { @@ -192,9 +193,9 @@ class box_last_modified_ticket extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index aa3f6464ee4..833af7f3cc1 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2016 Jean-François FERRY * Copyright (C) 2016 Christophe Battarel * Copyright (C) 2018-2021 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 @@ -186,9 +187,9 @@ class box_last_ticket extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index be72337879c..6561ebfe695 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012 Charles-François BENKE * Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2014-2020 Frederic 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 @@ -63,7 +64,7 @@ class box_lastlogin extends ModeleBoxes $textHead = $langs->trans("BoxLoginInformation"); $this->info_box_head = array( 'text' => $textHead, - 'limit'=> dol_strlen($textHead), + 'limit' => dol_strlen($textHead), ); $line = 0; @@ -97,9 +98,9 @@ class box_lastlogin extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 98efd0db77f..3209b710505 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -257,9 +257,9 @@ class box_members_by_tags extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 9a1ecb1bc76..812ad837abb 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -257,9 +257,9 @@ class box_members_by_type extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index a33b2b7577c..3f3d74f6c10 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-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 @@ -134,7 +135,7 @@ class box_members_last_modified extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' =>$memberstatic->company, + 'text' => $memberstatic->company, ); $this->info_box_contents[$line][] = array( @@ -159,7 +160,7 @@ class box_members_last_modified extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), + 'text' => $langs->trans("NoRecordedCustomers"), ); } @@ -167,7 +168,7 @@ class box_members_last_modified extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -182,9 +183,9 @@ class box_members_last_modified extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 8dbb96df25f..c1d637ebada 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-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 @@ -158,7 +159,7 @@ class box_members_last_subscriptions extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedMembers").'', + 'text' => ''.$langs->trans("NoRecordedMembers").'', ); } @@ -166,7 +167,7 @@ class box_members_last_subscriptions extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -181,9 +182,9 @@ class box_members_last_subscriptions extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index a06348c5f37..7b262f595eb 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -222,9 +222,9 @@ class box_members_subscriptions_by_year extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index c29cb773c33..985f7c48e3d 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic 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 box_mos extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedOrders").'' + 'text' => ''.$langs->trans("NoRecordedOrders").'' ); } @@ -156,7 +157,7 @@ class box_mos extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -171,9 +172,9 @@ class box_mos extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 3b3654695f1..82299daf345 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -236,9 +236,9 @@ class box_produits extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 760bb2bd189..650040367e2 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -228,9 +228,9 @@ class box_produits_alerte_stock extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 974e869b1a7..c2713dff76b 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Juan José Menent * Copyright (C) 2020 Pierre Ardoin + * 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 @@ -72,7 +73,7 @@ class box_project extends ModeleBoxes $totalnbTask = 0; $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); $i = 0; // list the summary of the orders @@ -206,9 +207,9 @@ class box_project extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_project_opportunities.php b/htdocs/core/boxes/box_project_opportunities.php index aedb173421d..53a30d2ae01 100644 --- a/htdocs/core/boxes/box_project_opportunities.php +++ b/htdocs/core/boxes/box_project_opportunities.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Juan José Menent * Copyright (C) 2020 Pierre Ardoin + * 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 @@ -69,7 +70,7 @@ class box_project_opportunities extends ModeleBoxes $this->max = $max; $textHead = $langs->trans("OpenedProjectsOpportunities"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); $i = 0; // list the summary of the orders @@ -146,7 +147,7 @@ class box_project_opportunities extends ModeleBoxes $this->info_box_contents[$i][] = array('td' => 'class="amount right nowraponall"', 'text' => ($projectstatic->opp_amount ? price($projectstatic->opp_amount) : '')); - $this->info_box_contents[$i][] = array('td' => 'class="nowraponall"', 'asis'=>1, 'text' => ($projectstatic->opp_status_code ? $langs->trans("OppStatus".$projectstatic->opp_status_code).' ' : '').'('.round($projectstatic->opp_percent).'%)'); + $this->info_box_contents[$i][] = array('td' => 'class="nowraponall"', 'asis' => 1, 'text' => ($projectstatic->opp_status_code ? $langs->trans("OppStatus".$projectstatic->opp_status_code).' ' : '').'('.round($projectstatic->opp_percent).'%)'); $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); @@ -191,9 +192,9 @@ class box_project_opportunities extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 40d286f54d9..02fe9be8912 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2021 Frederic France * Copyright (C) 2020 Pierre Ardoin + * 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 @@ -142,7 +143,7 @@ class box_propales extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', 'text' => $propalstatic->getNomUrl(1), - 'text2'=> $late, + 'text2' => $late, 'asis' => 1, ); @@ -173,7 +174,7 @@ class box_propales extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProposals"), + 'text' => $langs->trans("NoRecordedProposals"), ); } @@ -181,7 +182,7 @@ class box_propales extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -196,9 +197,9 @@ class box_propales extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 59cbebc54bb..88c93c86700 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2019 Frederic 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 box_prospect extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedProspects").'' + 'text' => ''.$langs->trans("NoRecordedProspects").'' ); } @@ -178,9 +179,9 @@ class box_prospect extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 539781c0da9..e30617482f2 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2017 Nicolas Zabouri + * 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 @@ -194,9 +195,9 @@ class box_scheduled_jobs extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 6a9dd91c55a..25df9d0275a 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2017 Nicolas Zabouri + * 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 @@ -189,7 +190,7 @@ class box_services_contracts extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), - 'text2'=> $late, + 'text2' => $late, ); $this->info_box_contents[$i][] = array( @@ -202,7 +203,7 @@ class box_services_contracts extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$i][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoContractedProducts").'' + 'text' => ''.$langs->trans("NoContractedProducts").'' ); } @@ -225,9 +226,9 @@ class box_services_contracts extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index dd74c078000..46dec068b35 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.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 @@ -142,7 +143,7 @@ class box_services_expired extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateEndPlanned").': '.dol_print_date($dateline, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($dateline, 'day', 'tzuserrel'), - 'text2'=> $late, + 'text2' => $late, ); $this->info_box_contents[$i][] = array( @@ -166,7 +167,7 @@ class box_services_expired extends ModeleBoxes } else { $this->info_box_contents[0][] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -181,9 +182,9 @@ class box_services_expired extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index d8571deba68..34d0e10a518 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2019 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 @@ -100,7 +101,7 @@ class box_shipments extends ModeleBoxes $sql .= " AND e.fk_statut = 1"; } if ($user->socid > 0) { - $sql.= " AND s.rowid = ".((int) $user->socid); + $sql .= " AND s.rowid = ".((int) $user->socid); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND sc.fk_user = ".((int) $user->id); @@ -165,7 +166,7 @@ class box_shipments extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedShipments").'' + 'text' => ''.$langs->trans("NoRecordedShipments").'' ); } @@ -173,7 +174,7 @@ class box_shipments extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -188,9 +189,9 @@ class box_shipments extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 88e87cff07b..3dbd7d852a6 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Raphaël Doursenaud * Copyright (C) 2015-2019 Frederic 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 @@ -170,7 +171,7 @@ class box_supplier_orders extends ModeleBoxes } else { $this->info_box_contents[0][] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -185,9 +186,9 @@ class box_supplier_orders extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index acddab7dc23..a882814a5ca 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Raphaël Doursenaud * Copyright (C) 2015 Frederic 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 @@ -169,7 +170,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes } else { $this->info_box_contents[0][] = array( 'td' => '', - 'maxlength'=>500, + 'maxlength' => 500, 'text' => ($this->db->error().' sql='.$sql), ); } @@ -184,9 +185,9 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 5298f360504..d81278383d3 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -1,6 +1,7 @@ * Copyright (C) 2015-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 @@ -96,12 +97,12 @@ class box_task extends ModeleBoxes $this->info_box_head = array( 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'limit' => dol_strlen($textHead), + 'sublink' => '', + 'subtext' => $langs->trans("Filter"), + 'subpicto' => 'filter.png', + 'subclass' => 'linkobject boxfilter', + 'target' => 'none' // Set '' to get target="_blank" ); // list the summary of the orders @@ -202,9 +203,9 @@ class box_task extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 8732e7d49f0..fc1df5741d0 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -5,6 +5,7 @@ * Copyright (C) 2016 Juan José Menent * Copyright (C) 2020 Pierre Ardoin * Copyright (C) 2023 Gauthier VERDOL + * 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 @@ -80,7 +81,7 @@ class box_validated_projects extends ModeleBoxes $totalnbTask = 0; $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); // list the summary of the orders if ($user->hasRight('projet', 'lire')) { @@ -188,9 +189,9 @@ class box_validated_projects extends ModeleBoxes /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines + * @param int<0,1> $nooutput No print, only return string * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 7520d84c6bc..4617bed86d2 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -219,12 +219,12 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo /** * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * - * @param array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title - * @param array> $contents Array with properties of box lines + * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title + * @param ?array> $contents Array with properties of box lines * @param int<0,1> $nooutput No print, only return string * @return string */ - public function showBox($head, $contents, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { global $langs, $user, $conf; @@ -243,6 +243,10 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $out = ''; + if ($contents === null) { + $contents = array(); + } + if ($refresh) { dol_syslog(get_class($this).'::showBox'); @@ -442,8 +446,8 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo * List is sorted by widget filename so by priority to run. * * @param ?string[] $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. - * @return array Array list of widgets - * + * @return array Array list of widgets + * */ public static function getWidgetsList($forcedirwidget = null) { @@ -540,7 +544,8 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo if (preg_match('/NORUN$/i', $files[$key])) { $disabledbyname = 1; } - // We set info of modules + + // We set info of modules @phan-suppress-next-line PhanUndeclaredProperty $widget[$j]['picto'] = ((!property_exists($objMod, 'picto') || empty($objMod->picto)) ? (empty($objMod->boximg) ? img_object('', 'generic') : $objMod->boximg) : img_object('', $objMod->picto)); $widget[$j]['file'] = $files[$key]; $widget[$j]['fullpath'] = $fullpath[$key]; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 74a7ccd6ac3..26735f84583 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5120,7 +5120,7 @@ abstract class CommonObject * * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell - * @param Societe $buyer Object thirdparty who buy + * @param ?Societe $buyer Object thirdparty who buy * @param string $defaulttpldir Directory where to find the template * @return void */ @@ -5170,7 +5170,7 @@ abstract class CommonObject * * @param string $action Action code * @param Societe $seller Object of seller third party - * @param Societe $buyer Object of buyer third party + * @param ?Societe $buyer Object of buyer third party * @param int $selected ID line selected * @param int $dateSelector 1=Show also date range input fields * @param string $defaulttpldir Directory where to find the template @@ -5256,7 +5256,7 @@ abstract class CommonObject * * @param string $action GET/POST action * @param CommonObjectLine $line Selected object line to output - * @param string $var Not used + * @param '' $var Not used * @param int $num Number of line (0) * @param int $i I * @param int $dateSelector 1=Show also date range input fields diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index c4307a9f316..aaad37ce505 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1741,7 +1741,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = null, $nopr * @param Translate $langs Object langs * @param DoliDB $db Object db * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket... to list events linked to an object - * @param Contact $objcon Filter on object contact to filter events on a contact + * @param ?Contact $objcon Filter on object contact to filter events on a contact * @param int $noprint Return string but does not output it * @param string|string[] $actioncode Filter on actioncode * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 98d3b66f34a..81e1a2fceba 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -26,14 +26,14 @@ /** * Regenerate files .class.php * - * @param string $destdir Directory - * @param string $module Module name - * @param string $objectname Name of object - * @param string $newmask New mask - * @param string $readdir Directory source (use $destdir when not defined) + * @param string $destdir Directory + * @param string $module Module name + * @param string $objectname Name of object + * @param string $newmask New mask + * @param string $readdir Directory source (use $destdir when not defined) * @param array{}|array{name:string,key:string,type:string,label:string,picot?:string,enabled:int<0,1>,notnull:int<0,1>,position:int,visible:int,noteditable?:int<0,1>,alwayseditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int<0,1>,css?:string,cssview?:string,csslist?:string,help?:string,showoncombobox?:int<0,1>,disabled?:int<0,1>,autofocusoncreate?:int<0,1>,arrayofkeyval?:array,validate?:int<0,1>,comment?:string} $addfieldentry Array of 1 field entry to add - * @param string $delfieldentry Id of field to remove - * @return int<-7,-1>|CommonObject Return integer <=0 if KO, Object if OK + * @param string $delfieldentry Id of field to remove + * @return int<-7,-1>|CommonObject Return integer <=0 if KO, Object if OK * @see rebuildObjectSql() */ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '') @@ -79,7 +79,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = return -3; } - //$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp'; + //$pathoffiletoedittmp = $destdir.'/class/'.strtolower($objectname).'.class.php.tmp'; //dol_delete_file($pathoffiletoedittmp, 0, 1, 1); try { @@ -116,67 +116,68 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $i = 0; $texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n"; $texttoinsert .= "\t".'/**'."\n"; - $texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n"; + $texttoinsert .= "\t".' * @inheritdoc'."\n"; + $texttoinsert .= "\t".' * Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n"; $texttoinsert .= "\t".' */'."\n"; - $texttoinsert .= "\t".'public $fields=array('."\n"; + $texttoinsert .= "\t".'public $fields = array('."\n"; if (count($object->fields)) { foreach ($object->fields as $key => $val) { $i++; $texttoinsert .= "\t\t".'"'.$key.'" => array('; - $texttoinsert .= '"type"=>"'.dol_escape_php($val['type']).'",'; - $texttoinsert .= ' "label"=>"'.dol_escape_php($val['label']).'",'; + $texttoinsert .= '"type" => "'.dol_escape_php($val['type']).'",'; + $texttoinsert .= ' "label" => "'.dol_escape_php($val['label']).'",'; if (!empty($val['picto'])) { - $texttoinsert .= ' "picto"=>"'.dol_escape_php($val['picto']).'",'; + $texttoinsert .= ' "picto" => "'.dol_escape_php($val['picto']).'",'; } - $texttoinsert .= ' "enabled"=>"'.($val['enabled'] !== '' ? dol_escape_php($val['enabled']) : 1).'",'; - $texttoinsert .= " 'position'=>".($val['position'] !== '' ? (int) $val['position'] : 50).","; - $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : (int) $val['notnull']).","; - $texttoinsert .= ' "visible"=>"'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",'; + $texttoinsert .= ' "enabled" => "'.($val['enabled'] !== '' ? dol_escape_php($val['enabled']) : 1).'",'; + $texttoinsert .= " 'position' => ".($val['position'] !== '' ? (int) $val['position'] : 50).","; + $texttoinsert .= " 'notnull' => ".(empty($val['notnull']) ? 0 : (int) $val['notnull']).","; + $texttoinsert .= ' "visible" => "'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",'; if (!empty($val['noteditable'])) { - $texttoinsert .= ' "noteditable"=>"'.dol_escape_php($val['noteditable']).'",'; + $texttoinsert .= ' "noteditable" => "'.dol_escape_php($val['noteditable']).'",'; } if (!empty($val['alwayseditable'])) { - $texttoinsert .= ' "alwayseditable"=>"'.dol_escape_php($val['alwayseditable']).'",'; + $texttoinsert .= ' "alwayseditable" => "'.dol_escape_php($val['alwayseditable']).'",'; } if (array_key_exists('default', $val) && (!empty($val['default']) || $val['default'] === '0')) { - $texttoinsert .= ' "default"=>"'.dol_escape_php($val['default']).'",'; + $texttoinsert .= ' "default" => "'.dol_escape_php($val['default']).'",'; } if (!empty($val['index'])) { - $texttoinsert .= ' "index"=>"'.(int) $val['index'].'",'; + $texttoinsert .= ' "index" => "'.(int) $val['index'].'",'; } if (!empty($val['foreignkey'])) { - $texttoinsert .= ' "foreignkey"=>"'.(int) $val['foreignkey'].'",'; + $texttoinsert .= ' "foreignkey" => "'.(int) $val['foreignkey'].'",'; } if (!empty($val['searchall'])) { - $texttoinsert .= ' "searchall"=>"'.(int) $val['searchall'].'",'; + $texttoinsert .= ' "searchall" => "'.(int) $val['searchall'].'",'; } if (!empty($val['isameasure'])) { - $texttoinsert .= ' "isameasure"=>"'.(int) $val['isameasure'].'",'; + $texttoinsert .= ' "isameasure" => "'.(int) $val['isameasure'].'",'; } if (!empty($val['css'])) { - $texttoinsert .= ' "css"=>"'.dol_escape_php($val['css']).'",'; + $texttoinsert .= ' "css" => "'.dol_escape_php($val['css']).'",'; } if (!empty($val['cssview'])) { - $texttoinsert .= ' "cssview"=>"'.dol_escape_php($val['cssview']).'",'; + $texttoinsert .= ' "cssview" => "'.dol_escape_php($val['cssview']).'",'; } if (!empty($val['csslist'])) { - $texttoinsert .= ' "csslist"=>"'.dol_escape_php($val['csslist']).'",'; + $texttoinsert .= ' "csslist" => "'.dol_escape_php($val['csslist']).'",'; } if (!empty($val['help'])) { - $texttoinsert .= ' "help"=>"'.dol_escape_php($val['help']).'",'; + $texttoinsert .= ' "help" => "'.dol_escape_php($val['help']).'",'; } if (!empty($val['showoncombobox'])) { - $texttoinsert .= ' "showoncombobox"=>"'.(int) $val['showoncombobox'].'",'; + $texttoinsert .= ' "showoncombobox" => "'.(int) $val['showoncombobox'].'",'; } if (!empty($val['disabled'])) { - $texttoinsert .= ' "disabled"=>"'.(int) $val['disabled'].'",'; + $texttoinsert .= ' "disabled" => "'.(int) $val['disabled'].'",'; } if (!empty($val['autofocusoncreate'])) { - $texttoinsert .= ' "autofocusoncreate"=>"'.(int) $val['autofocusoncreate'].'",'; + $texttoinsert .= ' "autofocusoncreate" => "'.(int) $val['autofocusoncreate'].'",'; } if (!empty($val['arrayofkeyval'])) { - $texttoinsert .= ' "arrayofkeyval"=>array('; + $texttoinsert .= ' "arrayofkeyval" => array('; $i = 0; foreach ($val['arrayofkeyval'] as $key2 => $val2) { if ($i) { @@ -188,10 +189,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $texttoinsert .= '),'; } if (!empty($val['validate'])) { - $texttoinsert .= ' "validate"=>"'.(int) $val['validate'].'",'; + $texttoinsert .= ' "validate" => "'.(int) $val['validate'].'",'; } if (!empty($val['comment'])) { - $texttoinsert .= ' "comment"=>"'.dol_escape_php($val['comment']).'"'; + $texttoinsert .= ' "comment" => "'.dol_escape_php($val['comment']).'"'; } $texttoinsert .= "),\n"; @@ -203,16 +204,16 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = //print ($texttoinsert);exit; if (count($object->fields)) { - //$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string'); + //$typetotypephp = array('integer' => 'integer', 'duration' => 'integer', 'varchar' => 'string'); foreach ($object->fields as $key => $val) { $i++; - //$typephp=$typetotypephp[$val['type']]; + //$typephp = $typetotypephp[$val['type']]; $texttoinsert .= "\t".'public $'.$key.";"; //if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; //if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; //$texttoinsert.= ($val['notnull']?' NOT NULL':''); - //if ($i < count($object->fields)) $texttoinsert.=";"; + //if ($i < count($object->fields)) $texttoinsert. = ";"; $texttoinsert .= "\n"; } } @@ -245,14 +246,14 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = /** * Save data into a memory area shared by all users, all sessions on server * - * @param string $destdir Directory - * @param string $module Module name - * @param string $objectname Name of object - * @param string $newmask New mask - * @param string $readdir Directory source (use $destdir when not defined) - * @param Object $object If object was already loaded/known, it is pass to avoid another include and new. - * @param string $moduletype 'external' or 'internal' - * @return int Return integer <=0 if KO, >0 if OK + * @param string $destdir Directory + * @param string $module Module name + * @param string $objectname Name of object + * @param string $newmask New mask + * @param string $readdir Directory source (use $destdir when not defined) + * @param Object $object If object was already loaded/known, it is pass to avoid another include and new. + * @param string $moduletype 'external' or 'internal' + * @return int Return integer <=0 if KO, >0 if OK * @see rebuildObjectClass() */ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null, $moduletype = 'external') @@ -430,8 +431,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' /** * Get list of existing objects from a directory * - * @param string $destdir Directory - * @return array|int Return integer <=0 if KO, array if OK + * @param string $destdir Directory + * @return string[]|int Return integer <=0 if KO, array if OK */ function dolGetListOfObjectClasses($destdir) { @@ -462,9 +463,9 @@ function dolGetListOfObjectClasses($destdir) /** * Function to check if comment BEGIN and END exists in modMyModule class * - * @param string $file Filename or path - * @param int $number 0 = For Menus, 1 = For permissions, 2 = For Dictionaries - * @return int 1 if OK , -1 if KO + * @param string $file Filename or path + * @param int<0,2> $number 0 = For Menus, 1 = For permissions, 2 = For Dictionaries + * @return int 1 if OK , -1 if KO */ function checkExistComment($file, $number) { @@ -507,8 +508,8 @@ function checkExistComment($file, $number) /** * Delete all permissions * - * @param string $file file with path - * @return void + * @param string $file file with path + * @return void */ function deletePerms($file) { @@ -538,10 +539,10 @@ function deletePerms($file) } /** - * Compare two value - * @param int|string $a value 1 - * @param int|string $b value 2 - * @return int less 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. + * Compare two values + * @param int|string $a value 1 + * @param int|string $b value 2 + * @return int<-1,1> <=0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. */ function compareFirstValue($a, $b) { @@ -549,25 +550,25 @@ function compareFirstValue($a, $b) } /** * Rewriting all permissions after any actions - * @param string $file filename or path - * @param array $permissions permissions existing in file - * @param int|null $key key for permission needed - * @param array{0:string,1:string}|null $right $right to update or add - * @param string|null $objectname name of object - * @param string|null $module name of module - * @param int<-2,2> $action 0 for delete, 1 for add, 2 for update, -1 when delete object completely, -2 for generate rights after add - * @return int<-1,1> 1 if OK,-1 if KO + * @param string $file filename or path + * @param array $permissions permissions existing in file + * @param ?int $key key for permission needed + * @param ?array{0:string,1:string} $right $right to update or add + * @param string $objectname name of object + * @param string $module name of module + * @param int<-2,2> $action 0 for delete, 1 for add, 2 for update, -1 when delete object completely, -2 for generate rights after add + * @return int<-1,1> 1 if OK,-1 if KO */ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $module, $action) { $error = 0; $rights = array(); - if ($action == 0) { + if ($action == 0 && $key !== null) { // delete right from permissions array array_splice($permissions, array_search($permissions[$key], $permissions), 1); } elseif ($action == 1) { array_push($permissions, $right); - } elseif ($action == 2 && !empty($right)) { + } elseif ($action == 2 && !empty($right) && $key !== null) { // update right from permissions array array_splice($permissions, array_search($permissions[$key], $permissions), 1, $right); } elseif ($action == -1 && !empty($objectname)) { @@ -624,7 +625,7 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ foreach ($permissions as $perms) { $object = $perms[4]; if (!isset($perms_grouped[$object])) { - $perms_grouped[$object] = []; + $perms_grouped[$object] = array(); } $perms_grouped[$object][] = $perms; } @@ -656,11 +657,10 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ //convert to string foreach ($permissions as $perms) { foreach ($perms as $per) { - $rights[] = implode(";\n\t\t", $per); - $rights[] = "\$r++;\n\t\t"; + $rights[] = implode(";\n\t\t", $per)."\$r++;\n"; } } - $rights_str = implode("", $rights); + $rights_str = implode("\t\t", $rights); // delete all permissions from file deletePerms($file); // rewrite all permissions again @@ -674,8 +674,8 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ /** * Converts a formatted properties string into an associative array. * - * @param string $string The formatted properties string. - * @return array The resulting associative array. + * @param string $string The formatted properties string. + * @return array The resulting associative array. */ function parsePropertyString($string) { @@ -683,7 +683,7 @@ function parsePropertyString($string) // Uses a regular expression to capture keys and values preg_match_all('/\s*([^\s=>]+)\s*=>\s*([^,]+),?/', $string, $matches, PREG_SET_ORDER); - $propertyArray = []; + $propertyArray = array(); foreach ($matches as $match) { $key = trim($match[1]); @@ -718,10 +718,10 @@ function parsePropertyString($string) /** * Write all properties of the object in AsciiDoc format - * @param string $file path of the class - * @param string $objectname name of the objectClass - * @param string $destfile file where write table of properties - * @return int 1 if OK, -1 if KO + * @param string $file path of the class + * @param string $objectname name of the objectClass + * @param string $destfile file where write table of properties + * @return int 1 if OK, -1 if KO */ function writePropsInAsciiDoc($file, $objectname, $destfile) { @@ -729,7 +729,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) // stock all properties in array $attributesUnique = array('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' ); - $start = "public \$fields=array("; + $start = "public \$fields = array("; $end = ");"; $i = 1; $keys = array(); @@ -817,9 +817,9 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) /** * Delete property and permissions from documentation ascii file if we delete an object * - * @param string $file file or path - * @param string $objectname name of object wants to deleted - * @return void + * @param string $file file or path + * @param string $objectname name of object wants to deleted + * @return void */ function deletePropsAndPermsFromDoc($file, $objectname) { @@ -846,12 +846,12 @@ function deletePropsAndPermsFromDoc($file, $objectname) /** * Search a string and return all lines needed from file. Does not include line $start nor $end * - * @param string $file file for searching - * @param string $start start line if exist - * @param string $end end line if exist - * @param string $excludestart Ignore if start line is $excludestart - * @param int $includese Include start and end line - * @return string Return the lines between first line with $start and $end. "" if not found. + * @param string $file file for searching + * @param string $start start line if it exists + * @param string $end end line if it exists + * @param string $excludestart Ignore if start line is $excludestart + * @param int<0,1> $includese Include start and end line + * @return string Return the lines between first line with $start and $end. "" if not found. */ function getFromFile($file, $start, $end, $excludestart = '', $includese = 0) { @@ -889,9 +889,9 @@ function getFromFile($file, $start, $end, $excludestart = '', $includese = 0) /** * Write all permissions of each object in AsciiDoc format - * @param string $file path of the class - * @param string $destfile file where write table of permissions - * @return int<-1,1> 1 if OK, -1 if KO + * @param string $file path of the class + * @param string $destfile file where write table of permissions + * @return int<-1,1> 1 if OK, -1 if KO */ function writePermsInAsciiDoc($file, $destfile) { @@ -939,10 +939,10 @@ function writePermsInAsciiDoc($file, $destfile) array_pop($permsN); // Group permissions by Object and add it to string - $final_array = []; + $final_array = array(); $index = 0; while ($index < count($permsN)) { - $temp_array = [$permsN[$index], $permsN[$index + 1]]; + $temp_array = array($permsN[$index], $permsN[$index + 1]); $final_array[] = $temp_array; $index += 2; } @@ -974,11 +974,11 @@ function writePermsInAsciiDoc($file, $destfile) /** * Add Object in ModuleApi File * - * @param string $srcfile Source file to use as example - * @param string $file Path of modified file - * @param string[] $objects Array of objects in the module - * @param string $modulename Name of module - * @return int<-1,1> Return 1 if OK, -1 if KO + * @param string $srcfile Source file to use as example + * @param string $file Path of modified file + * @param string[] $objects Array of objects in the module + * @param string $modulename Name of module + * @return int<-1,1> Return 1 if OK, -1 if KO */ function addObjectsToApiFile($srcfile, $file, $objects, $modulename) { @@ -1007,7 +1007,7 @@ function addObjectsToApiFile($srcfile, $file, $objects, $modulename) } elseif (preg_match('/'.$props.'/', $lineContent)) { $lineContent = ''; foreach ($objects as $objectname) { - $lineContent .= "\tpublic \$".strtolower($objectname).";". PHP_EOL; + $lineContent .= "\t/*".PHP_EOL."\t * @var mixed TODO: set type".PHP_EOL."\t */".PHP_EOL."\tpublic \$".strtolower($objectname).";". PHP_EOL; } } elseif (preg_match('/'.$constructObj.'/', $lineContent)) { $lineContent = ''; @@ -1040,7 +1040,7 @@ function addObjectsToApiFile($srcfile, $file, $objects, $modulename) 'myobject' => strtolower($objectname), 'MyObject' => $objectname, 'MYOBJECT' => strtoupper($objectname), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); $contentReplaced = make_substitutions($allContent, $arrayreplacement, null); //$contentReplaced = str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent); @@ -1060,10 +1060,10 @@ function addObjectsToApiFile($srcfile, $file, $objects, $modulename) /** * Remove Object variables and methods from API_Module File * - * @param string $file File api module - * @param string[] $objects Array of objects in the module - * @param string $objectname Name of object want to remove - * @return int<-1,1> 1 if OK, -1 if KO + * @param string $file File api module + * @param string[] $objects Array of objects in the module + * @param string $objectname Name of object want to remove + * @return int<-1,1> 1 if OK, -1 if KO */ function removeObjectFromApiFile($file, $objects, $objectname) { @@ -1108,12 +1108,12 @@ function removeObjectFromApiFile($file, $objects, $objectname) /** - * @param string $file path of filename - * @param array $menus all menus for module - * @param mixed|null $menuWantTo menu get for do actions - * @param int|null $key key for the concerned menu - * @param int<-1,2> $action for specify what action (0 = delete perm, 1 = add perm, 2 = update perm, -1 = when we delete object) - * @return int<-1,1> 1 if OK, -1 if KO + * @param string $file path of filename + * @param array $menus all menus for module + * @param null|string|array{commentgroup:string,fk_menu:string,type:string,titre:string,mainmenu:string,leftmenu:string,url:string,langs:string,position:int,enabled:int,perms:string,target:string,user:int} $menuWantTo menu get for do actions + * @param ?int $key key for the concerned menu + * @param int<-1,2> $action for specify what action (0 = delete perm, 1 = add perm, 2 = update perm, -1 = when we delete object) + * @return int<-1,1> 1 if OK, -1 if KO */ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) { @@ -1150,7 +1150,7 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) } else { $errors++; } - } elseif ($action == -1 && !empty($menuWantTo)) { + } elseif ($action == -1 && !empty($menuWantTo) && is_string($menuWantTo)) { // delete menus when delete Object foreach ($menus as $index => $menu) { if ((strpos(strtolower($menu['fk_menu']), strtolower($menuWantTo)) !== false) || (strpos(strtolower($menu['leftmenu']), strtolower($menuWantTo)) !== false)) { @@ -1184,20 +1184,20 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) //var_dump(dol_escape_php($menu['perms'], 1)); exit; $str_menu .= $start."\n"; - $str_menu .= "\t\t\$this->menu[\$r++]=array(\n"; - $str_menu .= "\t\t\t 'fk_menu' => '".dol_escape_php($menu['fk_menu'], 1)."',\n"; - $str_menu .= "\t\t\t 'type' => '".dol_escape_php($menu['type'], 1)."',\n"; - $str_menu .= "\t\t\t 'titre' => '".dol_escape_php($menu['titre'], 1)."',\n"; - $str_menu .= "\t\t\t 'mainmenu' => '".dol_escape_php($menu['mainmenu'], 1)."',\n"; - $str_menu .= "\t\t\t 'leftmenu' => '".dol_escape_php($menu['leftmenu'], 1)."',\n"; - $str_menu .= "\t\t\t 'url' => '".dol_escape_php($menu['url'], 1)."',\n"; - $str_menu .= "\t\t\t 'langs' => '".dol_escape_php($menu['langs'], 1)."',\n"; - $str_menu .= "\t\t\t 'position' => ".((int) $menu['position']).",\n"; - $str_menu .= "\t\t\t 'enabled' => '".dol_escape_php($menu['enabled'], 1)."',\n"; - $str_menu .= "\t\t\t 'perms' => '".dol_escape_php($menu['perms'], 1)."',\n"; - $str_menu .= "\t\t\t 'target' => '".dol_escape_php($menu['target'], 1)."',\n"; - $str_menu .= "\t\t\t 'user' => ".((int) $menu['user']).",\n"; - $str_menu .= "\t\t\t 'object' => '".dol_escape_php($menu['object'], 1)."',\n"; + $str_menu .= "\t\t\$this->menu[\$r++] = array(\n"; + $str_menu .= "\t\t\t'fk_menu' => '".dol_escape_php($menu['fk_menu'], 1)."',\n"; + $str_menu .= "\t\t\t'type' => '".dol_escape_php($menu['type'], 1)."',\n"; + $str_menu .= "\t\t\t'titre' => '".dol_escape_php($menu['titre'], 1)."',\n"; + $str_menu .= "\t\t\t'mainmenu' => '".dol_escape_php($menu['mainmenu'], 1)."',\n"; + $str_menu .= "\t\t\t'leftmenu' => '".dol_escape_php($menu['leftmenu'], 1)."',\n"; + $str_menu .= "\t\t\t'url' => '".dol_escape_php($menu['url'], 1)."',\n"; + $str_menu .= "\t\t\t'langs' => '".dol_escape_php($menu['langs'], 1)."',\n"; + $str_menu .= "\t\t\t'position' => ".((int) $menu['position']).",\n"; + $str_menu .= "\t\t\t'enabled' => '".dol_escape_php($menu['enabled'], 1)."',\n"; + $str_menu .= "\t\t\t'perms' => '".dol_escape_php($menu['perms'], 1)."',\n"; + $str_menu .= "\t\t\t'target' => '".dol_escape_php($menu['target'], 1)."',\n"; + $str_menu .= "\t\t\t'user' => ".((int) $menu['user']).",\n"; + $str_menu .= "\t\t\t'object' => '".dol_escape_php($menu['object'], 1)."',\n"; $str_menu .= "\t\t);\n"; if (is_null($next_val) || $val_actuel['leftmenu'] !== $next_val['leftmenu']) { @@ -1215,41 +1215,41 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) /** * Updates a dictionary in a module descriptor file. * - * @param string $module The name of the module. - * @param string $file The path to the module descriptor file. - * @param array> $dicts The dictionary data to be updated. - * @return int Returns the number of replacements made in the file. + * @param string $module The name of the module. + * @param string $file The path to the module descriptor file. + * @param array{langs:string,tabname:string[],tablib:string[],tabsql:string[],tabsqlsort:string[],tabfield:string[],tabfieldvalue:string[],tabfieldinsert:string[],tabrowid:string[],tabcond:string[],tabhelp:array} $dicts The dictionary data to be updated. + * @return int Returns the number of replacements made in the file. */ function updateDictionaryInFile($module, $file, $dicts) { $isEmpty = false; - $dicData = "\t\t\$this->dictionaries=array(\n"; + $dicData = "\t\t\$this->dictionaries = array(\n"; $module = strtolower($module); foreach ($dicts as $key => $value) { if (empty($value)) { $isEmpty = true; - $dicData = "\t\t\$this->dictionaries=array();"; + $dicData = "\t\t\$this->dictionaries = array();"; break; } - $dicData .= "\t\t\t'$key'=>"; + $dicData .= "\t\t\t'$key' => "; if ($key === 'tabcond') { $conditions = array_map( /** - * @param bool|string|int $val - * @return string|int + * @param bool|string|int $val + * @return string|int */ - function ($val) use ($module) { + static function ($val) use ($module) { return is_bool($val) ? "isModEnabled('$module')" : $val; }, $value ); - $dicData .= "array(" . implode(",", $conditions) . ")"; + $dicData .= "array(" . implode(", ", $conditions) . ")"; } elseif ($key === 'tabhelp') { $helpItems = array(); foreach ($value as $helpValue) { - $helpItems[] = "array('code'=>\$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')"; + $helpItems[] = "array('code' => \$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')"; } $dicData .= "array(" . implode(",", $helpItems) . ")"; } else { @@ -1258,8 +1258,8 @@ function updateDictionaryInFile($module, $file, $dicts) ",", array_map( /** - * @param string $val - * @return string + * @param string $val + * @return string */ static function ($val) { return "'$val'"; @@ -1282,16 +1282,16 @@ function updateDictionaryInFile($module, $file, $dicts) } /** - * Creates a new dictionary table. + * Create a new dictionary table. * - * for creating a new dictionary table in Dolibarr. It generates the necessary SQL code to define the table structure, + * It generates the necessary SQL code to define the table structure, * including columns such as 'rowid', 'code', 'label', 'position', 'use_default', 'active', etc. The table name is constructed based on the provided $namedic parameter. * - * @param string $modulename The lowercase name of the module for which the dictionary table is being created. - * @param string $file The file path to the Dolibarr module builder file where the dictionaries are defined. - * @param string $namedic The name of the dictionary, which will also be used as the base for the table name. - * @param array> $dictionnaires An optional array containing pre-existing dictionary data, including 'tabname', 'tablib', 'tabsql', etc. - * @return int<-1,-1> Return int < 0 if error, return nothing on success + * @param string $modulename The lowercase name of the module for which the dictionary table is being created. + * @param string $file The file path to the Dolibarr module builder file where the dictionaries are defined. + * @param string $namedic The name of the dictionary, which will also be used as the base for the table name. + * @param ?array{langs:string,tabname:string[],tablib:string[],tabsql:string[],tabsqlsort:string[],tabfield:string[],tabfieldvalue:string[],tabfieldinsert:string[],tabrowid:string[],tabcond:string[],tabhelp:array} $dictionnaires An optional array containing pre-existing dictionary data, including tabname, tablib, tabsql, etc. + * @return int<-1,-1> Return int < 0 if error, return nothing on success */ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = null) { @@ -1370,9 +1370,9 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul /** * Generate Urls and add them to documentation module * - * @param string $file_api filename or path of api - * @param string $file_doc filename or path of documentation - * @return int<-1,1> -1 if KO, 1 if OK, 0 if nothing change + * @param string $file_api filename or path of api + * @param string $file_doc filename or path of documentation + * @return int<-1,1> -1 if KO, 1 if OK, 0 if nothing change */ function writeApiUrlsInDoc($file_api, $file_doc) { @@ -1384,7 +1384,7 @@ function writeApiUrlsInDoc($file_api, $file_doc) $extractUrls = explode("\n", $string); // extract urls from file - $urlValues = []; + $urlValues = array(); foreach ($extractUrls as $key => $line) { $lineWithoutTabsSpaces = preg_replace('/^[\t\s]+/', '', $line); if (strpos($lineWithoutTabsSpaces, '* @url') === 0) { @@ -1395,7 +1395,7 @@ function writeApiUrlsInDoc($file_api, $file_doc) // get urls by object $str = $_SERVER['HTTP_HOST'].'/api/index.php/'; - $groupedUrls = []; + $groupedUrls = array(); foreach ($urlValues as $url) { if (preg_match('/(?:GET|POST|PUT|DELETE) (\w+)s/', $url, $matches)) { $objectName = $matches[1]; @@ -1427,9 +1427,9 @@ function writeApiUrlsInDoc($file_api, $file_doc) /** * count directories or files in modulebuilder folder - * @param string $path path of directory - * @param int $type type of file 1= file,2=directory - * @return int|bool + * @param string $path path of directory + * @param int<1,2> $type type of file 1= file,2=directory + * @return int|false False on failure (path is not a directory) */ function countItemsInDirectory($path, $type = 1) { diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 7a8d2d86f44..c9cac1a186f 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2004 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2004 Eric Seigne + * 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 @@ -390,6 +391,7 @@ class MailingTargets // This can't be abstract as it is used for some method $objMod = new $modName($db); if (is_object($objMod)) { + '@phan-var-force ModeleBoxes $objMod'; // Define disabledbyname and disabledbymodule $disabledbyname = 0; $disabledbymodule = 0; // TODO Set to 2 if module is not enabled @@ -400,7 +402,7 @@ class MailingTargets // This can't be abstract as it is used for some method $disabledbyname = 1; } - // We set info of modules + // We set info of modules @phan-suppress-next-line PhanUndeclaredProperty $widget[$j]['picto'] = (empty($objMod->picto) ? (empty($objMod->boximg) ? img_object('', 'generic') : $objMod->boximg) : img_object('', $objMod->picto)); $widget[$j]['file'] = $files[$key]; $widget[$j]['fullpath'] = $fullpath[$key]; diff --git a/htdocs/intracommreport/admin/intracommreport.php b/htdocs/intracommreport/admin/intracommreport.php index ad0ae7d226a..95f9f161806 100644 --- a/htdocs/intracommreport/admin/intracommreport.php +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -1,6 +1,7 @@ * Copyright (C) 2019-2020 Open-DSI + * 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 @@ -129,7 +130,7 @@ foreach ($list_DEB as $key) { print ''; print ''.$langs->trans("INTRACOMMREPORT_TYPE_ACTEUR").''; -$arraychoices = array(''=>$langs->trans("None"), 'PSI'=>'Déclarant pour son compte', 'TDP'=>'Tiers déclarant'); +$arraychoices = array('' => $langs->trans("None"), 'PSI' => 'Déclarant pour son compte', 'TDP' => 'Tiers déclarant'); print ''; print $form->selectarray('INTRACOMMREPORT_TYPE_ACTEUR', $arraychoices, $conf->global->INTRACOMMREPORT_TYPE_ACTEUR, 0); print ''; @@ -137,7 +138,7 @@ print "\n"; print ''; print ''.$langs->trans("INTRACOMMREPORT_ROLE_ACTEUR").''; -$arraychoices = array(''=>$langs->trans("None"), 'sender'=>'Emetteur', 'PSI'=>'Déclarant'); +$arraychoices = array('' => $langs->trans("None"), 'sender' => 'Emetteur', 'PSI' => 'Déclarant'); print ''; print $form->selectarray('INTRACOMMREPORT_ROLE_ACTEUR', $arraychoices, $conf->global->INTRACOMMREPORT_ROLE_ACTEUR, 0); print ''; @@ -145,7 +146,7 @@ print "\n"; print ''; print ''.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION").''; -$arraychoices = array(1=>'Seuil de 460 000 €', 2=>'En dessous de 460 000 €'); +$arraychoices = array(1 => 'Seuil de 460 000 €', 2 => 'En dessous de 460 000 €'); print ''; print $form->selectarray('INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION', $arraychoices, $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION, 0); print ''; @@ -153,7 +154,7 @@ print "\n"; print ''; print ''.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION").''; -$arraychoices = array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €'); +$arraychoices = array(3 => 'Seuil de 460 000 €', 4 => 'En dessous de 460 000 €'); print ''; print $form->selectarray('INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION', $arraychoices, $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION, 0); print ''; diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index 1f4c455cd22..2ca98e31396 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -103,16 +103,16 @@ class IntracommReport extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - "rowid" => array("type"=>"integer", "label"=>"TechnicalID", "enabled"=>"1", 'position'=>10, 'notnull'=>1, "visible"=>"0",), - "ref" => array("type"=>"varchar(30)", "label"=>"Ref", "enabled"=>"1", 'position'=>15, 'notnull'=>1, "visible"=>"1", "csslist"=>"tdoverflowmax150", "showoncombobox"=>"1",), - "type_declaration" => array("type"=>"varchar(32)", "label"=>"TypeOfDeclaration", "enabled"=>"1", 'position'=>25, 'notnull'=>0, "visible"=>"1", 'arrayofkeyval' => array("deb" => "DEB", "des" => "DES")), - "periods" => array("type"=>"varchar(32)", "label"=>"Periods", "enabled"=>"1", 'position'=>30, 'notnull'=>0, "visible"=>"-1",), - "mode" => array("type"=>"varchar(32)", "label"=>"Mode", "enabled"=>"1", 'position'=>35, 'notnull'=>0, "visible"=>"-1",), - "content_xml" => array("type"=>"text", "label"=>"Contentxml", "enabled"=>"1", 'position'=>40, 'notnull'=>0, "visible"=>"-1",), - "type_export" => array("type"=>"varchar(10)", "label"=>"TypeOfExport", "enabled"=>"1", 'position'=>45, 'notnull'=>0, "visible"=>"-1", 'arrayofkeyval' => array("in" => "Input", "out" => "Output")), - "datec" => array("type"=>"datetime", "label"=>"DateCreation", "enabled"=>"1", 'position'=>50, 'notnull'=>0, "visible"=>"-1",), - "tms" => array("type"=>"timestamp", "label"=>"DateModification", "enabled"=>"1", 'position'=>55, 'notnull'=>1, "visible"=>"-1",), + public $fields = array( + "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 10, 'notnull' => 1, "visible" => "0",), + "ref" => array("type" => "varchar(30)", "label" => "Ref", "enabled" => "1", 'position' => 15, 'notnull' => 1, "visible" => "1", "csslist" => "tdoverflowmax150", "showoncombobox" => "1",), + "type_declaration" => array("type" => "varchar(32)", "label" => "TypeOfDeclaration", "enabled" => "1", 'position' => 25, 'notnull' => 0, "visible" => "1", 'arrayofkeyval' => array("deb" => "DEB", "des" => "DES")), + "periods" => array("type" => "varchar(32)", "label" => "Periods", "enabled" => "1", 'position' => 30, 'notnull' => 0, "visible" => "-1",), + "mode" => array("type" => "varchar(32)", "label" => "Mode", "enabled" => "1", 'position' => 35, 'notnull' => 0, "visible" => "-1",), + "content_xml" => array("type" => "text", "label" => "Contentxml", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "-1",), + "type_export" => array("type" => "varchar(10)", "label" => "TypeOfExport", "enabled" => "1", 'position' => 45, 'notnull' => 0, "visible" => "-1", 'arrayofkeyval' => array("in" => "Input", "out" => "Output")), + "datec" => array("type" => "datetime", "label" => "DateCreation", "enabled" => "1", 'position' => 50, 'notnull' => 0, "visible" => "-1",), + "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 55, 'notnull' => 1, "visible" => "-1",), ); public $rowid; public $ref; diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index 5f8b5108bf9..d57d5a69972 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -516,8 +516,8 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/intracommreport/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -619,7 +619,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 94e4347a3bc..ddb9b357456 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -83,6 +83,7 @@ $version = GETPOST('version', 'alpha'); $family = GETPOST('family', 'alpha'); $picto = GETPOST('idpicto', 'alpha'); $idmodule = GETPOST('idmodule', 'alpha'); +$format = ''; // Prevent undefined in css tab // Security check if (!isModEnabled('modulebuilder')) { @@ -216,12 +217,31 @@ foreach ($dirsrootforscan as $tmpdirread) { } +/** + * Produce copyright replacement string for user + * + * @param User $user User to produce the copyright notice for. + * @param Translate $langs Translation object to use. + * @param int $now Date for which the copyright will be generated. + * + * @return string String to be used as replacement after Copyright (C) + */ +function getLicenceHeader($user, $langs, $now) +{ + $licInfo = $user->getFullName($langs); + $emailTabs = str_repeat("\t", (int) (max(0, (31 - mb_strlen($licInfo)) / 4))); + $licInfo .= ($user->email ? $emailTabs.'<'.$user->email.'>' : ''); + $licInfo = dol_print_date($now, '%Y')."\t\t".$licInfo; + return $licInfo; +} + /* * Actions */ if ($dirins && $action == 'initmodule' && $modulename) { $modulename = ucfirst($modulename); // Force first letter in uppercase + $destdir = '/not_set/'; if (preg_match('/[^a-z0-9_]/i', $modulename)) { $error++; @@ -336,6 +356,8 @@ if ($dirins && $action == 'initmodule' && $modulename) { // Edit PHP files if (!$error) { $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); + + $licInfo = getLicenceHeader($user, $langs, $now); foreach ($listofphpfilestoedit as $phpfileval) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( @@ -347,7 +369,8 @@ if ($dirins && $action == 'initmodule' && $modulename) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : ''), + '---Put here your own copyright and developer email---' => $licInfo, + '---Replace with your own copyright and developer email---' => $licInfo, 'Editor name' => $editorname, 'https://www.example.com' => $editorurl, '$this->version = \'1.0\'' => '$this->version = \''.$version.'\'', @@ -357,7 +380,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { ); if (getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR')) { - $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR'); + $arrayreplacement['---Replace with your own copyright and developer email---'] = dol_print_date($now, '%Y')."\t\t" . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR'); } // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -394,6 +417,9 @@ if ($dirins && $action == 'initmodule' && $modulename) { } } +$destdir = '/not_set/'; // Initialize (for static analysis) +$destfile = '/not_set/'; // Initialize (for static analysis) +$srcfile = '/not_set/'; // Initialize (for static analysis) // init API, PHPUnit if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontact', 'initpagedocument', 'initpagenote', 'initpageagenda')) && !empty($module)) { @@ -466,7 +492,8 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac 'myobject' => strtolower($objectname), 'MyObject' => $objectname, 'MYOBJECT' => strtoupper($objectname), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); if ($action == 'initapi') { @@ -527,7 +554,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { 'MyObject' => $objectname, 'my object' => strtolower($objectname), 'myobject' => strtolower($objectname), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); dolReplaceInFile($destfile1, $arrayreplacement); @@ -572,7 +599,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -607,7 +634,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -642,7 +669,7 @@ if ($dirins && $action == 'initwidget' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -677,7 +704,7 @@ if ($dirins && $action == 'initemailing' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -712,7 +739,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : ''), + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -752,7 +779,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) { 'Mon module' => $modulename, 'mon module' => $modulename, 'htdocs/modulebuilder/template' => strtolower($modulename), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -797,7 +824,7 @@ if ($dirins && $action == 'initcli' && !empty($module)) { '__USER_FULLNAME__' => $user->getFullName($langs), '__USER_EMAIL__' => $user->email, '__YYYY-MM-DD__' => dol_print_date($now, 'dayrfc'), - '---Put here your own copyright and developer email---' => dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -809,6 +836,8 @@ if ($dirins && $action == 'initcli' && !empty($module)) { } +$moduledescriptorfile = '/not_set/'; + // init Doc if ($dirins && $action == 'initdoc' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/doc'); @@ -838,7 +867,7 @@ if ($dirins && $action == 'initdoc' && !empty($module)) { '__USER_FULLNAME__' => $user->getFullName($langs), '__USER_EMAIL__' => $user->email, '__YYYY-MM-DD__' => dol_print_date($now, 'dayrfc'), - '---Put here your own copyright and developer email---' => dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -1098,14 +1127,14 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0') * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommended to name the field fk_...). + * 'foreignkey' => 'tablename.field' if the field is a foreign key (it is recommended to name the field fk_...). * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage) - * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200' + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css' => 'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview' => 'wordbreak', 'csslist' => 'tdoverflowmax200' * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. - * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' + * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0" => "Draft","1" => "Active","-1" => "Cancel"). Note that type can be 'integer' or 'varchar' * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'validate' is 1 if need to validate with $this->validateField() @@ -1113,27 +1142,27 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { */ /*public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'alwayseditable'=>'1'), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirdparty'), - 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), - //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), + 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'showoncombobox' => 1, 'index' => 1, 'position' => 10, 'searchall' => 1, 'comment' => 'Reference of object'), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'default' => 1, 'notnull' => 1, 'index' => 1, 'position' => 20), + 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'searchall' => 1, 'css' => 'minwidth200', 'help' => 'Help text', 'alwayseditable' => '1'), + 'amount' => array('type' => 'double(24,8)', 'label' => 'Amount', 'enabled' => 1, 'visible' => 1, 'default' => 'null', 'position' => 40, 'searchall' => 0, 'isameasure' => 1, 'help' => 'Help text'), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'visible' => 1, 'enabled' => 1, 'position' => 50, 'notnull' => -1, 'index' => 1, 'searchall' => 1, 'help' => 'LinkToThirdparty'), + 'description' => array('type' => 'text', 'label' => 'Descrption', 'enabled' => 1, 'visible' => 0, 'position' => 60), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 61), + 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 62), + 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 500), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 501), + //'date_valid' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'position' => 502), + 'fk_user_creat' => array('type' => 'integer', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 510), + 'fk_user_modif' => array('type' => 'integer', 'label' => 'UserModif', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 511), + //'fk_user_valid' => array('type' => 'integer', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 512), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'index' => 0, 'position' => 1000), + 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'default' => 0, 'index' => 1, 'position' => 1000, 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Active', -1 => 'Cancel')), );*/ $stringforproperties = '// BEGIN MODULEBUILDER PROPERTIES'."\n"; - $stringforproperties .= 'public $fields=array('."\n"; + $stringforproperties .= 'public $fields = array('."\n"; $i = 10; while ($obj = $db->fetch_object($_results)) { // fieldname @@ -1249,6 +1278,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // $alwayseditable if ($fieldname == 'label') { $alwayseditable = 1; + } else { + $alwayseditable = 0; } // index $index = 0; @@ -1283,36 +1314,36 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } // Build the property string - $stringforproperties .= "'".$obj->Field."'=>array('type'=>'".$type."', 'label'=>'".$label."',"; + $stringforproperties .= "'".$obj->Field."' => array('type' => '".$type."', 'label' => '".$label."',"; if ($default != '') { - $stringforproperties .= " 'default'=>".$default.","; + $stringforproperties .= " 'default' => ".$default.","; } - $stringforproperties .= " 'enabled'=>".$enabled.","; - $stringforproperties .= " 'visible'=>".$visible; + $stringforproperties .= " 'enabled' => ".$enabled.","; + $stringforproperties .= " 'visible' => ".$visible; if ($notnull) { - $stringforproperties .= ", 'notnull'=>".$notnull; + $stringforproperties .= ", 'notnull' => ".$notnull; } if ($alwayseditable) { - $stringforproperties .= ", 'alwayseditable'=>1"; + $stringforproperties .= ", 'alwayseditable' => 1"; } if ($fieldname == 'ref' || $fieldname == 'code') { - $stringforproperties .= ", 'showoncombobox'=>1"; + $stringforproperties .= ", 'showoncombobox' => 1"; } - $stringforproperties .= ", 'position'=>".$position; + $stringforproperties .= ", 'position' => ".$position; if ($index) { - $stringforproperties .= ", 'index'=>".$index; + $stringforproperties .= ", 'index' => ".$index; } if ($picto) { - $stringforproperties .= ", 'picto'=>'".$picto."'"; + $stringforproperties .= ", 'picto' => '".$picto."'"; } if ($css) { - $stringforproperties .= ", 'css'=>'".$css."'"; + $stringforproperties .= ", 'css' => '".$css."'"; } if ($cssview) { - $stringforproperties .= ", 'cssview'=>'".$cssview."'"; + $stringforproperties .= ", 'cssview' => '".$cssview."'"; } if ($csslist) { - $stringforproperties .= ", 'csslist'=>'".$csslist."'"; + $stringforproperties .= ", 'csslist' => '".$csslist."'"; } $stringforproperties .= "),\n"; $i += 5; @@ -1322,6 +1353,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } } + $filetogenerate = array(); // For static analysis if (!$error) { // Copy some files $filetogenerate = array( @@ -1333,14 +1365,14 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { 'myobject_list.php' => strtolower($objectname).'_list.php', 'admin/myobject_extrafields.php' => 'admin/'.strtolower($objectname).'_extrafields.php', 'lib/mymodule_myobject.lib.php' => 'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php', - //'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php', + //'test/phpunit/MyObjectTest.php' => 'test/phpunit/'.strtolower($objectname).'Test.php', 'sql/llx_mymodule_myobject.sql' => 'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql', 'sql/llx_mymodule_myobject.key.sql' => 'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql', 'sql/llx_mymodule_myobject_extrafields.sql' => 'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', 'sql/llx_mymodule_myobject_extrafields.key.sql' => 'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.key.sql', - //'scripts/mymodule.php'=>'scripts/'.strtolower($objectname).'.php', + //'scripts/mymodule.php' => 'scripts/'.strtolower($objectname).'.php', 'class/myobject.class.php' => 'class/'.strtolower($objectname).'.class.php', - //'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php', + //'class/api_mymodule.class.php' => 'class/api_'.strtolower($module).'.class.php', ); if (GETPOST('includerefgeneration', 'aZ09')) { @@ -1366,15 +1398,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); } } - $rights = $moduleobj->rights; + if (is_object($moduleobj)) { + $rights = $moduleobj->rights; + } else { + $rights = []; + } $moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php'; $checkComment = checkExistComment($moduledescriptorfile, 1); if ($checkComment < 0) { @@ -1421,9 +1459,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // Edit the class 'class/'.strtolower($objectname).'.class.php' if (GETPOST('includerefgeneration', 'aZ09')) { - // Replace 'visible'=>1, 'noteditable'=>0, 'default'=>'' + // Replace 'visible' => 1, 'noteditable' => 0, 'default' => '' $arrayreplacement = array( - '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' => "'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'" + '/\'visible\'s*=>s*1,\s*\'noteditable\'s*=>s*0,\s*\'default\'s*=>s*\'\'/' => "'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)'" ); //var_dump($arrayreplacement);exit; //var_dump($destdir.'/class/'.strtolower($objectname).'.class.php');exit; @@ -1451,7 +1489,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1); } - // TODO Update entries '$myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);' + // TODO Update entries '$myTmpObjects['MyObject'] = array('includerefgeneration' => 0, 'includedocgeneration' => 0);' // Scan for object class files @@ -1477,51 +1515,51 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // Regenerate left menu entry in descriptor for $objectname $stringtoadd = " - \$this->menu[\$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule', - 'type'=>'left', - 'titre'=>'MyObject', + \$this->menu[\$r++] = array( + 'fk_menu' => 'fk_mainmenu=mymodule', + 'type' => 'left', + 'titre' => 'MyObject', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), - 'mainmenu'=>'mymodule', - 'leftmenu'=>'myobject', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', - 'position'=>1000+\$r, - 'enabled'=>'isModEnabled(\"mymodule\")', - 'perms'=>'".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "read")' : '1')."', - 'target'=>'', - 'user'=>2, - 'object'=>'MyObject' + 'mainmenu' => 'mymodule', + 'leftmenu' => 'myobject', + 'url' => '/mymodule/myobject_list.php', + 'langs' => 'mymodule@mymodule', + 'position' => 1000 + \$r, + 'enabled' => 'isModEnabled(\"mymodule\")', + 'perms' => '".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "read")' : '1')."', + 'target' => '', + 'user' => 2, + 'object' => 'MyObject' ); - \$this->menu[\$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', - 'type'=>'left', - 'titre'=>'List MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_list', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', - 'position'=>1000+\$r, - 'enabled'=>'isModEnabled(\"mymodule\")', - 'perms'=>'".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "read")' : '1')."', - 'target'=>'', - 'user'=>2, - 'object'=>'MyObject' - ); - \$this->menu[\$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', - 'type'=>'left', - 'titre'=>'New MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_new', - 'url'=>'/mymodule/myobject_card.php?action=create', - 'langs'=>'mymodule@mymodule', - 'position'=>1000+\$r, - 'enabled'=>'isModEnabled(\"mymodule\")', - 'perms'=>'".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "write")' : '1')."', - 'target'=>'', - 'user'=>2, - 'object'=>'MyObject' + \$this->menu[\$r++] = array( + 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject', + 'type' => 'left', + 'titre' => 'List MyObject', + 'mainmenu' => 'mymodule', + 'leftmenu' => 'mymodule_myobject_list', + 'url' => '/mymodule/myobject_list.php', + 'langs' => 'mymodule@mymodule', + 'position' => 1000 + \$r, + 'enabled' => 'isModEnabled(\"mymodule\")', + 'perms' => '".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "read")' : '1')."', + 'target' => '', + 'user' => 2, + 'object' => 'MyObject' + ); + \$this->menu[\$r++] = array( + 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject', + 'type' => 'left', + 'titre' => 'New MyObject', + 'mainmenu' => 'mymodule', + 'leftmenu' => 'mymodule_myobject_new', + 'url' => '/mymodule/myobject_card.php?action=create', + 'langs' => 'mymodule@mymodule', + 'position' => 1000 + \$r, + 'enabled' => 'isModEnabled(\"mymodule\")', + 'perms' => '".(GETPOST('generatepermissions') ? '$user->hasRight("mymodule", "myobject", "write")' : '1')."', + 'target' => '', + 'user' => 2, + 'object' => 'MyObject' );"; $stringtoadd = preg_replace('/MyObject/', $objectname, $stringtoadd); $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); @@ -1536,15 +1574,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); } } - $menus = $moduleobj->menu; + if (is_object($moduleobj)) { + $menus = $moduleobj->menu; + } else { + $menus = array(); + } $counter = 0 ; foreach ($menus as $menu) { if ($menu['leftmenu'] == strtolower($objectname)) { @@ -1582,12 +1626,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { 'htdocs/modulebuilder/template/' => strtolower($modulename), 'myobject' => strtolower($objectname), 'MyObject' => $objectname, - //'MYOBJECT'=>strtoupper($objectname), - '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + //'MYOBJECT' => strtoupper($objectname), + '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); if (getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR')) { - $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR'); + $arrayreplacement['---Replace with your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR'); } $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); @@ -1670,6 +1714,7 @@ if ($dirins && $action == 'initdic' && $module && empty($cancel)) { if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -1751,6 +1796,9 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && $error++; setEventMessages($langs->trans("ErrorObjectNotFound", $langs->transnoentities($objectname)), null, 'errors'); } + + $addfieldentry = array(); + // We click on add property if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { if (!GETPOST('propname', 'aZ09')) { @@ -1766,6 +1814,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } + if (!$error && !GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { $addfieldentry = array( 'name' => GETPOST('propname', 'aZ09'), @@ -1786,8 +1835,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && 'cssview' => GETPOST('propcssview', 'alpha'), 'csslist' => GETPOST('propcsslist', 'alpha'), 'default' => GETPOST('propdefault', 'restricthtml'), - 'noteditable' => intval(GETPOSTINT('propnoteditable')), - //'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')), + 'noteditable' => GETPOSTINT('propnoteditable'), + //'alwayseditable' => GETPOSTINT('propalwayseditable'), 'validate' => GETPOSTINT('propvalidate') ); @@ -1801,8 +1850,6 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && } } } - } else { - $addfieldentry = array(); } /*if (GETPOST('regeneratemissing')) @@ -1913,9 +1960,12 @@ if ($dirins && $action == 'confirm_deletemodule') { dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; + if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -1994,9 +2044,11 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2083,6 +2135,8 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & if (!preg_match('/^c_/', $newdicname)) { $newdicname = 'c_'.strtolower($dicname); } + } else { + $newdicname = null; } dol_include_once($pathtofile); @@ -2091,6 +2145,7 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2113,9 +2168,13 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & $newdicname = $dicts['tabname'][GETPOSTINT('dictionnarykey') - 1]; } - //chercher la table dicname - $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname)); - if ($checkTable && $db->num_rows($checkTable) <= 0) { + // Lookup the table dicname + $checkTable = false; + if ($newdicname !== null) { + $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname)); + } + + if (is_bool($checkTable) || $db->num_rows($checkTable) <= 0) { $error++; } @@ -2171,6 +2230,7 @@ if ($dirins && $action == 'updatedictionary' && GETPOST('dictionnarykey')) { if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2239,6 +2299,7 @@ if ($dirins && $action == 'generatepackage') { if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2288,9 +2349,11 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2315,7 +2378,11 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { //check existing object permission $counter = 0; $permsForObject = array(); - $permissions = $moduleobj->rights; + if (is_object($moduleobj)) { + $permissions = $moduleobj->rights; + } else { + $permissions = array(); + } $allObject = array(); $countPerms = count($permissions); @@ -2339,15 +2406,16 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { } } + $rightToAdd = array(); if (!$error) { $key = $countPerms + 1; //prepare right to add - $rightToAdd = [ + $rightToAdd = array( 0 => $id, 1 => $label, 4 => $objectForPerms, 5 => $crud - ]; + ); if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); @@ -2384,9 +2452,11 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright') && $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrModules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2420,16 +2490,26 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright') && // $label = "Delete objects of $module"; } - $permissions = $moduleobj->rights; - $key = (int) GETPOST('counter') - 1; + if (is_object($moduleobj)) { + $permissions = $moduleobj->rights; + } else { + $permissions = []; + } + $key = GETPOSTINT('counter') - 1; //get permission want to delete from permissions array - $x1 = $permissions[$key][1]; - $x2 = $permissions[$key][4]; - $x3 = $permissions[$key][5]; + if (array_key_exists($key, $permissions)) { + $x1 = $permissions[$key][1]; + $x2 = $permissions[$key][4]; + $x3 = $permissions[$key][5]; + } else { + $x1 = null; + $x2 = null; + $x3 = null; + } //check existing object permission $counter = 0; $permsForObject = array(); - $permissions = $moduleobj->rights; + // $permissions = $moduleobj->rights; // Already fetched above $firstRight = 0; $existRight = 0; $allObject = array(); @@ -2471,6 +2551,7 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright') && if ($rewrite < 0) { setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Permissions"), "mod".$module."class.php"), null, 'warnings'); } else { + $rightUpdated = null; // I not set at this point reWriteAllPermissions($moduledescriptorfile, $permissions, $key, $rightUpdated, '', '', 2); setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); clearstatcache(true); @@ -2489,9 +2570,11 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOSTINT $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2661,9 +2744,11 @@ if ($dirins && $action == 'confirm_deletemenu' && GETPOSTINT('menukey')) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2723,9 +2808,11 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2879,9 +2966,11 @@ if ($dirins && $action == "update_menu" && GETPOSTINT('menukey') && GETPOST('tab $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -2980,9 +3069,11 @@ if ($dirins && $action == "update_props_module" && !empty(GETPOST('keydescriptio dol_include_once($pathtofile); $class = 'mod'.$module; + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); @@ -3140,9 +3231,11 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $loadclasserrormessage .= 'Line: '.$e->getLine()."
\n"; } + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; print $e->getMessage(); @@ -3229,7 +3322,7 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 8px"').''; } } else { - if (!empty($moduleobj)) { + if (is_object($moduleobj)) { $linktoenabledisable .= ''; $linktoenabledisable .= img_picto($langs->trans("ModuleIsNotActive", $urltomodulesetup), 'switch_off', 'style="padding-right: 8px"', false, 0, 0, '', 'classfortooltip', 1); $linktoenabledisable .= "\n"; @@ -3528,7 +3621,7 @@ if ($module == 'initmodule') { print load_fiche_titre($form->textwithpicto($langs->trans("DescriptorFile"), $langs->transnoentitiesnoconv("File").' '.$pathtofile), '', ''); - if (!empty($moduleobj)) { + if (is_object($moduleobj)) { print '
'; print '
'; print '
'; @@ -3745,7 +3838,7 @@ if ($module == 'initmodule') { print ''; print ''; print ''; - print $formadmin->select_language(getDolGlobalString('MAIN_LANG_DEFAULT'), 'newlangcode', 0, 0, 1, 0, 0, 'minwidth300', 1); + print $formadmin->select_language(getDolGlobalString('MAIN_LANG_DEFAULT'), 'newlangcode', 0, array(), 1, 0, 0, 'minwidth300', 1); print '
'; print '
'; @@ -6245,6 +6338,7 @@ if ($module == 'initmodule') { print ''; print ''; + $texttoshow = null; if ($cron['jobtype'] == 'method') { $text = $langs->trans("CronClass"); $texttoshow = $langs->trans('CronModule').': '.$module.'
'; @@ -6457,10 +6551,11 @@ if ($module == 'initmodule') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; - + $moduleobj = null; if (class_exists($class)) { try { $moduleobj = new $class($db); + '@phan-var-force DolibarrMOdules $moduleobj'; } catch (Exception $e) { $error++; dol_print_error($db, $e->getMessage()); diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index ecacf04f4c1..8f870de9c6f 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 +29,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; diff --git a/htdocs/modulebuilder/template/admin/myobject_extrafields.php b/htdocs/modulebuilder/template/admin/myobject_extrafields.php index 2cb2cc6882d..76526a7ae85 100644 --- a/htdocs/modulebuilder/template/admin/myobject_extrafields.php +++ b/htdocs/modulebuilder/template/admin/myobject_extrafields.php @@ -33,7 +33,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index f8a1e7b9041..b245895a586 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -1,7 +1,6 @@ - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -218,26 +217,26 @@ if ($action == 'updateMask') { $className = $myTmpObjects[$tmpobjectkey]['class']; $tmpobject = new $className($db); + '@phan-var-force MyObject $tmpobject'; $tmpobject->initAsSpecimen(); // Search template files $file = ''; $className = ''; - $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { - $filefound = 1; $className = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } - if ($filefound) { + if ($className !== '') { require_once $file; $module = new $className($db); + '@phan-var-force ModelePDFMyObject $module'; '@phan-var-force ModelePDFMyObject $module'; @@ -372,8 +371,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file.'.php'; $module = new $file($db); - - '@phan-var-force CommonNumRefGenerator $module'; + '@phan-var-force ModeleNumRefMyObject $module'; // Show modules according to features level if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -416,6 +414,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $className = $myTmpObjectArray['class']; $mytmpinstance = new $className($db); + '@phan-var-force MyObject $mytmpinstance'; $mytmpinstance->initAsSpecimen(); // Info @@ -498,6 +497,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { + $filelist = array(); while (($file = readdir($handle)) !== false) { $filelist[] = $file; } @@ -512,7 +512,6 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { require_once $dir.'/'.$file; $module = new $className($db); - '@phan-var-force ModelePDFMyObject $module'; $modulequalified = 1; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index f3427bf8a8d..e9ec563ebeb 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -1,7 +1,6 @@ - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -22,7 +21,7 @@ * \ingroup mymodule * \brief Example hook overload. * - * Put detailed description here. + * TODO: Write detailed description here. */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php'; @@ -43,13 +42,13 @@ class ActionsMyModule extends CommonHookActions public $error = ''; /** - * @var array Errors + * @var string[] Errors */ public $errors = array(); /** - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse + * @var mixed[] Hook results. Propagated to $hookmanager->resArray for later reuse */ public $results = array(); @@ -67,7 +66,7 @@ class ActionsMyModule extends CommonHookActions /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { @@ -78,12 +77,12 @@ class ActionsMyModule extends CommonHookActions /** * Execute action * - * @param array $parameters Array of parameters - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action 'add', 'update', 'view' - * @return int Return integer <0 if KO, + * @param array $parameters Array of parameters + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action 'add', 'update', 'view' + * @return int Return integer <0 if KO, * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. + * >0 if OK and we want to replace standard actions. */ public function getNomUrl($parameters, &$object, &$action) { @@ -93,13 +92,13 @@ class ActionsMyModule extends CommonHookActions } /** - * Overloading the doActions function : replacing the parent's function with the one below + * Overload the doActions function : replacing the parent's function with the one below * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code + * @param array $parameters Hook metadata (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param ?string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code */ public function doActions($parameters, &$object, &$action, $hookmanager) { @@ -108,9 +107,10 @@ class ActionsMyModule extends CommonHookActions $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ + // @phan-suppress-next-line PhanPluginEmptyStatementIf if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' // Do what you want here... - // You can for example load and use call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and GETPOST values. + // You can for example load and use call global vars like $fieldstosearchall to overwrite them, or update the database depending on $action and GETPOST values. } if (!$error) { @@ -125,13 +125,13 @@ class ActionsMyModule extends CommonHookActions /** - * Overloading the doMassActions function : replacing the parent's function with the one below + * Overload the doMassActions function : replacing the parent's function with the one below * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code + * @param array $parameters Hook metadata (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param ?string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code */ public function doMassActions($parameters, &$object, &$action, $hookmanager) { @@ -141,6 +141,7 @@ class ActionsMyModule extends CommonHookActions /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + // @phan-suppress-next-line PhanPluginEmptyStatementForeachLoop foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } @@ -158,13 +159,13 @@ class ActionsMyModule extends CommonHookActions /** - * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * Overload the addMoreMassActions function : replacing the parent's function with the one below * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code + * @param array $parameters Hook metadata (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param ?string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code */ public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) { @@ -189,14 +190,14 @@ class ActionsMyModule extends CommonHookActions /** - * Execute action + * Execute action before PDF (document) creation * - * @param array $parameters Array of parameters - * @param Object $object Object output on PDF - * @param string $action 'add', 'update', 'view' - * @return int Return integer <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. + * @param array $parameters Array of parameters + * @param CommonObject $object Object output on PDF + * @param string $action 'add', 'update', 'view' + * @return int Return integer <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. */ public function beforePDFCreation($parameters, &$object, &$action) { @@ -210,6 +211,7 @@ class ActionsMyModule extends CommonHookActions dol_syslog(get_class($this).'::executeHooks action='.$action); /* print_r($parameters); print_r($object); echo "action: " . $action; */ + // @phan-suppress-next-line PhanPluginEmptyStatementIf if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' } @@ -217,14 +219,14 @@ class ActionsMyModule extends CommonHookActions } /** - * Execute action + * Execute action after PDF (document) creation * - * @param array $parameters Array of parameters - * @param Object $pdfhandler PDF builder handler - * @param string $action 'add', 'update', 'view' - * @return int Return integer <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. + * @param array $parameters Array of parameters + * @param CommonDocGenerator $pdfhandler PDF builder handler + * @param string $action 'add', 'update', 'view' + * @return int Return integer <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. */ public function afterPDFCreation($parameters, &$pdfhandler, &$action) { @@ -238,6 +240,7 @@ class ActionsMyModule extends CommonHookActions dol_syslog(get_class($this).'::executeHooks action='.$action); /* print_r($parameters); print_r($object); echo "action: " . $action; */ + // @phan-suppress-next-line PhanPluginEmptyStatementIf if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' } @@ -248,12 +251,12 @@ class ActionsMyModule extends CommonHookActions /** - * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool + * Overload the loadDataForCustomReports function : returns data to complete the customreport tool * - * @param array $parameters Hook metadatas (context, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code + * @param array $parameters Hook metadata (context, etc...) + * @param ?string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int Return integer < 0 on error, 0 on success, 1 to replace standard code */ public function loadDataForCustomReports($parameters, &$action, $hookmanager) { @@ -293,14 +296,14 @@ class ActionsMyModule extends CommonHookActions /** - * Overloading the restrictedArea function : check permission on an object + * Overload the restrictedArea function : check permission on an object * - * @param array $parameters Hook metadatas (context, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int Return integer <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. + * @param array $parameters Hook metadata (context, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int Return integer <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. */ public function restrictedArea($parameters, &$action, $hookmanager) { @@ -322,13 +325,13 @@ class ActionsMyModule extends CommonHookActions /** * Execute action completeTabsHead * - * @param array $parameters Array of parameters - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action 'add', 'update', 'view' - * @param Hookmanager $hookmanager hookmanager - * @return int Return integer <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. + * @param array $parameters Array of parameters + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action 'add', 'update', 'view' + * @param Hookmanager $hookmanager Hookmanager + * @return int Return integer <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. */ public function completeTabsHead(&$parameters, &$object, &$action, $hookmanager) { @@ -364,7 +367,7 @@ class ActionsMyModule extends CommonHookActions // return 1 to replace standard code return 1; } else { - // en V14 et + $parameters['head'] est modifiable par référence + // From V14 onwards, $parameters['head'] is modifiable by referende return 0; } } else { @@ -373,5 +376,5 @@ class ActionsMyModule extends CommonHookActions } } - /* Add here any other hooked methods... */ + /* Add other hook methods here... */ } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index d41f3e2ca66..818992d46c1 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -1,7 +1,6 @@ - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -65,6 +64,8 @@ class MyModuleApi extends DolibarrApi * * @param int $id ID of myobject * @return Object Object with cleaned properties + * @phan-return MyObject Object with cleaned properties + * @phpstan-return MyObject Object with cleaned properties * * @phan-return MyObject * @@ -102,9 +103,9 @@ class MyModuleApi extends DolibarrApi * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names - * @return array Array of ordered objects - * - * @phan-return MyObject[] + * @return array Array of MyObject objects + * @phan-return array + * @phpstan-return array * * @throws RestException 403 Not allowed * @throws RestException 503 System error @@ -192,7 +193,8 @@ class MyModuleApi extends DolibarrApi * Create myobject object * * @param array $request_data Request data - * @phan-param array $request_data + * @phan-param array{string,mixed} $request_data + * @phpstan-param array{string,mixed} $request_data * @return int ID of myobject * * @throws RestException 403 Not allowed @@ -239,9 +241,12 @@ class MyModuleApi extends DolibarrApi * Update myobject * * @param int $id Id of myobject to update - * @param array $request_data Datas - * @phan-param array $request_data + * @param array $request_data Data + * @phan-param mixed[] $request_data + * @phpstan-param mixed[] $request_data * @return Object Object after update + * @phan-return MyObject + * @phpstan-return MyObject * * @phan-return MyObject * @@ -300,7 +305,8 @@ class MyModuleApi extends DolibarrApi * * @param int $id MyObject ID * @return array - * @phan-return array + * @phan-return array + * @phpstan-return array * * @throws RestException 403 Not allowed * @throws RestException 404 Not found @@ -342,9 +348,11 @@ class MyModuleApi extends DolibarrApi * Validate fields before creating or updating object * * @param array $data Array of data to validate - * @phan-param array $data + * @phan-param array $data + * @phpstan-param array $data * @return array - * @phan-return array $data + * @phan-return array|array{} + * @phpstan-return array|array{} * * @throws RestException */ @@ -369,10 +377,14 @@ class MyModuleApi extends DolibarrApi // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Clean sensible object data fields + * Clean sensitive object data fields + * @phpstan-template T of Object * * @param Object $object Object to clean * @return Object Object with cleaned properties + * + * @phpstan-param T $object + * @phpstan-return T */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index c2045903283..3d24afca4f3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1,8 +1,7 @@ * Copyright (C) 2023-2024 Frédéric France - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -107,30 +106,28 @@ class MyObject extends CommonObject // BEGIN MODULEBUILDER PROPERTIES /** - * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @inheritdoc + * Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'noteditable' => 1, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id', 'css' => 'left'), - 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'default' => 1, 'index' => 1, 'position' => 10), - 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 1, 'noteditable' => 0, 'default' => '', 'notnull' => 1, 'showoncombobox' => 1, 'index' => 1, 'position' => 20, 'searchall' => 1, 'comment' => 'Reference of object', 'validate' => 1), - 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'help' => 'Help text', 'showoncombobox' => 2, 'validate' => 1, 'alwayseditable' => 1), - 'amount' => array('type' => 'price', 'label' => 'Amount', 'enabled' => 1, 'visible' => 1, 'default' => 'null', 'position' => 40, 'searchall' => 0, 'isameasure' => 1, 'help' => 'Help text for amount', 'validate' => 1), - 'qty' => array('type' => 'real', 'label' => 'Qty', 'enabled' => 1, 'visible' => 1, 'default' => '0', 'position' => 45, 'searchall' => 0, 'isameasure' => 1, 'help' => 'Help text for quantity', 'css' => 'maxwidth75imp', 'validate' => 1), - 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'picto' => 'company', 'label' => 'ThirdParty', 'visible' => 1, 'enabled' => 'isModEnabled("societe")', 'position' => 50, 'notnull' => -1, 'index' => 1, 'help' => 'OrganizationEventLinkToThirdParty', 'validate' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), - 'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => 'isModEnabled("project")', 'visible' => -1, 'position' => 52, 'notnull' => -1, 'index' => 1, 'validate' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), - 'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => 1, 'visible' => 3, 'position' => 60, 'validate' => 1), - 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 61, 'validate' => 1, 'cssview' => 'wordbreak'), - 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 62, 'validate' => 1, 'cssview' => 'wordbreak'), - 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 500), - 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -2, 'notnull' => 0, 'position' => 501), - //'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 510, 'foreignkey' => 'user.rowid', 'csslist' => 'tdoverflowmax150'), - 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 511, 'csslist' => 'tdoverflowmax150'), - //'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => 0, 'notnull' => 0, 'position' => 600), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'index' => 0, 'position' => 1000), - 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'notnull' => -1, 'position' => 1010), - 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'default' => 0, 'index' => 1, 'position' => 2000, 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', 9 => 'Canceled'), 'validate' => 1), + "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 1, 'notnull' => 1, "visible" => "0", "noteditable" => "1", "index" => "1", "css" => "left", "comment" => "Id"), + "ref" => array("type" => "varchar(128)", "label" => "Ref", "enabled" => "1", 'position' => 20, 'notnull' => 1, "visible" => "1", "index" => "1", "searchall" => "1", "showoncombobox" => "1", "validate" => "1", "comment" => "Reference of object"), + "label" => array("type" => "varchar(255)", "label" => "Label", "enabled" => "1", 'position' => 30, 'notnull' => 0, "visible" => "1", "alwayseditable" => "1", "searchall" => "1", "css" => "minwidth300", "cssview" => "wordbreak", "help" => "Help text", "showoncombobox" => "2", "validate" => "1",), + "amount" => array("type" => "price", "label" => "Amount", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "1", "default" => "null", "isameasure" => "1", "help" => "Help text for amount", "validate" => "1",), + "qty" => array("type" => "real", "label" => "Qty", "enabled" => "1", 'position' => 45, 'notnull' => 0, "visible" => "1", "default" => "0", "isameasure" => "1", "css" => "maxwidth75imp", "help" => "Help text for quantity", "validate" => "1",), + "fk_soc" => array("type" => "integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))", "label" => "ThirdParty", "picto" => "company", "enabled" => "isModEnabled('societe')", 'position' => 50, 'notnull' => -1, "visible" => "1", "index" => "1", "css" => "maxwidth500 widthcentpercentminusxx", "csslist" => "tdoverflowmax150", "help" => "OrganizationEventLinkToThirdParty", "validate" => "1",), + "fk_project" => array("type" => "integer:Project:projet/class/project.class.php:1", "label" => "Project", "picto" => "project", "enabled" => "isModEnabled('project')", 'position' => 52, 'notnull' => -1, "visible" => "-1", "index" => "1", "css" => "maxwidth500 widthcentpercentminusxx", "csslist" => "tdoverflowmax150", "validate" => "1",), + "description" => array("type" => "text", "label" => "Description", "enabled" => "1", 'position' => 60, 'notnull' => 0, "visible" => "3", "validate" => "1",), + "note_public" => array("type" => "html", "label" => "NotePublic", "enabled" => "1", 'position' => 61, 'notnull' => 0, "visible" => "0", "cssview" => "wordbreak", "validate" => "1",), + "note_private" => array("type" => "html", "label" => "NotePrivate", "enabled" => "1", 'position' => 62, 'notnull' => 0, "visible" => "0", "cssview" => "wordbreak", "validate" => "1",), + "date_creation" => array("type" => "datetime", "label" => "DateCreation", "enabled" => "1", 'position' => 500, 'notnull' => 1, "visible" => "-2",), + "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 501, 'notnull' => 0, "visible" => "-2",), + "fk_user_creat" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserAuthor", "picto" => "user", "enabled" => "1", 'position' => 510, 'notnull' => 1, "visible" => "-2", "foreignkey" => "0", "csslist" => "tdoverflowmax150",), + "fk_user_modif" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserModif", "picto" => "user", "enabled" => "1", 'position' => 511, 'notnull' => -1, "visible" => "-2", "csslist" => "tdoverflowmax150",), + "last_main_doc" => array("type" => "varchar(255)", "label" => "LastMainDoc", "enabled" => "1", 'position' => 600, 'notnull' => 0, "visible" => "0",), + "import_key" => array("type" => "varchar(14)", "label" => "ImportId", "enabled" => "1", 'position' => 1000, 'notnull' => -1, "visible" => "-2",), + "model_pdf" => array("type" => "varchar(255)", "label" => "Model pdf", "enabled" => "1", 'position' => 1010, 'notnull' => -1, "visible" => "0",), + "status" => array("type" => "integer", "label" => "Status", "enabled" => "1", 'position' => 2000, 'notnull' => 1, "visible" => "1", "index" => "1", "arrayofkeyval" => array("0" => "Draft", "1" => "Validated", "9" => "Canceled"), "validate" => "1",), ); /** @@ -162,6 +159,9 @@ class MyObject extends CommonObject * @var int Thirdparty ID */ public $socid; // both socid and fk_soc are used + /** + * @var int Thirdparty ID + */ public $fk_soc; // both socid and fk_soc are used /** @@ -230,7 +230,7 @@ class MyObject extends CommonObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { @@ -275,9 +275,9 @@ class MyObject extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers - * @return int<-1,max> Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int<-1,max> Return integer <0 if KO, Id of created object if OK */ public function create(User $user, $notrigger = 0) { @@ -291,9 +291,9 @@ class MyObject extends CommonObject /** * Clone an object into another one * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return self|int<-1,-1> New object created, <0 if KO */ public function createFromClone(User $user, $fromid) { @@ -390,11 +390,11 @@ class MyObject extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref + * @param int $id Id object + * @param string $ref Ref * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=No extrafields * @param int<0,1> $nolines 0=Default to load extrafields, 1=No extrafields - * @return int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK + * @return int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null, $noextrafields = 0, $nolines = 0) { @@ -409,7 +409,7 @@ class MyObject extends CommonObject * Load object lines in memory from the database * * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=No extrafields - * @return int<1,1> Return integer <0 if KO, 0 if not found, >0 if OK + * @return int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetchLines($noextrafields = 0) { @@ -432,7 +432,7 @@ class MyObject extends CommonObject * @param string $filter Filter as an Universal Search string. * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * @param string $filtermode No longer used - * @return self[]|int<-1,-1> int <0 if KO, array of pages if OK + * @return array|int<-1,-1> <0 if KO, array of pages if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 1000, $offset = 0, string $filter = '', $filtermode = 'AND') { @@ -752,9 +752,9 @@ class MyObject extends CommonObject /** * getTooltipContentArray * - * @param array $params Params to construct tooltip data + * @param array $params Params to construct tooltip data * @since v18 - * @return array + * @return array{optimize?:string,picto?:string,ref?:string} */ public function getTooltipContentArray($params) { @@ -782,11 +782,11 @@ class MyObject extends CommonObject /** * Return a link to the object card (with optionally the picto) * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -904,9 +904,9 @@ class MyObject extends CommonObject /** * Return a thumb for kanban views * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param ?array $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = null) { @@ -947,7 +947,7 @@ class MyObject extends CommonObject /** * Return the label of the status * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLabelStatus($mode = 0) @@ -958,8 +958,8 @@ class MyObject extends CommonObject /** * Return the label of the status * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -970,9 +970,9 @@ class MyObject extends CommonObject /** * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { @@ -1004,7 +1004,7 @@ class MyObject extends CommonObject /** * Load the info information in the object * - * @param int $id Id of object + * @param int $id Id of object * @return void */ public function info($id) @@ -1056,10 +1056,10 @@ class MyObject extends CommonObject } /** - * Initialise object with example values + * Initialize object with example values * Id must be 0 if object instance is a specimen * - * @return int + * @return int */ public function initAsSpecimen() { @@ -1073,7 +1073,7 @@ class MyObject extends CommonObject /** * Create an array of lines * - * @return array|int array of lines if OK, <0 if KO + * @return CommonObjectLine[]|int array of lines if OK, <0 if KO */ public function getLinesArray() { @@ -1094,7 +1094,7 @@ class MyObject extends CommonObject /** * Returns the reference to the following non used object depending on the active numbering module. * - * @return string Object free reference + * @return string Object free reference */ public function getNextNumRef() { @@ -1127,6 +1127,7 @@ class MyObject extends CommonObject if (class_exists($classname)) { $obj = new $classname(); + '@phan-var-force ModeleNumRefMyObject $obj'; $numref = $obj->getNextValue($this); if ($numref != '' && $numref != '-1') { @@ -1149,13 +1150,13 @@ class MyObject extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Force template to use ('' to not force) - * @param Translate $outputlangs object lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs object lang a utiliser pour traduction + * @param int<0,1> $hidedetails Hide details of lines + * @param int<0,1> $hidedesc Hide description + * @param int<0,1> $hideref Hide ref + * @param ?array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -1189,10 +1190,10 @@ class MyObject extends CommonObject * Return validation test result for a field. * Need MAIN_ACTIVATE_VALIDATION_RESULT to be called. * - * @param array $fields Array of properties of field to show - * @param string $fieldKey Key of attribute - * @param string $fieldValue value of attribute - * @return bool Return false if fail, true on success, set $this->error for error message + * @param array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> $fields Array of properties of field to show + * @param string $fieldKey Key of attribute + * @param string $fieldValue value of attribute + * @return bool Return false if fail, true on success, set $this->error for error message */ public function validateField($fields, $fieldKey, $fieldValue) { @@ -1261,7 +1262,7 @@ class MyObjectLine extends CommonObjectLine /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index fc3f69c412b..90321797398 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -1,8 +1,7 @@ * Copyright (C) 2018-2023 Frédéric France - * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -189,7 +188,7 @@ class mymodulewidget1 extends ModeleBoxes * @param ?array{text?:string,sublink?:string,subpicto:?string,nbcol?:int,limit?:int,subclass?:string,graph?:string} $head Array with properties of box title * @param ?array> $contents Array with properties of box lines * @param int<0,1> $nooutput When 1, do not print, return string - * @return ?string + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php index c885b1355c6..8375a01d867 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailing_mymodule_selector1.modules.php @@ -1,7 +1,6 @@ - * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -23,11 +22,18 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets public $name = 'mailing_mymodule_selector1'; // CHANGE THIS: Put here a description of your selector module public $desc = 'Emailing target selector1'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + /** + * @var int<0,1> + */ public $require_admin = 0; public $enabled = 'isModEnabled("mymodule")'; + /** + * @var string[] The modules on which this selector depends (can be "none" to not show the module. + */ public $require_module = array(); /** @@ -165,7 +171,7 @@ class mailing_mailing_mymodule_selector1 extends MailingTargets * array of SQL request that returns two field: * One called "label", One called "nb". * - * @return string[] + * @return array{}|array{label:string,nb:string} */ public function getSqlArrayForStats() { diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 3f954cdd7a4..636141c9ed5 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -2,8 +2,7 @@ /* Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2018-2019 Nicolas ZABOURI * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -42,7 +41,7 @@ class modMyModule extends DolibarrModules */ public function __construct($db) { - global $conf; + global $conf, $langs; $this->db = $db; @@ -189,11 +188,11 @@ class modMyModule extends DolibarrModules /* END MODULEBUILDER TABS */ // Example: // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight('mymodule', 'read'):/mymodule/mynewtab1.php?id=__ID__'); + // $this->tabs[] = array('data' => 'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight(\'mymodule\', \'read\'):/mymodule/mynewtab1.php?id=__ID__'); // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->hasRight('othermodule', 'read'):/mymodule/mynewtab2.php?id=__ID__', + // $this->tabs[] = array('data' => 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->hasRight(\'othermodule\', \'read\'):/mymodule/mynewtab2.php?id=__ID__', // To remove an existing tab identified by code tabname - // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); + // $this->tabs[] = array('data' => 'objecttype:-tabname:NU:conditiontoremove'); // // Where objecttype can be // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) @@ -221,27 +220,27 @@ class modMyModule extends DolibarrModules // Dictionaries /* Example: $this->dictionaries=array( - 'langs'=>'mymodule@mymodule', + 'langs' => 'mymodule@mymodule', // List of tables we want to see into dictonnary editor - 'tabname'=>array("table1", "table2", "table3"), + 'tabname' => array("table1", "table2", "table3"), // Label of tables - 'tablib'=>array("Table1", "Table2", "Table3"), + 'tablib' => array("Table1", "Table2", "Table3"), // Request to select fields - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Sort order - 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), + 'tabsqlsort' => array("label ASC", "label ASC", "label ASC"), // List of fields (result of select to show dictionary) - 'tabfield'=>array("code,label", "code,label", "code,label"), + 'tabfield' => array("code,label", "code,label", "code,label"), // List of fields (list of fields to edit a record) - 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), + 'tabfieldvalue' => array("code,label", "code,label", "code,label"), // List of fields (list of fields for insert) - 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), + 'tabfieldinsert' => array("code,label", "code,label", "code,label"), // Name of columns with primary key (try to always name it 'rowid') - 'tabrowid'=>array("rowid", "rowid", "rowid"), + 'tabrowid' => array("rowid", "rowid", "rowid"), // Condition to show each dictionary - 'tabcond'=>array(isModEnabled('mymodule'), isModEnabled('mymodule'), isModEnabled('mymodule')), + 'tabcond' => array(isModEnabled('mymodule'), isModEnabled('mymodule'), isModEnabled('mymodule')), // Tooltip for every fields of dictionaries: DO NOT PUT AN EMPTY ARRAY - 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), ...), + 'tabhelp' => array(array('code' => $langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), array('code' => $langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), ...), ); */ /* BEGIN MODULEBUILDER DICTIONARIES */ @@ -337,50 +336,50 @@ class modMyModule extends DolibarrModules /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */ /* $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'MyObject', + 'fk_menu' => 'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type' => 'left', // This is a Left menu entry + 'titre' => 'MyObject', 'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth valignmiddle paddingright"'), - 'mainmenu'=>'mymodule', - 'leftmenu'=>'myobject', - 'url'=>'/mymodule/mymoduleindex.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. - 'perms'=>'$user->hasRight("mymodule", "myobject", "read")', - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - 'object'=>'MyObject' + 'mainmenu' => 'mymodule', + 'leftmenu' => 'myobject', + 'url' => '/mymodule/mymoduleindex.php', + 'langs' => 'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position' => 1000 + $r, + 'enabled' => 'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. + 'perms' => '$user->hasRight("mymodule", "myobject", "read")', + 'target' => '', + 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both + 'object' => 'MyObject' ); $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New_MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_new', - 'url'=>'/mymodule/myobject_card.php?action=create', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->hasRight("mymodule", "myobject", "write")' - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - 'object'=>'MyObject' + 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type' => 'left', // This is a Left menu entry + 'titre' => 'New_MyObject', + 'mainmenu' => 'mymodule', + 'leftmenu' => 'mymodule_myobject_new', + 'url' => '/mymodule/myobject_card.php?action=create', + 'langs' => 'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position' => 1000 + $r, + 'enabled' => 'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms' => '$user->hasRight("mymodule", "myobject", "write")' + 'target' => '', + 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both + 'object' => 'MyObject' ); $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List_MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_list', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. - 'perms'=>'$user->hasRight("mymodule", "myobject", "read")' - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - 'object'=>'MyObject' + 'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type' => 'left', // This is a Left menu entry + 'titre' => 'List_MyObject', + 'mainmenu' => 'mymodule', + 'leftmenu' => 'mymodule_myobject_list', + 'url' => '/mymodule/myobject_list.php', + 'langs' => 'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position' => 1000 + $r, + 'enabled' => 'isModEnabled("mymodule")', // Define condition to show or hide menu entry. Use 'isModEnabled("mymodule")' if entry must be visible if module is enabled. + 'perms' => '$user->hasRight("mymodule", "myobject", "read")' + 'target' => '', + 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both + 'object' => 'MyObject' ); */ /* END MODULEBUILDER LEFTMENU MYOBJECT */ @@ -405,10 +404,10 @@ class modMyModule extends DolibarrModules include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@mymodule'; //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r] = array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - //$this->export_special_array[$r] = array('t.field'=>'...'); - //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); - //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); + //$this->export_dependencies_array[$r] = array('myobjectline' => array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$this->export_special_array[$r] = array('t.field' => '...'); + //$this->export_examplevalues_array[$r] = array('t.field' => 'Example'); + //$this->export_help_array[$r] = array('t.field' => 'FieldDescHelp'); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mymodule_myobject as t'; //$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'mymodule_myobject_line as tl ON tl.fk_myobject = t.rowid'; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 2f9988bc741..968920c09fa 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -6,7 +6,7 @@ * Copyright (C) 2018-2021 Philippe Grand * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -63,7 +63,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 411a3658018..342afa54c73 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -10,7 +10,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -102,7 +102,7 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { @@ -261,6 +261,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (getMultidirOutput($object)) { $object->fetch_thirdparty(); + $dir = null; // Definition of $dir and $file if ($object->specimen) { $dir = getMultidirOutput($object); @@ -270,6 +271,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $dir = getMultidirOutput($object)."/".$objectref; $file = $dir."/".$objectref.".pdf"; } + if ($dir === null) { + return 0; + } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); @@ -293,6 +297,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Create pdf instance $pdf = pdf_getInstance($this->format); + '@phan-var-force TCPDI|TCPDF $pdf'; $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); @@ -346,6 +351,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info); } + // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -499,7 +505,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - $tab_height = $tab_height - $height_note; + $tab_height -= $height_note; $tab_top = $posyafter + 6; } else { $height_note = 0; @@ -791,7 +797,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); + $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod } $pdf->Close(); @@ -841,15 +847,15 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Show table for lines * - * @param tcpdf $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) - * @param int $nexY Y (not used) - * @param Translate $outputlangs Langs object - * @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title - * @param int<0,1> $hidebottom Hide bottom bar of array - * @param string $currency Currency code - * @param ?Translate $outputlangsbis Langs object bis + * @param TCPDF|TCPDI $pdf Object PDF + * @param int $tab_top Top position of table + * @param int $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int<0,1> $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @param ?Translate $outputlangsbis Langs object bis * @return void */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) @@ -880,7 +886,7 @@ class pdf_standard_myobject extends ModelePDFMyObject //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -902,12 +908,12 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Show top header of page. * - * @param TCPDF $pdf Object PDF - * @param MyObject $object Object to show - * @param int<0,1> $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @param ?Translate $outputlangsbis Object lang for output bis - * @return float|int Return topshift value + * @param TCPDF|TCPDI $pdf Object PDF + * @param MyObject $object Object to show + * @param int<0,1> $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @param ?Translate $outputlangsbis Object lang for output bis + * @return float|int Return topshift value */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { @@ -993,10 +999,12 @@ class pdf_standard_myobject extends ModelePDFMyObject $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); - if ($object->ref_client) { + // @phan-suppress-next-line PhanUndeclaredProperty + if (property_exists($object, 'ref_client') && $object->ref_client) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); + // @phan-suppress-next-line PhanUndeclaredProperty $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } @@ -1029,7 +1037,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("Date"); } - $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_creation, "day", false, $outputlangs, true), '', 'R'); if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) { $posy += 3; @@ -1119,6 +1127,8 @@ class pdf_standard_myobject extends ModelePDFMyObject if (is_object($thirdparty)) { $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + } else { + $carac_client_name = null; } $mode = 'target'; @@ -1148,6 +1158,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); + // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection); $posy = $pdf->getY(); @@ -1155,6 +1166,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); + // @phan-suppress-next-line PhanPluginSuspiciousParamOrder $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection); } @@ -1166,11 +1178,11 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Show footer of page. Need this->emetteur object * - * @param TCPDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int<0,1> $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param TCPDI|TCPDF $pdf PDF + * @param CommonObject $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int<0,1> $hidefreetext 1=Hide free text + * @return int<0,1> Return height of bottom margin including footer text */ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { @@ -1182,11 +1194,11 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Define Array Column Field * - * @param CommonObject $object common object - * @param Translate $outputlangs langs + * @param CommonObject $object common object + * @param Translate $outputlangs langs * @param int<0,1> $hidedetails Do not show line details * @param int<0,1> $hidedesc Do not show desc - * @param int<0,1> $hideref Do not show ref + * @param int<0,1> $hideref Do not show ref * @return void */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) @@ -1242,7 +1254,7 @@ class pdf_standard_myobject extends ModelePDFMyObject ); // PHOTO - // $rank = $rank + 10; + // $rank += 10; // $this->cols['photo'] = array( // 'rank' => $rank, // 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm @@ -1262,7 +1274,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // } - $rank = $rank + 10; + $rank += 10; $this->cols['vat'] = array( 'rank' => $rank, 'status' => false, @@ -1277,7 +1289,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->cols['vat']['status'] = true; } - $rank = $rank + 10; + $rank += 10; $this->cols['subprice'] = array( 'rank' => $rank, 'width' => 19, // in mm @@ -1288,7 +1300,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - $rank = $rank + 10; + $rank += 10; $this->cols['qty'] = array( 'rank' => $rank, 'width' => 16, // in mm @@ -1299,7 +1311,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - $rank = $rank + 10; + $rank += 10; $this->cols['unit'] = array( 'rank' => $rank, 'width' => 11, // in mm @@ -1313,7 +1325,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->cols['unit']['status'] = true; } - $rank = $rank + 10; + $rank += 10; $this->cols['discount'] = array( 'rank' => $rank, 'width' => 13, // in mm @@ -1327,7 +1339,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->cols['discount']['status'] = true; } - $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100 + $rank += 1000; // add a big offset to be sure is the last col because default extrafield rank is 100 $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm @@ -1356,6 +1368,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } elseif (empty($reshook)) { + // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys } else { $this->cols = $hookmanager->resArray; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index d34bee94ea6..c8117863f12 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -5,7 +5,7 @@ * Copyright (C) 2008i Raphael Bertrand (Resultic) * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -124,8 +124,8 @@ class mod_myobject_advanced extends ModeleNumRefMyObject /** * Return next free value * - * @param MyObject $object Object we need next value for - * @return string|int<-1,0> Next free value if OK, <=0 if KO + * @param MyObject $object Object we need next value for + * @return string|int<-1,0> Next value if OK, <=0 if KO */ public function getNextValue($object) { @@ -141,7 +141,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject return 0; } - $date = $object->date; + $date = $object->date_creation; $numFinal = get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', '', $date); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index 3670e7f9c5e..4d2329d8a2f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -38,6 +38,9 @@ class mod_myobject_standard extends ModeleNumRefMyObject */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + /** + * @var string + */ public $prefix = 'MYOBJECT'; /** @@ -78,8 +81,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param MyObject $object Object we need next value for - * @return bool false if conflict, true if ok + * @param CommonObject $object Object we need next value for + * @return bool false if conflict, true if ok */ public function canBeActivated($object) { @@ -94,7 +97,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; if ($object->ismultientitymanaged == 1) { $sql .= " AND entity = ".$conf->entity; - } elseif ($object->ismultientitymanaged == 2) { + } elseif ($object->ismultientitymanaged == 2) { // @phan-suppress-current-line PhanPluginEmptyStatementIf // TODO } @@ -118,8 +121,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject /** * Return next free value * - * @param MyObject $object Object we need next value for - * @return string|int<-1,0> Next free value if OK, -1 if KO + * @param MyObject $object Object we need next value for + * @return string|int<-1,0> Next value if OK, <=0 if KO */ public function getNextValue($object) { @@ -156,7 +159,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject 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("%04u", $max + 1); } dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php index b32b87c6ab1..ea6858106e9 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php @@ -7,7 +7,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -59,22 +59,19 @@ abstract class ModelePDFMyObject extends CommonDocGenerator return $list; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build and write pdf to disk + * Function to build a document on disk * - * @param MyObject $object Source object to generate document from - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int<0,1> $hidedetails Do not show line details - * @param int<0,1> $hidedesc Do not show desc - * @param int<0,1> $hideref Do not show ref - * @return int<-1,1> 1 if OK, <=0 if KO + * @param MyObject $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int<0,1> $hidedetails Do not show line details + * @param int<0,1> $hidedesc Do not show desc + * @param int<0,1> $hideref Do not show ref + * @return int<-1,1> 1 if OK, <=0 if KO */ abstract public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0); - // phpcs:enable } @@ -84,10 +81,17 @@ abstract class ModelePDFMyObject extends CommonDocGenerator abstract class ModeleNumRefMyObject extends CommonNumRefGenerator { /** - * Return next free value + * Return an example of numbering * - * @param MyObject $object Object we need next value for - * @return string|int<-1,0> Next free value if OK, -1 if KO + * @return string Example + */ + abstract public function getExample(); + + /** + * Return next free value + * + * @param MyObject $object Object we need next value for + * @return string|int<-1,0> Next value if OK, <=0 if KO */ abstract public function getNextValue($object); } diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php index 01ca3c22f64..47d372c68ab 100644 --- a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 MDW - * Copyright (C) ---Put your own copyright and developer email here--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -33,7 +33,7 @@ global $noMoreLinkedObjectBlockAfter; $langs = $GLOBALS['langs']; '@phan-var-force Translate $langs'; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; -'@phan-var-force MyObject[] $linkedObjectBlock'; +'@phan-var-force array $linkedObjectBlock'; // Load translation files required by the page $langs->load("mymodule"); @@ -51,7 +51,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { trans("MyObject"); ?> getNomUrl(1); ?> - date, 'day'); ?> + date_creation, 'day'); ?> getLibStatut(7); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 18b2f29dfdc..89e4ed53480 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -1,7 +1,6 @@ - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -88,7 +87,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers } // Or you can execute some code here - switch ($action) { + switch ($action) { // @phan-suppress-current-line PhanNoopSwitchCases // Users //case 'USER_CREATE': //case 'USER_MODIFY': diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index f243960ecee..a51d758db5b 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -1,5 +1,5 @@ 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index 416294e214f..3620b5ac828 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -1,5 +1,5 @@ 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -96,5 +99,3 @@ if (empty($dolibarr_nocache)) { ?> /* Javascript library of module MyModule */ - - diff --git a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang index 8677fa58069..b898de60555 100644 --- a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang @@ -1,4 +1,4 @@ -# Copyright (C) ---Put here your own copyright and developer email--- +# Copyright (C) ---Replace with your own copyright and developer email--- # # 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/modulebuilder/template/lib/mymodule.lib.php b/htdocs/modulebuilder/template/lib/mymodule.lib.php index 0ebae6eb74f..d432a35b4af 100644 --- a/htdocs/modulebuilder/template/lib/mymodule.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule.lib.php @@ -1,5 +1,5 @@ */ function mymoduleAdminPrepareHead() { diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index 442908079a5..e63dc663ae5 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -1,5 +1,5 @@ Array of tabs */ function myobjectPrepareHead($object) { diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 6405f5c67d9..91781a7d148 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -31,7 +31,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -67,7 +70,7 @@ $now = dol_now(); $max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5); // Security check - Protection if external user -$socid = GETPOST('socid', 'int'); +$socid = GETPOSTINT('socid'); if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index baf04bf9c70..b3cbeea107c 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -48,7 +48,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -101,10 +104,10 @@ if (GETPOST('actioncode', 'array')) { $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -160,7 +163,7 @@ if (!$permissiontoread) { * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -266,14 +269,14 @@ if ($object->id > 0) { $objthirdparty = $object; $objcon = new stdClass(); - $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); + $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode((string) $object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -52,7 +52,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -110,10 +113,12 @@ $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array($object->element.'card', 'globalcard')); // Note that conf->hooks_modules contains array +$soc = null; // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); + $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criteria @@ -472,7 +477,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show object lines $result = $object->getLinesArray(); - print '
+ print ' @@ -490,7 +495,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + $object->printObjectLines($action, $mysoc, null, GETPOSTINT('lineid'), 1); } // Form to add new line diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 6f1e63f280b..7e36ea63d91 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 +29,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -62,10 +65,10 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); -$id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$id = (GETPOST('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$socid = GETPOST('socid', 'int'); +$lineid = GETPOSTINT('lineid'); +$socid = GETPOSTINT('socid'); $action = GETPOST('action', 'aZ09'); // Initialize a technical objects @@ -108,7 +111,7 @@ if (!$permissiontoread) { */ if ($action == 'addcontact' && $permissiontoadd) { - $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); @@ -125,7 +128,7 @@ if ($action == 'addcontact' && $permissiontoadd) { } } elseif ($action == 'swapstatut' && $permissiontoadd) { // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); + $result = $object->swapContactStatus(GETPOSTINT('ligne')); } elseif ($action == 'deletecontact' && $permissiontoadd) { // Permission to add on object because this is an update of a link of object, not a deletion of data // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 85bebb0e658..3742b25099a 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -50,7 +50,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -88,13 +91,13 @@ $langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); // Get parameters $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id')); $ref = GETPOST('ref', 'alpha'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 75d3031b524..626cffa950f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -52,7 +52,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -91,7 +94,7 @@ $langs->loadLangs(array("mymodule@mymodule", "other")); // Get parameters $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list @@ -312,7 +315,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")"; } else { $sql .= " WHERE 1 = 1"; } @@ -492,9 +495,9 @@ foreach ($search as $key => $val) { } } } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { - $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); - $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); - $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); + $param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month'); + $param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day'); + $param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year'); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } @@ -537,8 +540,8 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -553,6 +556,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { $setupstring = ''; + // @phan-suppress-next-line PhanEmptyForeach foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; @@ -640,7 +644,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 283bf743067..cecbd7cf14d 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -51,7 +51,10 @@ if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -83,7 +86,7 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); $langs->loadLangs(array("mymodule@mymodule", "companies")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 1f59f3a602c..eb7b634e6dc 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -1,7 +1,7 @@ #!/usr/bin/env php - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -68,7 +68,10 @@ define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to // Load Dolibarr environment $res = 0; // Try master.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; +$tmp2 = realpath(__FILE__); +$i = strlen($tmp) - 1; +$j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; @@ -100,7 +103,7 @@ if (!$res) { $langs->load("main"); // To load language file for default language // Load user and its permissions -$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. +$result = $user->fetch(0, 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. if (!($result > 0)) { dol_print_error(null, $user->error); exit; diff --git a/htdocs/modulebuilder/template/sql/data.sql b/htdocs/modulebuilder/template/sql/data.sql index 37860e8bf7b..d2bf44a0b2e 100644 --- a/htdocs/modulebuilder/template/sql/data.sql +++ b/htdocs/modulebuilder/template/sql/data.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) ---Replace with your own copyright and developer email--- -- -- 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,4 +29,3 @@ --insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MYOBJECT_VALIDATE','MyObject validated','Executed when myobject is validated', 'mymodule', 1000); --insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MYOBJECT_UNVALIDATE','MyObject unvalidated','Executed when myobject is unvalidated', 'mymodule', 1001); --insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MYOBJECT_DELETE','MyObject deleted','Executed when myobject deleted', 'mymodule', 1004); - diff --git a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql index fc6b7b0d243..a100c64e5bc 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.key.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) ---Replace with your own copyright and developer email--- -- -- 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 @@ -21,4 +21,3 @@ ALTER TABLE llx_mymodule_myobject ADD INDEX idx_mymodule_myobject_fieldobject (f --ALTER TABLE llx_mymodule_myobject ADD UNIQUE INDEX uk_mymodule_myobject_fieldxy(fieldx, fieldy); --ALTER TABLE llx_mymodule_myobject ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid); - diff --git a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.sql index cc9cca0c34a..84275e204c1 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) ---Replace with your own copyright and developer email--- -- -- 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/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql index 462a114674d..bca79bec4aa 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.key.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) ---Replace with your own copyright and developer email--- -- -- 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/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.sql b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.sql index e0fc9ff40b9..53eab2a7179 100644 --- a/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.sql +++ b/htdocs/modulebuilder/template/sql/llx_mymodule_myobject_extrafields.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) ---Replace with your own copyright and developer email--- -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -20,4 +20,3 @@ create table llx_mymodule_myobject_extrafields fk_object integer NOT NULL, import_key varchar(14) -- import key ) ENGINE=innodb; - diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index 97861ddf147..1001eeb1efa 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -1,8 +1,7 @@ -/* Copyright (C) 2023 Alexandre Janniaux - * Copyright (C) 2024 MDW - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -47,12 +46,25 @@ $langs->load("main"); * @backupGlobals disabled * @backupStaticAttributes enabled * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + * @phan-file-suppress PhanCompatibleVoidTypePHP70 */ -class MyObjectTest extends PHPUnit\Framework\TestCase +class MyObjectTest extends PHPUnit\Framework\TestCase // @phan-suppress-current-line PhanUndeclaredExtendedClass { + /** + * @var Conf Saved configuration object + */ protected $savconf; + /** + * @var User Saved User object + */ protected $savuser; + /** + * @var Translate Saved translations object (from $langs) + */ protected $savlangs; + /** + * @var DoliDB Saved database object + */ protected $savdb; /** @@ -63,7 +75,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase */ public function __construct($name = '') { - parent::__construct($name); + parent::__construct($name); // @phan-suppress-current-line PhanUndeclaredClass //$this->sharedFixture global $conf, $user, $langs, $db; @@ -80,7 +92,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase /** * Global test setup * - * @return void + * @return void No return value */ public static function setUpBeforeClass(): void { @@ -93,7 +105,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase /** * Unit test setup * - * @return void + * @return void No return value */ protected function setUp(): void { @@ -109,7 +121,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase /** * Unit test teardown * - * @return void + * @return void No return value */ protected function tearDown(): void { @@ -119,7 +131,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase /** * Global test teardown * - * @return void + * @return void No return value */ public static function tearDownAfterClass(): void { @@ -134,6 +146,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase * A sample test * * @return bool + * @phan-suppress PhanUndeclaredMethod */ public function testSomething() { @@ -145,7 +158,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase $result = true; - print __METHOD__." result=".$result."\n"; + print __METHOD__." result=".((int) $result)."\n"; $this->assertTrue($result); return $result; @@ -155,6 +168,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase * testMyObjectCreate * * @return int + * @phan-suppress PhanUndeclaredMethod */ public function testMyObjectCreate() { @@ -182,6 +196,7 @@ class MyObjectTest extends PHPUnit\Framework\TestCase * * @depends testMyObjectCreate * The depends says test is run only if previous is ok + * @phan-suppress PhanUndeclaredMethod */ public function testMyObjectDelete($id) { @@ -199,4 +214,4 @@ class MyObjectTest extends PHPUnit\Framework\TestCase $this->assertLessThan($result, 0); return $result; } -} +} // @phan-suppress-current-line PhanUndeclaredClass diff --git a/htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php b/htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php index 660b4cc4105..07de8ce7503 100644 --- a/htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) ---Replace with your own copyright and developer email--- * * 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 @@ -40,8 +40,9 @@ use PHPUnit_Extensions_Selenium2TestCase_WebDriverException; * @todo OSX support (Safari, Google Chrome, Mozilla Firefox) * * @package Testmymodule + * @phan-file-suppress PhanPluginUnknownObjectMethodCall,PhanUndeclaredMethod,PhanNonClassMethodCall */ -class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase +class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase // @phan-suppress-current-line PhanUndeclaredExtendedClass { // TODO: move to a global configuration file? /** @var string Base URL of the webserver under test */ @@ -82,15 +83,17 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Helper function to select links by href * - * @param string $value Href - * @return mixed Helper string + * @param string $value Href + * @return ?string Helper string + * @phan */ protected function byHref($value) { - $anchor = null; $anchors = $this->elements($this->using('tag name')->value('a')); - foreach ($anchors as $anchor) { - if (strstr($anchor->attribute('href'), $value)) { + $anchor = null; + foreach ($anchors as $test_anchor) { + if (\strstr($test_anchor->attribute('href'), $value)) { + $anchor = $test_anchor; break; } } @@ -126,6 +129,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Handle Dolibarr authentication * @return void + * @phan-suppress PhanUndeclaredClassCatch */ private function authenticate() { @@ -174,7 +178,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase $this->authenticate(); $module_status_image_path = '//a[contains(@href, "'.self::$module_id.'")]/img'; $module_status_image = $this->byXPath($module_status_image_path); - if (strstr($module_status_image->attribute('src'), 'switch_off.png')) { + if (\strstr($module_status_image->attribute('src'), 'switch_off.png')) { // Enable the module $this->byHref('modMyModule')->click(); } else { diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index efcafcd26fa..46bdb48a3e3 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -1269,7 +1269,7 @@ class ProductAttribute extends CommonObject * * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell - * @param Societe $buyer Object thirdparty who buy + * @param ?Societe $buyer Object thirdparty who buy * @param string $defaulttpldir Directory where to find the template * @return void */ @@ -1310,7 +1310,7 @@ class ProductAttribute extends CommonObject * * @param string $action Action code * @param Societe $seller Object of seller third party - * @param Societe $buyer Object of buyer third party + * @param ?Societe $buyer Object of buyer third party * @param int $selected Object line selected * @param int $dateSelector 1=Show also date range input fields * @param string $defaulttpldir Directory where to find the template @@ -1392,7 +1392,7 @@ class ProductAttribute extends CommonObject * * @param string $action GET/POST action * @param CommonObjectLine $line Selected object line to output - * @param string $var Is it a an odd line (true) + * @param '' $var Is it a an odd line (not used) * @param int $num Number of line (0) * @param int $i I * @param int $dateSelector 1=Show also date range input fields