Fix php 8.1 warnings

This commit is contained in:
lmarcouiller 2022-10-28 15:48:46 +02:00
parent c9f43dc7a6
commit bbebdbb840
21 changed files with 40 additions and 32 deletions

View File

@ -704,7 +704,7 @@ if (empty($reshook)) {
// Clone
if ($permissiontoadd) {
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=bom', 'clone', $permissiontoadd);
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=bom', 'clone', $permissiontoadd);
}
// Close / Cancel

View File

@ -435,7 +435,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
$newlang = !empty($object->thirdparty->default_lang) ? $object->thirdparty->default_lang : "";
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);

View File

@ -5060,7 +5060,7 @@ class Form
$more .= $input['label'].'</div><div class="tagtd left">';
}
if ($input['type'] == 'select') {
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
$more .= $this->selectarray($input['name'], $input['values'], !empty($input['default']) ? $input['default'] : '-1', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
} else {
$more .= $this->multiselectarray($input['name'], $input['values'], is_array($input['default']) ? $input['default'] : [$input['default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr);
}

View File

@ -1610,7 +1610,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// Duration
print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0;
if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0;
$totalforeachday[$preselectedday] += $dayWorkLoad;
$alreadyspent = '';
@ -1990,7 +1991,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$modeinput = 'hours';
for ($idw = 0; $idw < 7; $idw++) {
$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
$cssonholiday = '';
if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
$cssonholiday .= 'onholidayallday ';
@ -2001,14 +2002,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
$tmparray = dol_getdate($tmpday);
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
$dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
$totalforeachday[$tmpday] += $dayWorkLoad;
$alreadyspent = '';
if ($dayWorkLoad > 0) {
$alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
}
$alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']);
$alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']);
global $numstartworkingday, $numendworkingday;
$cssweekend = '';
@ -2288,7 +2289,8 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
$year = $firstdaytoshowarray['year'];
$month = $firstdaytoshowarray['mon'];
foreach ($TWeek as $weekIndex => $weekNb) {
$weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
$weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
$totalforeachweek[$weekNb] += $weekWorkLoad;
$alreadyspent = '';

View File

@ -49,7 +49,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moc
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$TBomLineId = GETPOST('bomlineid', 'array');
//$lineid = GETPOST('lineid', 'int');
$lineid = GETPOST('lineid', 'int');
$socid = GETPOST("socid", 'int');
// Initialize technical objects
$object = new Mo($db);
@ -678,7 +679,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone
if ($permissiontoadd) {
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=mo', 'clone', $permissiontoadd);
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=mo', 'clone', $permissiontoadd);
}
// Cancel - Reopen
@ -725,7 +726,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$filedir = $conf->mrp->dir_output.'/'.$objref;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card
$delallowed = $user->hasRight("mrp", "creer"); // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang);
// Show links to link elements

View File

@ -47,7 +47,8 @@ $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mostockmovement'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
//$lineid = GETPOST('lineid', 'int');
$massaction = GETPOST('massaction', 'aZ09');
$lineid = GETPOST('lineid', 'int');
$msid = GETPOST('msid', 'int');
$year = GETPOST("year", 'int');

View File

@ -403,6 +403,7 @@ class FormProduct
dol_syslog(get_class($this)."::selectWorkstations $selected, $htmlname, $empty, $disabled, $fk_product, $empty_label, $forcecombo, $morecss", LOG_DEBUG);
$filterstatus='';
$out = '';
if (!empty($fk_product) && $fk_product > 0) {
$this->cache_workstations = array();

View File

@ -126,7 +126,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This may be
/*
* Number of products and/or services
*/
if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) {
if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
$prodser = array();
$prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
$prodser[0]['sell'] = 0;
@ -284,7 +284,7 @@ print '</div><div class="fichetwothirdright">';
/*
* Latest modified products
*/
if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) {
if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
$max = 15;
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
$sql .= " p.entity,";

View File

@ -1909,7 +1909,7 @@ if ($resql) {
// Status (to sell)
if (!empty($arrayfields['p.tosell']['checked'])) {
print '<td class="center nowrap">';
if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else {
print $product_static->LibStatut($obj->tosell, 5, 0);
@ -1922,7 +1922,7 @@ if ($resql) {
// Status (to buy)
if (!empty($arrayfields['p.tobuy']['checked'])) {
print '<td class="center nowrap">';
if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
print $product_static->LibStatut($obj->tobuy, 5, 1);

View File

@ -709,7 +709,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}

View File

@ -524,7 +524,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}

View File

@ -747,7 +747,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}

View File

@ -2046,7 +2046,7 @@ class Project extends CommonObject
$sql .= " AND pt.fk_projet = ".((int) $this->id);
$sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
$sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')";
if ($task_id) {
if ($taskid) {
$sql .= " AND ptt.fk_task=".((int) $taskid);
}
if (is_numeric($userid)) {

View File

@ -254,7 +254,7 @@ class RecruitmentJobPosition extends CommonObject
// Reset some properties
unset($object->id);
unset($object->fk_user_creat);
unset($object->import_key);
$object->import_key = null;
// Clear fields
if (property_exists($object, 'ref')) {

View File

@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
$upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php

View File

@ -43,7 +43,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
//$lineid = GETPOST('lineid', 'int');
$lineid = GETPOST('lineid', 'int');
// Initialize technical objects
$object = new RecruitmentCandidature($db);
@ -565,7 +565,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone
if ($permissiontoadd) {
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd);
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd);
}
// Button to convert into a user

View File

@ -47,6 +47,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((e
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ');
$lineid = GETPOST('lineid', 'int');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -437,7 +438,7 @@ if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action !=
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {

View File

@ -48,7 +48,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
$upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php

View File

@ -42,7 +42,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
//$lineid = GETPOST('lineid', 'int');
$lineid = GETPOST('lineid', 'int');
// Initialize technical objects
$object = new RecruitmentJobPosition($db);
@ -279,6 +279,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
if ($action == 'closeas') {
$text = "";
//Form to close proposal (signed or not)
$formquestion = array(
array('type' => 'select', 'name' => 'status', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))),
@ -340,7 +341,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
@ -435,7 +436,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone
if ($permissiontoadd) {
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd);
print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd);
}
/*

View File

@ -148,7 +148,7 @@ if ($object->id) {
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {

View File

@ -53,7 +53,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
$upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) {
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {