From 2cd13853d584994a68fade5823fc17685527fa9c Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 2 Feb 2025 22:19:18 +0100 Subject: [PATCH] Qual: Fix phan notices (ftp, holiday) # Qual: Fix phan notices (ftp, holiday) --- dev/tools/phan/baseline.txt | 16 +++----- .../holiday/mod_holiday_immaculate.php | 4 +- .../modules/holiday/mod_holiday_madonna.php | 4 +- .../core/modules/holiday/modules_holiday.php | 4 +- htdocs/ftp/admin/ftpclient.php | 9 +++++ htdocs/ftp/index.php | 8 ++-- htdocs/holiday/card.php | 15 +++---- htdocs/holiday/card_group.php | 20 +++++----- htdocs/holiday/class/holiday.class.php | 16 ++++---- htdocs/holiday/define_holiday.php | 18 ++++----- htdocs/holiday/list.php | 35 +++++++++-------- htdocs/holiday/month_report.php | 23 +++++------ htdocs/holiday/view_log.php | 39 ++++++++++--------- 13 files changed, 110 insertions(+), 101 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index eb6649f9507..2773f00fb3a 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,12 +9,12 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 3800+ occurrences + // PhanTypeMismatchArgument : 3760+ occurrences // PhanUndeclaredProperty : 540+ occurrences // PhanTypeMismatchArgumentNullable : 460+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 200+ occurrences // PhanUndeclaredGlobalVariable : 190+ occurrences // PhanPluginUnknownArrayMethodReturnType : 180+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 180+ occurrences // PhanTypeMismatchArgumentProbablyReal : 150+ occurrences // PhanTypeMismatchProperty : 130+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences @@ -22,8 +22,8 @@ return [ // PhanPluginUndeclaredVariableIsset : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences - // PhanTypeMismatchDimFetch : 25+ occurrences // PhanTypeMismatchArgumentNullableInternal : 20+ occurrences + // PhanTypeMismatchDimFetch : 20+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanTypeComparisonFromArray : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences @@ -628,15 +628,9 @@ return [ 'htdocs/fourn/facture/paiement.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fourn/facture/rapport.php' => ['PhanTypeMismatchArgument'], 'htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], - 'htdocs/ftp/admin/ftpclient.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/ftp/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/holiday/card.php' => ['PhanTypeMismatchArgument'], - 'htdocs/holiday/card_group.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/holiday/class/holiday.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/holiday/define_holiday.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/holiday/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable'], + 'htdocs/holiday/card_group.php' => ['PhanTypeMismatchArgument'], + 'htdocs/holiday/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/holiday/month_report.php' => ['PhanTypeMismatchArgument'], - 'htdocs/holiday/view_log.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchDimFetch'], 'htdocs/hrm/admin/admin_hrm.php' => ['PhanEmptyForeach'], 'htdocs/hrm/class/establishment.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/hrm/class/evaluation.class.php' => ['PhanUndeclaredProperty'], diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index c8ed8ec5996..b2d4cd403e6 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -2,7 +2,7 @@ /* Copyright (C) 2011-2019 Juanjo Menent * Copyright (C) 2018 Charlene Benke * 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 @@ -110,7 +110,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays /** * Return next value * - * @param Societe $objsoc third party object + * @param ?Societe $objsoc third party object * @param Holiday $holiday holiday object * @return string|int<-1,0> Value if OK, <=0 if KO */ diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 9f10ed28eef..a20eebdc1f3 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -2,7 +2,7 @@ /* Copyright (C) 2011 Juanjo Menent * Copyright (C) 2018-2023 Charlene Benke * 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 @@ -113,7 +113,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays /** * Return next value * - * @param Societe $objsoc third party object + * @param ?Societe $objsoc third party object * @param Holiday $holiday holiday object * @return string|int<-1,0> Value if OK, <=0 if KO */ diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 0bc07d3e73a..f5073b546ae 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -8,7 +8,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2014 Marcos García * Copyright (C) 2018 Charlene Benke - * 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 @@ -85,7 +85,7 @@ abstract class ModelNumRefHolidays extends CommonNumRefGenerator /** * Return next value * - * @param Societe $objsoc third party object + * @param ?Societe $objsoc third party object * @param Holiday $holiday holiday object * @return string|int<-1,0> Value if OK, <=0 if KO */ diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index 7299245250e..c10fe97ca93 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2011 Juanjo Menent * 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 @@ -48,6 +49,14 @@ if (!$user->admin) { accessforbidden(); } +// Initialise variables +$result1 = 0; +$result2 = 0; +$result3 = 0; +$result4 = 0; +$result5 = 0; +$result6 = 0; + /* * Action diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index a91f23eff26..265b3709e75 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2008-2016 Laurent Destailleur * Copyright (C) 2008-2009 Regis Houssin * Copyright (C) 2019-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 @@ -107,6 +107,7 @@ $result = restrictedArea($user, 'ftp', ''); */ if ($action == 'uploadfile' && $user->hasRight('ftp', 'write')) { + $newsectioniso = null; // set up a connection or die if (!$conn_id) { $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1'); @@ -115,7 +116,7 @@ if ($action == 'uploadfile' && $user->hasRight('ftp', 'write')) { $ok = $resultarray['ok']; $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) { + if ($conn_id && $ok && !$mesg && $newsectioniso) { $nbfile = count($_FILES['userfile']['name']); for ($i = 0; $i < $nbfile; $i++) { $newsection = $newsectioniso; @@ -138,6 +139,7 @@ if ($action == 'uploadfile' && $user->hasRight('ftp', 'write')) { if ($action == 'addfolder' && $user->hasRight('ftp', 'write')) { // set up a connection or die + $newsectioniso = null; if (!$conn_id) { $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1'); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); @@ -145,7 +147,7 @@ if ($action == 'addfolder' && $user->hasRight('ftp', 'write')) { $ok = $resultarray['ok']; $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) { + if ($conn_id && $ok && !$mesg && $newsectioniso) { $result = dol_ftp_mkdir($conn_id, $newfolder, $newsectioniso); if ($result) { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 29595dc17a2..ad025b35c10 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2020-2021 Udo Tamm * Copyright (C) 2022 Anthony Berton * Copyright (C) 2024 Charlene Benke + * 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 @@ -980,7 +981,7 @@ $form = new Form($db); $formfile = new FormFile($db); $object = new Holiday($db); -$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); +$listhalfday = array('morning' => $langs->trans("Morning"), "afternoon" => $langs->trans("Afternoon")); $title = $langs->trans('Leave'); $help_url = 'EN:Module_Holiday'; @@ -1079,10 +1080,10 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''.$langs->trans("User").''; print '
'; if ($permissiontoadd && !$permissiontoaddall) { - print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500 inline-block'); + print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, null, 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500 inline-block'); //print ''; } else { - print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500 inline-block'); + print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, null, 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500 inline-block'); } print '
'; @@ -1104,7 +1105,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $htmltooltip = $langs->trans("Detail").'
'; $htmltooltip .= $out; - print $form->textwithtooltip($langs->trans('SoldeCPUser', round($nb_holiday, 5)).' '.img_picto('', 'help'), $htmltooltip); + print $form->textwithtooltip($langs->trans('SoldeCPUser', (string) round($nb_holiday, 5)).' '.img_picto('', 'help'), $htmltooltip); print ''; if (!empty($conf->use_javascript_ajax)) { @@ -1141,7 +1142,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', 1); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -1201,7 +1202,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if (GETPOSTINT('valideur') > 0) { $defaultselectuser = GETPOSTINT('valideur'); } - $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, null, 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); print img_picto('', 'user', 'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } @@ -1549,7 +1550,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // Si refus de la demande if ($action == 'refuse') { - $array_input = array(array('type'=>"text", 'label'=> $langs->trans('DetailRefusCP'), 'name'=>"detail_refuse", 'size'=>"50", 'value'=>"")); + $array_input = array(array('type' => "text", 'label' => $langs->trans('DetailRefusCP'), 'name' => "detail_refuse", 'size' => "50", 'value' => "")); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0); } diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 9eb3f2ab5d0..0a913e24274 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -171,10 +171,10 @@ if (empty($reshook)) { $users = GETPOST('users', 'array'); $groups = GETPOST('groups', 'array'); - $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); - $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); - $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); - $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); + $date_debut = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year')); + $date_fin = dol_mktime(0, 0, 0, GETPOSTINT('date_fin_month'), GETPOSTINT('date_fin_day'), GETPOSTINT('date_fin_year')); + $date_debut_gmt = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year'), 1); + $date_fin_gmt = dol_mktime(0, 0, 0, GETPOSTINT('date_fin_month'), GETPOSTINT('date_fin_day'), GETPOSTINT('date_fin_year'), 1); $starthalfday = GETPOST('starthalfday'); $endhalfday = GETPOST('endhalfday'); $type = GETPOSTINT('type'); @@ -414,7 +414,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { break; } - setEventMessages($errors, array(), 'errors'); + setEventMessages('', $errors, 'errors'); } @@ -508,7 +508,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $Tgroup[$obj->rowid] = $obj->nom; } - print $form->multiselectarray('groups', $Tgroup, GETPOST('groups', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('groups', $Tgroup, GETPOST('groups', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ''; @@ -543,7 +543,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } } - print img_picto('', 'users', 'class="pictofixedwidth"') . $form->multiselectarray('users', $userlist, GETPOST('users', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print img_picto('', 'users', 'class="pictofixedwidth"') . $form->multiselectarray('users', $userlist, GETPOST('users', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ''; // Type @@ -557,7 +557,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', 1); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -618,7 +618,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if (GETPOSTINT('valideur') > 0) { $defaultselectuser = GETPOSTINT('valideur'); } - $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, null, 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } @@ -701,7 +701,7 @@ function sendMail($id, $cancreate, $now, $autoValidation) if ($result) { // If draft and owner of leave if ($object->status == Holiday::STATUS_VALIDATED && $cancreate) { - $object->oldcopy = dol_clone($object, 2); + $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty //if ($autoValidation) $object->status = Holiday::STATUS_VALIDATED; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c6808b57aff..082111cd7f0 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 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 @@ -1012,9 +1012,9 @@ class Holiday extends CommonObject /** * Update database * - * @param User $user User that modify - * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param ?User $user User that modify + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ public function update($user = null, $notrigger = 0) { @@ -1054,7 +1054,7 @@ class Holiday extends CommonObject $error++; } if (!empty($this->fk_validator)) { - $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + $sql .= " fk_validator = ".((int) $this->fk_validator).","; } else { $error++; } @@ -1123,7 +1123,7 @@ class Holiday extends CommonObject } if (!$error) { - if (!$notrigger) { + if (!$notrigger && $user !== null) { // Call trigger $result = $this->call_trigger('HOLIDAY_MODIFY', $user); if ($result < 0) { @@ -2211,7 +2211,7 @@ class Holiday extends CommonObject * @param int $fk_user_action Id user creation * @param int $fk_user_update Id user update * @param string $label Label (Example: 'Leave', 'Manual update', 'Leave request cancelation'...) - * @param int $new_solde New value + * @param float $new_solde New value * @param int $fk_type Type of vacation * @return int Id of record added, 0 if nothing done, < 0 if KO */ @@ -2221,7 +2221,7 @@ class Holiday extends CommonObject $error = 0; - $prev_solde = price2num($this->getCPforUser($fk_user_update, $fk_type), 5); + $prev_solde = price2num((float) $this->getCPforUser($fk_user_update, $fk_type), 5); $new_solde = price2num($new_solde, 5); //print "$prev_solde == $new_solde"; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 3b1f193e1b6..48dde5e60bd 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -5,7 +5,7 @@ * Copyright (C) 2016 Regis Houssin * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro - * 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 @@ -83,10 +83,10 @@ $extrafields = new ExtraFields($db); $holiday = new Holiday($db); $arrayfields = array( - 'cp.rowid' => array('label' => $langs->trans("Employee"), 'checked' => 1, 'position' => 20), - 'cp.fk_user' => array('label' => $langs->trans("Supervisor"), 'checked' => 1, 'position' => 30), - 'cp.nbHoliday' => array('label' => $langs->trans("MenuConfCP"), 'checked' => 1, 'position' => 40), - 'cp.note_public' => array('label' => $langs->trans("Note"), 'checked' => 1, 'position' => 50), + 'cp.rowid' => array('label' => $langs->trans("Employee"), 'checked' => '1', 'position' => 20), + 'cp.fk_user' => array('label' => $langs->trans("Supervisor"), 'checked' => '1', 'position' => 30), + 'cp.nbHoliday' => array('label' => $langs->trans("MenuConfCP"), 'checked' => '1', 'position' => 40), + 'cp.note_public' => array('label' => $langs->trans("Note"), 'checked' => '1', 'position' => 50), ); $permissiontoread = $user->hasRight('holiday', 'read'); @@ -178,7 +178,7 @@ if (empty($reshook)) { //print 'holiday: '.$val['rowid'].'-'.$userValue;exit; if ($userValue != '') { // We add the modification to the log (must be done before the update of balance because we read current value of balance inside this method) - $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']); + $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, (float) $userValue, $val['rowid']); if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; @@ -188,7 +188,7 @@ if (empty($reshook)) { if ($result > 0) { $nbok++; - $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']); + $result = $holiday->updateSoldeCP($userID, (float) $userValue, $val['rowid']); if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; @@ -373,7 +373,7 @@ if (count($typeleaves) == 0) { // Supervisor if (!empty($arrayfields['cp.fk_user']['checked'])) { print ''; - print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, array(), '', 0, 0, 0, '', 0, '', 'maxwidth150'); + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, array(), '', '', 0, 0, '', 0, '', 'maxwidth150'); print ''; } // Type of leave request @@ -493,7 +493,7 @@ if (count($typeleaves) == 0) { foreach ($typeleaves as $key => $val) { $nbtoshow = ''; if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') { - $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5); + $nbtoshow = price2num((float) $holiday->getCPforUser($users['rowid'], $val['rowid']), 5); } //var_dump($users['rowid'].' - '.$val['rowid']); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index de0d14ebd49..a3563b839e4 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 Alexandre Spangaro - * 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 @@ -129,18 +129,18 @@ $fieldstosearchall = array( ); $arrayfields = array( - 'cp.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1), - 'cp.fk_user' => array('label' => $langs->trans("Employee"), 'checked' => 1, 'position' => 20), - 'cp.fk_validator' => array('label' => $langs->trans("ValidatorCP"), 'checked' => 1, 'position' => 30), - 'cp.fk_type' => array('label' => $langs->trans("Type"), 'checked' => 1, 'position' => 35), - 'duration' => array('label' => $langs->trans("NbUseDaysCPShort"), 'checked' => 1, 'position' => 38), - 'cp.date_debut' => array('label' => $langs->trans("DateStart"), 'checked' => 1, 'position' => 40), - 'cp.date_fin' => array('label' => $langs->trans("DateEnd"), 'checked' => 1, 'position' => 42), - 'cp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => 1, 'position' => 60), - 'cp.date_approval' => array('label' => $langs->trans("DateApprove"), 'checked' => 1, 'position' => 70), - 'cp.date_create' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), - 'cp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 501), - 'cp.statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000), + 'cp.ref' => array('label' => $langs->trans("Ref"), 'checked' => '1'), + 'cp.fk_user' => array('label' => $langs->trans("Employee"), 'checked' => '1', 'position' => 20), + 'cp.fk_validator' => array('label' => $langs->trans("ValidatorCP"), 'checked' => '1', 'position' => 30), + 'cp.fk_type' => array('label' => $langs->trans("Type"), 'checked' => '1', 'position' => 35), + 'duration' => array('label' => $langs->trans("NbUseDaysCPShort"), 'checked' => '1', 'position' => 38), + 'cp.date_debut' => array('label' => $langs->trans("DateStart"), 'checked' => '1', 'position' => 40), + 'cp.date_fin' => array('label' => $langs->trans("DateEnd"), 'checked' => '1', 'position' => 42), + 'cp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => '1', 'position' => 60), + 'cp.date_approval' => array('label' => $langs->trans("DateApprove"), 'checked' => '1', 'position' => 70), + 'cp.date_create' => array('label' => $langs->trans("DateCreation"), 'checked' => '0', 'position' => 500), + 'cp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => '0', 'position' => 501), + 'cp.statut' => array('label' => $langs->trans("Status"), 'checked' => '1', 'position' => 1000), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -364,7 +364,7 @@ if (!$user->hasRight('holiday', 'readall')) { $sql .= ' AND cp.fk_user IN ('.$db->sanitize(implode(',', $childids)).')'; } if ($id > 0) { - $sql .= " AND cp.fk_user IN (".$db->sanitize($id).")"; + $sql .= " AND cp.fk_user = ".((int) $id); } // Add where from extra fields @@ -627,7 +627,7 @@ if (!empty($arrayfields['cp.fk_user']['checked'])) { } print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); + print $form->select_dolusers($search_employee, "search_employee", 1, null, $disabled, $include, '', '0', 0, 0, $morefilter, 0, '', 'maxwidth125'); print ''; } @@ -642,7 +642,7 @@ if (!empty($arrayfields['cp.fk_validator']['checked'])) { foreach ($valideurobjects as $val) { $valideurarray[$val] = $val; } - print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); + print $form->select_dolusers($search_valideur, "search_valideur", 1, null, 0, $valideurarray, '', '0', 0, 0, $morefilter, 0, '', 'maxwidth125'); print ''; } else { print ' '; @@ -886,6 +886,7 @@ if ($id && !$user->hasRight('holiday', 'readall') && !in_array($id, $childids)) $holidaystatic->fk_type = empty($typeleaves[$obj->fk_type]['rowid']) ? 0 : $typeleaves[$obj->fk_type]['rowid']; + $arraydata = array(); // Output Kanban if ($massactionbutton || $massaction) { $selected = 0; @@ -1127,7 +1128,7 @@ function showMyBalance($holiday, $user_id) $nb_holiday += $nb_type; $out .= ' - '.$val['label'].': '.($nb_type ? price2num($nb_type) : 0).'
'; } - $out = $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'.$out; + $out = $langs->trans('SoldeCPUser', (string) round($nb_holiday, 5)).'
'.$out; return $out; } diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index b1be5ddcff2..08f56f3dafa 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -4,6 +4,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -132,16 +133,16 @@ if (empty($reshook)) { } $arrayfields = array( - 'cp.ref' => array('label' => 'Ref', 'checked' => 1, 'position' => 5), - 'cp.fk_type' => array('label' => 'Type', 'checked' => 1, 'position' => 10), - 'cp.fk_user' => array('label' => 'Employee', 'checked' => 1, 'position' => 20), - 'cp.date_debut' => array('label' => 'DateDebCP', 'checked' => -1, 'position' => 30), - 'cp.date_fin' => array('label' => 'DateFinCP', 'checked' => -1, 'position' => 32), - 'used_days' => array('label' => 'NbUseDaysCPShort', 'checked' => -1, 'position' => 34), - 'date_start_month' => array('label' => 'DateStartInMonth', 'checked' => 1, 'position' => 50), - 'date_end_month' => array('label' => 'DateEndInMonth', 'checked' => 1, 'position' => 52), - 'used_days_month' => array('label' => 'NbUseDaysCPShortInMonth', 'checked' => 1, 'position' => 54), - 'cp.description' => array('label' => 'DescCP', 'checked' => -1, 'position' => 800), + 'cp.ref' => array('label' => 'Ref', 'checked' => '1', 'position' => 5), + 'cp.fk_type' => array('label' => 'Type', 'checked' => '1', 'position' => 10), + 'cp.fk_user' => array('label' => 'Employee', 'checked' => '1', 'position' => 20), + 'cp.date_debut' => array('label' => 'DateDebCP', 'checked' => '-1', 'position' => 30), + 'cp.date_fin' => array('label' => 'DateFinCP', 'checked' => '-1', 'position' => 32), + 'used_days' => array('label' => 'NbUseDaysCPShort', 'checked' => '-1', 'position' => 34), + 'date_start_month' => array('label' => 'DateStartInMonth', 'checked' => '1', 'position' => 50), + 'date_end_month' => array('label' => 'DateEndInMonth', 'checked' => '1', 'position' => 52), + 'used_days_month' => array('label' => 'NbUseDaysCPShortInMonth', 'checked' => '1', 'position' => 54), + 'cp.description' => array('label' => 'DescCP', 'checked' => '-1', 'position' => 800), ); @@ -282,7 +283,7 @@ if (!empty($arrayfields['cp.fk_type']['checked'])) { // Filter: Employee if (!empty($arrayfields['cp.fk_user']['checked'])) { print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth100'); + print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth100'); print ''; } diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index a6a4aae0481..761edc5c8f6 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -4,6 +4,7 @@ * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -167,15 +168,15 @@ if (empty($reshook)) { // Definition of fields for lists $arrayfields = array( - 'cpl.rowid' => array('label' => "ID", 'checked' => 1), - 'cpl.date_action' => array('label' => "Date", 'checked' => 1), - 'cpl.fk_user_action' => array('label' => "ActionByCP", 'checked' => 1), - 'cpl.fk_user_update' => array('label' => "UserUpdateCP", 'checked' => 1), - 'cpl.type_action' => array('label' => "Description", 'checked' => 1), - 'cpl.fk_type' => array('label' => "Type", 'checked' => 1), - 'cpl.prev_solde' => array('label' => "PrevSoldeCP", 'checked' => 1), - 'variation' => array('label' => "Variation", 'checked' => 1), - 'cpl.new_solde' => array('label' => "NewSoldeCP", 'checked' => 1), + 'cpl.rowid' => array('label' => "ID", 'checked' => '1'), + 'cpl.date_action' => array('label' => "Date", 'checked' => '1'), + 'cpl.fk_user_action' => array('label' => "ActionByCP", 'checked' => '1'), + 'cpl.fk_user_update' => array('label' => "UserUpdateCP", 'checked' => '1'), + 'cpl.type_action' => array('label' => "Description", 'checked' => '1'), + 'cpl.fk_type' => array('label' => "Type", 'checked' => '1'), + 'cpl.prev_solde' => array('label' => "PrevSoldeCP", 'checked' => '1'), + 'variation' => array('label' => "Variation", 'checked' => '1'), + 'cpl.new_solde' => array('label' => "NewSoldeCP", 'checked' => '1'), ); @@ -363,14 +364,14 @@ if (!empty($arrayfields['cpl.fk_user_action']['checked'])) { } print ''; - print $form->select_dolusers($search_validator, "search_validator", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_validator, "search_validator", 1, null, 0, $valideurarray, '', '0', 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } // Filter: User if (!empty($arrayfields['cpl.fk_user_update']['checked'])) { print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_employee, "search_employee", 1, null, $disabled, $include, '', '0', 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } @@ -475,14 +476,14 @@ while ($i < min($num, $limit)) { break; } - $holidaylogstatic->id = $obj['rowid']; - $holidaylogstatic->date = $obj['date_action']; - $holidaylogstatic->validator = $obj['fk_user_action']; - $holidaylogstatic->employee = $obj['fk_user_update']; - $holidaylogstatic->description = $obj['type_action']; - $holidaylogstatic->type = $obj['fk_type']; - $holidaylogstatic->balance_previous = $obj['prev_solde']; - $holidaylogstatic->balance_new = $obj['new_solde']; + $holidaylogstatic->id = (int) $obj['rowid']; + $holidaylogstatic->date = (string) $obj['date_action']; + $holidaylogstatic->validator = (int) $obj['fk_user_action']; + $holidaylogstatic->employee = (int) $obj['fk_user_update']; + $holidaylogstatic->description = (string) $obj['type_action']; + $holidaylogstatic->type = (int) $obj['fk_type']; + $holidaylogstatic->balance_previous = (float) $obj['prev_solde']; + $holidaylogstatic->balance_new = (float) $obj['new_solde']; print '';