From 17c887a433bb87ba3a8ca8bb29bce137d1507f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 13 Aug 2024 20:29:40 +0200 Subject: [PATCH 01/11] fix typos (#30630) * fix typos * fix typos --- htdocs/comm/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/core/lib/fichinter.lib.php | 14 +++++++------- htdocs/fichinter/class/fichinter.class.php | 6 +++--- htdocs/fichinter/index.php | 3 ++- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/public/onlinesign/newonlinesign.php | 4 ++-- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 15f6b6204ce..9d684db1d0f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1647,7 +1647,7 @@ if ($object->id > 0) { } if (isModEnabled('intervention') && $user->hasRight('ficheinter', 'creer') && $object->status == 1) { - $langs->load("fichinter"); + $langs->load("interventions"); print '
'.$langs->trans("AddIntervention").'
'; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 05764ef546e..31a5b980b19 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -599,7 +599,7 @@ class Contrat extends CommonObject } } - // Set new ref and define current statut + // Set new ref and define current status if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 43b6d112d45..7d2ad3a69a2 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -1,11 +1,11 @@ - * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2016 Gilles Poirier - * Copyright (C) 2018-2024 Charlene Benke - * Copyright (C) 2024 MDW - + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2018-2024 Charlene Benke + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ function fichinter_prepare_head($object) { global $db, $langs, $conf, $user; - $langs->load("fichinter"); + $langs->load("interventions"); $h = 0; $head = array(); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 5cdc7ca08d5..781fdb0539b 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -709,7 +709,7 @@ class Fichinter extends CommonObject } } - // Set new ref and define current statut + // Set new ref and define current status if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; @@ -860,7 +860,7 @@ class Fichinter extends CommonObject // Init/load array of translation of status if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; - $langs->load("fichinter"); + $langs->load("interventions"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); @@ -890,7 +890,7 @@ class Fichinter extends CommonObject { global $conf, $langs; - $langs->load('fichinter'); + $langs->load('interventions'); $datas = []; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Intervention").''; diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 6d8376bb54b..ed3be373df1 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Charlene Benke * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -195,7 +196,7 @@ if (isModEnabled('intervention')) { print ''; print ''; print ''; - $langs->load("fichinter"); + $langs->load("interventions"); $num = $db->num_rows($resql); if ($num) { $i = 0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b0bddc92183..5bf5b0d930f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1948,7 +1948,7 @@ class FactureFournisseur extends CommonInvoice } } - // Set new ref and define current statut + // Set new ref and define current status if (!$error) { $this->ref = $this->newref; $this->statut = self::STATUS_VALIDATED; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index fb3890a478b..e9728001582 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -497,7 +497,7 @@ if ($source == 'proposal') { } elseif ($source == 'fichinter') { // Signature on fichinter $found = true; - $langs->load("fichinter"); + $langs->load("interventions"); $result = $object->fetch_thirdparty($object->socid); @@ -602,7 +602,7 @@ if ($source == 'proposal') { } elseif ($source == 'expedition') { // Signature on expedition $found = true; - $langs->load("fichinter"); + $langs->load("interventions"); $result = $object->fetch_thirdparty($object->socid); From f2ada1ffbb5db8a8b094d3546d7231955b66c342 Mon Sep 17 00:00:00 2001 From: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:29:54 +0200 Subject: [PATCH 02/11] Update import.class.php (#30627) --- htdocs/imports/class/import.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index eac1d838cf8..1ef8e3ca14d 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -332,7 +332,7 @@ class Import } /** - * Save an export model in database + * Save an import model in database * * @param User $user Object user that save * @return int Return integer <0 if KO, >0 if OK From a9f93f35c76558e2e16a83c8a01c09f42e288e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 13 Aug 2024 20:31:03 +0200 Subject: [PATCH 03/11] add phpdoc (#30631) * add phpdoc * Update contrat.class.php --- htdocs/contrat/class/contrat.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 31a5b980b19..dfd33b47691 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -112,8 +112,10 @@ class Contrat extends CommonObject */ public $fk_soc; - - public $societe; // Object societe + /** + * @var Societe thirdparty Object + */ + public $societe; /** * Status of the contract @@ -170,6 +172,7 @@ class Contrat extends CommonObject public $fk_commercial_suivi; /** + * @var int * @deprecated Use fk_project instead * @see $fk_project */ From 803c3c2f3066c5957afa895856924717d2ff4939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 13 Aug 2024 20:39:40 +0200 Subject: [PATCH 04/11] fix phpstan sendXXX expects int (#30519) * fix sendXXX expects int * fix sendEmailTo expects int * fix regression * fix loadxxx expects int * fix loadxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int * fix getxxx expects int --- htdocs/admin/mails.php | 2 +- htdocs/admin/mails_emailing.php | 2 +- htdocs/admin/mails_passwordreset.php | 2 +- htdocs/admin/mails_ticket.php | 2 +- htdocs/bookcal/availabilities_card.php | 7 ++++--- htdocs/core/class/commondocgenerator.class.php | 9 ++++++--- htdocs/core/customreports.php | 1 + htdocs/core/lib/project.lib.php | 4 ++-- .../core/modules/facture/doc/pdf_crabe.modules.php | 2 +- .../modules/facture/doc/pdf_octopus.modules.php | 2 +- .../core/modules/facture/doc/pdf_sponge.modules.php | 2 +- htdocs/emailcollector/lib/emailcollector.lib.php | 2 +- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/tasks.php | 2 +- htdocs/societe/class/societe.class.php | 5 +++-- phpstan.neon.dist | 4 ---- .../email_expire_services_to_customers.php | 13 +++++++------ 17 files changed, 33 insertions(+), 30 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 208cb94d83e..460232bae14 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -169,7 +169,7 @@ if (!getDolGlobalString('MAIN_MAIL_SENDMODE')) { $conf->global->MAIN_MAIL_SENDMODE = 'mail'; } -$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT', ini_get('smtp_port')); +$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT', (int) ini_get('smtp_port')); if (!$port) { $port = 25; } diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 183c3b9341c..77f5d942497 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -140,7 +140,7 @@ if (preg_match('/^mac/i', PHP_OS)) { if (!getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')) { $conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default'; } -$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_EMAILING', ini_get('smtp_port')); +$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_EMAILING', (int) ini_get('smtp_port')); if (!$port) { $port = 25; } diff --git a/htdocs/admin/mails_passwordreset.php b/htdocs/admin/mails_passwordreset.php index adcb1ea1fc6..02e0ef24be1 100644 --- a/htdocs/admin/mails_passwordreset.php +++ b/htdocs/admin/mails_passwordreset.php @@ -138,7 +138,7 @@ if (preg_match('/^mac/i', PHP_OS)) { if (!getDolGlobalString('MAIN_MAIL_SENDMODE_PASSWORDRESET')) { $conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET = 'default'; } -$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_PASSWORDRESET', ini_get('smtp_port')); +$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_PASSWORDRESET', (int) ini_get('smtp_port')); if (!$port) { $port = 25; } diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 2715f032ed8..29e97f93504 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -138,7 +138,7 @@ if (preg_match('/^mac/i', PHP_OS)) { if (!getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')) { $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default'; } -$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', ini_get('smtp_port')); +$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', (int) ini_get('smtp_port')); if (!$port) { $port = 25; } diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index d3efc65056f..f13d1ffad9c 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -1,6 +1,7 @@ - * Copyright (C) 2022 Alice Adminson +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -248,7 +249,7 @@ if ($action == 'create') { exit; } - print load_fiche_titre($langs->trans("NewAvailabilities"), '', '', 'object_'.$object->picto); + print load_fiche_titre($langs->trans("NewAvailabilities"), '', 'object_'.$object->picto); print '
'; print ''; if ($error != 0) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 776b9c776f1..58948ec2aa8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -309,7 +309,8 @@ abstract class CommonDocGenerator $mysoc->country = $outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); } if (empty($mysoc->state) && !empty($mysoc->state_code)) { - $mysoc->state = getState($mysoc->state_code, '0'); + $state_id = dol_getIdFromCode($this->db, $mysoc->state_code, 'c_departements', 'code_departement', 'rowid'); + $mysoc->state = getState($state_id, '0'); } $logotouse = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; @@ -365,7 +366,8 @@ abstract class CommonDocGenerator $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } if (empty($object->state) && !empty($object->state_code)) { - $object->state = getState($object->state_code, '0'); + $state_id = dol_getIdFromCode($this->db, $object->state_code, 'c_departements', 'code_departement', 'rowid'); + $object->state = getState($state_id, '0'); } $array_thirdparty = array( @@ -431,7 +433,8 @@ abstract class CommonDocGenerator $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } if (empty($object->state) && !empty($object->state_code)) { - $object->state = getState($object->state_code, '0'); + $state_id = dol_getIdFromCode($this->db, $object->state_code, 'c_departements', 'code_departement', 'rowid'); + $object->state = getState($state_id, '0'); } $array_contact = array( diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 1323dc311c0..2846e939f98 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 920a815f429..b4fe047978a 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2010 Regis Houssin * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Charlene Benke * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 MDW @@ -2385,7 +2385,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Fields to show current time $tableCell = ''; $modeinput = 'hours'; - $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow)); + $TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow)); $TFirstDay[reset($TWeek)] = 1; $firstdaytoshowarray = dol_getdate($firstdaytoshow); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ba01c1c89ea..f60cb68a325 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1260,7 +1260,7 @@ class pdf_crabe extends ModelePDFFactures $langs->loadLangs(array('payment', 'paybox', 'stripe')); $servicename = $langs->transnoentities('Online'); - $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', ''); + $paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0); $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 6cf64cbba58..7ddafc39eb3 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -1462,7 +1462,7 @@ class pdf_octopus extends ModelePDFFactures $langs->loadLangs(array('payment', 'paybox', 'stripe')); $servicename = $langs->transnoentities('Online'); - $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', ''); + $paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0); $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 6f605ea38a2..3183e69484a 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1360,7 +1360,7 @@ class pdf_sponge extends ModelePDFFactures $langs->loadLangs(array('payment', 'paybox', 'stripe')); $servicename = $langs->transnoentities('Online'); - $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', ''); + $paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0); $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; $pdf->SetXY($this->marge_gauche, $posy); diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php index befbbef16b2..34638e7f1d1 100644 --- a/htdocs/emailcollector/lib/emailcollector.lib.php +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -113,7 +113,7 @@ function getDParameters($part) * * @param integer $jk Number of email * @param object $mbox object connection imap - * @return array type, filename, pos + * @return array type, filename, pos */ function getAttachments($jk, $mbox) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 316efd3bffe..f33b4b08337 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2224,7 +2224,7 @@ class Project extends CommonObject $obj = $this->db->fetch_object($resql); if (!empty($obj->element_date)) { $date = explode('-', $obj->element_date); - $week_number = getWeekNumber($date[2], $date[1], $date[0]); + $week_number = getWeekNumber((int) $date[2], (int) $date[1], (int) $date[0]); } '@phan-var-force int $week_number'; // Needed because phan considers it might be null if (empty($weekalreadyfound[$week_number])) { diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 226a08d8c21..86e7771c855 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -910,7 +910,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object- $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss' => 'reposition marginleftonly')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); - print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask', '', '', '', $massactionbutton); + print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask', 0, '', '', $massactionbutton); $objecttmp = new Task($db); $trackid = 'task'.$taskstatic->id; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cc000d0fb8f..68a6518c7d3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4381,10 +4381,11 @@ class Societe extends CommonObject //TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it. // We define state_id, state_code and state $state_id = 0; - $state_code = $state_label = ''; + $state_code = ''; + $state_label = ''; if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) { $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE')); - $state_id = $tmp[0]; + $state_id = (int) $tmp[0]; if (!empty($tmp[1])) { // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" $state_code = $tmp[1]; $state_label = $tmp[2]; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 07524a8b99a..aa7e18a45ec 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -72,17 +72,13 @@ parameters: - '#expects int\|null#' - '#expects int<-2, 2>, bool given.#' - '#expects int<0, 1>#' - - '#load.* expects int, string#' - '#ajax.* expects int, string#' - '#measu.* expects int, string#' - '#color.* expects int, string#' - '#imap.* expects int, string#' - '#show.* expects int, string#' - '#dol.* expects int, string#' - - '#get.* expects int, string#' - - '#send.* expects int, string#' - '#convert.* expects int, string#' - #- '#constructor expects int, string#' - '#\(\) expects int, string#' - '#run_sql expects int, string#' - '#expects int, float#' diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 60aa2b1cbcb..f4a6e136e69 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -1,10 +1,11 @@ #!/usr/bin/env php - * Copyright (C) 2005-2013 Laurent Destailleur - * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2024 MDW + * Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -153,7 +154,7 @@ if ($resql) { if ($startbreak) { // Break onto sales representative (new email or cid) if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { - sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, $duration_value); + sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, (int) $duration_value); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { @@ -207,7 +208,7 @@ if ($resql) { // If there are remaining messages to send in the buffer if ($foundtoprocess) { if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) - sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, $duration_value); + sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, (int) $duration_value); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { From e5c0150be4992b1d31322783049255ad7747e276 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Tue, 13 Aug 2024 22:50:31 +0200 Subject: [PATCH 05/11] qual: avoid double negations by introducing getDolGlobalBool() (#30618) * Update index.php * Update api.class.php * Update pdf_eratosthene.modules.php * Update pdf_sponge.modules.php * Update pdf_cyan.modules.php * Update partnershiputils.class.php * Update paypalfunctions.lib.php * Update societe.class.php * Update functions.lib.php - create getDolGlobalBool() * Update index.php * Update api.class.php * Update pdf_eratosthene.modules.php * Update pdf_sponge.modules.php * Update pdf_cyan.modules.php * Update partnershiputils.class.php * Update paypalfunctions.lib.php * Update societe.class.php * Update functions.lib.php --------- Co-authored-by: Laurent Destailleur --- htdocs/api/admin/index.php | 4 ++-- htdocs/api/class/api.class.php | 2 +- htdocs/core/lib/functions.lib.php | 22 +++++++++++++++---- .../commande/doc/pdf_eratosthene.modules.php | 2 +- .../facture/doc/pdf_sponge.modules.php | 2 +- .../modules/propale/doc/pdf_cyan.modules.php | 2 +- htdocs/paypal/lib/paypalfunctions.lib.php | 2 +- htdocs/societe/class/societe.class.php | 12 +++++----- 8 files changed, 31 insertions(+), 17 deletions(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 83c20b77116..2ee3bdb6ea4 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -117,7 +117,7 @@ print ""; print '
'; print ''; -$production_mode = !(!getDolGlobalString('API_PRODUCTION_MODE')); +$production_mode = getDolGlobalBool('API_PRODUCTION_MODE'); if ($production_mode) { print ''; print ''; print ''; -$disable_compression = !(!getDolGlobalString('API_DISABLE_COMPRESSION')); +$disable_compression = getDolGlobalBool('API_DISABLE_COMPRESSION'); if ($disable_compression) { print ''; print ''; print ''; print ''; diff --git a/htdocs/core/lib/socialnetwork.lib.php b/htdocs/core/lib/socialnetwork.lib.php index ac1a28d0538..368b356f962 100644 --- a/htdocs/core/lib/socialnetwork.lib.php +++ b/htdocs/core/lib/socialnetwork.lib.php @@ -31,7 +31,7 @@ function socialnetwork_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/dict.php?id=38'; + $head[$h][0] = DOL_URL_ROOT.'/admin/dict.php?id=38&from=socialnetworksetup'; $head[$h][1] = $langs->trans("Dictionary").' - '.$langs->trans("SocialNetworks"); $head[$h][2] = 'dict'; $h++; diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index ff6e42f1bb4..df025b3b82c 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -59,7 +59,7 @@ class modSocialNetworks extends DolibarrModules $this->dirs = array(); // Config pages - $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38'); + $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38&from=socialnetworksetup'); // Dependencies $this->hidden = getDolGlobalInt('MODULE_SOCIALNETWORKS_DISABLED'); // A condition to hide module From e570f59e2d4e2cc3093468ca300bd92d21f099db Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 14 Aug 2024 01:24:55 +0200 Subject: [PATCH 09/11] Qual: Phan fixes (mainly Initial type cannot be inferred) in popular changed classes (#30604) * Update setValueFrom $id type to include null * Only 2 arguments for ModeleNumRefMembers::getToolTip * Fix PhanTypeConversionFromArray * Only 6 args for PaymentSalary::addPaymentToBank * Fix typing hints (array -> string) * Fix uninitialized variables * Add cssview to attributes phpdoc * Avoid double typing specification (Phan notice) * Qual: Ensure variable is defined (phan) * Ensure phpdoc typing for verif method * Ensure phpdoc typing for getNextValue method * Add status as data key in cols array * Ensure preg_replace operates on string (phan) * Correct type for desiredstock * Fix typing with casts (phan) * Fix check that notification already exists * Initialise fk_parent_id to fix typing issue * Qual: Fix phan notices for Societe & related * Qual: Fix typing for Facture and related * Qual: Fix typing for Product & related * Update baseline * Fix new phpstan notices --- dev/tools/phan/baseline.txt | 36 +- htdocs/adherents/admin/member.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 440 ++++++++++------- .../class/bonprelevement.class.php | 8 +- .../class/rejetprelevement.class.php | 9 +- htdocs/compta/prelevement/line.php | 5 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 18 +- htdocs/core/class/commonorder.class.php | 4 +- htdocs/core/class/extrafields.class.php | 2 +- .../asset/doc/pdf_standard_asset.modules.php | 2 +- .../barcode/mod_barcode_product_standard.php | 12 +- .../mod_barcode_thirdparty_standard.php | 11 +- .../modules/barcode/modules_barcode.class.php | 18 + .../commande/doc/pdf_eratosthene.modules.php | 2 +- .../facture/doc/pdf_octopus.modules.php | 2 +- .../facture/doc/pdf_sponge.modules.php | 2 +- .../core/modules/facture/mod_facture_mars.php | 6 +- .../modules/facture/mod_facture_mercure.php | 11 +- .../core/modules/facture/modules_facture.php | 11 +- .../modules/propale/doc/pdf_cyan.modules.php | 2 +- .../societe/mod_codeclient_elephant.php | 4 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 6 +- .../modules/societe/modules_societe.class.php | 17 + .../takepos/mod_takepos_ref_universal.php | 3 +- htdocs/core/tpl/formlayoutai.tpl.php | 4 + ...e_20_modWorkflow_WorkflowManager.class.php | 1 + .../fourn/class/fournisseur.facture.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 6 +- htdocs/fourn/facture/card-rec.php | 2 +- .../doc/pdf_standard_myobject.modules.php | 2 +- htdocs/product/class/api_products.class.php | 2 +- htdocs/product/class/product.class.php | 444 ++++++++++++------ htdocs/product/stock/product.php | 10 +- htdocs/product/stock/replenish.php | 11 +- ...tandard_recruitmentjobposition.modules.php | 2 +- .../societe/class/api_thirdparties.class.php | 5 +- htdocs/societe/class/societe.class.php | 184 +++++--- htdocs/takepos/invoice.php | 2 + htdocs/ticket/class/ticket.class.php | 2 +- .../class/webportalinvoice.class.php | 2 +- 43 files changed, 873 insertions(+), 451 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 94b83291a3d..1fef6d775bf 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -57,7 +57,6 @@ return [ 'file_suppressions' => [ 'htdocs/accountancy/admin/productaccount.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'htdocs/accountancy/bookkeeping/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/accountancy/bookkeeping/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/bookkeeping/listbyaccount.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], @@ -74,7 +73,7 @@ return [ 'htdocs/accountancy/journal/variousjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/supplier/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/tpl/export_journal.tpl.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/adherents/admin/member.php' => ['PhanParamTooMany', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], + 'htdocs/adherents/admin/member.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], 'htdocs/adherents/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeSuspiciousNonTraversableForeach'], 'htdocs/adherents/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], @@ -219,13 +218,13 @@ return [ 'htdocs/bookcal/calendar_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/bookcal/calendar_document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/bookcal/calendar_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/bookcal/class/availabilities.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], + 'htdocs/bookcal/class/availabilities.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/bookcal/class/calendar.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/bookmarks/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bookmarks/class/bookmark.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/categories/card.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/categories/class/categorie.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeConversionFromArray', 'PhanTypeMismatchProperty'], + 'htdocs/categories/class/categorie.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchProperty'], 'htdocs/categories/edit.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch'], 'htdocs/categories/index.php' => ['PhanTypeMismatchDimFetch'], 'htdocs/categories/info.php' => ['PhanTypeMismatchDimFetch'], @@ -301,7 +300,7 @@ return [ 'htdocs/compta/facture/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetchNullable', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/facture/class/api_invoices.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/compta/facture/class/facture.class.php' => ['PhanEmptyForeach', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/compta/facture/class/facture.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/facture/class/facturestats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/compta/facture/class/paymentterm.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/compta/facture/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -321,7 +320,7 @@ return [ 'htdocs/compta/localtax/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetch'], 'htdocs/compta/paiement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/compta/paiement/cheque/card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/compta/paiement/cheque/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement/cheque/class/remisecheque.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanUndeclaredMethod'], 'htdocs/compta/paiement/cheque/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement/class/cpaiement.class.php' => ['PhanPluginUnknownPropertyType'], @@ -332,12 +331,11 @@ return [ 'htdocs/compta/paiement_vat.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/payment_vat/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], + 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], 'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/demandes.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/factures.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/compta/prelevement/line.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeConversionFromArray'], 'htdocs/compta/prelevement/orders_list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/stats.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/resultat/clientfourn.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -472,7 +470,7 @@ return [ 'htdocs/core/class/canvas.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'], 'htdocs/core/class/ccountry.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/cgenericdic.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], - 'htdocs/core/class/commondocgenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], + 'htdocs/core/class/commondocgenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/core/class/commonhookactions.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/core/class/commonincoterm.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredProperty'], 'htdocs/core/class/commoninvoice.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'], @@ -496,7 +494,7 @@ return [ 'htdocs/core/class/emailsenderprofile.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/evalmath.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/class/events.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNull', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], + 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/core/class/extralanguages.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/class/fileupload.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'], 'htdocs/core/class/fiscalyear.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], @@ -704,7 +702,7 @@ return [ 'htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod'], 'htdocs/core/modules/stock/modules_stock.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod'], + 'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/modules/stocktransfer/modules_stocktransfer.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], @@ -712,7 +710,7 @@ return [ 'htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/supplier_order/modules_commandefournisseur.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], @@ -720,7 +718,7 @@ return [ 'htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_payment/modules_supplier_payment.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/syslog/logHandler.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], @@ -748,7 +746,7 @@ return [ 'htdocs/core/tpl/extrafields_list_print_fields.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/extrafields_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/core/tpl/filemanager.tpl.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/tpl/formlayoutai.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredVariableAssignOp'], + 'htdocs/core/tpl/formlayoutai.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/login.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/massactions_pre.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/core/tpl/notes.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -874,6 +872,7 @@ return [ 'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.facture.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchProperty'], + 'htdocs/fourn/class/paiementfourn.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/commande/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/fourn/commande/contact.php' => ['PhanUndeclaredGlobalVariable'], @@ -935,7 +934,6 @@ return [ 'htdocs/install/fileconf.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/install/inc.php' => ['PhanRedefineFunction'], 'htdocs/install/index.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/install/install.forced.php' => ['PhanPluginWhitespaceTrailing'], 'htdocs/install/repair.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/install/step2.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], 'htdocs/install/upgrade.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], @@ -1004,7 +1002,7 @@ return [ 'htdocs/product/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/product/class/html.formproduct.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/product/class/product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn', 'PhanUndeclaredMethod'], + 'htdocs/product/class/product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], 'htdocs/product/class/productbatch.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType'], 'htdocs/product/class/productcustomerprice.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/product/class/productfournisseurprice.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], @@ -1020,7 +1018,6 @@ return [ 'htdocs/product/inventory/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/price.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/price_suppliers.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/product/reassort.php' => ['PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/reassortlot.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stats/card.php' => ['PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], @@ -1045,7 +1042,7 @@ return [ 'htdocs/product/stock/movement_card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/movement_list.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/product.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/product/stock/productlot_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/productlot_card.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/productlot_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stock/replenish.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stock/stats/commande_fournisseur.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -1196,7 +1193,6 @@ return [ 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/societe/class/companypaymentmode.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/societe/class/societe.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/societe/class/societeaccount.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/societe/document.php' => ['PhanTypeInvalidLeftOperandOfNumericOp'], @@ -1250,7 +1246,7 @@ return [ 'htdocs/ticket/class/actions_ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/ticket/class/ticket.class.php' => ['PhanPluginRedundantReturnComment', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], + 'htdocs/ticket/class/ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], 'htdocs/ticket/class/ticketstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], 'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f8c95fca83b..5a6a10d4fa3 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -315,7 +315,7 @@ foreach ($arrayofmodules as $file => $modCodeMember) { } print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b3fabcd497d..4ab4182c0bd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1827,7 +1827,7 @@ class Categorie extends CommonObject } if (file_exists($dir)) { - if (is_array($file['name']) && count($file['name']) > 0) { + if (is_array($file['name'])) { $nbfile = count($file['name']); for ($i = 0; $i < $nbfile; $i++) { $originImage = $dir.$file['name'][$i]; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index da36cdcaafa..30e28c432e7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -116,7 +116,9 @@ class Facture extends CommonInvoice */ public $fk_user_modif; - + /** + * @var string + */ public $datem; /** @@ -136,27 +138,58 @@ class Facture extends CommonInvoice */ public $ref_customer; + /** + * @var float + */ public $total_ht; + /** + * @var float + */ public $total_tva; + /** + * @var float + */ public $total_localtax1; + /** + * @var float + */ public $total_localtax2; + /** + * @var float + */ public $total_ttc; + /** + * @var float + */ public $revenuestamp; + /** + * @var float|string + */ public $resteapayer; /** - * 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + * + * @var int<0,1> 1 if invoice paid COMPLETELY, 0 otherwise + * @deprecated * Use statut and close_code) */ public $paye; - //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) + /** + * @var string key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) + */ public $module_source; - //! key of pos source ('0', '1', ...) + /** + * @var int key of pos source ('0', '1', ...) + */ public $pos_source; - //! id of template invoice when generated from a template invoice + /** + * @var int id of template invoice when generated from a template invoice + */ public $fk_fac_rec_source; - //! id of source invoice if replacement invoice or credit note + /** + * @var int id of source invoice if replacement invoice or credit note + */ public $fk_facture_source; public $linked_objects = array(); @@ -174,6 +207,9 @@ class Facture extends CommonInvoice * @var FactureLigne */ public $line; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); /** @@ -181,6 +217,9 @@ class Facture extends CommonInvoice */ public $fac_rec; + /** + * @var string + */ public $date_pointoftax; @@ -200,12 +239,12 @@ class Facture extends CommonInvoice public $situation_final; /** - * @var array Table of previous situations + * @var Facture[] Table of previous situations */ public $tab_previous_situation_invoice = array(); /** - * @var array Table of next situations + * @var Facture[] Table of next situations */ public $tab_next_situation_invoice = array(); @@ -215,7 +254,7 @@ class Facture extends CommonInvoice public $oldcopy; /** - * @var double percentage of retainage + * @var float percentage of retainage */ public $retained_warranty; @@ -234,6 +273,9 @@ class Facture extends CommonInvoice */ public $availability_id; + /** + * @var string + */ public $date_closing; /** @@ -280,7 +322,7 @@ class Facture extends CommonInvoice // 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. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> 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' => -1, 'notnull' => 1, 'position' => 1), @@ -506,6 +548,8 @@ class Facture extends CommonInvoice $nextdatewhen = null; $previousdaynextdatewhen = null; + $_facrec = null; + // Erase some properties of the invoice to create with the one of the recurring invoice if ($this->fac_rec > 0) { $this->fk_fac_rec_source = $this->fac_rec; @@ -594,8 +638,9 @@ class Facture extends CommonInvoice if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->thirdparty->default_lang)) { $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... } + // @phan-suppress-next-line PhanUndeclaredProperty if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->default_lang)) { - $newlang = $this->default_lang; // for thirdparty + $newlang = $this->default_lang; // for thirdparty @phan-suppress-current-line PhanUndeclaredProperty } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); @@ -789,6 +834,7 @@ class Facture extends CommonInvoice dol_syslog("There is ".count($this->lines)." lines into ->lines that are InvoiceLines"); foreach ($this->lines as $i => $val) { $newinvoiceline = $this->lines[$i]; + '@phan-var-force FactureLigne $newinvoiceline'; $newinvoiceline->context = $this->context; @@ -819,7 +865,7 @@ class Facture extends CommonInvoice $newinvoiceline->fk_parent_line = $fk_parent_line; - if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { + if ($this->type == Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); @@ -880,6 +926,7 @@ class Facture extends CommonInvoice foreach ($this->lines as $i => $val) { $line = $this->lines[$i]; + '@phan-var-force FactureLigne $line'; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. @@ -963,7 +1010,7 @@ class Facture extends CommonInvoice /* * Insert lines coming from the template invoice */ - if (!$error && $this->fac_rec > 0) { + if (!$error && $this->fac_rec > 0 && is_object($_facrec)) { dol_syslog("There is ".count($_facrec->lines)." lines from recurring invoice"); $fk_parent_line = 0; @@ -1032,7 +1079,7 @@ class Facture extends CommonInvoice ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, - '', + 0, // fk_remise_except 'HT', 0, $_facrec->lines[$i]->product_type, @@ -1046,7 +1093,7 @@ class Facture extends CommonInvoice $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options) ? null : $_facrec->lines[$i]->array_options, 100, // situation percent is undefined on recurring invoice lines - '', + 0, // fk_prev_id $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->multicurrency_subprice, $_facrec->lines[$i]->ref_ext, @@ -1115,9 +1162,9 @@ class Facture extends CommonInvoice /** * Create a new invoice in database from current invoice * - * @param User $user Object user that ask creation - * @param int $invertdetail Reverse sign of amounts for lines - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user that ask creation + * @param int<0,1> $invertdetail Reverse sign of amounts for lines + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function createFromCurrent(User $user, $invertdetail = 0) { @@ -1191,7 +1238,7 @@ class Facture extends CommonInvoice $this->error = $facture->error; $this->errors = $facture->errors; } elseif ($this->type == self::TYPE_SITUATION && getDolGlobalString('INVOICE_USE_SITUATION')) { - $this->fetchObjectLinked('', '', $this->id, 'facture'); + $this->fetchObjectLinked(null, '', $this->id, 'facture'); foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) { foreach ($Tfk_object as $fk_object) { @@ -1267,7 +1314,8 @@ class Facture extends CommonInvoice // Loop on each line of new invoice foreach ($object->lines as $i => $line) { - if (($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts + '@phan-var-force FactureLigne $line'; + if (($line->info_bits & 0x02) == 0x02) { // We do not clone line of discounts unset($object->lines[$i]); continue; } @@ -1348,11 +1396,11 @@ class Facture extends CommonInvoice } /** - * Load an object from an order and create a new invoice into database + * Load an object from an order and create a new invoice into database * - * @param Object $object Object source - * @param User $user Object user - * @return int Return integer <0 if KO, 0 if nothing done, 1 if OK + * @param Facture $object Object source + * @param User $user Object user + * @return int<-1,1> Return integer <0 if KO, 0 if nothing done, 1 if OK */ public function createFromOrder($object, User $user) { @@ -1367,48 +1415,49 @@ class Facture extends CommonInvoice $num = count($object->lines); for ($i = 0; $i < $num; $i++) { $line = new FactureLigne($this->db); - - $line->libelle = $object->lines[$i]->libelle; // deprecated - $line->label = $object->lines[$i]->label; - $line->desc = $object->lines[$i]->desc; - $line->subprice = $object->lines[$i]->subprice; - $line->total_ht = $object->lines[$i]->total_ht; - $line->total_tva = $object->lines[$i]->total_tva; - $line->total_localtax1 = $object->lines[$i]->total_localtax1; - $line->total_localtax2 = $object->lines[$i]->total_localtax2; - $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; - $line->localtax1_tx = $object->lines[$i]->localtax1_tx; - $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; - $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; - $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; + $src_line = $object->lines[$i]; + '@phan-var-force FactureLigne $src_line'; + $line->libelle = $src_line->libelle; // deprecated + $line->label = $src_line->label; + $line->desc = $src_line->desc; + $line->subprice = $src_line->subprice; + $line->total_ht = $src_line->total_ht; + $line->total_tva = $src_line->total_tva; + $line->total_localtax1 = $src_line->total_localtax1; + $line->total_localtax2 = $src_line->total_localtax2; + $line->total_ttc = $src_line->total_ttc; + $line->vat_src_code = $src_line->vat_src_code; + $line->tva_tx = $src_line->tva_tx; + $line->localtax1_tx = $src_line->localtax1_tx; + $line->localtax2_tx = $src_line->localtax2_tx; + $line->qty = $src_line->qty; + $line->fk_remise_except = $src_line->fk_remise_except; + $line->remise_percent = $src_line->remise_percent; + $line->fk_product = $src_line->fk_product; + $line->info_bits = $src_line->info_bits; + $line->product_type = $src_line->product_type; + $line->rang = $src_line->rang; + $line->special_code = $src_line->special_code; + $line->fk_parent_line = $src_line->fk_parent_line; + $line->fk_unit = $src_line->fk_unit; + $line->date_start = $src_line->date_start; + $line->date_end = $src_line->date_end; // Multicurrency - $line->fk_multicurrency = $object->lines[$i]->fk_multicurrency; - $line->multicurrency_code = $object->lines[$i]->multicurrency_code; - $line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice; - $line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht; - $line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva; - $line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc; + $line->fk_multicurrency = $src_line->fk_multicurrency; + $line->multicurrency_code = $src_line->multicurrency_code; + $line->multicurrency_subprice = $src_line->multicurrency_subprice; + $line->multicurrency_total_ht = $src_line->multicurrency_total_ht; + $line->multicurrency_total_tva = $src_line->multicurrency_total_tva; + $line->multicurrency_total_ttc = $src_line->multicurrency_total_ttc; - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; - $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->fk_fournprice = $src_line->fk_fournprice; + $marginInfos = getMarginInfos($src_line->subprice, $src_line->remise_percent, $src_line->tva_tx, $src_line->localtax1_tx, $src_line->localtax2_tx, $src_line->fk_fournprice, $src_line->pa_ht); $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals(); - foreach ($object->lines[$i]->array_options as $options_key => $value) { + $src_line->fetch_optionals(); + foreach ($src_line->array_options as $options_key => $value) { $line->array_options[$options_key] = $value; } @@ -1477,11 +1526,11 @@ class Facture extends CommonInvoice } /** - * Load an object from an order and create a new invoice into database + * Load an object from a contract and create a new invoice into database * - * @param Object $object Object source + * @param Facture $object Object source * @param User $user Object user - * @param array $lines Ids of lines to use for invoice. If empty, all lines will be used. + * @param int[] $lines Ids of lines to use for invoice. If empty, all lines will be used. * @return int Return integer <0 if KO, 0 if nothing done, 1 if OK */ public function createFromContract($object, User $user, $lines = array()) @@ -1614,14 +1663,14 @@ class Facture extends CommonInvoice /** * Creates a deposit from a proposal or an order by grouping lines by VAT rates * - * @param Propal|Commande $origin The original proposal or order - * @param int $date Invoice date - * @param int $payment_terms_id Invoice payment terms - * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param bool $autoValidateDeposit Whether to aumatically validate the deposit created - * @param array $overrideFields Array of fields to force values - * @return Facture|null The deposit created, or null if error (populates $origin->error in this case) + * @param Propal|Commande $origin The original proposal or order + * @param int $date Invoice date + * @param int $payment_terms_id Invoice payment terms + * @param User $user Object user + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers + * @param bool $autoValidateDeposit Whether to automatically validate the deposit created + * @param array $overrideFields Array of fields to force values + * @return ?Facture The deposit created, or null if error (populates $origin->error in this case) */ public static function createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger = 0, $autoValidateDeposit = false, $overrideFields = array()) { @@ -1735,11 +1784,16 @@ class Facture extends CommonInvoice if (!empty($line->special_code)) { continue; } - $TTotalByTva[$line->tva_tx] += $line->total_ttc; - $descriptions[$line->tva_tx] .= '
  • ' . (!empty($line->product_ref) ? $line->product_ref . ' - ' : ''); - $descriptions[$line->tva_tx] .= (!empty($line->product_label) ? $line->product_label . ' - ' : ''); - $descriptions[$line->tva_tx] .= $langs->trans('Qty') . ' : ' . $line->qty; - $descriptions[$line->tva_tx] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($line->total_ht) . '
  • '; + $key = $line->tva_tx; + if (!array_key_exists($key, $TTotalByTva)) { + $TTotalByTva[$key] = 0; + $descriptions[$key] = ''; + } + $TTotalByTva[$key] += $line->total_ttc; + $descriptions[$key] .= '
  • ' . (!empty($line->product_ref) ? $line->product_ref . ' - ' : ''); + $descriptions[$key] .= (!empty($line->product_label) ? $line->product_label . ' - ' : ''); + $descriptions[$key] .= $langs->trans('Qty') . ' : ' . $line->qty; + $descriptions[$key] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($line->total_ht) . '
  • '; } foreach ($TTotalByTva as $tva => &$total) { @@ -1762,7 +1816,7 @@ class Facture extends CommonInvoice $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; - $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $origin->deposit_percent) / 100; + $amountdeposit[$tva_tx] += ((float) $lines[$i]->total_ht * (float) $origin->deposit_percent) / 100; $descriptions[$tva_tx] .= '
  • ' . (!empty($lines[$i]->product_ref) ? $lines[$i]->product_ref . ' - ' : ''); $descriptions[$tva_tx] .= (!empty($lines[$i]->product_label) ? $lines[$i]->product_label . ' - ' : ''); $descriptions[$tva_tx] .= $langs->trans('Qty') . ' : ' . $lines[$i]->qty; @@ -1894,9 +1948,9 @@ class Facture extends CommonInvoice /** * getTooltipContentArray * - * @param array $params ex option, infologin + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -3160,6 +3214,7 @@ class Facture extends CommonInvoice $productStatic = null; $warehouseStatic = null; + $productbatch = null; if ($batch_rule > 0) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; @@ -3343,9 +3398,11 @@ class Facture extends CommonInvoice } // We check if the invoice was provisional + /* if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne } + */ if (!$error) { // Define third party as a customer @@ -3378,7 +3435,7 @@ class Facture extends CommonInvoice $is_batch_line = false; if ($batch_rule > 0) { $productStatic->fetch($this->lines[$i]->fk_product); - if ($productStatic->hasbatch()) { + if ($productStatic->hasbatch() && is_object($productbatch)) { $is_batch_line = true; $product_qty_remain = $this->lines[$i]->qty; @@ -3561,13 +3618,15 @@ class Facture extends CommonInvoice $final = true; $nboflines = count($this->lines); while (($i < $nboflines) && $final) { + $line = $this->lines[$i]; + '@phan-var-force FactureLigne $line'; if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { - $previousprogress = $this->lines[$i]->get_allprev_progress($this->lines[$i]->fk_facture); - $current_progress = floatval($this->lines[$i]->situation_percent); + $previousprogress = $line->get_allprev_progress($line->fk_facture); + $current_progress = (float) $line->situation_percent; $full_progress = $previousprogress + $current_progress; $final = ($full_progress == 100); } else { - $final = ($this->lines[$i]->situation_percent == 100); + $final = ($line->situation_percent == 100); } $i++; } @@ -3611,6 +3670,7 @@ class Facture extends CommonInvoice } foreach ($next_invoice->lines as $line) { + '@phan-var-force FactureLigne $line'; $result = $next_invoice->updateline( $line->id, $line->desc, @@ -3743,38 +3803,38 @@ class Facture extends CommonInvoice * par l'appelant par la method get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * - * @param string $desc Description of line - * @param double $pu_ht Unit price without tax (> 0 even for credit note) - * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) - * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) - * @param int $fk_product Id of predefined product/service - * @param double $remise_percent Percent of discount on line - * @param int|string $date_start Date start of service - * @param int|string $date_end Date end of service - * @param int $fk_code_ventilation Code of dispatching into accountancy - * @param int $info_bits Bits of type of lines - * @param int $fk_remise_except Id discount used - * @param string $price_base_type 'HT' or 'TTC' - * @param double $pu_ttc Unit price with tax (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line (-1 means last value + 1) - * @param int $special_code Special code (also used by externals modules!) - * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... - * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id - * @param int $fk_parent_line Id of parent line - * @param int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @param string $label Label of the line (deprecated, do not use) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int $fk_prev_id Previous situation line id reference - * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in foreign currency - * @param string $ref_ext External reference of the line - * @param int $noupdateafterinsertline No update after insert of line - * @return int Return integer <0 if KO, Id of line if OK + * @param string $desc Description of line + * @param float $pu_ht Unit price without tax (> 0 even for credit note) + * @param float $qty Quantity + * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) + * @param int $fk_product Id of predefined product/service + * @param float $remise_percent Percent of discount on line + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service + * @param int $fk_code_ventilation Code of dispatching into accountancy + * @param int $info_bits Bits of type of lines + * @param int $fk_remise_except Id discount used + * @param string $price_base_type 'HT' or 'TTC' + * @param float $pu_ttc Unit price with tax (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int $rang Position of line (-1 means last value + 1) + * @param int $special_code Special code (also used by externals modules!) + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id + * @param int $fk_parent_line Id of parent line + * @param int $fk_fournprice Supplier price id (to calculate margin) or '' + * @param int $pa_ht Buying price of line (to calculate margin) or '' + * @param string $label Label of the line (deprecated, do not use) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param int $fk_prev_id Previous situation line id reference + * @param int|null $fk_unit Code of the unit to use. Null to use the default one + * @param float $pu_ht_devise Unit price in foreign currency + * @param string $ref_ext External reference of the line + * @param int $noupdateafterinsertline No update after insert of line + * @return int Return integer <0 if KO, Id of line if OK */ public function addline( $desc, @@ -4044,33 +4104,33 @@ class Facture extends CommonInvoice /** * Update a detail line * - * @param int $rowid Id of line to update - * @param string $desc Description of line - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) - * @param double $qty Quantity - * @param double $remise_percent Percentage discount of the line - * @param int $date_start Date de debut de validite du service - * @param int $date_end Date de fin de validite du service - * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param string $price_base_type HT or TTC - * @param int $info_bits Miscellaneous information - * @param int $type Type of line (0=product, 1=service) - * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). - * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) - * @param int $fk_fournprice Id of origin supplier price - * @param int $pa_ht Price (without tax) of product when it was bought - * @param string $label Label of the line (deprecated, do not use) - * @param int $special_code Special code (also used by externals modules!) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @param int $notrigger disable line update trigger - * @param string $ref_ext External reference of the line - * @param integer $rang rank of line - * @return int Return integer < 0 if KO, > 0 if OK + * @param int $rowid Id of line to update + * @param string $desc Description of line + * @param float $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) + * @param float $qty Quantity + * @param float $remise_percent Percentage discount of the line + * @param int $date_start Date de debut de validite du service + * @param int $date_end Date de fin de validite du service + * @param float $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') + * @param float $txlocaltax1 Local tax 1 rate + * @param float $txlocaltax2 Local tax 2 rate + * @param string $price_base_type HT or TTC + * @param int $info_bits Miscellaneous information + * @param int $type Type of line (0=product, 1=service) + * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). + * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) + * @param int $fk_fournprice Id of origin supplier price + * @param int $pa_ht Price (without tax) of product when it was bought + * @param string $label Label of the line (deprecated, do not use) + * @param int $special_code Special code (also used by externals modules!) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param ?int $fk_unit Code of the unit to use. Null to use the default one + * @param float $pu_ht_devise Unit price in currency + * @param int<0,1> $notrigger disable line update trigger + * @param string $ref_ext External reference of the line + * @param integer $rang rank of line + * @return int Return integer < 0 if KO, > 0 if OK */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { @@ -4334,10 +4394,10 @@ class Facture extends CommonInvoice $previous_progress = $line->get_allprev_progress($line->fk_facture); $current_progress = $percent - $previous_progress; $line->situation_percent = $current_progress; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $current_progress); + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $current_progress); } else { $line->situation_percent = $percent; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $percent); } $line->total_ht = $tabprice[0]; $line->total_tva = $tabprice[1]; @@ -4649,7 +4709,7 @@ class Facture extends CommonInvoice } $obj = new $classname(); - '@phan-var-force CommonNumRefGenerator $obj'; + '@phan-var-force ModeleNumRefFactures $obj'; $numref = $obj->getNextValue($soc, $this, $mode); @@ -4989,7 +5049,7 @@ class Facture extends CommonInvoice /** * Retourne id des contacts clients de facturation * - * @return array Liste des id contacts facturation + * @return int[] Liste des id contacts facturation */ public function getIdBillingContact() { @@ -4999,7 +5059,7 @@ class Facture extends CommonInvoice /** * Retourne id des contacts clients de livraison * - * @return array Liste des id contacts livraison + * @return int[] Liste des id contacts livraison */ public function getIdShippingContact() { @@ -5206,7 +5266,7 @@ class Facture extends CommonInvoice /** * Create an array of invoice lines * - * @return int >0 if OK, <0 if KO + * @return int<-1,1> >0 if OK, <0 if KO */ public function getLinesArray() { @@ -5218,11 +5278,11 @@ class Facture extends CommonInvoice * * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example. * @param Translate $outputlangs Object lang to use for translation - * @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 Return integer <0 if KO, >0 if OK + * @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<-1,1> Return integer <0 if KO, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -5946,8 +6006,8 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. * - * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. - * @return array return array + * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. + * @return array{0?:bool,1?:string} return array */ public function willBeLastOfSameType($allow_validated_drafts = false) { @@ -5987,9 +6047,9 @@ class Facture extends CommonInvoice /** * Return clickable link of object (with eventually picto) * - * @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) { @@ -6062,23 +6122,55 @@ class FactureLigne extends CommonInvoiceLine public $oldline; //! From llx_facturedet - //! Id facture + /** + * @var int Id facture + */ public $fk_facture; - //! Id parent line + /** + * @var int Id parent line + */ public $fk_parent_line; - //! Description ligne + /** + * @var string Description ligne + */ public $desc; - public $ref_ext; // External reference of the line + /** + * @var string External reference of the line + */ + public $ref_ext; + /** + * @var int<0,6> + */ public $localtax1_type; // Local tax 1 type + /** + * @var int<0,6> + */ public $localtax2_type; // Local tax 2 type + /** + * @var int + */ public $fk_remise_except; // Link to line into llx_remise_except + /** + * @var int + */ public $rang = 0; - + /** + * @var int + */ public $fk_fournprice; + /** + * @var string|int|float + */ public $pa_ht; + /** + * @var string + */ public $marge_tx; + /** + * @var string + */ public $marque_tx; /** @@ -6086,6 +6178,9 @@ class FactureLigne extends CommonInvoiceLine */ public $tva_npr; + /** + * @var float + */ public $remise_percent; /** @@ -6093,23 +6188,38 @@ class FactureLigne extends CommonInvoiceLine */ public $batch; /** - * @var string To store the warehouse where to consume stock when using a POS module + * @var int To store the warehouse where to consume stock when using a POS module */ public $fk_warehouse; + /** + * @var string + */ public $origin; + /** + * @var int + */ public $origin_id; /** - * @var integer Id in table llx_accounting_bookeeping to know accounting account for product line + * @var int Id in table llx_accounting_bookeeping to know accounting account for product line */ public $fk_code_ventilation = 0; + /** + * @var string|int + */ public $date_start; + /** + * @var string|int + */ public $date_end; + /** + * @var int<0,1> + */ public $skip_update_total; // Skip update price total for special lines /** diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 468052be7e0..7385c90005c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -634,7 +634,13 @@ class BonPrelevement extends CommonObject $addbankurl = 'direct-debit'; // = 'directdebit' } - $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); + + if ($paiement instanceof PaymentSalary) { + // Only 6 arguments for PaymentSalary + $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', ''); + } else { + $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); + } if ($result < 0) { $error++; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 805176543cb..0db8f92ffef 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2021 OpenDsi * Copyright (C) 2024 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 @@ -47,20 +48,20 @@ class RejetPrelevement public $date_rejet; /** - * @var array Reason of error + * @var string Reason of error */ public $motif; /** - * @var array Label status of invoicing + * @var string Label status of invoicing */ public $invoicing; /** - * @var array Labels of reason + * @var string[] Labels of reason */ public $motifs; /** - * @var array Labels of invoicing status + * @var string[] Labels of invoicing status */ public $labelsofinvoicing; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 96d9a2d6b2c..4bf3836cd5f 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * 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 @@ -84,6 +85,7 @@ $error = 0; if ($action == 'confirm_rejet' && $permissiontoadd) { if (GETPOST("confirm") == 'yes') { + $datarej = null; if (GETPOSTINT('remonth')) { $daterej = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); } @@ -156,6 +158,7 @@ $h++; if ($id) { $lipre = new LignePrelevement($db); + $bon = null; if ($lipre->fetch($id) >= 0) { $bon = new BonPrelevement($db); @@ -264,7 +267,7 @@ if ($id) { print '
    '; if ($action == '') { - if ($bon->statut == BonPrelevement::STATUS_CREDITED) { + if (is_object($bon) && $bon->statut == BonPrelevement::STATUS_CREDITED) { if ($lipre->statut == 2) { if ($user->hasRight('prelevement', 'bons', 'credit')) { print ''.$langs->trans("StandingOrderReject").''; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 58948ec2aa8..38060f89b73 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -154,7 +154,7 @@ abstract class CommonDocGenerator public $phpmin = array(7, 1); /** - * @var array Array of columns + * @var array Array of columns */ public $cols; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 45e68e0abd4..29c7a9f6661 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -843,8 +843,8 @@ abstract class CommonObject public $cond_reglement_supplier_id; /** - * @var float Deposit percent for payment terms. - * Populated by setPaymentTerms(). + * @var float|string Deposit percent for payment terms. + * Populated by setPaymentTerms(). * @see setPaymentTerms() */ public $deposit_percent; @@ -2160,13 +2160,13 @@ abstract class CommonObject * Setter generic. Update a specific field into database. * Warning: Trigger is run only if param trigkey is provided. * - * @param string $field Field to update - * @param mixed $value New value - * @param string $table To force other table element or element line (should not be used) - * @param int $id To force other object id (should not be used) - * @param string $format Data format ('text', 'int', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used if not defined - * @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' + * @param string $field Field to update + * @param mixed $value New value + * @param string $table To force other table element or element line (should not be used) + * @param ?int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'int', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used if not defined + * @param User|string|null $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') * @param string $fk_user_field Name of field to save user id making change * @return int<-2,1> Return integer <0 if KO, >0 if OK diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index c8dbda9c9bf..6d42c9de5f2 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -205,7 +205,7 @@ abstract class CommonOrderLine extends CommonObjectLine /** * Percent line discount - * @var float + * @var float|string */ public $remise_percent; @@ -217,7 +217,7 @@ abstract class CommonOrderLine extends CommonObjectLine /** * VAT % - * @var float + * @var float|string */ public $tva_tx; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d83543dabf9..7ec13372775 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -45,7 +45,7 @@ class ExtraFields public $db; /** - * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,pos:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,hidden:array,mandatoryfieldsofotherentities:array,loaded?:int,count:int}> New array to store extrafields definition Note: count set as present to avoid static analysis notices + * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,pos:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,cssview:array,hidden:array,mandatoryfieldsofotherentities:array,loaded?:int,count:int}> New array to store extrafields definition Note: count set as present to avoid static analysis notices */ public $attributes = array(); diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index 3c3b12131ae..7491eca24ff 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -81,7 +81,7 @@ class pdf_standard_asset extends ModelePDFAsset public $situationinvoice; /** - * @var array Array of document table columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 92bb510c107..c1470f290ef 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -224,18 +224,22 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * * @param DoliDB $db Database handler * @param string $code Code to check/correct - * @param Product $product Object product - * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param Product|Societe $product Object product + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier * @param string $type type of barcode (EAN, ISBN, ...) - * @return int 0 if OK + * @return int<-7,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -7 ErrorBadClass */ public function verif($db, &$code, $product, $thirdparty_type, $type) { - global $conf; + if (!$product instanceof Product) { + dol_syslog(get_class($this)."::verif called with ".get_class($product)." Expected Product", LOG_ERR); + return -7; + } //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index bcaeeea69a5..036a5b4a4cb 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -231,17 +231,22 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode * * @param DoliDB $db Database handler * @param string $code Code to check/correct - * @param Societe $thirdparty Object third-party - * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param Societe|Product $thirdparty Object third party + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier * @param string $type type of barcode (EAN, ISBN, ...) - * @return int 0 if OK + * @return int<-7,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -7 ErrorBadClass */ public function verif($db, &$code, $thirdparty, $thirdparty_type, $type) { + if (!$thirdparty instanceof Societe) { + dol_syslog(get_class($this)."::verif called with ".get_class($thirdparty)." Expected Societe", LOG_ERR); + return -7; + } require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $result = 0; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index c531c97aeed..51ba9c9a0d6 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -156,4 +156,22 @@ abstract class ModeleNumRefBarCode extends CommonNumRefGenerator return $s; } + + + /** + * Check validity of code according to its rules + * + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Product|Societe $object Object product or ThirdParty + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param string $type type of barcode (EAN, ISBN, ...) + * @return int<-7,0> 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + * -7 ErrorBadClass + */ + abstract public function verif($db, &$code, $object, $thirdparty_type, $type); } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 42ac7d00046..7627e5725c4 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -80,7 +80,7 @@ class pdf_eratosthene extends ModelePDFCommandes public $version = 'dolibarr'; /** - * @var array Array of document table columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 7ddafc39eb3..0800058f148 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -117,7 +117,7 @@ class pdf_octopus extends ModelePDFFactures /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 13285e9aa25..3a9a320981b 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -109,7 +109,7 @@ class pdf_sponge extends ModelePDFFactures /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 65f5e84f0a4..348ee5bbaac 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -160,9 +160,9 @@ class mod_facture_mars extends ModeleNumRefFactures * Return next value not used or last value used * * @param Societe $objsoc Object third party - * @param Facture $invoice Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|int Value if OK, 0 if KO + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index a3607cac7a0..55b74491ad4 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2022 Anthony Berton * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,12 +136,12 @@ class mod_facture_mercure extends ModeleNumRefFactures } /** - * Return next value + * Return next value not used or last value used * - * @param Societe $objsoc Object third party - * @param Facture $invoice Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|int Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 7c7392e30eb..05f3859c92e 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -4,6 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Marcos García + * 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 @@ -250,5 +251,13 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ abstract class ModeleNumRefFactures extends CommonNumRefGenerator { - // No overload code + /** + * Return next value not used or last value used + * + * @param Societe $objsoc Object third party + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO + */ + abstract public function getNextValue($objsoc, $invoice, $mode = 'next'); } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1296c735070..0e5e7cbecc5 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -74,7 +74,7 @@ class pdf_cyan extends ModelePDFPropales public $version = 'dolibarr'; /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 9f363057497..52180617a6e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -289,8 +289,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 39c7bda525b..d684dfa2040 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -106,12 +106,14 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) */ public function verif($db, &$code, $soc, $type) { diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index b0f6cc1114a..a9ba86c8c7e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -151,12 +151,14 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) */ public function verif($db, &$code, $soc, $type) { diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index f5ac07fb2ff..86c4103cf2b 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -194,6 +194,23 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator // phpcs:enable return 0; } + + /** + * Check validity of code according to its rules + * + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Societe $soc Object third party + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) + */ + abstract public function verif($db, &$code, $soc, $type); } diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index e11fa61a3b0..e9ee32958d1 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2020 Open-DSI * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -142,7 +143,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos $date = (empty($invoice->date) ? dol_now() : $invoice->date); $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0; - $mask = str_replace('{TN}', $pos_source, $mask); + $mask = str_replace('{TN}', (string) $pos_source, $mask); $numFinal = get_next_value($db, $mask, 'facture', 'ref', '', $objsoc, $date, $mode, false, null, $entity); return $numFinal; diff --git a/htdocs/core/tpl/formlayoutai.tpl.php b/htdocs/core/tpl/formlayoutai.tpl.php index 8cf9f934d32..088fc6d776b 100644 --- a/htdocs/core/tpl/formlayoutai.tpl.php +++ b/htdocs/core/tpl/formlayoutai.tpl.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 @@ -40,6 +41,9 @@ if (empty($htmlname)) { '; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 8270b068a7a..db51f5e36d9 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -106,6 +106,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (isModEnabled('invoice') && getDolGlobalString('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + '@phan-var-force Facture $object'; $newobject = new Facture($this->db); $newobject->context['createfromorder'] = 'createfromorder'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5bf5b0d930f..e403acb9cca 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3885,7 +3885,7 @@ class SupplierInvoiceLine extends CommonObjectLine /** * Percent of discount - * @var float + * @var float|string */ public $remise_percent; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 326e927f5d5..c9badc4c1ef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -61,6 +61,7 @@ class ProductFournisseur extends Product public $id; /** + * @var string * @deprecated * @see $ref_supplier */ @@ -82,11 +83,12 @@ class ProductFournisseur extends Product public $desc_supplier; /** - * @var float The VAT rate by default for this {supplier, qty, product}. Can be set by get_buyprice(). + * @var string The VAT rate by default for this {supplier, qty, product}. Can be set by get_buyprice(). */ public $vatrate_supplier; /** + * @var int * @deprecated * @see $product_id */ @@ -772,7 +774,7 @@ class ProductFournisseur extends Product * @param int $limit Limit * @param int $offset Offset * @param int $socid Filter on a third party id - * @return array|int Array of ProductFournisseur with new properties to define supplier price + * @return ProductFournisseur[]|int<-1,-1> Array of ProductFournisseur with new properties to define supplier price * @see find_min_price_product_fournisseur() */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 19c64acc849..1d997d650eb 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -560,7 +560,7 @@ if (empty($reshook)) { $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; - $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', (string) $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? 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 1b3fbeb2c44..f35f94dba18 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 @@ -93,7 +93,7 @@ class pdf_standard_myobject extends ModelePDFMyObject public $emetteur; /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 4c869bc0203..fd2d9eaa115 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -2158,7 +2158,7 @@ class Products extends DolibarrApi $children[] = array_combine($keys, $values); } - $this->product->sousprods = $children; + $this->product->sousprods = $children; // @phpstan-ignore-line } if ($includeparentid) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d700fa9c81a..3ee571bb504 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -104,9 +104,14 @@ class Product extends CommonObject */ protected $table_ref_field = 'ref'; - public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into images.lib.php + /** + * @var string + * @see images.lib.php + */ + public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; /** + * @var string * @deprecated Use $label instead * @see $label */ @@ -147,6 +152,9 @@ class Product extends CommonObject */ public $price; + /** + * @var string + */ public $price_formated; // used by takepos/ajax/ajax.php /** @@ -156,6 +164,9 @@ class Product extends CommonObject */ public $price_ttc; + /** + * @var string + */ public $price_ttc_formated; // used by takepos/ajax/ajax.php /** @@ -177,22 +188,64 @@ class Product extends CommonObject * @var string */ public $price_base_type; + /** + * @var string + */ public $price_label; //! Arrays for multiprices + /** + * @var array + */ public $multiprices = array(); + /** + * @var array + */ public $multiprices_ttc = array(); + /** + * @var array + */ public $multiprices_base_type = array(); + /** + * @var array + */ public $multiprices_default_vat_code = array(); + /** + * @var array + */ public $multiprices_min = array(); + /** + * @var array + */ public $multiprices_min_ttc = array(); + /** + * @var array + */ public $multiprices_tva_tx = array(); + /** + * @var array + */ public $multiprices_recuperableonly = array(); + /** + * @var array + */ //! Price by quantity arrays + /** + * @var int<0,0>|float + */ public $price_by_qty; + /** + * @var array + */ public $prices_by_qty = array(); + /** + * @var array + */ public $prices_by_qty_id = array(); + /** + * @var array> + */ public $prices_by_qty_list = array(); /** @@ -200,13 +253,19 @@ class Product extends CommonObject */ public $level; - //! Array for multilangs + /** + * @var ?array Array for multilangs + */ public $multilangs = array(); - //! Default VAT code for product (link to code into llx_c_tva but without foreign keys) + /** + * @var string Default VAT code for product (link to code into llx_c_tva but without foreign keys) + */ public $default_vat_code; - //! Default VAT rate of product + /** + * @var string|int Default VAT rate of product + */ public $tva_tx; /** @@ -214,25 +273,65 @@ class Product extends CommonObject */ public $tva_npr = 0; - //! Default discount percent + /** + * @var string Default discount percent + */ public $remise_percent; - //! Other local taxes + /** + * @var string|int|float Other local taxes + */ public $localtax1_tx; + /** + * @var string|int|float + */ public $localtax2_tx; + /** + * @var string + */ public $localtax1_type; + /** + * @var string + */ public $localtax2_type; // Properties set by get_buyprice() for return + /** + * @var string + */ public $desc_supplier; + /** + * @var string + */ public $vatrate_supplier; + /** + * @var string + */ public $default_vat_code_supplier; + /** + * @var string|int + */ public $fourn_multicurrency_price; + /** + * @var string|int + */ public $fourn_multicurrency_unitprice; + /** + * @var string|int + */ public $fourn_multicurrency_tx; + /** + * @var string + */ public $fourn_multicurrency_id; + /** + * @var string + */ public $fourn_multicurrency_code; + /** + * @var float + */ public $packaging; @@ -273,7 +372,9 @@ class Product extends CommonObject */ public $cost_price; - //! Average price value for product entry into stock (PMP) + /** + * @var float Average price value for product entry in stock (PMP) + */ public $pmp; /** @@ -284,20 +385,20 @@ class Product extends CommonObject public $seuil_stock_alerte = 0; /** - * Ask for replenishment when $desiredstock < $stock_reel + * @var float Ask for replenishment when $desiredstock < $stock_reel */ public $desiredstock = 0; /** - * Service expiration + * @var ?int Service expiration */ public $duration_value; /** - * Service expiration unit + * @var string Service expiration unit */ public $duration_unit; /** - * Service expiration label (value + unit) + * @var string Service expiration label (value + unit) */ public $duration; @@ -407,28 +508,88 @@ class Product extends CommonObject */ public $url; - //! Metric of products + //! Metrics of products + /** + * @var float|string + */ public $weight; + /** + * @var int|string + */ public $weight_units; // scale -3, 0, 3, 6 + /** + * @var float|string + */ public $length; + /** + * @var int|string + */ public $length_units; // scale -3, 0, 3, 6 + /** + * @var float|string + */ public $width; + /** + * @var int|string + */ public $width_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $height; + /** + * @var int|string|null + */ public $height_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $surface; + /** + * @var int|string|null + */ public $surface_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $volume; + /** + * @var int|string|null + */ public $volume_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $net_measure; + /** + * @var ?string + */ public $net_measure_units; // scale -3, 0, 3, 6 + /** + * @var string + */ public $accountancy_code_sell; + /** + * @var string + */ public $accountancy_code_sell_intra; + /** + * @var string + */ public $accountancy_code_sell_export; + /** + * @var string + */ public $accountancy_code_buy; + /** + * @var string + */ public $accountancy_code_buy_intra; + /** + * @var string + */ public $accountancy_code_buy_export; /** @@ -461,8 +622,13 @@ class Product extends CommonObject public $stats_facturerec = array(); public $stats_facture_fournisseur = array(); - //! Size of image + /** + * @var int|string Size of image / height + */ public $imgWidth; + /** + * @var int|string Size of image / height + */ public $imgHeight; /** @@ -520,6 +686,7 @@ class Product extends CommonObject public $fourn_socid; /** + * @var string * @deprecated * @see $ref_supplier */ @@ -547,19 +714,19 @@ class Product extends CommonObject /** * Array with list of supplier prices of product * - * @var array + * @var ProductFournisseur[] */ public $supplierprices; /** * Array with list of sub-products for Kits * - * @var array + * @var array> */ public $sousprods; /** - * @var array Path of subproducts. Build from ->sousprods with get_arbo_each_prod() + * @var array,entity:CommonObject}> Path of subproducts. Build from ->sousprods with get_arbo_each_prod() */ public $res; @@ -594,6 +761,9 @@ class Product extends CommonObject */ public $is_sousproduit_incdec; + /** + * @var int + */ public $mandatory_period; @@ -623,7 +793,7 @@ class Product extends CommonObject */ /** - * @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. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> 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, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), @@ -1141,19 +1311,19 @@ class Product extends CommonObject $this->note_private = (isset($this->note_private) ? trim($this->note_private) : null); $this->note_public = (isset($this->note_public) ? trim($this->note_public) : null); $this->net_measure = price2num($this->net_measure); - $this->net_measure_units = (empty($this->net_measure_units) ? '' : trim($this->net_measure_units)); + $this->net_measure_units = (empty($this->net_measure_units) ? '' : trim((string) $this->net_measure_units)); $this->weight = price2num($this->weight); - $this->weight_units = (empty($this->weight_units) ? '' : trim($this->weight_units)); + $this->weight_units = (empty($this->weight_units) ? '' : trim((string) $this->weight_units)); $this->length = price2num($this->length); - $this->length_units = (empty($this->length_units) ? '' : trim($this->length_units)); + $this->length_units = (empty($this->length_units) ? '' : trim((string) $this->length_units)); $this->width = price2num($this->width); - $this->width_units = (empty($this->width_units) ? '' : trim($this->width_units)); + $this->width_units = (empty($this->width_units) ? '' : trim((string) $this->width_units)); $this->height = price2num($this->height); - $this->height_units = (empty($this->height_units) ? '' : trim($this->height_units)); + $this->height_units = (empty($this->height_units) ? '' : trim((string) $this->height_units)); $this->surface = price2num($this->surface); - $this->surface_units = (empty($this->surface_units) ? '' : trim($this->surface_units)); + $this->surface_units = (empty($this->surface_units) ? '' : trim((string) $this->surface_units)); $this->volume = price2num($this->volume); - $this->volume_units = (empty($this->volume_units) ? '' : trim($this->volume_units)); + $this->volume_units = (empty($this->volume_units) ? '' : trim((string) $this->volume_units)); // set unit not defined if (is_numeric($this->length_units)) { @@ -1699,7 +1869,7 @@ class Product extends CommonObject /** * Get sell or eat by mandatory list * - * @return array Sell or eat by mandatory list + * @return array{0:string,1:string,2:string,3:string} Sell or eat by mandatory list */ public static function getSellOrEatByMandatoryList() { @@ -1782,7 +1952,7 @@ class Product extends CommonObject return -1; } } elseif (isset($this->multilangs[$key])) { - if (empty($this->multilangs["$key"]["label"])) { + if (empty($this->multilangs[$key]["label"])) { $this->errors[] = $key . ' : ' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); return -1; } @@ -1974,7 +2144,7 @@ class Product extends CommonObject * used to check if price have really change to avoid log pollution * * @param int $level price level to change - * @return array + * @return array{level:int,multiprices:float,multiprices_ttc:float,multiprices_base_type:string,multiprices_min:float,multiprices_min_ttc:float,multiprices_tva_tx:float,multiprices_recuperableonly:float}|array{} */ private function getArrayForPriceCompare($level = 0) { @@ -2048,9 +2218,9 @@ class Product extends CommonObject /** * Delete a price line * - * @param User $user Object user - * @param int $rowid Line id to delete - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user + * @param int $rowid Line id to delete + * @return int Return integer <0 if KO, >0 if OK */ public function log_price_delete($user, $rowid) { @@ -2077,7 +2247,7 @@ class Product extends CommonObject * @param Societe $thirdparty_seller Seller * @param Societe $thirdparty_buyer Buyer * @param int $pqp Id of product price per quantity if a selection was done of such a price - * @return array Array of price information array('pu_ht'=> , 'pu_ttc'=> , 'tva_tx'=>'X.Y (code)', ...), 'tva_npr'=>0, ...) + * @return array{pu_ht:float|int|string,pu_ttc:float|int|string,price_min:float|int|string,price_base_type:string,tva_tx:float|string|null|int,tva_npr:float|int} * @see get_buyprice(), find_min_price_product_fournisseur() */ public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) @@ -2195,12 +2365,12 @@ class Product extends CommonObject * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. * This also set some properties on product like ->buyprice, ->fourn_pu, ... * - * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price - * @param double $qty Quantity asked or -1 to get first entry found - * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. - * @param int $fk_soc If of supplier - * @return int|string Return integer <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...), or printable result of hook + * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price + * @param float|int<-1,-1> $qty Quantity asked or -1 to get first entry found + * @param int $product_id Filter on a particular product id + * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. + * @param int $fk_soc If of supplier + * @return int|string|mixed[] Return integer <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...), or printable result of hook * @see getSellPrice(), find_min_price_product_fournisseur() */ public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0) @@ -2362,20 +2532,20 @@ class Product extends CommonObject /** * Modify customer price of a product/Service for a given level * - * @param double $newprice New price - * @param string $newpricebase HT or TTC - * @param User $user Object user that make change - * @param ?double $newvat New VAT Rate (For example 8.5. Should not be a string) - * @param double|int $newminprice New price min - * @param int $level 0=standard, >0 = level if multilevel prices - * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT - * @param int $newpbq 1 if it has price by quantity - * @param int $ignore_autogen Used to avoid infinite loops - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param string $price_label Price Label - * @param int $notrigger Disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param double $newprice New price + * @param string $newpricebase HT or TTC + * @param User $user Object user that make change + * @param ?float $newvat New VAT Rate (For example 8.5. Should not be a string) + * @param float|int $newminprice New price min + * @param int $level 0=standard, >0 = level if multilevel prices + * @param int<0,1> $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT + * @param int<0,1> $newpbq 1 if it has price by quantity + * @param int<0,1> $ignore_autogen Used to avoid infinite loops + * @param array{}|array{0:string,1:int|string,2:string,3:string}|array{0:string,1:int|string,2:string,3:int|string,4:string,5:string} $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param string $newdefaultvatcode Default vat code + * @param string $price_label Price Label + * @param int $notrigger Disable triggers + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) { @@ -2401,6 +2571,9 @@ class Product extends CommonObject $newvat = $this->tva_tx; } + $localtaxtype1 = ''; + $localtaxtype2 = ''; + // If multiprices are enabled, then we check if the current product is subject to price autogeneration // Price will be modified ONLY when the first one is the one that is being modified if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { @@ -2442,7 +2615,6 @@ class Product extends CommonObject } } //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc; - if (count($localtaxes_array) > 0) { $localtaxtype1 = $localtaxes_array['0']; $localtax1 = $localtaxes_array['1']; @@ -3880,8 +4052,8 @@ class Product extends CommonObject /** * Charge tableau des stats facture recurrentes pour le produit/service * - * @param int $socid Id societe - * @return int Array of stats in $this->stats_facture, <0 if ko or >0 if ok + * @param int $socid Id societe + * @return int Array of stats in $this->stats_facture, <0 if ko or >0 if ok */ public function load_stats_facturerec($socid = 0) { @@ -4007,10 +4179,10 @@ class Product extends CommonObject /** * Return an array formatted for showing graphs * - * @param string $sql Request to execute - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $year Year (0=current year, -1=all years) - * @return array|int Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param string $sql Request to execute + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $year Year (0=current year, -1=all years) + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ private function _get_stats($sql, $mode, $year = 0) { @@ -4090,7 +4262,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4143,7 +4315,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4195,7 +4367,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4247,7 +4419,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4299,7 +4471,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4346,12 +4518,12 @@ class Product extends CommonObject /** * Return nb of units in orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only - * @param int $year Year (0=last 12 month, -1=all years) - * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @param int $year Year (0=last 12 month, -1=all years) + * @param string $morefilter More sql filters + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4403,7 +4575,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_contract($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4452,12 +4624,12 @@ class Product extends CommonObject /** * Return nb of units in orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only - * @param int $year Year (0=last 12 month, -1=all years) - * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @param int $year Year (0=last 12 month, -1=all years) + * @param string $morefilter More sql filters + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_mos($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4696,9 +4868,9 @@ class Product extends CommonObject /** * Check if it is a sub-product into a kit * - * @param int $fk_parent Id of parent kit product - * @param int $fk_child Id of child product - * @return int Return 1 or 0; -1 if error + * @param int $fk_parent Id of parent kit product + * @param int $fk_child Id of child product + * @return int<-1,1> Return 1 or 0; -1 if error */ public function is_sousproduit($fk_parent, $fk_child) { @@ -4734,11 +4906,11 @@ class Product extends CommonObject * Add a supplier price for the product. * Note: Duplicate ref is accepted for different quantity only, or for different companies. * - * @param User $user User that make link - * @param int $id_fourn Supplier id - * @param string $ref_fourn Supplier ref - * @param float $quantity Quantity minimum for price - * @return int Return integer < 0 if KO, 0 if link already exists for this product, > 0 if OK + * @param User $user User that make link + * @param int $id_fourn Supplier id + * @param string $ref_fourn Supplier ref + * @param float $quantity Quantity minimum for price + * @return int<-3,1> Return integer < 0 if KO, 0 if link already exists for this product, > 0 if OK */ public function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { @@ -4834,7 +5006,7 @@ class Product extends CommonObject /** * Return list of suppliers providing the product or service * - * @return array Array of vendor ids + * @return int[] Array of vendor ids */ public function list_suppliers() { @@ -5095,9 +5267,9 @@ class Product extends CommonObject * Build the tree of subproducts and return it. * this->sousprods must have been loaded by this->get_sousproduits_arbo() * - * @param int $multiply Because each sublevel must be multiplicated by parent nb - * @param int $ignore_stock_load Ignore stock load - * @return array Array with tree + * @param int $multiply Because each sublevel must be multiplicated by parent nb + * @param int $ignore_stock_load Ignore stock load + * @return array,entity:CommonObject}> Array with tree */ public function get_arbo_each_prod($multiply = 1, $ignore_stock_load = 0) { @@ -5238,11 +5410,11 @@ class Product extends CommonObject /** * Return children of product $id * - * @param int $id Id of product to search children of - * @param int $firstlevelonly Return only direct child - * @param int $level Level of recursing call (start to 1) - * @param array $parents Array of all parents of $id - * @return array|int Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) + * @param int $id Id of product to search children of + * @param int $firstlevelonly Return only direct child + * @param int $level Level of recursing call (start to 1) + * @param int[] $parents Array of all parents of $id + * @return array|array{}|int<-1,-1> Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref,6:int,7:int) */ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array()) { @@ -5327,15 +5499,16 @@ class Product extends CommonObject $parent[$this->label][$keyChild] = $valueChild; } foreach ($parent as $key => $value) { // key=label, value is array of children - $this->sousprods[$key] = $value; + $this->sousprods[$key] = $value; // @phan-suppress-current-line PhanTypeMismatchProperty } } /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -5731,18 +5904,18 @@ class Product extends CommonObject /** * Adjust stock in a warehouse for product * - * @param User $user user asking change - * @param int $id_entrepot id of warehouse - * @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) - * @param int $movement 0 = add, 1 = remove - * @param string $label Label of stock movement - * @param double $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. - * @param string $inventorycode Inventory code - * @param string $origin_element Origin element type - * @param int $origin_id Origin id of element - * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) - * @param Extrafields $extrafields Array of extrafields - * @return int Return integer <0 if KO, >0 if OK + * @param User $user user asking change + * @param int $id_entrepot id of warehouse + * @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) + * @param int<0,1> $movement 0 = add, 1 = remove + * @param string $label Label of stock movement + * @param float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. + * @param string $inventorycode Inventory code + * @param string $origin_element Origin element type + * @param ?int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) + * @param ?ExtraFields $extrafields Array of extrafields + * @return int Return integer <0 if KO, >0 if OK */ public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) { @@ -5790,21 +5963,21 @@ class Product extends CommonObject /** * Adjust stock in a warehouse for product with batch number * - * @param User $user user asking change - * @param int $id_entrepot id of warehouse - * @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) - * @param int $movement 0 = add, 1 = remove - * @param string $label Label of stock movement - * @param double $price Price to use for stock eval - * @param int|string $dlc eat-by date - * @param int|string $dluo sell-by date - * @param string $lot Lot number - * @param string $inventorycode Inventory code - * @param string $origin_element Origin element type - * @param int $origin_id Origin id of element - * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) - * @param Extrafields $extrafields Array of extrafields - * @param boolean $force_update_batch Force update batch + * @param User $user user asking change + * @param int $id_entrepot id of warehouse + * @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) + * @param int<0,1> $movement 0 = add, 1 = remove + * @param string $label Label of stock movement + * @param float $price Price to use for stock eval + * @param int|string $dlc eat-by date + * @param int|string $dluo sell-by date + * @param string $lot Lot number + * @param string $inventorycode Inventory code + * @param string $origin_element Origin element type + * @param ?int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) + * @param ?ExtraFields $extrafields Array of extrafields + * @param boolean $force_update_batch Force update batch * @return int Return integer <0 if KO, >0 if OK */ public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null, $force_update_batch = false) @@ -6061,9 +6234,9 @@ class Product extends CommonObject /** * Load existing information about a serial * - * @param string $batch Lot/serial number - * @return array Array with record into product_batch - * @see load_stock(), load_virtual_stock() + * @param string $batch Lot/serial number + * @return array Array with record into product_batch + * @see load_stock(), load_virtual_stock() */ public function loadBatchInfo($batch) { @@ -6094,9 +6267,10 @@ class Product extends CommonObject /** * Move an uploaded file described into $file array into target directory $sdir. * - * @param string $sdir Target directory - * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) - * @return int Return integer <0 if KO, >0 if OK + * @param string $sdir Target directory + + * @param array{name:string,tmp_name:string} $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) + * @return int Return integer <0 if KO, >0 if OK */ public function add_photo($sdir, $file) { @@ -6179,7 +6353,7 @@ class Product extends CommonObject * * @param string $dir Directory to scan * @param int $nbmax Number maximum of photos (0=no maximum) - * @return array Array of photos + * @return array Array of photos */ public function liste_photos($dir, $nbmax = 0) { @@ -6400,7 +6574,7 @@ class Product extends CommonObject } $var = getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM'); $mod = new $var(); - '@phan-var-force ModeleNumRefBarCode $module'; + '@phan-var-force ModeleNumRefBarCode $mod'; $result = $mod->getNextValue($object, $type); @@ -6709,9 +6883,9 @@ class Product extends CommonObject /** * Return clickable link of object (with eventually picto) * - * @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{string,mixed} $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = null) { @@ -6773,7 +6947,7 @@ class Product extends CommonObject /** * Class to manage products or services. - * Do not use 'Service' as class name since it is already used by APIs. + * Do not use 'Service' as class name since it is already used by APIs (Note: in namespace Stripe\Service) */ class ProductService extends Product { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 791577fe95a..5652daf890f 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -68,8 +68,8 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); -$stocklimit = (float) GETPOST('seuil_stock_alerte'); -$desiredstock = GETPOST('desiredstock'); +$stocklimit = GETPOSTFLOAT('seuil_stock_alerte'); +$desiredstock = GETPOSTFLOAT('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; $d_eatby = dol_mktime(0, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear')); @@ -175,11 +175,13 @@ if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); $maj_ok = false; } - if ($desiredstock == '') { + if ($desiredstock == '' || is_array($desiredstock)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } + $desiredstock = (float) $desiredstock; + if ($maj_ok) { $pse = new ProductStockEntrepot($db); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -195,7 +197,7 @@ if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) $pse->fk_entrepot = GETPOSTINT('fk_entrepot'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); - $pse->desiredstock = GETPOST('desiredstock'); + $pse->desiredstock = GETPOSTFLOAT('desiredstock'); if ($pse->create($user) > 0) { setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index f7640d2a2bf..cf358161eb4 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -7,6 +7,7 @@ * Copyright (C) 2019 Frédéric France * Copyright (C) 2021 Ferran Marcet * Copyright (C) 2021 Antonin MARCHAL + * 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 @@ -202,7 +203,7 @@ if ($action == 'order' && GETPOST('valid')) { $tva = $line->tva_tx / 100; $line->total_tva = $line->total_ht * $tva; $line->total_ttc = $line->total_ht + $line->total_tva; - $line->remise_percent = $productsupplier->remise_percent; + $line->remise_percent = (float) $productsupplier->remise_percent; $line->ref_fourn = $productsupplier->ref_supplier; $line->type = $productsupplier->type; $line->fk_unit = $productsupplier->fk_unit; @@ -243,7 +244,7 @@ if ($action == 'order' && GETPOST('valid')) { foreach ($supplier['lines'] as $line) { if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; + $line->remise_percent = (float) $order->thirdparty->remise_supplier_percent; } $result = $order->addline( $line->desc, @@ -285,12 +286,12 @@ if ($action == 'order' && GETPOST('valid')) { foreach ($supplier['lines'] as $line) { if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; + $line->remise_percent = (float) $order->thirdparty->remise_supplier_percent; } $order->lines[] = $line; } - $order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id; - $order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id; + $order->cond_reglement_id = (int) $order->thirdparty->cond_reglement_supplier_id; + $order->mode_reglement_id = (int) $order->thirdparty->mode_reglement_supplier_id; $id = $order->create($user); if ($id < 0) { diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index a0b165e98e8..fd1189fcfba 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -108,7 +108,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio public $defaultTitlesFieldsStyle = array(); /** - * @var array Array of document tablecolumns + * @var array Array of document table columns */ public $cols = array(); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index dd781cbc3b0..64ea19bf2fd 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1213,7 +1213,7 @@ class Thirdparties extends DolibarrApi $exists_sql .= " AND fk_contact = '".$this->db->escape($contact_id)."'"; $exists_result = $this->db->query($exists_sql); - if ($this->db->num_rows($exists_sql) > 0) { + if ($this->db->num_rows($exists_result) > 0) { throw new RestException(403, 'Notification already exists'); } @@ -1235,6 +1235,7 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return array|mixed Notification of thirdparty + * @phan-return Notify * * @url POST {id}/notificationsbycode/{code} */ @@ -1279,7 +1280,7 @@ class Thirdparties extends DolibarrApi $exists_sql .= " AND fk_contact = '".$this->db->escape($contact_id)."'"; $exists_result = $this->db->query($exists_sql); - if ($this->db->num_rows($exists_sql) > 0) { + if ($this->db->num_rows($exists_result) > 0) { throw new RestException(403, 'Notification already exists'); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 97054dcf2e7..aa67f97c5a4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -129,7 +129,7 @@ class Societe extends CommonObject /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer + * @var int<0,1> */ public $restrictiononfksoc = 1; @@ -140,7 +140,7 @@ class Societe extends CommonObject /** * array of supplier categories - * @var array + * @var string[] */ public $SupplierCategories = array(); @@ -511,14 +511,26 @@ class Societe extends CommonObject public $tva_intra; /** - * @var int Vat reverse-charge concerned + * @var int<0,1> Vat reverse-charge concerned */ public $vat_reverse_charge = 0; // Local taxes + /** + * @var int + */ public $localtax1_assuj; + /** + * @var string + */ public $localtax1_value; + /** + * @var int + */ public $localtax2_assuj; + /** + * @var string + */ public $localtax2_value; /** @@ -535,20 +547,60 @@ class Societe extends CommonObject * @var int Type thirdparty */ public $typent_id = 0; + /** + * @var string + */ public $typent_code; + /** + * @var int + */ public $effectif; + /** + * @var int + */ public $effectif_id = 0; - public $forme_juridique_code; - public $forme_juridique = 0; + /** + * @var int + */ + public $forme_juridique_code = 0; + /** + * @var string Label for Legal Form (of company) + * @see CommonDocGenerator::get_substitutionarray_mysoc() + */ + public $forme_juridique; + /** + * @var string + */ public $remise_percent; + /** + * @var string + */ public $remise_supplier_percent; + /** + * @var int + */ public $mode_reglement_id; + /** + * @var int + */ public $cond_reglement_id; + /** + * @var string|float + */ public $deposit_percent; + /** + * @var int + */ public $mode_reglement_supplier_id; + /** + * @var int + */ public $cond_reglement_supplier_id; + /** + * @var int + */ public $transport_mode_supplier_id; /** @@ -1084,11 +1136,11 @@ class Societe extends CommonObject /** * Create a contact/address from thirdparty * - * @param User $user Object user - * @param int $no_email 1=Do not send mailing, 0=Ok to receive mailing - * @param array $tags Array of tag to affect to contact - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user + * @param int<0,1> $no_email 1=Do not send mailing, 0=Ok to receive mailing + * @param string[] $tags Array of tag to affect to contact + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function create_individual(User $user, $no_email = 0, $tags = array(), $notrigger = 0) { @@ -1401,16 +1453,16 @@ class Societe extends CommonObject } // Local taxes - $this->localtax1_assuj = trim($this->localtax1_assuj); - $this->localtax2_assuj = trim($this->localtax2_assuj); + $this->localtax1_assuj = (int) trim((string) $this->localtax1_assuj); + $this->localtax2_assuj = (int) trim((string) $this->localtax2_assuj); $this->localtax1_value = trim($this->localtax1_value); $this->localtax2_value = trim($this->localtax2_value); $this->capital = ($this->capital != '') ? (float) price2num(trim((string) $this->capital)) : null; - $this->effectif_id = trim((string) $this->effectif_id); - $this->forme_juridique_code = trim((string) $this->forme_juridique_code); + $this->effectif_id = (int) trim((string) $this->effectif_id); + $this->forme_juridique_code = (int) trim((string) $this->forme_juridique_code); //Gencod $this->barcode = trim($this->barcode); @@ -2151,6 +2203,7 @@ class Societe extends CommonObject $columnName = $deleteFromObject[2]; if (dol_include_once($filepath)) { $child_object = new $className($this->db); + '@phan-var-force CommonObject $child_object'; $result = $child_object->deleteByParentField($id, $columnName); if ($result < 0) { $error++; @@ -2701,9 +2754,9 @@ class Societe extends CommonObject /** * getTooltipContentArray * - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -2727,11 +2780,11 @@ class Societe extends CommonObject $photo .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. $photo .= '
    '; $datas['photo'] = $photo; - } elseif (!empty($this->logo_squarred) && class_exists('Form')) { - /*$label.= '
    '; - $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label.= '
    ';*/ - } + } //elseif (!empty($this->logo_squarred) && class_exists('Form')) { + /*$label.= '
    '; + $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $label.= '
    ';*/ + // } $datas['divopen'] = '
    '; @@ -3049,10 +3102,10 @@ class Societe extends CommonObject /** - * Return label of status (activity, closed) + * Return label of status (activity, closed) * - * @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) { @@ -3063,8 +3116,8 @@ class Societe extends CommonObject /** * Return the label of a given status * - * @param int $status Status id - * @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 $status Status id + * @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 Status label */ public function LibStatut($status, $mode = 0) @@ -3090,10 +3143,10 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of contacts emails existing for third party + * Return list of contacts emails existing for third party * - * @param int $addthirdparty 1=Add also a record for thirdparty email, 2=Same than 1 but add text ThirdParty in grey - * @return array Array of contacts emails + * @param int<0,2> $addthirdparty 1=Add also a record for thirdparty email, 2=Same than 1 but add text ThirdParty in grey + * @return array<'thirdparty'|int,string> Array of contact's emails */ public function thirdparty_and_contact_email_array($addthirdparty = 0) { @@ -3115,9 +3168,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of contacts mobile phone existing for third party + * Return list of contacts mobile phone existing for third party * - * @return array Array of contacts emails + * @return array<'thirdparty'|int,string> Array of contacts mobile phone */ public function thirdparty_and_contact_phone_array() { @@ -3140,9 +3193,9 @@ class Societe extends CommonObject /** * Return list of contacts emails or mobile existing for third party * - * @param string $mode 'email' or 'mobile' - * @param int $hidedisabled 1=Hide contact if disabled - * @return array Array of contacts emails or mobile. Example: array(id=>'Name ') + * @param 'email'|'mobile' $mode 'email' or 'mobile' + * @param int<0,1> $hidedisabled 1=Hide contact if disabled + * @return string[] Array of contacts emails or mobile. Example: array(id=>'Name ') */ public function contact_property_array($mode = 'email', $hidedisabled = 0) { @@ -3208,9 +3261,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the contact list of this company + * Return the contact list of this company * - * @return array array of contacts + * @return string[] $contacts array of contacts */ public function contact_array() { @@ -3237,9 +3290,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the contact list of this company + * Return the contact list of this company * - * @return array $contacts array of contacts + * @return Contact[] $contacts array of contacts */ public function contact_array_objects() { @@ -3360,8 +3413,8 @@ class Societe extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { - $this->error++; - $this->errors[] = $this->db->lasterror; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); return 0; } else { $num_rows = $this->db->num_rows($result); @@ -3402,6 +3455,7 @@ class Societe extends CommonObject } /** @var ModeleThirdPartyCode $mod */ $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; $this->code_client = $mod->getNextValue($objsoc, $type); $this->prefixCustomerIsRequired = $mod->prefixIsRequired; @@ -3435,6 +3489,7 @@ class Societe extends CommonObject } /** @var ModeleThirdPartyCode $mod */ $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; $this->code_fournisseur = $mod->getNextValue($objsoc, $type); @@ -3465,6 +3520,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); if ($mod->code_modifiable_null && !$this->code_client) { @@ -3505,6 +3561,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); if ($mod->code_modifiable_null && !$this->code_fournisseur) { @@ -3551,6 +3608,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::check_codeclient code_client=".$this->code_client." module=".$module); $result = $mod->verif($this->db, $this->code_client, $this, 0); @@ -3592,6 +3650,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); $result = $mod->verif($this->db, $this->code_fournisseur, $this, 1); @@ -3632,6 +3691,7 @@ class Societe extends CommonObject if ($res) { $mod = new $module(); + '@phan-var-force ModeleAccountancyCode $mod'; // Set code count in $mod->code $result = $mod->get_code($this->db, $this, $type); @@ -3735,8 +3795,8 @@ class Societe extends CommonObject * Get parents for company * * @param int $company_id ID of company to search parent - * @param array $parents List of companies ID found - * @return array + * @param int[] $parents List of companies ID found + * @return int[] */ public function getParentsForCompany($company_id, $parents = array()) { @@ -4445,7 +4505,7 @@ class Societe extends CommonObject $this->tva_intra = getDolGlobalString('MAIN_INFO_TVAINTRA'); // VAT number, not necessarily INTRA. $this->managers = getDolGlobalString('MAIN_INFO_SOCIETE_MANAGERS'); $this->capital = is_numeric(getDolGlobalString('MAIN_INFO_CAPITAL')) ? (float) price2num(getDolGlobalString('MAIN_INFO_CAPITAL')) : 0; - $this->forme_juridique_code = getDolGlobalString('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'); + $this->forme_juridique_code = getDolGlobalInt('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'); $this->email = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); $this->default_lang = getDolGlobalString('MAIN_LANG_DEFAULT', 'auto'); $this->logo = getDolGlobalString('MAIN_INFO_SOCIETE_LOGO'); @@ -4716,8 +4776,8 @@ class Societe extends CommonObject /** * Return amount of proposal not yet paid and total an dlist of all proposals * - * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingProposals($mode = 'customer') { @@ -4760,8 +4820,8 @@ class Societe extends CommonObject /** * Return amount of order not yet paid and total and list of all orders * - * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') { @@ -4803,9 +4863,9 @@ class Societe extends CommonObject /** * Return amount of bill not yet paid and total of all invoices * - * @param string $mode 'customer' or 'supplier' - * @param int $late 0 => all invoice, 1=> only late - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param int<0,1> $late 0 => all invoice, 1=> only late + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingBills($mode = 'customer', $late = 0) { @@ -4933,13 +4993,13 @@ class Societe extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Generator to use. Caller must set it to obj->model_pdf. - * @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 Return integer <0 if KO, >0 if OK + * @param string $modele Generator to use. Caller must set it to obj->model_pdf. + * @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 Return integer <0 if KO, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -5017,7 +5077,7 @@ class Societe extends CommonObject * * @param int[]|int $salesrep User ID or array of user IDs * @param bool $onlyAdd Only add (no delete before) - * @return int Return integer <0 if KO, >0 if OK + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function setSalesRep($salesrep, $onlyAdd = false) { @@ -5196,11 +5256,11 @@ class Societe extends CommonObject } /** - * Return clickable link of object (with eventually picto) + * Return clickable link of object (with optional picto) * - * @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 = array()) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index be7bfbc6c87..4992081e976 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -384,6 +384,8 @@ if (empty($reshook)) { //$creditnote->remise_percent = $invoice->remise_percent; $creditnote->create($user); + $fk_parent_line = 0; // Initialise + foreach ($invoice->lines as $line) { // Extrafields if (method_exists($line, 'fetch_optionals')) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 316accdfcd6..7ea228c62c4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -474,7 +474,7 @@ class Ticket extends CommonObject * @param string $getRef Reference of object * @return bool */ - public function checkExistingRef(string $action, string $getRef): bool + public function checkExistingRef(string $action, string $getRef) { $test = new self($this->db); diff --git a/htdocs/webportal/class/webportalinvoice.class.php b/htdocs/webportal/class/webportalinvoice.class.php index 94d92ffde54..2a55e8af420 100644 --- a/htdocs/webportal/class/webportalinvoice.class.php +++ b/htdocs/webportal/class/webportalinvoice.class.php @@ -93,7 +93,7 @@ class WebPortalInvoice extends Facture // 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. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> 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' => 0, 'notnull' => 1, 'position' => 1,), From 4df9e4466393d860cd677ad9e4da2abf4089e5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 14 Aug 2024 13:58:17 +0200 Subject: [PATCH 10/11] fix expects string, bool given (#30636) * fix expects string, bool given * fix expects string, bool given * fix expects string, bool given --- htdocs/adherents/admin/website.php | 15 ++++++++------- htdocs/core/class/doleditor.class.php | 3 ++- phpstan.neon.dist | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 2ccb20f51bb..c4937a8a8a8 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -1,9 +1,10 @@ - * Copyright (C) 2006-2015 Laurent Destailleur - * Copyright (C) 2006-2012 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2024 Alexandre Spangaro +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2012 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,8 +76,8 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", !$showtable, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" - $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" + $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", (string) !$showtable, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" + $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", (string) !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 925263411d0..22cc60a81c7 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2021 Gaëtan MAISON * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -202,7 +203,7 @@ class DolEditor $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; + $out .= ''."\n"; $out .= '
  • '.$langs->trans("DraftFichinter").'
    '.$langs->trans("ApiProductionMode").''; print img_picto($langs->trans("Activated"), 'switch_on'); @@ -132,7 +132,7 @@ print '
    '.$langs->trans("API_DISABLE_COMPRESSION").''; print img_picto($langs->trans("Activated"), 'switch_on'); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index e516ed44ba2..c3c74cd9e69 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -55,7 +55,7 @@ class DolibarrApi Defaults::$cacheDirectory = $cachedir; $this->db = $db; - $production_mode = !(!getDolGlobalString('API_PRODUCTION_MODE')); + $production_mode = getDolGlobalBool('API_PRODUCTION_MODE'); $this->r = new Restler($production_mode, $refreshCache); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 08207add827..8386268e1d7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -205,7 +205,7 @@ function getMultidirVersion($object, $module = '', $forobject = 0) /** - * Return dolibarr global constant string value + * Return a Dolibarr global constant string value * * @param string $key Key to return value, return $default if not set * @param string|int|float $default Value to return if not defined @@ -222,9 +222,9 @@ function getDolGlobalString($key, $default = '') * Return a Dolibarr global constant int value. * The constants $conf->global->xxx are loaded by the script master.inc.php included at begin of any PHP page. * - * @param string $key key to return value, return 0 if not set - * @param int $default value to return - * @return int + * @param string $key Key to return value, return $default if not set + * @param int $default Value to return if not defined + * @return int Value returned * @see getDolUserInt() */ function getDolGlobalInt($key, $default = 0) @@ -233,6 +233,20 @@ function getDolGlobalInt($key, $default = 0) return (int) (isset($conf->global->$key) ? $conf->global->$key : $default); } +/** + * Return a Dolibarr global constant boolean value. + * The constants $conf->global->xxx are loaded by the script master.inc.php included at begin of any PHP page. + * + * @param string $key Key to return value, return $default if not set + * @param bool $default Value to return if not defined + * @return bool Value returned + */ +function getDolGlobalBool($key, $default = false) +{ + global $conf; + return (bool) ($conf->global->$key ?? $default); +} + /** * Return Dolibarr user constant string value * diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 28f35d2a4be..42ac7d00046 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1926,7 +1926,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->cols['totalincltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => !(!getDolGlobalString('PDF_ORDER_SHOW_PRICE_INCL_TAX')), + 'status' => getDolGlobalBool('PDF_ORDER_SHOW_PRICE_INCL_TAX'), 'title' => array( 'textkey' => 'TotalTTCShort' ), diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3183e69484a..13285e9aa25 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2708,7 +2708,7 @@ class pdf_sponge extends ModelePDFFactures $this->cols['totalincltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')), + 'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'), 'title' => array( 'textkey' => 'TotalTTCShort' ), diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 9819d3e7c1e..1296c735070 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -2050,7 +2050,7 @@ class pdf_cyan extends ModelePDFPropales $this->cols['totalincltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => !(!getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')), + 'status' => getDolGlobalBool('PDF_PROPAL_SHOW_PRICE_INCL_TAX'), 'title' => array( 'textkey' => 'TotalTTCShort' ), diff --git a/htdocs/paypal/lib/paypalfunctions.lib.php b/htdocs/paypal/lib/paypalfunctions.lib.php index 36130b3cc67..b3a714489a2 100644 --- a/htdocs/paypal/lib/paypalfunctions.lib.php +++ b/htdocs/paypal/lib/paypalfunctions.lib.php @@ -79,4 +79,4 @@ $PROXY_HOST = getDolGlobalString('MAIN_PROXY_HOST'); $PROXY_PORT = getDolGlobalString('MAIN_PROXY_PORT'); $PROXY_USER = getDolGlobalString('MAIN_PROXY_USER'); $PROXY_PASS = getDolGlobalString('MAIN_PROXY_PASS'); -$USE_PROXY = !(!getDolGlobalString('MAIN_PROXY_USE')); +$USE_PROXY = getDolGlobalBool('MAIN_PROXY_USE'); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 68a6518c7d3..97054dcf2e7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3778,22 +3778,22 @@ class Societe extends CommonObject switch ($idprof) { case 1: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF1_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF1_UNIQUE'); break; case 2: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF2_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF2_UNIQUE'); break; case 3: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF3_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF3_UNIQUE'); break; case 4: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF4_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF4_UNIQUE'); break; case 5: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF5_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF5_UNIQUE'); break; case 6: - $ret = !(!getDolGlobalString('SOCIETE_IDPROF6_UNIQUE')); + $ret = getDolGlobalBool('SOCIETE_IDPROF6_UNIQUE'); break; default: $ret = false; From 32839b138bc0cca86ee8da60bbedac7acbbf4eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 13 Aug 2024 23:16:09 +0200 Subject: [PATCH 06/11] fix phpstan level 5 (#30565) * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phpstan level 5 * fix phan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan fix phpstan fix phpstan fix phpstan * increase level for apstat --- dev/tools/apstats.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- .../core/class/socialnetworkmanager.class.php | 3 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- .../task/doc/doc_generic_task_odt.modules.php | 155 ++++++++++-------- htdocs/imports/import.php | 20 +-- .../Documentation_full_en.example.asciidoc | 10 +- htdocs/public/webportal/tpl/menu.tpl.php | 19 ++- phpstan.neon.dist | 13 +- 11 files changed, 140 insertions(+), 90 deletions(-) diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 6f71492b32d..e33526e270b 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -98,7 +98,7 @@ while ($i < $argc) { } // PHPSTAN setup -$PHPSTANLEVEL = 4; +$PHPSTANLEVEL = 6; // PHAN setup. Configuration is required, otherwise phan is disabled. $PHAN_CONFIG = "{$path}phan/config_extended.php"; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f4630cc04b4..3a7b1d18a51 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2707,7 +2707,7 @@ class ActionComm extends CommonObject $errormesg = ''; // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $this); complete_substitutions_array($substitutionarray, $langs, $this); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3859944b65f..da36cdcaafa 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5746,7 +5746,7 @@ class Facture extends CommonInvoice $errormesg = ''; // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, '', $tmpinvoice); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $tmpinvoice); complete_substitutions_array($substitutionarray, $outputlangs, $tmpinvoice); diff --git a/htdocs/core/class/socialnetworkmanager.class.php b/htdocs/core/class/socialnetworkmanager.class.php index 5957a34526e..fbac124cb52 100644 --- a/htdocs/core/class/socialnetworkmanager.class.php +++ b/htdocs/core/class/socialnetworkmanager.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,7 +52,7 @@ class SocialNetworkManager /** * @var int */ - private $lastFetchDate; + private $lastFetchDate; // @phpstan-ignore-line /** * Constructor diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 1649b5e3682..5c627f94655 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -41,7 +41,7 @@ * @param int $pid Product id * @param int $socid Third party id * @param string $action Action string - * @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend + * @param array|int $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend * @param string|array $actioncode Preselected value(s) of actioncode for filter on event type * @param int $usergroupid Id of group to filter on users * @param string $excludetype A type to exclude ('systemauto', 'system', '') diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e1c67c5b01f..a3f6a341221 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -744,7 +744,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"] ?? ''); $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"] ?? '')); - if (is_null($mainmenu)) { + if (empty($mainmenu)) { $mainmenu = 'home'; } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index b330aaac9b2..517a0dc3067 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -531,8 +531,8 @@ class doc_generic_task_odt extends ModelePDFTask // Make substitution $substitutionarray = array( - '__FROM_NAME__' => $this->emetteur->name, - '__FROM_EMAIL__' => $this->emetteur->email, + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook @@ -547,10 +547,10 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler = new Odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->project->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + 'PATH_TO_TMP' => $conf->project->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { @@ -607,8 +607,6 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } } @@ -621,9 +619,16 @@ class doc_generic_task_odt extends ModelePDFTask $contact_arrray = array_merge($contact_arrray, $contact_temp); } } - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { + // Check for segment + $foundtagforlines = 1; + try { $listlinestaskres = $odfHandler->setSegment('tasksressources'); - + } catch (OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines && (is_array($contact_arrray) && count($contact_arrray) > 0)) { foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); @@ -644,8 +649,6 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -655,6 +658,16 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler->mergeSegment($listlinestaskres); } + // Check for segment + $foundtagforlines = 1; + try { + $listlinestasktime = $odfHandler->setSegment('taskstimes'); + } catch (OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + // Time resources $sql = "SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note"; $sql .= ", u.lastname, u.firstname"; @@ -666,17 +679,17 @@ class doc_generic_task_odt extends ModelePDFTask $sql .= " ORDER BY t.element_date DESC"; $resql = $this->db->query($sql); - if ($resql) { + if ($foundtagforlines && $resql) { $num = $this->db->num_rows($resql); $i = 0; $tasks = array(); - $listlinestasktime = $odfHandler->setSegment('taskstimes'); + while ($i < $num) { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); - // TODO Use a cache to aoid fetch for same user + // TODO Use a cache to avoid fetch for same user $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { $row['fullcivname'] = ''; @@ -687,8 +700,6 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -703,29 +714,35 @@ class doc_generic_task_odt extends ModelePDFTask // Replace tags of project files - $listtasksfiles = $odfHandler->setSegment('tasksfiles'); - - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); - - - foreach ($filearray as $filedetail) { - $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); - //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); - foreach ($tmparray as $key => $val) { - try { - $listtasksfiles->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } - } - $listtasksfiles->merge(); + // Check for segment + $foundtagforlines = 1; + try { + $listtasksfiles = $odfHandler->setSegment('tasksfiles'); + } catch (OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); } - //$listlines->merge(); + if ($foundtagforlines) { + $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); - $odfHandler->mergeSegment($listtasksfiles); + foreach ($filearray as $filedetail) { + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); + //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); + foreach ($tmparray as $key => $val) { + try { + $listtasksfiles->setVars($key, $val, true, 'UTF-8'); + } catch (SegmentException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listtasksfiles->merge(); + } + //$listlines->merge(); + + $odfHandler->mergeSegment($listtasksfiles); + } } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); @@ -733,35 +750,40 @@ class doc_generic_task_odt extends ModelePDFTask } - // Replace tags of project files + // Check for segment + $foundtagforlines = 1; try { $listlines = $odfHandler->setSegment('projectfiles'); + } catch (OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) { + try { + $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref); - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + foreach ($filearray as $filedetail) { + //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - - foreach ($filearray as $filedetail) { - //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); - $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - - foreach ($tmparray as $key => $val) { - try { - $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + foreach ($tmparray as $key => $val) { + try { + $listlines->setVars($key, $val, true, 'UTF-8'); + } catch (SegmentException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } } + $listlines->merge(); } - $listlines->merge(); + $odfHandler->mergeSegment($listlines); + } catch (OdfException $e) { + $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; } - $odfHandler->mergeSegment($listlines); - } catch (OdfException $e) { - $this->error = $e->getMessage(); - dol_syslog($this->error, LOG_WARNING); - return -1; } // Replace tags of lines for contacts @@ -773,10 +795,17 @@ class doc_generic_task_odt extends ModelePDFTask $contact_arrray = array_merge($contact_arrray, $contact_temp); } } - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { + // Check for segment + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('projectcontacts'); + } catch (OdfExceptionSegmentNotFound $e) { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines && (is_array($contact_arrray) && count($contact_arrray) > 0)) { try { - $listlines = $odfHandler->setSegment('projectcontacts'); - foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); @@ -797,8 +826,6 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index ebdb27c1089..ca26244439d 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -820,6 +820,7 @@ if ($step == 4 && $datatoimport) { $fieldssource[$i]['example1'] = $langs->trans('Empty'); $i++; } + $fieldssource[$i]['imported'] = 0; } $obj->import_close_file(); } @@ -1085,20 +1086,22 @@ if ($step == 4 && $datatoimport) { $optionsall = array(); foreach ($fieldstarget as $code => $line) { - //var_dump($line); - $tmparray = explode('|', $line["label"]); // If label of field is several translation keys separated with | $labeltoshow = ''; foreach ($tmparray as $tmpkey => $tmpval) { $labeltoshow .= ($labeltoshow ? ' '.$langs->trans('or').' ' : '').$langs->transnoentities($tmpval); } - $optionsall[$code] = array('labelkey' => $line['label'], 'labelkeyarray' => $tmparray, 'label' => $labeltoshow, 'required' => (empty($line["required"]) ? 0 : 1), 'position' => !empty($line['position']) ? $line['position'] : 0); // TODO Get type from a new array into module descriptor. - //$picto = 'email'; + // $picto = 'email'; $picto = ''; - if ($picto) { - $optionsall[$code]['picto'] = $picto; - } + $optionsall[$code] = array( + 'labelkey' => $line['label'], + 'labelkeyarray' => $tmparray, + 'label' => $labeltoshow, + 'required' => (empty($line["required"]) ? 0 : 1), + 'position' => (!empty($line['position']) ? $line['position'] : 0), + 'picto' => $picto, + ); } // $optionsall is an array of all possible target fields. key=>array('label'=>..., 'xxx') @@ -1137,9 +1140,6 @@ if ($step == 4 && $datatoimport) { print '=> '; - //var_dump($_SESSION['dol_array_match_file_to_database_select']); - //var_dump($_SESSION['dol_array_match_file_to_database']); - $selectforline = ''; $selectforline .= '
    '; - print $form->textwithpicto($langs->trans("URLOfOAuthServiceEndpoints"), $langs->trans("URLOfOAuthServiceEndpointsExample")); + $tooltiphelp = $langs->trans("Example").'
    https://mastodon.example.com
    https://mastodon.social'; + print $form->textwithpicto($langs->trans("URLOfOAuthServiceEndpoints"), $tooltiphelp); print '
    '; print ''; - $s = $modCodeMember->getToolTip($langs, null, -1); + $s = $modCodeMember->getToolTip($langs, null); print $form->textwithpicto('', $s, 1); print '