From a24071492eb4bca739f4e51c99958eb6b800479b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Oct 2020 05:45:36 +0100 Subject: [PATCH] Start fix for php8 compatibility --- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/mails_senderprofile_list.php | 2 +- htdocs/admin/modules.php | 4 ++-- htdocs/asset/list.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 1 - htdocs/core/class/html.formother.class.php | 1 + htdocs/core/db/DoliDB.class.php | 2 +- htdocs/core/get_info.php | 15 +++++++++------ htdocs/core/js/lib_notification.js.php | 2 +- htdocs/core/lib/functions.lib.php | 17 ++++++++++------- .../class/DataCollector/DolibarrCollector.php | 4 ++-- .../class/emailcollector.class.php | 2 +- .../class/emailcollectoraction.class.php | 2 +- .../class/emailcollectorfilter.class.php | 2 +- htdocs/index.php | 2 +- htdocs/main.inc.php | 17 +++++++++++------ .../template/class/myobject.class.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/class/mo.class.php | 4 ++-- htdocs/mrp/mo_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- .../class/recruitmentcandidature.class.php | 2 +- .../class/recruitmentjobposition.class.php | 2 +- .../recruitment/recruitmentcandidature_list.php | 2 +- .../recruitment/recruitmentjobposition_list.php | 2 +- htdocs/societe/class/societe.class.php | 6 ++++-- htdocs/ticket/list.php | 2 +- 34 files changed, 68 insertions(+), 55 deletions(-) diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 98dcfd592a2..6e868d73728 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -393,7 +393,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 4556ec80bff..488997b5b78 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -474,7 +474,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index e281cb21155..c97ccb182b8 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -281,7 +281,7 @@ if ($action == 'set' && $user->admin) $form = new Form($db); -//$morejs = array("/admin/dolistore/js/dolistore.js.php"); +$morejs = array(); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed @@ -402,7 +402,7 @@ foreach ($modulesdir as $dir) $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } - $familyposition = $familyinfo[$familykey]['position']; + $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); if ($external && ! in_array($familykey, $listOfOfficialModuleGroups)) { diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index ef3ea4ce975..2a7271fed4a 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -386,7 +386,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 7687ab250ac..02cee1c4d90 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -486,7 +486,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4e5d28274a8..4a341ce2c8b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -204,7 +204,7 @@ class BOM extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { @@ -1145,7 +1145,7 @@ class BOMLine extends CommonObjectLine // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index b41e46aff76..55ad8914a9e 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -390,7 +390,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); else print ''; print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6e0a3a0e195..10c844f3149 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -281,7 +281,7 @@ class Contact extends CommonObject { foreach($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5371b8078fa..ef062b8acaf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6410,7 +6410,7 @@ abstract class CommonObject $type = 'varchar'; // convert varchar(xx) int varchar $size = $reg[1]; } elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar - if (is_array($val['arrayofkeyval'])) $type = 'select'; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $type = 'select'; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link'; $default = $val['default']; @@ -6420,7 +6420,7 @@ abstract class CommonObject $param = array(); $param['options'] = array(); - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { $type = 'link'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bf52ff5871a..42468973a69 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -509,7 +509,6 @@ class Form * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string Code html du tooltip (texte+picto) * @see textwithpicto() Use thisfunction if you can. - * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5d3bd181753..7606779afe5 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1152,6 +1152,7 @@ class FormOther } // Define boxlista and boxlistb + $boxlista = ''; $boxlistb = ''; $nbboxactivated = count($boxidactivatedforuser); if ($nbboxactivated) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 481a4669dc6..170fa42cde3 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -248,7 +248,7 @@ abstract class DoliDB implements Database $return .= preg_replace('/[^0-9a-z_\.]/i', '', $val); // Add field - $tmpsortorder = trim($orders[$i]); + $tmpsortorder = (empty($orders[$i]) ? '' : trim($orders[$i])); // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index 48b957b9e8a..a91d5a6afec 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -60,8 +60,6 @@ print ''."\n"; print '
'; //print '
'; -$nbofsearch = 0; - // Define link to login card $appli = constant('DOL_APPLICATION_TITLE'); if (!empty($conf->global->MAIN_APPLICATION_TITLE)) @@ -117,6 +115,11 @@ if (is_numeric($result)) else $toprightmenu = $hookmanager->resPrint; // replace } else $toprightmenu .= $result; // For backward compatibility +if (!isset($form) || !is_object($form)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); +} + // Link to module builder if (!empty($conf->modulebuilder->enabled)) { @@ -124,7 +127,7 @@ if (!empty($conf->modulebuilder->enabled)) //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); } // Link to print main content area @@ -144,7 +147,7 @@ if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OP //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); $text.=''; $text.=''; - $toprightmenu.=@Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); + $toprightmenu .= $form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); } */ @@ -183,13 +186,13 @@ if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPT //if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')'; $text.=''; //$toprightmenu.='
'."\n"; - $toprightmenu.=@Form::textwithtooltip('',$title,2,1,$text,'login_block_elem',2); + $toprightmenu .= $form->textwithtooltip('',$title,2,1,$text,'login_block_elem',2); } } */ // Logout link -if (GETPOST('withlogout', 'int')) $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2); +if (GETPOST('withlogout', 'int')) $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2); $toprightmenu .= ''; diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index ee212b4373f..23290f220bd 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -51,7 +51,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP /* Launch timer */ // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. //var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds - var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; + var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; if (login != '') { setTimeout(first_execution, time_first_execution * 1000); time_js_next_test = nowtime + time_first_execution; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df2eab61378..94e7ee85586 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -185,6 +185,7 @@ function getBrowserInfo($user_agent) if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; } // Name + $reg = array(); if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end @@ -3344,13 +3345,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. // class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes. + $morestyle = ''; $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { - $morestyle = ' '.$reg[1]; + $morestyle = $reg[1]; $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); } $moreatt = trim($moreatt); @@ -6484,11 +6486,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $tmp4 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp5 = dol_get_next_month($tmp['mon'], $tmp['year']); + $daytext = $outputlangs->trans('Day'.$tmp['wday']); + $substitutionarray = array_merge($substitutionarray, array( '__DAY__' => (string) $tmp['mday'], - '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday - '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon - '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M + '__DAY_TEXT__' => $daytext, // Monday + '__DAY_TEXT_SHORT__' => dol_trunc($daytext, 3, 'right', 'UTF-8', 1), // Mon + '__DAY_TEXT_MIN__' => dol_trunc($daytext, 1, 'right', 'UTF-8', 1), // M '__MONTH__' => (string) $tmp['mon'], '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])), '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])), @@ -7198,8 +7202,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1) global $soc; // For backward compatibility //print $s."
\n"; - if ($returnvalue) - { + if ($returnvalue) { if ($hideerrors) return @eval('return '.$s.';'); else return eval('return '.$s.';'); } else { @@ -7602,7 +7605,7 @@ function printCommonFooter($zone = 'private') // A div to store page_y POST parameter so we can read it using javascript print "\n\n"; - print ''."\n"; + print ''."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php index b1b31bc9154..2e11887360f 100644 --- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -91,8 +91,8 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid $info .= $langs->trans('Port').': '.$conf->global->MAIN_MAIL_SMTP_PORT.'
'; $info .= $langs->trans('ID').': '.$conf->global->MAIN_MAIL_SMTPS_ID.'
'; $info .= $langs->trans('Pwd').': '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'; - $info .= $langs->trans('TLS/STARTTLS').': '.$conf->global->MAIN_MAIL_EMAIL_TLS.' / '.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'
'; - $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('Yes') : $langs->trans('No')).'
'; + $info .= $langs->trans('TLS/STARTTLS').': '.(empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_TLS).' / '.(empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_STARTTLS).'
'; + $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(empty($conf->global->MAIN_DISABLE_ALL_MAILS) ? $langs->trans('No') : $langs->trans('Yes')).'
'; $info .= 'dolibarr_mailing_limit_sendbyweb = '.$dolibarr_mailing_limit_sendbyweb.'
'; return $info; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 943b7c73fb3..aed02f40531 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -227,7 +227,7 @@ class EmailCollector extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index ed6942f34d6..604ed6a2d11 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -170,7 +170,7 @@ class EmailCollectorAction extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index cb8db05fa34..217416cbe89 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -139,7 +139,7 @@ class EmailCollectorFilter extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/index.php b/htdocs/index.php index ebc343b5e8d..952ff525258 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -68,7 +68,7 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis * View */ -if (!is_object($form)) $form = new Form($db); +if (!isset($form) || !is_object($form)) $form = new Form($db); // Title $title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 77958deca5f..4f1266c0afd 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1566,6 +1566,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead */ if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { + if (!isset($form) || !is_object($form)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $form = new Form($db); + } + print "\n".''."\n"; print '
'; // dol_invisible_topmenu differs from dol_hide_topmenu: dol_invisible_topmenu means we output menu but we make it invisible. @@ -1632,7 +1637,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2); } // Link to print main content area @@ -1651,7 +1656,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $langs->trans("PrintContentArea"), 2, 1, $text, 'login_block_elem', 2); } // Link to Dolibarr wiki pages @@ -1688,7 +1693,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $text .= '">'; $text .= ''; $text .= ''; - $toprightmenu .= @Form::textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2); } // Version @@ -1700,11 +1705,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $text = ''.DOL_VERSION.''; - $toprightmenu .= @Form::textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); + $toprightmenu .= $form->textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); } // Logout link - $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem logout-btn', 2); + $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem logout-btn', 2); $toprightmenu .= '
'; // end div class="login_block_other" @@ -1747,7 +1752,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead print "\n\n"; } - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 2c03c3dd2a9..dd802953c2d 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -254,7 +254,7 @@ class MyObject extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 4e21ea4f46c..db532d7412c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -445,7 +445,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cf4b4ccddd1..cfc34f4a637 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -223,7 +223,7 @@ class Mo extends CommonObject // Translate some data of arrayofkeyval foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { @@ -1436,7 +1436,7 @@ class MoLine extends CommonObjectLine { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 7734e992d48..3303c2a92b4 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -392,7 +392,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 5a19906d088..879a6196450 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -371,7 +371,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 57051393893..33923985d9a 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -419,7 +419,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 95123b7c873..e03de931a58 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -377,7 +377,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index df96744526b..5f3b1d076c6 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -222,7 +222,7 @@ class RecruitmentCandidature extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index ffe2a1373e8..0be2cfbc310 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -236,7 +236,7 @@ class RecruitmentJobPosition extends CommonObject { foreach ($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach ($val['arrayofkeyval'] as $key2 => $val2) { diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 1354dd9611f..7442523b7d3 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -433,7 +433,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 03f558b3d4a..cfc237af267 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -433,7 +433,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3fcc7e610ac..27d99cb778d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1509,8 +1509,10 @@ class Societe extends CommonObject $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; - $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; + $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; + $sql .= ', s.fk_account, s.tva_assuj'; + $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mod_supplier'; + $sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; $sql .= ', s.order_min_amount, s.supplier_order_min_amount'; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 7b456e70f02..cd5afe018f2 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -663,7 +663,7 @@ foreach ($object->fields as $key => $val) print ''; } else { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';