From fee2005faacd0796c4b60d653ca2b67d29f82761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Wed, 8 Jan 2025 14:41:45 +0100 Subject: [PATCH 1/6] FIX: reception picto alignement in product menu --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8bfe214c523..a3d10ee3d14 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2222,7 +2222,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme // Receptions if (isModEnabled('reception')) { $langs->load("receptions"); - $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->hasRight('reception', 'lire'), '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->hasRight('reception', 'lire'), '', $mainmenu, 'receptions', 0, '', '', '', img_picto('', 'dollyrevert', 'class="pictofixedwidth", style="text-align: right;"')); $newmenu->add("/reception/card.php?action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->hasRight('reception', 'creer')); $newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->hasRight('reception', 'lire')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") { From b9419a869c43ced535cf41877f563cdffb6fd1e2 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 8 Jan 2025 13:47:18 +0100 Subject: [PATCH 2/6] purchasesjournal: fix empty IN () SQL request `WHERE xx IN ()` is not allowed in PostgreSQL queries, and result in the following fatal error: GROUP BY fk_facture_fourn 33 DoliDBPgsql::query SQL Error message: ERROR: 42601: syntax error at or near ")" LINE 10: AND fk_facture_fourn IN () ^ We can check whether we have valid invoices before running the query, since the query will only check whether the invoices are complete or not. It also fixes the following error on the development PHP output. Fatal error: Uncaught TypeError: pg_num_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given in /var/www/html/core/db/pgsql.class.php:654 Stack trace: #0 /var/www/html/core/db/pgsql.class.php(654): pg_num_rows(false) #1 /var/www/html/accountancy/journal/purchasesjournal.php(418): DoliDBPgsql->num_rows(false) #2 {main} thrown in /var/www/html/core/db/pgsql.class.php on line 654 Fixes #32374 --- .../accountancy/journal/purchasesjournal.php | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 1c64cc8934a..437b436b733 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -399,34 +399,34 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice } } */ + // New way, single query, load all unbound lines -$sql = " -SELECT - fk_facture_fourn, - COUNT(fd.rowid) as nb -FROM - " . MAIN_DB_PREFIX . "facture_fourn_det as fd -WHERE - fd.product_type <= 2 - AND fd.fk_code_ventilation <= 0 - AND fd.total_ttc <> 0 - AND fk_facture_fourn IN (".$db->sanitize(implode(",", array_keys($tabfac))).") -GROUP BY fk_facture_fourn -"; -$resql = $db->query($sql); +if (!empty($tabfac)) { + $sql = " + SELECT + fk_facture_fourn, + COUNT(fd.rowid) as nb + FROM + " . MAIN_DB_PREFIX . "facture_fourn_det as fd + WHERE + fd.product_type <= 2 + AND fd.fk_code_ventilation <= 0 + AND fd.total_ttc <> 0 + AND fk_facture_fourn IN (".$db->sanitize(implode(",", array_keys($tabfac))).") + GROUP BY fk_facture_fourn + "; + $resql = $db->query($sql); -$num = $db->num_rows($resql); -$i = 0; -while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_facture_fourn] = 'somelinesarenotbound'; + } + $i++; } - $i++; } -//var_dump($errorforinvoice);exit; - - // Bookkeeping Write if ($action == 'writebookkeeping' && !$error && $user->hasRight('accounting', 'bind', 'write')) { From 5d778eedab385667424397c4229a74d67f73bc7f Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 8 Jan 2025 14:37:07 +0100 Subject: [PATCH 3/6] expensereportsjournal: fix empty IN () SQL request `WHERE xx IN ()` is not allowed in PostgreSQL queries, and result in fatal errors. We can check whether we have valid invoices before running the query, since the query will only check whether the invoices are complete or not. It also fixes the following error on the development PHP output: Fatal error: Uncaught TypeError: pg_num_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given in /var/www/html/core/db/pgsql.class.php:654 Stack trace: #0 /var/www/html/core/db/pgsql.class.php(654): pg_num_rows(false) #1 /var/www/html/accountancy/journal/expensereportsjournal.php(264): DoliDBPgsql->num_rows(false) #2 {main} thrown in /var/www/html/core/db/pgsql.class.php on line 654 Refs #32374 but for the expensereportsjournal page. --- .../journal/expensereportsjournal.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index fb88ad3ac40..21131a25177 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -253,22 +253,24 @@ if ($result) { } // Load all unbound lines -$sql = "SELECT fk_expensereport, COUNT(erd.rowid) as nb"; -$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; -$sql .= " WHERE erd.fk_code_ventilation <= 0"; -$sql .= " AND erd.total_ttc <> 0"; -$sql .= " AND fk_expensereport IN (".$db->sanitize(implode(",", array_keys($taber))).")"; -$sql .= " GROUP BY fk_expensereport"; -$resql = $db->query($sql); +if (!empty($taber)) { + $sql = "SELECT fk_expensereport, COUNT(erd.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " WHERE erd.fk_code_ventilation <= 0"; + $sql .= " AND erd.total_ttc <> 0"; + $sql .= " AND fk_expensereport IN (".$db->sanitize(implode(",", array_keys($taber))).")"; + $sql .= " GROUP BY fk_expensereport"; + $resql = $db->query($sql); -$num = $db->num_rows($resql); -$i = 0; -while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj->nb > 0) { - $errorforinvoice[$obj->fk_expensereport] = 'somelinesarenotbound'; + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj->nb > 0) { + $errorforinvoice[$obj->fk_expensereport] = 'somelinesarenotbound'; + } + $i++; } - $i++; } // Bookkeeping Write From 8cdd88e27d230a2cee09836e2663bae1657da27c Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Wed, 8 Jan 2025 14:51:08 +0100 Subject: [PATCH 4/6] bookkeeping: listbyaccount: fix $num_rows warning Fix the following warning: Warning: Undefined property: PgSql\Result::$num_rows in /var/www/html/accountancy/bookkeeping/listbyaccount.php on line 160 The warning is happening when listing the operations after the accounting setup is done but no accounts for bank nor operations are created. --- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 17663bf411b..8f9d300d893 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -157,7 +157,7 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc $sql .= $db->plimit(1); $res = $db->query($sql); - if ($res->num_rows > 0) { + if ($res !== false && $db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); $search_date_end = strtotime($fiscalYear->date_end); From 4ab4c2772b9a5d9f831cf61d885757a5803c78af Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 8 Jan 2025 19:26:14 +0100 Subject: [PATCH 5/6] FIX compatibility with xdebug 3 --- htdocs/admin/system/perf.php | 2 +- htdocs/admin/system/xdebug.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 3ebd9607449..09b6e73ba2a 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -83,7 +83,7 @@ print "
\n"; print '
'; print ''.$langs->trans("XDebug").'
'; print '
'; -$test = !function_exists('xdebug_is_enabled'); +$test = !function_exists('xdebug_is_debugger_active'); if ($test) { print img_picto('', 'tick.png', 'class="pictofixedwidth"').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index 3151234ea2a..7150c5d0647 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -48,7 +48,7 @@ llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_xdebug'); print load_fiche_titre("XDebug", '', 'title_setup'); -if (!function_exists('xdebug_is_enabled')) { +if (!function_exists('xdebug_is_debugger_active')) { print "
\n"; print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.'; llxFooter(); @@ -62,8 +62,8 @@ print ''; print '

'; if (function_exists('socket_create')) { - $address = ini_get('xdebug.remote_host') ? ini_get('xdebug.remote_host') : '127.0.0.1'; - $port = ini_get('xdebug.remote_port') ? ini_get('xdebug.remote_port') : 9000; + $address = ini_get('xdebug.client_host') ? ini_get('xdebug.client_host') : '127.0.0.1'; + $port = ini_get('xdebug.client_port') ? (int) ini_get('xdebug.client_port') : 9000; print "Current xdebug setup:
\n"; print "* Remote debug setup:
\n"; From 929aa8ee91414a9868e7058a85cfeb9ea1578db3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 8 Jan 2025 20:32:19 +0100 Subject: [PATCH 6/6] FIX avoid warnings + debug --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formsetup.class.php | 4 ++-- htdocs/public/webportal/tpl/header_login.tpl.php | 6 +++--- htdocs/webportal/controllers/document.controller.class.php | 4 ++-- htdocs/website/websiteaccount_card.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a23db2adf8a..83dbfbc5979 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -11663,7 +11663,7 @@ class Form foreach ($buttons as $button) { $addclass = empty($button['addclass']) ? '' : $button['addclass']; - $retstring .= ''; + $retstring .= ''; } $retstring .= $withoutdiv ? '' : '
'; diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 6b1ab1cb007..ce549b8f52f 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -906,8 +906,8 @@ class FormSetupItem } elseif ($this->type == 'yesno') { if (!empty($conf->use_javascript_ajax)) { $input = $this->fieldParams['input'] ?? array(); - $revertonoff = $this->fieldParams['revertonoff'] ? 1 : 0; - $forcereload = $this->fieldParams['forcereload'] ? 1 : 0; + $revertonoff = isset($this->fieldParams['revertonoff']) ? 1 : 0; + $forcereload = isset($this->fieldParams['forcereload']) ? 1 : 0; $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload); } else { diff --git a/htdocs/public/webportal/tpl/header_login.tpl.php b/htdocs/public/webportal/tpl/header_login.tpl.php index 813c6a15b6c..b0c9d1402f0 100644 --- a/htdocs/public/webportal/tpl/header_login.tpl.php +++ b/htdocs/public/webportal/tpl/header_login.tpl.php @@ -28,17 +28,17 @@ global $langs; rootUrl.'includes/jquery/plugins/jnotify/jquery.jnotify.css'; $jNotifyCSSUrl = dol_buildpath('/includes/jquery/plugins/jnotify/jquery.jnotify.min.css', 2); - print ''; + print ''."\n"; // JQuery //$jQueryJSUrl = $context->rootUrl.'includes/jquery/js/jquery.js'; $jQueryJSUrl = dol_buildpath('/includes/jquery/js/jquery.js', 2); - print ''; + print ''."\n"; // JNotify //$jNotifyJSUrl = $context->rootUrl.'includes/jquery/plugins/jnotify/jquery.jnotify.js'; $jNotifyJSUrl = dol_buildpath('/includes/jquery/plugins/jnotify/jquery.jnotify.min.js', 2); - print ''; + print ''."\n"; ?> diff --git a/htdocs/webportal/controllers/document.controller.class.php b/htdocs/webportal/controllers/document.controller.class.php index 2efd83fd953..3a0d338c917 100644 --- a/htdocs/webportal/controllers/document.controller.class.php +++ b/htdocs/webportal/controllers/document.controller.class.php @@ -212,8 +212,8 @@ class DocumentController extends Controller exit; } - $fileSize = dol_filesize($fullpath_original_file); - $fileSizeMaxDefault = 20 * 1024; // 20 Mo by default + $fileSize = dol_filesize($fullpath_original_file); // the returned value is in byte + $fileSizeMaxDefault = 20 * 1024 * 1024; // 20 Mo by default $fileSizeMax = getDolGlobalInt('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', $fileSizeMaxDefault); if ($fileSize > $fileSizeMax) { dol_syslog('ErrorFileSizeTooLarge: ' . $fileSize); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 846b1e57d44..858ac1ead2a 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -93,7 +93,7 @@ if ($object->id > 0) { $permissiontocreate = isModEnabled('website') && $user->hasRight('website', 'write'); $permissiontodelete = isModEnabled('website') && $user->hasRight('website', 'delete'); } elseif ($object->site == 'dolibarr_portal') { - $permissiontocreate = isModEnabled('webportal') && $user->hasRight('webportal', 'write'); + $permissiontocreate = $permissiontodelete = isModEnabled('webportal') && $user->hasRight('webportal', 'write'); } } else { $permissiontocreate = isModEnabled('website') && $user->hasRight('website', 'write') || isModEnabled('webportal') && $user->hasRight('webportal', 'write');