diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 121bb4c5ca8..686d19ca860 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -18696,12 +18696,6 @@ parameters: count: 4 path: ../../htdocs/eventorganization/conferenceorboothattendee_card.php - - - message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../htdocs/eventorganization/conferenceorboothattendee_card.php - - message: '#^Variable \$text might not be defined\.$#' identifier: variable.undefined @@ -18768,12 +18762,6 @@ parameters: count: 1 path: ../../htdocs/eventorganization/core/actions_massactions_mail.inc.php - - - message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/eventorganization/core/actions_massactions_mail.inc.php - - message: '#^Variable \$from might not be defined\.$#' identifier: variable.undefined @@ -21549,42 +21537,6 @@ parameters: - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse - count: 2 - path: ../../htdocs/holiday/card.php - - - - message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 8 - path: ../../htdocs/holiday/card.php - - - - message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 8 - path: ../../htdocs/holiday/card.php - - - - message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\\|string given\.$#' - identifier: argument.type - count: 8 - path: ../../htdocs/holiday/card.php - - - - message: '#^Variable \$canread might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/holiday/card.php - - - - message: '#^Variable \$endhalfdaykey might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/holiday/card.php - - - - message: '#^Variable \$starthalfdaykey might not be defined\.$#' - identifier: variable.undefined count: 1 path: ../../htdocs/holiday/card.php @@ -24426,12 +24378,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php - - - message: '#^Parameter \#3 \$tab_height of method pdf_standard_myobject\:\:_tableau\(\) expects int, float given\.$#' - identifier: argument.type - count: 6 - path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php - - message: '#^Property pdf_standard_myobject\:\:\$cols \(array\\) does not accept non\-empty\-array\\.$#' identifier: assign.propertyType @@ -24492,12 +24438,6 @@ parameters: count: 1 path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -27756,12 +27696,6 @@ parameters: count: 1 path: ../../htdocs/projet/admin/project.php - - - message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/projet/admin/website.php - - message: '#^Call to function method_exists\(\) with Project and ''fetchComments'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 92139f01d2a..c1ca2befd67 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1148,8 +1148,10 @@ function GETPOSTFLOAT($paramname, $rounding = '') * @param string $hourTime 'getpost' to include hour, minute, second values from the HTTP request, * or 'XX:YY:ZZ' to set hour, minute, second respectively (for instance '23:59:59') * or '' means '00:00:00' (default) - * @param string $gm Passed to dol_mktime + * @param int|string $gm Passed to dol_mktime * @return int|string Date as a timestamp, '' or false if error + * + * @see dol_mktime() */ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') { @@ -3647,7 +3649,7 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '') * @param int $month Month (1 to 12) * @param int $day Day (1 to 31) * @param int $year Year - * @param mixed $gm True or 1 or 'gmt'=Input information are GMT values + * @param bool|int|string $gm True or 1 or 'gmt'=Input information are GMT values * False or 0 or 'tzserver' = local to server TZ * 'auto' * 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented. diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 95bb39f7f3f..29595dc17a2 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -85,11 +85,11 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); +$canread = 0; if (($id > 0) || $ref) { $object->fetch($id, $ref); // Check current user can read this leave request - $canread = 0; if ($user->hasRight('holiday', 'readall')) { $canread = 1; } @@ -169,10 +169,10 @@ if (empty($reshook)) { $db->begin(); - $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 = GETPOSTDATE('date_debut_', '00:00:00'); + $date_fin = GETPOSTDATE('date_fin_', '00:00:00'); + $date_debut_gmt = GETPOSTDATE('date_debut_', '00:00:00', 1); + $date_fin_gmt = GETPOSTDATE('date_fin_', '00:00:00', 1); $starthalfday = GETPOST('starthalfday'); $endhalfday = GETPOST('endhalfday'); $type = GETPOST('type'); @@ -325,10 +325,10 @@ if (empty($reshook)) { } if ($action == 'update' && !GETPOSTISSET('savevalidator')) { // Test on permission done later - $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 = GETPOSTDATE('date_debut_', '00:00:00'); + $date_fin = GETPOSTDATE('date_fin_', '00:00:00'); + $date_debut_gmt = GETPOSTDATE('date_debut_', '00:00:00', 1); + $date_fin_gmt = GETPOSTDATE('date_fin_', '00:00:00', 1); $starthalfday = GETPOST('starthalfday'); $endhalfday = GETPOST('endhalfday'); $halfday = 0; @@ -542,6 +542,9 @@ if (empty($reshook)) { } elseif ($object->halfday == 0 || $object->halfday == 2) { $starthalfdaykey = "Morning"; $endhalfdaykey = "Afternoon"; + } else { + $starthalfdaykey = ""; + $endhalfdaykey = ""; } $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; @@ -1154,7 +1157,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if (!GETPOST('date_debut_')) { // If visitor does not come from agenda print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year')); + $tmpdate = GETPOSTDATE('date_debut_', '00:00:00'); print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); } print '     '; @@ -1171,7 +1174,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if (!GETPOST('date_fin_')) { print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_fin_month'), GETPOSTINT('date_fin_day'), GETPOSTINT('date_fin_year')); + $tmpdate = GETPOSTDATE('date_fin_', '00:00:00'); print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1); } print '     '; @@ -1349,7 +1352,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); print ''; print ''; - $tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year')); + $tmpdate = GETPOSTDATE('date_debut_', '00:00:00'); print $form->selectDate($tmpdate ? $tmpdate : $object->date_debut, 'date_debut_'); print '     '; print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday') ? GETPOST('starthalfday') : $starthalfday)); @@ -1650,9 +1653,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print '
'; print ''; // ancre - $includedocgeneration = 0; - // Documents + /* $includedocgeneration = 0; if ($includedocgeneration) { $objref = dol_sanitizeFileName($object->ref); $relativepath = $objref.'/'.$objref.'.pdf'; @@ -1661,7 +1663,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $genallowed = ($user->hasRight('holiday', 'read') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'readall'); // If you can read, you can build the PDF to read content $delallowed = ($user->hasRight('holiday', 'write') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'writeall_advance'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('holiday:Holiday', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - } + } */ // Show links to link elements //$tmparray = $form->showLinkToObjectBlock($object, null, array('myobject'), 1); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index aa2406f6cc8..8621d9aca3c 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -170,7 +170,7 @@ class pdf_standard_myobject extends ModelePDFMyObject public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; + global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); @@ -854,8 +854,8 @@ class pdf_standard_myobject extends ModelePDFMyObject * Show table for lines * * @param TCPDF|TCPDI $pdf Object PDF - * @param int $tab_top Top position of table - * @param int $tab_height Height of table (rectangle) + * @param float $tab_top Top position of table + * @param float $tab_height Height of table (rectangle) * @param int $nexY Y (not used) * @param Translate $outputlangs Langs object * @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php index 47d372c68ab..009d9876cb2 100644 --- a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2019 Laurent Destailleur + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * Copyright (C) ---Replace with your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -17,6 +18,11 @@ * along with this program. If not, see . */ +/** + * @var CommonObject $object + * @var Translate $langs + * @var User $user + */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL";