diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index a12f0d94454..ccbaaf9a33f 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,24 +9,24 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 2000+ occurrences + // PhanTypeMismatchArgument : 1900+ occurrences // PhanUndeclaredProperty : 520+ occurrences - // PhanTypeMismatchArgumentNullable : 400+ occurrences - // PhanUndeclaredGlobalVariable : 180+ occurrences + // PhanTypeMismatchArgumentNullable : 380+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences + // PhanUndeclaredGlobalVariable : 170+ occurrences // PhanTypeMismatchProperty : 130+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 110+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 100+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 100+ occurrences // PhanRedefineFunction : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences - // PhanPluginUndeclaredVariableIsset : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences + // PhanPluginUndeclaredVariableIsset : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences - // PhanTypeComparisonFromArray : 9 occurrences + // PhanTypeComparisonFromArray : 8 occurrences // PhanPluginSuspiciousParamPosition : 7 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanPluginUnknownObjectMethodCall : 6 occurrences @@ -352,7 +352,6 @@ return [ 'htdocs/core/class/html.formfile.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/class/html.formmail.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/core/class/html.formother.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/core/class/html.formprojet.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/class/html.formsetup.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/core/class/link.class.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/core/class/menubase.class.php' => ['PhanTypeMismatchArgument'], @@ -417,7 +416,6 @@ return [ 'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanTypeMismatchProperty'], - 'htdocs/core/modules/mailings/eventorganization.modules.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/member/doc/pdf_standard_member.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/member/modules_cards.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/modAdherent.class.php' => ['PhanTypeMismatchArgument'], @@ -612,25 +610,9 @@ return [ 'htdocs/product/stock/stocktransfer/stocktransfer_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/product/stock/tpl/stockcorrection.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/tpl/stocktransfer.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/projet/activity/perday.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/activity/permonth.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/activity/perweek.php' => ['PhanTypeMismatchArgument'], 'htdocs/projet/admin/project.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/projet/admin/website.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/ajax/projects.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/projet/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/projet/class/api_projects.class.php' => ['PhanTypeMismatchArgument'], + 'htdocs/projet/card.php' => ['PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], 'htdocs/projet/class/api_tasks.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], - 'htdocs/projet/class/project.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/class/projectstats.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/class/task.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/class/taskstats.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/projet/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/projet/element.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], - 'htdocs/projet/ganttchart.inc.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/projet/ganttview.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/projet/graph_opportunities.inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable'], - 'htdocs/projet/list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/projet/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'], 'htdocs/projet/tasks.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/tasks/comment.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -778,7 +760,7 @@ return [ 'htdocs/ticket/class/ticketstats.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgument'], 'htdocs/ticket/document.php' => ['PhanTypeMismatchArgument'], - 'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], + 'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/ticket/list.php' => ['PhanTypeMismatchArgument'], 'htdocs/ticket/messaging.php' => ['PhanTypeMismatchArgument'], 'htdocs/ticket/stats/index.php' => ['PhanTypeMismatchArgument'], diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6af0cf4aca6..9ebc4408438 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1682,7 +1682,7 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx maxwidth500'); + print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx maxwidth500'); print ' '; print ''; @@ -1708,14 +1708,14 @@ if ($action == 'create') { // Task print ''.$langs->trans("Task").''; print img_picto('', 'projecttask', 'class="paddingrightonly"'); - $projectsListId = false; + $projectsListId = ''; if (!empty($projectid)) { $projectsListId = $projectid; } $tid = GETPOSTISSET("projecttaskid") ? GETPOSTINT("projecttaskid") : (GETPOSTISSET("taskid") ? GETPOSTINT("taskid") : ''); - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500 widthcentpercentminusxx', $projectsListId); + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500 widthcentpercentminusxx', (string) $projectsListId); print ''; } @@ -2144,8 +2144,8 @@ if ($id > 0) { 'type' => 'user', //'transparency'=>$object->userassigned[$user->id]['transparency'], 'transparency' => $object->transparency, // Force transparency on ownerfrom event - 'answer_status' => (isset($object->userassigned[$object->userownerid]['answer_status']) ? $object->userassigned[$object->userownerid]['answer_status']: null), - 'mandatory' => (isset($object->userassigned[$object->userownerid]['mandatory']) ? $object->userassigned[$object->userownerid]['mandatory']:null) + 'answer_status' => (isset($object->userassigned[$object->userownerid]['answer_status']) ? $object->userassigned[$object->userownerid]['answer_status'] : null), + 'mandatory' => (isset($object->userassigned[$object->userownerid]['mandatory']) ? $object->userassigned[$object->userownerid]['mandatory'] : null) ); } if (!empty($object->userassigned)) { // Now concat assigned users @@ -2255,7 +2255,7 @@ if ($id > 0) { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx'); + $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), (string) $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx'); if ($numprojet == 0) { print '   '; } @@ -2294,7 +2294,7 @@ if ($id > 0) { })'; print ''."\n"; - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, '', 1, 0, 0, 'maxwidth500', (string) $object->fk_project); print ''; print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7e0da30d5c8..f815cd849ed 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -17,7 +17,7 @@ * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Lenin Rivas * Copyright (C) 2023 William Mead - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -2164,7 +2164,7 @@ if ($action == 'create') { $sday = date("d", $tmpdte); print $form->selectDate($syear."-".$smonth."-".$sday, 'date_livraison', 0, 0, 0, "addprop"); } else { - $tmp_date_delivery = GETPOST('date_delivery') ? : -1; + $tmp_date_delivery = GETPOST('date_delivery') ?: -1; print $form->selectDate($tmp_date_delivery, 'date_livraison', 0, 0, 0, "addprop", 1, 1); } print ''; @@ -2174,7 +2174,7 @@ if ($action == 'create') { $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' id).'">'; print ''; print ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5f3e292e106..7457acd4e36 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -19,7 +19,7 @@ * Copyright (C) 2022 OpenDSI * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 William Mead - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -3771,7 +3771,7 @@ class Propal extends CommonObject if (is_null($this->project) || (is_object($this->project) && $this->project->isEmpty())) { $res = $this->fetchProject(); if ($res > 0 && $this->project instanceof Project) { - $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); + $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, '1'); } } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f448bf25154..5fb70cfcc54 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3728,7 +3728,7 @@ class Commande extends CommonOrder if (is_null($this->project) || (is_object($this->project) && $this->project->isEmpty())) { $res = $this->fetchProject(); if ($res > 0 && $this->project instanceof Project) { - $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); + $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, '1'); } } } diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 5ccd1ffa2d8..94bd781bcdd 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -5,7 +5,7 @@ * Copyright (C) 2020 Maxime DEMAREST * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2022-2025 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -673,7 +673,7 @@ if (isModEnabled('project')) { $formproject = new FormProjets($db); $langs->load('projects'); print ''.$langs->trans('Project').":"; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, ''); + print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, ''); print ''; print '
'; } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index fe6102bbf61..5d985f68ce0 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -514,7 +514,7 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); + print $formproject->select_projects(-1, (string) $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); print ''; } @@ -626,7 +626,7 @@ if ($id) { $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(-1, $object->fk_project, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + $morehtmlref .= $formproject->select_projects(-1, (string) $object->fk_project, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); $morehtmlref .= ''; $morehtmlref .= '
'; } else { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 932f72d8864..e374e52450e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -17,7 +17,7 @@ * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -892,27 +892,27 @@ if (empty($reshook)) { $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); if (!isset($amount_ht[$keyforvatrate])) { - $amount_ht[$keyforvatrate]=0; + $amount_ht[$keyforvatrate] = 0; } $amount_ht[$keyforvatrate] += $line->total_ht; if (!isset($amount_tva[$keyforvatrate])) { - $amount_tva[$keyforvatrate]=0; + $amount_tva[$keyforvatrate] = 0; } $amount_tva[$keyforvatrate] += $line->total_tva; if (!isset($amount_ttc[$keyforvatrate])) { - $amount_ttc[$keyforvatrate]=0; + $amount_ttc[$keyforvatrate] = 0; } $amount_ttc[$keyforvatrate] += $line->total_ttc; if (!isset($multicurrency_amount_ht[$keyforvatrate])) { - $multicurrency_amount_ht[$keyforvatrate]=0; + $multicurrency_amount_ht[$keyforvatrate] = 0; } $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht; if (!isset($multicurrency_amount_tva[$keyforvatrate])) { - $multicurrency_amount_tva[$keyforvatrate]=0; + $multicurrency_amount_tva[$keyforvatrate] = 0; } $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva; if (!isset($multicurrency_amount_ttc[$keyforvatrate])) { - $multicurrency_amount_ttc[$keyforvatrate]=0; + $multicurrency_amount_ttc[$keyforvatrate] = 0; } $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc; $i++; @@ -4070,7 +4070,7 @@ if ($action == 'create') { $langs->load('projects'); print ''.$langs->trans('Project').''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; print ''; } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 4bda1228b91..9c37b76e37b 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2016-2024 Frédéric France * Copyright (C) 2017-2024 Alexandre Spangaro * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -431,7 +431,7 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); + print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(-1, (string) $fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); print ''; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f1ea95f0024..e2e5496e0c8 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2068,7 +2068,7 @@ class Contrat extends CommonObject if (is_null($this->project) || (is_object($this->project) && $this->project->isEmpty())) { $res = $this->fetchProject(); if ($res > 0 && $this->project instanceof Project) { - $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); + $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, '1'); } } } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f817c7b98bb..2534c04a58c 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * * This program is free software; you can redistribute it and/or modify @@ -113,7 +113,7 @@ class FormProjets extends Form } $out .= ''; - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array()); + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, getDolGlobalInt('PROJECT_USE_SEARCH_TO_SELECT'), 0, array()); } else { $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss, $morefilter); } @@ -153,7 +153,6 @@ class FormProjets extends Form * @param string $morecss More CSS * @param string $morefilter More filters (Must be a sql sanitized string) * @return int|string|array HTML string or array of option or <0 if KO - */ public function select_projects_list($socid = -1, $selected = 0, $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500', $morefilter = '') { @@ -333,16 +332,16 @@ class FormProjets extends Form * @param int $selected Id task preselected * @param string $htmlname Name of HTML select * @param int $maxlength Maximum length of label - * @param int $option_only Return only html options lines without the select tag + * @param int<0,1> $option_only Return only html options lines without the select tag * @param string $show_empty Add an empty line ('1' or string to show for empty line) - * @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable) - * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $disabled Disabled + * @param int<0,2> $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable) + * @param int<0,1> $forcefocus Force focus on field (works with javascript only) + * @param int<0,1> $disabled Disabled * @param string $morecss More css added to the select component * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. - * @param string $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more - * @param User $usertofilter User object to use for filtering - * @param int $nooutput 1=Return string, do not send to output + * @param 'all'|'progress'|'' $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more + * @param ?User $usertofilter User object to use for filtering + * @param int<0,1> $nooutput 1=Return string, do not send to output * * @return int|string Nbr of tasks if OK, <0 if KO. If nooutput=1: Return a HTML select string. */ @@ -694,17 +693,17 @@ class FormProjets extends Form * Build a HTML select list of element of same thirdparty to suggest to link them to project * * @param string $htmlname HTML name - * @param string $preselected Preselected (int or 'all' or 'none') - * @param int $showempty Add an empty line - * @param int $useshortlabel Use short label - * @param int $showallnone Add choice "All" and "None" - * @param int $showpercent Show default probability for status - * @param string $morecss Add more css - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $addcombojs 1=Add a js combo + * @param int|'all'|'none'|'notopenedopp' $preselected Preselected (int or 'all' or 'none') + * @param int<0,1> $showempty Add an empty line + * @param int<0,1> $useshortlabel Use short label + * @param int<0,1> $showallnone Add choice "All" and "None" + * @param int<0,1> $showpercent Show default probability for status + * @param string $morecss Add more css + * @param int<0,1> $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int<0,1> $addcombojs 1=Add a js combo * @return int<-1,-1>|string The HTML select list of element or '' if nothing or -1 if KO */ - public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0) + public function selectOpportunityStatus($htmlname, $preselected = -1, $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0) { global $conf, $langs, $user; @@ -780,12 +779,12 @@ class FormProjets extends Form /** * Return combo list of different statuses of orders * - * @param string $selected Preselected value - * @param int $short Use short labels - * @param string $hmlname Name of HTML select element + * @param string $selected Preselected value + * @param int<0,1> $short Use short labels + * @param string $htmlname Name of HTML select element * @return void */ - public function selectProjectsStatus($selected = '', $short = 0, $hmlname = 'order_status') + public function selectProjectsStatus($selected = '', $short = 0, $htmlname = 'order_status') { $options = array(); @@ -813,7 +812,7 @@ class FormProjets extends Form $selectedarray = explode(',', $selected); } - print Form::multiselectarray($hmlname, $options, $selectedarray, 0, 0, 'minwidth100'); + print Form::multiselectarray($htmlname, $options, $selectedarray, 0, 0, 'minwidth100'); } /** @@ -947,11 +946,11 @@ class FormProjets extends Form * * @param string $page Page * @param string $selected Id preselected - * @param int $percent_value percentage of the opportunity + * @param ''|int $percent_value percentage of the opportunity * @param string $htmlname_status name of HTML element for status select * @param string $htmlname_percent name of HTML element for percent input * @param string $filter optional filters criteras - * @param int $nooutput No print output. Return it only. + * @param int<0,1> $nooutput No print output. Return it only. * @return void|string */ public function formOpportunityStatus($page, $selected = '', $percent_value = 0, $htmlname_status = 'none', $htmlname_percent = 'none', $filter = '', $nooutput = 0) diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 6143ed6ac5b..6945ef93e8c 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2022-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -138,7 +138,7 @@ function print_actions_filter( print '
'; print img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth inline-block"'); - print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); + print $formproject->select_projects($socid ? $socid : -1, (string) $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); print '
'; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 4c5e77fb0a3..f7b1f3e7203 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -5,7 +5,7 @@ * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2022 Charlene Benke * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Vincent de Grandpré * * This program is free software; you can redistribute it and/or modify @@ -587,7 +587,7 @@ function project_admin_prepare_head() * @param int $level Level (start to 0, then increased/decrease by recursive call), or -1 to show all level in order of $lines without the recursive groupment feature. * @param string $var Not used * @param int $showproject Show project columns - * @param int $taskrole Array of roles of user for each tasks + * @param array $taskrole Array of roles of user for each tasks * @param string $projectsListId List of id of projects allowed to user (string separated with comma) * @param int $addordertick Add a tick to move task * @param int $projectidfortotallink 0 or Id of project to use on total line (link to see all time consumed for project) @@ -1182,8 +1182,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t * @param ?User $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) - * @param string $projectsrole Array of roles user has on project - * @param string $tasksrole Array of roles user has on task + * @param array $projectsrole Array of roles user has on project + * @param array $tasksrole Array of roles user has on task * @param string $mine Show only task lines I am assigned to * @param int<0,1> $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @param int $preselectedday Preselected day @@ -1412,8 +1412,8 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec * @param ?User $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) - * @param string $projectsrole Array of roles user has on project - * @param string $tasksrole Array of roles user has on task + * @param array $projectsrole Array of roles user has on project + * @param array $tasksrole Array of roles user has on task * @param int<0,1> $mine Show only task lines I am assigned to * @param int<0,2> $restricteditformytask 0=No restriction, 1=Enable add time only if task is assigned to me, 2=Enable add time only if tasks is assigned to me and hide others * @param int $preselectedday Preselected day @@ -1816,8 +1816,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) - * @param string $projectsrole Array of roles user has on project - * @param string $tasksrole Array of roles user has on task + * @param array $projectsrole Array of roles user has on project + * @param array $tasksrole Array of roles user has on task * @param int<0,1> $mine Show only task lines I am assigned to * @param int<0,2> $restricteditformytask 0=No restriction, 1=Enable add time only if task is assigned to me, 2=Enable add time only if tasks is assigned to me and hide others * @param array,afternoon:int<0,1>}> $isavailable Array with data that say if user is available for several days for morning and afternoon @@ -2222,13 +2222,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) - * @param string $projectsrole Array of roles user has on project - * @param string $tasksrole Array of roles user has on task + * @param array $projectsrole Array of roles user has on project + * @param array $tasksrole Array of roles user has on task * @param int<0,1> $mine Show only task lines I am assigned to * @param int<0,1> $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @param array,afternoon:int<0,1>}> $isavailable Array with data that say if user is available for several days for morning and afternoon * @param int $oldprojectforbreak Old project id of last project break - * @param string[] $TWeek Array of week numbers ('02', ... + * @param string[] $TWeek Array of week numbers ('02', ... * @param array> $arrayfields Array of additional column * @param Extrafields $extrafields Object extrafields * @return array Array with time spent for $fuser for each day of week on tasks in $lines and subtasks (index is string, month is '01', ...) @@ -2525,7 +2525,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & * @param int $inc Counter that count number of lines legitimate to show (for return) * @param int $parent Id of parent task to start * @param Task[] $lines Array of all tasks - * @param string $taskrole Array of task filtered on a particular user + * @param array $taskrole Array of task filtered on a particular user * @return int 1 if there is */ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 92afd4da700..b7a37c346d6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -1113,10 +1113,10 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl } $checkonentitydone = 1; } - if (in_array($feature, $checktask) && $objectid > 0) { + if (in_array($feature, $checktask) && (int) $objectid > 0) { if (isModEnabled('project') && !$user->hasRight('projet', 'all', 'lire')) { $task = new Task($db); - $task->fetch($objectid); + $task->fetch((int) $objectid); $projectid = $task->fk_project; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 528072d76e9..79ee29df177 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2018-2018 Andre Schild * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside @@ -204,7 +204,7 @@ class mailing_eventorganization extends MailingTargets $formproject = new FormProjets($this->db); $s = img_picto($langs->trans("OrganizedEvent"), 'project', 'class="pictofixedwidth"'); - $s .= $formproject->select_projects(-1, 0, "filter_eventorganization", 0, 0, $langs->trans("OrganizedEvent"), 1, 0, 0, 0, '', 1, 0, '', '', 'usage_organize_event=1'); + $s .= $formproject->select_projects(-1, '0', "filter_eventorganization", 0, 0, $langs->trans("OrganizedEvent"), 1, 0, 0, 0, '', 1, 0, '', '', 'usage_organize_event=1'); return $s; } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 63f17a6a644..94878e5d2ae 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -183,7 +183,6 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Task $task Task Object * @param Translate $outputlangs Lang object to use for output * @return array{task_ref:string,task_fk_project:string,task_projectref:string,task_projectlabel:string,task_label:string,task_description:string,task_fk_parent:string,task_duration:string,task_duration_hour:string,task_planned_workload:string,task_planned_workload_hour:string,task_progress:string,task_public:string,task_date_start:string,task_date_end:string,task_note_private:string,task_note_public:string} Return a substitution array + extrafields - */ public function get_substitutionarray_tasks(Task $task, $outputlangs) { @@ -1053,7 +1052,7 @@ class doc_generic_project_odt extends ModelePDFProjects $ref_array['type'] = (string) $langs->trans($classname); $element = new $classname($this->db); - $element->fetch($elementarray[$i]); + $element->fetch((int) $elementarray[$i]); $element->fetch_thirdparty(); //Ref object diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 3b5cf8daf32..0c0a6527da8 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -467,7 +467,7 @@ class pdf_beluga extends ModelePDFProjects //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, 0, 0, $projectField); - $num = count($elementarray); + $num = is_array($elementarray) ? count($elementarray) : $elementarray; if ($num >= 0) { $nexY = $pdf->GetY() + 5; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 082111cd7f0..2ddcc41a1c0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -887,7 +887,7 @@ class Holiday extends CommonObject * * @param User $user User that approve * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer <0 if KO, >0 if OK */ public function approve($user = null, $notrigger = 0) { @@ -1151,9 +1151,9 @@ class Holiday extends CommonObject /** * Delete object in database * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that delete + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ public function delete($user, $notrigger = 0) { @@ -1202,12 +1202,12 @@ class Holiday extends CommonObject * This function can be used to avoid to have 2 leave requests on same period for example. * Warning: It consumes a lot of memory because it load in ->holiday all holiday of a dedicated user at each call. * - * @param int $fk_user Id user - * @param integer $dateStart Start date of period to check - * @param integer $dateEnd End date of period to check - * @param int $halfday Tag to define how start and end the period to check: + * @param int $fk_user Id user + * @param int $dateStart Start date of period to check + * @param int $dateEnd End date of period to check + * @param int<-1,2> $halfday Tag to define how start and end the period to check: * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). + * @return bool False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). * @see verifDateHolidayForTimestamp() */ public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) @@ -1287,9 +1287,9 @@ class Holiday extends CommonObject * Check that a user is not on holiday for a particular timestamp. Can check approved leave requests and not into public holidays of company. * * @param int $fk_user Id user - * @param integer $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) + * @param int $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) * @param string $status Filter on holiday status. '-1' = no filter. - * @return array{morning_reason?:string,afternoon_reason?:string} array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. + * @return array{morning:int<0,1>,afternoon:int<0,1>,morning_reason?:string,afternoon_reason?:string} array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP() */ public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') @@ -1349,7 +1349,7 @@ class Holiday extends CommonObject dol_print_error($this->db); } - $result = array('morning' => $isavailablemorning, 'afternoon' => $isavailableafternoon); + $result = array('morning' => (int) $isavailablemorning, 'afternoon' => (int) $isavailableafternoon); if (!$isavailablemorning) { $result['morning_reason'] = 'leave_request'; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 3a784e4db5e..e5958376156 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 François Legastelois * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,9 +90,9 @@ $search_declared_progress = GETPOST('search_declared_progress', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$monthofday = GETPOST('addtimemonth'); -$dayofday = GETPOST('addtimeday'); -$yearofday = GETPOST('addtimeyear'); +$monthofday = GETPOSTINT('addtimemonth'); +$dayofday = GETPOSTINT('addtimeday'); +$yearofday = GETPOSTINT('addtimeyear'); //var_dump(GETPOST('remonth')); //var_dump(GETPOST('button_search_x')); @@ -134,9 +134,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Definition of fields for list $arrayfields = array(); -$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => 1, 'enabled' => 1, 'position' => 0); -$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => 1, 'enabled' => 1, 'position' => 0); -$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, 'enabled' => 1, 'position' => 15); +$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => '1', 'enabled' => '1', 'position' => 0); +$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => '1', 'enabled' => '1', 'position' => 0); +$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => '1', 'enabled' => '1', 'position' => 15); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -150,7 +150,7 @@ $arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { - $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => (($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => (abs((int) $extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => (($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? '0' : '1'), 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => (string) (int) (abs((int) $extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } } @@ -407,14 +407,14 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, (string) $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. $tasksarraywithoutfilter = array(); if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks - $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', (string) $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? $project->id : 0), 0, $onlyopenedproject); -$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? (string) $project->id : '0'), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? (string) $project->id : '0'), 0, $onlyopenedproject); llxHeader('', $title, '', '', 0, 0, array('/core/js/timesheet.js'), '', '', 'mod-project project-activity page-activity_perday'); @@ -521,7 +521,7 @@ if (!$user->hasRight('user', 'user', 'lire')) { $includeonly = array($user->id); } $selecteduser = $search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id; -$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, '', '0', 0, 0, '', 0, '', 'maxwidth200'); if ($form->num > 1 || empty($conf->dol_optimize_smallscreen)) { $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -656,7 +656,7 @@ if (getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS')) { } $statusofholidaytocheck = Holiday::STATUS_APPROVED; -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, (string) $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day $test = num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code); diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 502e85e1cba..dbb30f61c91 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 François Legastelois - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2025 Alexandre Spangaro * @@ -137,9 +137,9 @@ $arrayfields = array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => 1, 'enabled' => 1, 'position' => 5); -$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => 1, 'enabled' => 1, 'position' => 10); -$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, 'enabled' => 1, 'position' => 15); +$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => '1', 'enabled' => '1', 'position' => 5); +$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => '1', 'enabled' => '1', 'position' => 10); +$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => '1', 'enabled' => '1', 'position' => 15); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -150,7 +150,7 @@ $arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, if (!empty($extrafields->attributes['projet_task']['label']) && is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if (!empty($extrafields->attributes['projet_task']['list'][$key])) { - $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes['projet_task']['label'][$key], 'checked' => (($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position' => $extrafields->attributes['projet_task']['pos'][$key], 'enabled' => (abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); + $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes['projet_task']['label'][$key], 'checked' => (($extrafields->attributes['projet_task']['list'][$key] < 0) ? '0' : '1'), 'position' => $extrafields->attributes['projet_task']['pos'][$key], 'enabled' => (string) (int) (abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); } } } @@ -424,12 +424,12 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $tasksarraywithoutfilter = array(); // Default -$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, (string) $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks - $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', (string) $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? $project->id : 0), 0, $onlyopenedproject); -$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? (string) $project->id : '0'), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? (string) $project->id : '0'), 0, $onlyopenedproject); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -536,7 +536,7 @@ if (!$user->hasRight('user', 'user', 'lire')) { $includeonly = array($user->id); } $selecteduser = $search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id; -$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, array(), 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, array(), '0', 0, 0, '', 0, '', 'maxwidth200'); if ($form->num > 1 || empty($conf->dol_optimize_smallscreen)) { $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -774,8 +774,8 @@ if (count($tasksarray) > 0) { if (!empty($THolidays[$weekNb]["ids"]) && in_array($h->rowid, $THolidays[$weekNb]["ids"])) { continue; } - $startweekholiday =(int) (($h["date_debut"] <= $weekstart) ? $weekstart : $h["date_debut"] ); - $endweekholiday =(int) (($h["date_fin"] >= $weekend) ? $weekend : $h["date_fin"]); + $startweekholiday = (int) (($h["date_debut"] <= $weekstart) ? $weekstart : $h["date_debut"]); + $endweekholiday = (int) (($h["date_fin"] >= $weekend) ? $weekend : $h["date_fin"]); $halfdays = (int) $h["halfday"]; $nbdays = num_open_day($startweekholiday, $endweekholiday, 0, 1, $halfdays); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index a7f799d74aa..a2a96bb2b01 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 François Legastelois * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -139,9 +139,9 @@ $arrayfields = array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => 1, 'enabled' => 1, 'position' => 5); -$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => 1, 'enabled' => 1, 'position' => 10); -$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, 'enabled' => 1, 'position' => 15); +$arrayfields['t.planned_workload'] = array('label' => 'PlannedWorkload', 'checked' => '1', 'enabled' => '1', 'position' => 5); +$arrayfields['t.progress'] = array('label' => 'ProgressDeclared', 'checked' => '1', 'enabled' => '1', 'position' => 10); +$arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => '1', 'enabled' => '1', 'position' => 15); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -152,7 +152,7 @@ $arrayfields['timeconsumed'] = array('label' => 'TimeConsumed', 'checked' => 1, if (!empty($extrafields->attributes['projet_task']['label']) && is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if (!empty($extrafields->attributes['projet_task']['list'][$key])) { - $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes['projet_task']['label'][$key], 'checked' => (($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position' => $extrafields->attributes['projet_task']['pos'][$key], 'enabled' => (abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); + $arrayfields["efpt.".$key] = array('label' => $extrafields->attributes['projet_task']['label'][$key], 'checked' => (($extrafields->attributes['projet_task']['list'][$key] < 0) ? '0' : '1'), 'position' => $extrafields->attributes['projet_task']['pos'][$key], 'enabled' => (string) (int) (abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); } } } @@ -422,13 +422,13 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, (string) $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. $tasksarraywithoutfilter = array(); if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks - $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(null, null, ($project->id ? $project->id : 0), $socid, 0, '', (string) $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? $project->id : 0), 0, $onlyopenedproject); -$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, null, ($project->id ? (string) $project->id : '0'), 0, (int) $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(null, $usertoprocess, ($project->id ? (string) $project->id : '0'), 0, (int) $onlyopenedproject); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -542,7 +542,7 @@ for ($idw = 0; $idw < 7; $idw++) { $statusofholidaytocheck = Holiday::STATUS_APPROVED; - $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); + $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, (string) $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); @@ -571,7 +571,7 @@ if (!$user->hasRight('user', 'user', 'lire')) { $includeonly = array($user->id); } $selecteduser = $search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id; -$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfiltertmp = $form->select_dolusers($selecteduser, 'search_usertoprocessid', 0, null, 0, $includeonly, '', '0', 0, 0, '', 0, '', 'maxwidth200'); if ($form->num > 1 || empty($conf->dol_optimize_smallscreen)) { $moreforfilter .= '
'; $moreforfilter .= '
'; diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 81ffe73f17d..8b2dc432e60 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -4,6 +4,7 @@ * Copyright (C) 2007-2020 Laurent Destailleur * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,7 +79,7 @@ if (empty($mode) || $mode != 'gettasks') { $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : ''); $formproject = new FormProjets($db); - $arrayresult = $formproject->select_projects_list($socid, '', '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); + $arrayresult = $formproject->select_projects_list($socid, 0, '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); $db->close(); @@ -93,7 +94,7 @@ if ($mode == 'gettasks') { top_httphead(); $formproject = new FormProjets($db); - $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOSTINT('projectid'), ''); + $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', (string) GETPOSTINT('projectid'), ''); $db->close(); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index dba5f48db1c..08625a71259 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2023 Charlene Benke * Copyright (C) 2023 Christian Foellmann - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro * @@ -313,7 +313,7 @@ if (empty($reshook)) { } $db->begin(); - $old_start_date = null; + $old_start_date = 0; if (!$error) { $object->oldcopy = clone $object; @@ -1095,7 +1095,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { print ''.$langs->trans("Parent").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - $formproject->select_projects(-1, $object->fk_project, 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', ''); + $formproject->select_projects(-1, (string) $object->fk_project, 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', ''); print ''; } @@ -1240,7 +1240,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { print ''.$langs->trans("OpportunityStatus").''; print ''; print '
'; - print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1); + print $formproject->selectOpportunityStatus('opp_status', (string) $object->opp_status, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1); // Opportunity probability print ' %'; @@ -1442,8 +1442,8 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { print ''; $html_name_status = ($action == 'edit_opp_status') ? 'opp_status' : 'none'; $html_name_percent = ($action == 'edit_opp_status') ? 'opp_percent' : 'none'; - $percent_value = (GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ? vatrate($object->opp_percent) : '')); - $formproject->formOpportunityStatus($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->opp_status, $percent_value, $html_name_status, $html_name_percent); + $percent_value = (GETPOSTISSET('opp_percent') ? GETPOSTINT('opp_percent') : (strcmp($object->opp_percent, '') ? vatrate($object->opp_percent) : '')); + $formproject->formOpportunityStatus($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->opp_status, $percent_value, $html_name_status, $html_name_percent); print ''; // Opportunity Amount @@ -1808,7 +1808,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { $genallowed = ($user->hasRight('projet', 'lire') && $userAccess > 0); $delallowed = ($user->hasRight('projet', 'creer') && $userWrite > 0); - print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object); + print $formfile->showdocuments('project', $filename, $filedir, $urlsource, (int) $genallowed, (int) $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object); print '
'; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 979745c3805..842522ff561 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; class Projects extends DolibarrApi { /** - * @var string[] $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'ref', @@ -39,12 +39,12 @@ class Projects extends DolibarrApi ); /** - * @var Project $project {@type Project} + * @var Project {@type Project} */ public $project; /** - * @var Task $task {@type Task} + * @var Task {@type Task} */ public $task; @@ -459,7 +459,7 @@ class Projects extends DolibarrApi $userp = new User($this->db); $userp->fetch($userid); } - $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, null, $id, 0); + $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, null, (string) $id, 0); $result = array(); foreach ($this->project->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index fa22c00d98b..fa328d51da8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -861,13 +861,13 @@ class Project extends CommonObject /** * Return list of elements for type, linked to a project * - * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... - * @param string $tablename name of table associated of the type - * @param string $datefieldname name of date field for filter - * @param int $date_start Start date - * @param int $date_end End date - * @param string $projectkey Equivalent key to fk_projet for actual type - * @return mixed Array list of object ids linked to project, < 0 or string if error + * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... + * @param string $tablename name of table associated of the type + * @param string $datefieldname name of date field for filter + * @param ?int $date_start Start date + * @param ?int $date_end End date + * @param string $projectkey Equivalent key to fk_projet for actual type + * @return array|int<-1,-1>|string Array list of object ids linked to project, < 0 or string if error */ public function get_element_list($type, $tablename, $datefieldname = '', $date_start = null, $date_end = null, $projectkey = 'fk_projet') { @@ -884,23 +884,23 @@ class Project extends CommonObject $ids = $this->id; if ($type == 'agenda') { - $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity('agenda').")"; + $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project IN (".$this->db->sanitize((string) $ids).") AND entity IN (".getEntity('agenda').")"; } elseif ($type == 'expensereport') { - $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$this->db->sanitize($ids).")"; + $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$this->db->sanitize((string) $ids).")"; } elseif ($type == 'project_task') { - $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$this->db->sanitize($ids).")"; + $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$this->db->sanitize((string) $ids).")"; } elseif ($type == 'element_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet IN (".$this->db->sanitize($ids).")"; + $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet IN (".$this->db->sanitize((string) $ids).")"; } elseif ($type == 'stocktransfer_stocktransfer') { - $sql = "SELECT ms.rowid, ms.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."stocktransfer_stocktransfer as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1"; + $sql = "SELECT ms.rowid, ms.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."stocktransfer_stocktransfer as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize((string) $ids).") AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = "SELECT l.rowid, l.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$this->db->sanitize($ids).")"; + $sql = "SELECT l.rowid, l.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$this->db->sanitize((string) $ids).")"; } else { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize((string) $ids).") AND entity IN (".getEntity($type).")"; } if (isDolTms($date_start) && $type == 'loan') { - $sql .= " AND (dateend > '".$this->db->idate($date_start)."' OR dateend IS NULL)"; + $sql .= " AND (dateend > '".$this->db->idate((int) $date_start)."' OR dateend IS NULL)"; } elseif (isDolTms($date_start) && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table if (empty($datefieldname) && !empty($this->table_element_date)) { $datefieldname = $this->table_element_date; @@ -908,11 +908,11 @@ class Project extends CommonObject if (empty($datefieldname)) { return 'Error this object has no date field defined'; } - $sql .= " AND (".$datefieldname." >= '".$this->db->idate($date_start)."' OR ".$datefieldname." IS NULL)"; + $sql .= " AND (".$datefieldname." >= '".$this->db->idate((int) $date_start)."' OR ".$datefieldname." IS NULL)"; } if (isDolTms($date_end) && $type == 'loan') { - $sql .= " AND (datestart < '".$this->db->idate($date_end)."' OR datestart IS NULL)"; + $sql .= " AND (datestart < '".$this->db->idate((int) $date_end)."' OR datestart IS NULL)"; } elseif (isDolTms($date_end) && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table if (empty($datefieldname) && !empty($this->table_element_date)) { $datefieldname = $this->table_element_date; @@ -920,7 +920,7 @@ class Project extends CommonObject if (empty($datefieldname)) { return 'Error this object has no date field defined'; } - $sql .= " AND (".$datefieldname." <= '".$this->db->idate($date_end)."' OR ".$datefieldname." IS NULL)"; + $sql .= " AND (".$datefieldname." <= '".$this->db->idate((int) $date_end)."' OR ".$datefieldname." IS NULL)"; } $parameters = array( @@ -1411,18 +1411,18 @@ class Project extends CommonObject } /** - * Return clickable name (with picto eventually) + * Return clickable name (with optional picto) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option Variant where the link point to ('', 'nolink') - * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string - * @param string $moreinpopup Text to add into popup - * @param string $sep Separator between ref and label if option addlabel is set - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param string $morecss More css on a link - * @param string $save_pageforbacktolist Back to this page 'context:url' - * @return string String with URL + * @param int<0,2> $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option Variant where the link point to ('', 'nolink') + * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string + * @param string $moreinpopup Text to add into popup + * @param string $sep Separator between ref and label if option addlabel is set + * @param int<0,1> $notooltip 1=Disable tooltip + * @param int<-1,1> $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $morecss More css on a link + * @param string $save_pageforbacktolist Back to this page 'context:url' + * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1, $morecss = '', $save_pageforbacktolist = '') { @@ -1740,17 +1740,17 @@ class Project extends CommonObject /** * Load an object from its id and create a new one in database * - * @param User $user User making the clone - * @param int $fromid Id of object to clone - * @param bool $clone_contact Clone contact of project - * @param bool $clone_task Clone task of project - * @param bool $clone_project_file Clone file of project - * @param bool $clone_task_file Clone file of task (if task are copied) - * @param bool $clone_note Clone note of project - * @param bool $move_date Move task date on clone - * @param int $notrigger No trigger flag - * @param int $newthirdpartyid New thirdparty id - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @param bool|int<0,1> $clone_contact Clone contact of project + * @param bool|int<0,1> $clone_task Clone task of project + * @param bool|int<0,1> $clone_project_file Clone file of project + * @param bool|int<0,1> $clone_task_file Clone file of task (if task are copied) + * @param bool|int<0,1> $clone_note Clone note of project + * @param bool|int<0,1> $move_date Move task date on clone + * @param int<0,1> $notrigger No trigger flag + * @param int $newthirdpartyid New thirdparty id + * @return int New id of clone */ public function createFromClone(User $user, $fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) { diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 90eb6b41040..892171de15e 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -224,7 +224,7 @@ class ProjectStats extends Stats } if (!empty($this->status)) { - $sqlwhere[] = " t.fk_statut IN (".$this->db->sanitize($this->status).")"; + $sqlwhere[] = " t.fk_statut IN (".$this->db->sanitize((string) $this->status).")"; } if (!empty($this->opp_status)) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index d76e3a605f4..da26f12997b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -674,7 +674,7 @@ class Task extends CommonObjectLine // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; - $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "'".$this->db->escape($this->id)."'").","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "'".$this->db->escape((string) $this->id)."'").","; $sql .= " fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; @@ -1121,24 +1121,24 @@ class Task extends CommonObjectLine * Return list of tasks for all projects or for one particular project * Sort order is on project, then on position of task, and last on start date of first level task * - * @param ?User $usert Object user to limit tasks affected to a particular user - * @param ?User $userp Object user to limit projects of a particular user and public projects - * @param int $projectid Project id - * @param int $socid Third party id - * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists - * @param string $filteronproj Filter on project ref or label - * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated only) - * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @param int $filteronprojuser Filter on user that is a contact of project - * @param int $filterontaskuser Filter on user assigned to task - * @param ?Extrafields $extrafields Show additional column from project or task - * @param int $includebilltime Calculate also the time to bill and billed + * @param ?User $usert Object user to limit tasks affected to a particular user + * @param ?User $userp Object user to limit projects of a particular user and public projects + * @param int $projectid Project id + * @param int $socid Third party id + * @param int<0,1> $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists + * @param string $filteronproj Filter on project ref or label + * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated only) + * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') + * @param int<0,1> $filteronprojuser Filter on user that is a contact of project + * @param int<0,1> $filterontaskuser Filter on user assigned to task + * @param ?Extrafields $extrafields Show additional column from project or task + * @param int<0,1> $includebilltime Calculate also the time to bill and billed * @param array $search_array_options Array of search filters. Not Used yet. - * @param int $loadextras Fetch all Extrafields on each project and task - * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @return Task[]|string Array of tasks + * @param int<0,1> $loadextras Fetch all Extrafields on each project and task + * @param int<0,1> $loadRoleMode 1= will test Roles on task; 0 used in delete project action + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @return Task[]|string Array of tasks */ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = null, $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '') { @@ -1244,7 +1244,7 @@ class Task extends CommonObjectLine $sql .= " AND p.fk_soc = ".((int) $socid); } if ($projectid) { - $sql .= " AND p.rowid IN (".$this->db->sanitize($projectid).")"; + $sql .= " AND p.rowid IN (".$this->db->sanitize((string) $projectid).")"; } if ($filteronproj) { $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); @@ -1907,11 +1907,11 @@ class Task extends CommonObjectLine } if ($dates > 0) { $datefieldname = "element_datehour"; - $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; + $sql .= " AND (".$datefieldname." >= '".$this->db->idate((int) $dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { $datefieldname = "element_datehour"; - $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; + $sql .= " AND (".$datefieldname." <= '".$this->db->idate((int) $datee)."' OR ".$datefieldname." IS NULL)"; } //print $sql; @@ -2220,7 +2220,7 @@ class Task extends CommonObjectLine if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0); + $sql .= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? (string) $this->timespent_duration : '0'); $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); @@ -2291,7 +2291,7 @@ class Task extends CommonObjectLine require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON').'.php'; $modTask = new $obj(); '@phan-var-force ModeleNumRefTask $modTask'; - $defaultref = $modTask->getNextValue(0, $clone_task); + $defaultref = $modTask->getNextValue(null, $clone_task); } $ori_project_id = $clone_task->fk_project; diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 3db3f872217..99a176c9470 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -162,7 +162,7 @@ class TaskStats extends Stats $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->year, $this->month))."' AND '".$this->db->idate(dol_get_last_day($this->year, $this->month))."'"; } if (!empty($this->priority)) { - $sqlwhere[] = " t.priority IN (".$this->db->sanitize($this->priority, 1).")"; + $sqlwhere[] = " t.priority IN (".$this->db->sanitize((string) $this->priority, 1).")"; } if (count($sqlwhere) > 0) { diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f04c1df9ae6..22f4d4a33a9 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -1,7 +1,7 @@ * Copyright (C) 2012-2015 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -88,16 +88,16 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +$formconfirmtoaddtasks = ''; if (empty($reshook)) { // Test if we can add contact to the tasks at the same times, if not or not required, make a redirect - $formconfirmtoaddtasks = ''; if ($action == 'addcontact' && $permissiontoadd) { $form = new Form($db); $source = GETPOST("source", 'aZ09'); $taskstatic = new Task($db); - $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0); + $task_array = $taskstatic->getTasksArray(null, null, $object->id, 0, 0); $nbTasks = count($task_array); //If no task available, redirec to to add confirm @@ -191,7 +191,7 @@ if (empty($reshook)) { if ($result > 0) { $excludefilter = 'statut = 1'; $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0); - if ($contactarray <= 0) { + if (!is_array($tmpcontactarray)) { $error++; } else { foreach ($tmpcontactarray as $tmpuser) { @@ -245,7 +245,7 @@ if (empty($reshook)) { foreach ($task_to_affect as $task_id) { if (GETPOSTISSET('person_'.$task_id) && GETPOST('person_'.$task_id, 'san_alpha')) { $tasksToAffect = new Task($db); - $result = $tasksToAffect->fetch($task_id); + $result = $tasksToAffect->fetch((int) $task_id); if ($result < 0) { setEventMessages($tasksToAffect->error, null, 'errors'); } else { diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 21fea1424d9..7d03c54a5b6 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -737,7 +737,7 @@ if (!empty($hookmanager->resArray)) { if ($action == "addelement") { $tablename = GETPOST("tablename"); - $elementselectid = GETPOST("elementselect"); + $elementselectid = GETPOSTINT("elementselect"); $result = $object->update_element($tablename, $elementselectid); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -766,10 +766,10 @@ if (!$showdatefilter) { print ''; print ''; print '
'; - print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print $form->selectDate((int) $dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print $form->selectDate((int) $datee, 'datee', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print '
'; print ''; @@ -866,8 +866,8 @@ foreach ($listofreferent as $key => $value) { $num = count($elementarray); for ($i = 0; $i < $num; $i++) { $tmp = explode('_', $elementarray[$i]); - $idofelement = $tmp[0]; - $idofelementuser = !empty($tmp[1]) ? $tmp[1] : ""; + $idofelement = (int) $tmp[0]; + $idofelementuser = !empty($tmp[1]) ? (int) $tmp[1] : 0; $element->fetch($idofelement); if ($idofelementuser) { @@ -896,15 +896,20 @@ foreach ($listofreferent as $key => $value) { // Define $total_ht_by_line if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { + '@phan-var-force ChargeSociales|PaymentVarious|Salary $element'; $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { + '@phan-var-force Fichinter $element'; $total_ht_by_line = $element->getAmount(); } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; $total_ht_by_line = $element->price * abs($element->qty); } elseif ($tablename == 'projet_task') { - $tmp = $element->getSumOfAmount($idofelementuser ? $elementuser : '', $dates, $datee); + '@phan-var-force Task $element'; + $tmp = $element->getSumOfAmount($idofelementuser ? $elementuser : '', (string) $dates, (string) $datee); $total_ht_by_line = price2num($tmp['amount'], 'MT'); } elseif ($key == 'loan') { + '@phan-var-force Loan $element'; if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) { // Get total loan $total_ht_by_line = -$element->capital; @@ -933,12 +938,16 @@ foreach ($listofreferent as $key => $value) { // Define $total_ttc_by_line if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { + '@phan-var-force ChargeSociales|PaymentVarious|Salary $element'; $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { + '@phan-var-force Fichinter $element'; $total_ttc_by_line = $element->getAmount(); } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; $total_ttc_by_line = $element->price * abs($element->qty); } elseif ($tablename == 'projet_task') { + '@phan-var-force Task $element'; $defaultvat = get_default_tva($mysoc, $mysoc); $reg = array(); if (preg_replace('/^(\d+\.)\s\(.*\)/', $defaultvat, $reg)) { @@ -1101,7 +1110,7 @@ foreach ($listofreferent as $key => $value) { $exclude_select_element[] = $value['exclude_select_element']; } - if ($qualified) { + if ($qualified && $tablename !== null) { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; @@ -1268,8 +1277,8 @@ foreach ($listofreferent as $key => $value) { $total_time = 0; for ($i = 0; $i < $num; $i++) { $tmp = explode('_', $elementarray[$i]); - $idofelement = $tmp[0]; - $idofelementuser = isset($tmp[1]) ? $tmp[1] : ""; + $idofelement = (int) $tmp[0]; + $idofelementuser = isset($tmp[1]) ? (int) $tmp[1] : 0; $element->fetch($idofelement); if ($idofelementuser) { @@ -1390,6 +1399,7 @@ foreach ($listofreferent as $key => $value) { print "\n"; // Product and qty on stock movement if ('MouvementStock' == $classname) { + '@phan-var-force MouvementStock $element'; $mvsProd = new Product($element->db); $mvsProd->fetch($element->product_id); print ''.$mvsProd->getNomUrl(1).''; @@ -1397,28 +1407,38 @@ foreach ($listofreferent as $key => $value) { } // Date or TimeSpent $date = ''; - $total_time_by_line = null; + $total_time_by_line = 0; if ($tablename == 'expensereport_det') { + '@phan-var-force ExpenseReportLine $element'; $date = $element->date; // No draft status on lines } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; $date = $element->datem; } elseif ($tablename == 'salary') { + '@phan-var-force Salary $element'; $date = $element->datesp; } elseif ($tablename == 'payment_various') { + '@phan-var-force PaymentVarious $element'; $date = $element->datev; } elseif ($tablename == 'chargesociales') { + '@phan-var-force ChargeSociales $element'; $date = $element->date_ech; } elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) { if ($tablename == 'don') { - $date = $element->datedon; + '@phan-var-force Don $element'; + $date = $element->date; } if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') { + '@phan-var-force CommandeFournisseur $element'; $date = ($element->date_commande ? $element->date_commande : $element->date_valid); } elseif ($tablename == 'supplier_proposal') { + '@phan-var-force SupplierProposal $element'; $date = $element->date_validation; // There is no other date for this } elseif ($tablename == 'fichinter') { + '@phan-var-force Fichinter $element'; $date = $element->datev; // There is no other date for this } elseif ($tablename == 'projet_task') { + '@phan-var-force Task $element'; $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed } else { $date = $element->date; // invoice, ... @@ -1429,21 +1449,25 @@ foreach ($listofreferent as $key => $value) { $date = $element->datev; } if (empty($date) && !empty($datefieldname)) { + // @phan-suppress-next-line PhanUndeclaredProperty $date = $element->$datefieldname; } } } elseif ($key == 'loan') { + '@phan-var-force Loan $element'; $date = $element->datestart; } print ''; if ($tablename == 'actioncomm') { + '@phan-var-force ActionComm $element'; print dol_print_date($element->datep, 'dayhour'); if ($element->datef && $element->datef > $element->datep) { print " - ".dol_print_date($element->datef, 'dayhour'); } } elseif (in_array($tablename, array('projet_task'))) { - $tmpprojtime = $element->getSumOfAmount($idofelementuser ? $elementuser : '', $dates, $datee); // $element is a task. $elementuser may be empty + '@phan-var-force Task $element'; + $tmpprojtime = $element->getSumOfAmount($idofelementuser ? $elementuser : '', (string) $dates, (string) $datee); // $element is a task. $elementuser may be empty print ''; print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin'); print ''; @@ -1466,6 +1490,7 @@ foreach ($listofreferent as $key => $value) { $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); } elseif ($tablename == 'don' || $tablename == 'stock_mouvement') { + '@phan-var-force Don|MouvementStock $element'; if ($element->fk_user_author > 0) { $tmpuser2 = new User($db); $tmpuser2->fetch($element->fk_user_author); @@ -1474,12 +1499,14 @@ foreach ($listofreferent as $key => $value) { } elseif ($tablename == 'projet_task' && $key == 'element_time') { // if $key == 'project_task', we don't want details per user print $elementuser->getNomUrl(1); } elseif ($tablename == 'payment_various') { // payment label + '@phan-var-force PaymentVarious $element'; print $element->label; } print ''; // Add duration and store it in counter for fichinter if ($tablename == 'fichinter') { + '@phan-var-force FichInter $element'; print ''; print convertSecondToTime($element->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); $total_duration += $element->duration; @@ -1492,10 +1519,13 @@ foreach ($listofreferent as $key => $value) { $total_ht_by_line = null; $othermessage = ''; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { + '@phan-var-force Don|ChargeSociales|PaymentVarious|Salary $element'; $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { + '@phan-var-force FichInter $element'; $total_ht_by_line = $element->getAmount(); } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; $total_ht_by_line = $element->price * abs($element->qty); } elseif (in_array($tablename, array('projet_task'))) { if (isModEnabled('salaries')) { @@ -1509,6 +1539,7 @@ foreach ($listofreferent as $key => $value) { $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } elseif ($key == 'loan') { + '@phan-var-force Loan $element'; $total_ht_by_line = $element->capital; } else { $total_ht_by_line = $element->total_ht; @@ -1546,10 +1577,13 @@ foreach ($listofreferent as $key => $value) { if (empty($value['disableamount'])) { $total_ttc_by_line = null; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { + '@phan-var-force Don|ChargeSociales|PaymentVarious $element'; $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { + '@phan-var-force Fichinter $element'; $total_ttc_by_line = $element->getAmount(); } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; $total_ttc_by_line = $element->price * abs($element->qty); } elseif ($tablename == 'projet_task') { if (isModEnabled('salaries')) { @@ -1560,6 +1594,7 @@ foreach ($listofreferent as $key => $value) { $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } elseif ($key == 'loan') { + '@phan-var-force Loan $element'; $total_ttc_by_line = $element->capital - $element->getSumPayment(); } else { $total_ttc_by_line = $element->total_ttc; @@ -1605,6 +1640,7 @@ foreach ($listofreferent as $key => $value) { print $element->progress.' %'; } } elseif ($tablename == 'stock_mouvement') { + '@phan-var-force MouvementStock $element'; print $element->getLibStatut(3); } else { print $element->getLibStatut(5); @@ -1662,7 +1698,7 @@ foreach ($listofreferent as $key => $value) { print ''.$langs->trans("Number").': '.$i.''; if (in_array($tablename, array('projet_task'))) { print ''; - print convertSecondToTime($total_time, 'allhourmin'); + print convertSecondToTime((int) $total_time, 'allhourmin'); print ''; print ''; print ''; @@ -1746,8 +1782,8 @@ function canApplySubtotalOn($tablename) /** * sortElementsByClientName * - * @param int[] $elementarray Element array - * @return int[] Element array sorted + * @param array $elementarray Element array + * @return array Element array sorted */ function sortElementsByClientName($elementarray) { diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index a887f6d24b5..c2a68c65d7c 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,13 @@ * @var DoliDB $db * @var Translate $langs */ +' +@phan-var-force string $dateformatinput +@phan-var-force string $dateformat +@phan-var-force string $datehourformat +@phan-var-force array,task_css:string,task_position:int,task_planned_workload:int,task_milestone:int,task_percent_complete:float,task_name:string,task_start_date:int,task_end_date:int,task_color:string,task_resources:string,note:string,task_parent_alternate_id:int}> $tasks +@phan-var-force array{} $task_dependencies +'; ?>
@@ -129,14 +136,14 @@ if (g.getDivId() != null) $projecttmp = new Project($db); $projecttmp->fetch($t['task_project_id']); $tmpt = array( - 'task_id' => '-'.$t['task_project_id'], - 'task_alternate_id' => '-'.$t['task_project_id'], + 'task_id' => (int) -$t['task_project_id'], + 'task_alternate_id' => (int) -$t['task_project_id'], 'task_name' => $projecttmp->ref.' '.$projecttmp->title, 'task_resources' => '', - 'task_start_date' => '', - 'task_end_date' => '', + 'task_start_date' => 0, + 'task_end_date' => 0, 'task_is_group' => 1, 'task_position' => 0, 'task_css' => 'ggroupblack', 'task_milestone' => 0, 'task_parent' => 0, 'task_parent_alternate_id' => 0, - 'task_notes' => '', + 'note' => '', 'task_planned_workload' => 0 ); constructGanttLine($tasks, $tmpt, array(), 0, $t['task_project_id']); @@ -166,10 +173,10 @@ else ,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr Array of all tasks - * @param array{task_id:string,task_alternate_id:string,task_name:string,task_resources:string,task_start_date:string,task_end_date:string,task_is_group:int<0,1>,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int} $task Array with properties of one task + * @param array,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr Array of all tasks + * @param array{task_id:int,task_alternate_id:int,task_name:string,task_resources:string,task_start_date:int,task_end_date:int,task_is_group:int<0,1>,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int} $task Array with properties of one task * @param array $task_dependencies Task dependencies (array(array(0=>idtask,1=>idtasktofinishfisrt)) * @param int $level Level * @param int $project_id Id of project @@ -280,8 +287,8 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje /** * Find child Gantt line * - * @param array,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr tarr - * @param string $parent Parent + * @param array,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr tarr + * @param int $parent Parent * @param array $task_dependencies Task dependencies * @param int $level Level * @return void @@ -298,12 +305,12 @@ function findChildGanttLine($tarr, $parent, $task_dependencies, $level) { $tmpt = array( 'task_id'=> -98, 'task_name'=>'Level '.$level, 'task_resources'=>'', 'task_start_date'=>'', 'task_end_date'=>'', - 'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>$tarr[$x]["task_parent"], 'task_notes'=>''); + 'task_is_group'=>1, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>$tarr[$x]["task_parent"], 'note'=>''); constructGanttLine($tasks, $tmpt, array(), 0, $tarr[$x]['task_project_id']); $old_parent_id = $tarr[$x]['task_project_id']; }*/ - constructGanttLine($tarr, $tarr[$x], $task_dependencies, $level, null); + constructGanttLine($tarr, $tarr[$x], $task_dependencies, $level, 0); findChildGanttLine($tarr, $tarr[$x]["task_id"], $task_dependencies, $level + 1); } } diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 33f7122723b..97ea895d75f 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -101,6 +101,8 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-project page-card_ganttview'); +$userWrite = 0; + if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); @@ -272,7 +274,7 @@ print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'proje // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user // can have a parent that is not affected to him). -$tasksarray = $task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); +$tasksarray = $task->getTasksArray(null, null, ($object->id ? $object->id : $id), $socid, 0); // We load also tasks limited to a particular user //$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(null, $user, $object->id, 0) : ''); //var_dump($tasksarray); @@ -313,7 +315,7 @@ if (count($tasksarray) > 0) { $tasks[$taskcursor]['task_css'] = 'ggroupblack'; //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; } - $tasks[$taskcursor]['task_milestone'] = '0'; + $tasks[$taskcursor]['task_milestone'] = 0; $tasks[$taskcursor]['task_percent_complete'] = $val->progress; //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1); //print dol_print_date($val->date_start).dol_print_date($val->date_end).'
'."\n"; diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 78d3ead854d..9ddb37a5d26 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024-2025 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -29,6 +29,13 @@ * @var int $socid * @var string[] $listofoppstatus */ +' +@phan-var-force string $projectsListId +@phan-var-force int $socid +@phan-var-force string[] $listofoppstatus +@phan-var-force ?array $listofopplabel +@phan-var-force array $colorseries +'; if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c606b0d14f1..71c71590c54 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -8,7 +8,7 @@ * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2019 Juanjo Menent * Copyright (C) 2020 Tobias Sean - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 William Mead @@ -246,8 +246,8 @@ foreach ($object->fields as $key => $val) { $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1'); $arrayfields['p.'.$key] = array( 'label' => $val['label'], - 'checked' => (($visible < 0) ? 0 : 1), - 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position' => $val['position'], 'help' => isset($val['help']) ? $val['help'] : '' ); @@ -257,38 +257,48 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; // Add non object fields to fields for list -$arrayfields['s.nom'] = array('label' => "ThirdParty", 'checked' => 1, 'position' => 21, 'enabled' => (!isModEnabled('societe') ? 0 : 1)); -$arrayfields['s.name_alias'] = array('label' => "AliasNameShort", 'checked' => 0, 'position' => 22); -$arrayfields['co.country_code'] = array('label' => "Country", 'checked' => -1, 'position' => 23); -$arrayfields['commercial'] = array('label' => "SaleRepresentativesOfThirdParty", 'checked' => 0, 'position' => 25); -$arrayfields['c.assigned'] = array('label' => "AssignedTo", 'checked' => 1, 'position' => 120); -$arrayfields['opp_weighted_amount'] = array('label' => 'OpportunityWeightedAmountShort', 'checked' => 0, 'enabled' => (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES') ? 0 : 1), 'position' => 106); -$arrayfields['u.login'] = array('label' => "Author", 'checked' => -1, 'position' => 165); +$arrayfields['s.nom'] = array('label' => "ThirdParty", 'checked' => '1', 'position' => 21, 'enabled' => (!isModEnabled('societe') ? '0' : '1')); +$arrayfields['s.name_alias'] = array('label' => "AliasNameShort", 'checked' => '0', 'position' => 22); +$arrayfields['co.country_code'] = array('label' => "Country", 'checked' => '-1', 'position' => 23); +$arrayfields['commercial'] = array('label' => "SaleRepresentativesOfThirdParty", 'checked' => '0', 'position' => 25); +$arrayfields['c.assigned'] = array('label' => "AssignedTo", 'checked' => '1', 'position' => 120); +$arrayfields['opp_weighted_amount'] = array('label' => 'OpportunityWeightedAmountShort', 'checked' => '0', 'enabled' => (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES') ? '0' : '1'), 'position' => 106); +$arrayfields['u.login'] = array('label' => "Author", 'checked' => '-1', 'position' => 165); // Force some fields according to search_usage filter... //if (GETPOST('search_usage_opportunity')) { //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not required, filter on search_opp_status is enough //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not required, filter on search_opp_status is enough //} if (GETPOST('search_usage_event_organization')) { - $arrayfields['p.fk_opp_status']['enabled'] = 0; - $arrayfields['p.opp_amount']['enabled'] = 0; - $arrayfields['p.opp_percent']['enabled'] = 0; - $arrayfields['opp_weighted_amount']['enabled'] = 0; - $arrayfields['p.usage_organize_event']['visible'] = 1; - $arrayfields['p.usage_organize_event']['checked'] = 1; + if (array_key_exists('p.fk_opp_status', $arrayfields)) { + $arrayfields['p.fk_opp_status']['enabled'] = '0'; + } + if (array_key_exists('p.fk_opp_amount', $arrayfields)) { + $arrayfields['p.opp_amount']['enabled'] = '0'; + } + if (array_key_exists('p.fk_opp_percent', $arrayfields)) { + $arrayfields['p.opp_percent']['enabled'] = '0'; + } + $arrayfields['opp_weighted_amount']['enabled'] = '0'; + if (array_key_exists('p.usage_organize_event', $arrayfields)) { + $arrayfields['p.usage_organize_event']['visible'] = '1'; + $arrayfields['p.usage_organize_event']['checked'] = '1'; + } } -$arrayfields['p.fk_project']['enabled'] = 0; +$arrayfields['p.fk_project']['enabled'] = '0'; // Force this field to be visible if ($contextpage == 'lead') { - $arrayfields['p.fk_opp_status']['enabled'] = 1; - $arrayfields['p.fk_opp_status']['visible'] = 1; + if (array_key_exists('p.fk_opp_status', $arrayfields)) { + $arrayfields['p.fk_opp_status']['enabled'] = '1'; + $arrayfields['p.fk_opp_status']['visible'] = '1'; + } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan +// '@phan-var-force array $arrayfields'; // dol_sort_array looses type for Phan // Add a groupby field. Set $groupby and $groupbyvalues. // TODO Move this into a inc file @@ -1203,7 +1213,7 @@ $includeonly = ''; if (!$user->hasRight('user', 'user', 'lire')) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, null, 0, $includeonly, '', '0', 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -1291,7 +1301,7 @@ if (!empty($arrayfields['s.nom']['checked'])) { $tmpthirdparty->fetch($socid); $search_societe = $tmpthirdparty->name; } - print ''; + print ''; print ''; } @@ -1527,14 +1537,17 @@ if (!empty($arrayfields['c.assigned']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['p.fk_opp_status']['checked'])) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } if (!empty($arrayfields['p.opp_amount']['checked'])) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; } if (!empty($arrayfields['p.opp_percent']['checked'])) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; } @@ -1559,6 +1572,7 @@ if (!empty($arrayfields['p.usage_bill_time']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['p.usage_organize_event']['checked'])) { + // @phan-suppress-next-line PhanTypeInvalidDimOffset print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, ''); $totalarray['nbfield']++; } diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 4f9091a3df4..87921d46d99 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -420,7 +420,7 @@ function getProject($authentication, $id = '', $ref = '') foreach ($listofreferent as $key => $tablename) { $elements[$key] = array(); $element_array = $project->get_element_list($key, $tablename); - if (count($element_array) > 0 && is_array($element_array)) { + if (is_array($element_array) && count($element_array) > 0) { foreach ($element_array as $element) { $tmp = explode('_', $element); $idofelement = count($tmp) > 0 ? $tmp[0] : "";