From c45b7fb84445307d57ba3c23cfa63418d7b80892 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:24:33 +0200 Subject: [PATCH 01/12] fix undefined array key (#28048) --- htdocs/compta/recap-compta.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 4998d3a653f..6757ce15011 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -247,6 +247,9 @@ if ($id > 0) { $balance = 0; foreach ($TData as &$data1) { $balance += $data1['amount']; + if (!isset($data1['balance'])) { + $data1['balance'] = 0; + } $data1['balance'] += $balance; } From 66604c12d3218ce697804aae40fe401976fd035f Mon Sep 17 00:00:00 2001 From: Ikarus <44511582+LeKarSol@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:25:13 -0500 Subject: [PATCH 02/12] Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) --- htdocs/install/mysql/data/llx_10_c_regions.sql | 6 ++++++ .../mysql/data/llx_20_c_departements.sql | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 3a08a73fa6f..a88d05e2ff8 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -558,3 +558,9 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23208, '', 0, 'Nor-Oriental'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23209, '', 0, 'Zuliana'); +-- Cuba Regions (id_country=77) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7700, '', 0, 'Cuba'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7701, '', 0, 'Occidente'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7702, '', 0, 'Centro'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7703, '', 0, 'Occidente'); + diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 59127065612..14f0ab419e2 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -2041,3 +2041,21 @@ INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-78 INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-79',22105,'Kilis'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-80',22104,'Osmaniye'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce'); + +-- Provinces Cuba (id country=77) +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-PRI', 7701, 'Pinar del Rio'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-ART', 7701, 'Artemisa'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-HAB', 7701, 'La Habana'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-MYB', 7701, 'Mayabeque'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-MTZ', 7701, 'Matanzas'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-IJV', 7701, 'Isla de la Juventud'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-VLC', 7702, 'Villa Calra'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CFG', 7702, 'Cienfuegos'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-SSP', 7702, 'Sancti Spiritus'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CAV', 7702, 'Ciego de Avila'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CMG', 7702, 'Camagüey'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-LTU', 7703, 'Las Tunas'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-GRM', 7703, 'Granma'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-SCU', 7703, 'Santiago de Cuba'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-GTM', 7703, 'Guantanamo'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-HLG', 7703, 'Holguin'); From 43ec918e63c4fef46c1e946272edb8ae05656d83 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 8 Feb 2024 02:07:05 +0100 Subject: [PATCH 03/12] FIX #27670 Qual clean ticket libstatut method (#28025) * Fixed empty labelStatus. Refactored logic. * Added contributor details * Cleaned PHPDoc --- htdocs/ticket/class/ticket.class.php | 68 ++++++++++++++++------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index b7c75c7a2e9..d4d498ab18d 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2020 Laurent Destailleur * Copyright (C) 2023 Charlene Benke * Copyright (C) 2023 Benjamin Falière + * Copyright (C) 2024 William Mead * * 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 @@ -1410,43 +1411,52 @@ class Ticket extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return status label of object + * Return status label of object * - * @param string $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @param int $notooltip 1=No tooltip - * @param int $progress Progression (0 to 100) - * @return string Label + * @param string $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @param int $notooltip 1=No tooltip + * @param int $progress Progression (0 to 100) + * @return string Label */ public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0) { // phpcs:enable global $langs, $hookmanager; - $labelStatus = $this->labelStatus[$status]; - $labelStatusShort = $this->labelStatusShort[$status]; + $labelStatus = !empty($status) ? $this->labelStatus[$status] : ''; + $labelStatusShort = !empty($status) ? $this->labelStatusShort[$status] : ''; - if ($status == self::STATUS_NOT_READ) { - $statusType = 'status0'; - } elseif ($status == self::STATUS_READ) { - $statusType = 'status1'; - } elseif ($status == self::STATUS_ASSIGNED) { - $statusType = 'status2'; - } elseif ($status == self::STATUS_IN_PROGRESS) { - $statusType = 'status4'; - } elseif ($status == self::STATUS_WAITING) { - $statusType = 'status7'; - } elseif ($status == self::STATUS_NEED_MORE_INFO) { - $statusType = 'status3'; - } elseif ($status == self::STATUS_CANCELED) { - $statusType = 'status9'; - } elseif ($status == self::STATUS_CLOSED) { - $statusType = 'status6'; - } else { - $labelStatus = 'Unknown'; - $labelStatusShort = 'Unknown'; - $statusType = 'status0'; - $mode = 0; + switch ($status) { + case self::STATUS_NOT_READ: + $statusType = 'status0'; + break; + case self::STATUS_READ: + $statusType = 'status1'; + break; + case self::STATUS_ASSIGNED: + $statusType = 'status2'; + break; + case self::STATUS_IN_PROGRESS: + $statusType = 'status4'; + break; + case self::STATUS_WAITING: + $statusType = 'status7'; + break; + case self::STATUS_NEED_MORE_INFO: + $statusType = 'status3'; + break; + case self::STATUS_CANCELED: + $statusType = 'status9'; + break; + case self::STATUS_CLOSED: + $statusType = 'status6'; + break; + default: + $labelStatus = 'Unknown'; + $labelStatusShort = 'Unknown'; + $statusType = 'status0'; + $mode = 0; } $parameters = array( From 8e0559f9a411b72663dd050807bfaef1ae99f845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Feb 2024 04:23:29 +0100 Subject: [PATCH 04/12] Debug v19 --- htdocs/compta/prelevement/factures.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index f1d9c22cc19..e02a1b9cb70 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals', 'suppliers')); +$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals', 'salaries', 'suppliers')); // Get supervariables $id = GETPOST('id', 'int'); From 7783575bf760119cc75f3dff95a7d4f6fb3d275c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Feb 2024 15:02:54 +0100 Subject: [PATCH 05/12] Fix bad parameter --- htdocs/core/lib/files.lib.php | 14 +++++++------- htdocs/website/samples/wrapper.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 6b4b56e1475..d8d49aa2ff2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2560,13 +2560,13 @@ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('( * Security check when accessing to a document (used by document.php, viewimage.php and webservices to get documents). * TODO Replace code that set $accessallowed by a call to restrictedArea() * - * @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp'). Exemple: 'medias', 'invoice', 'logs', 'tax-vat', ... - * @param string $original_file Relative path with filename, relative to modulepart. - * @param string $entity Restrict onto entity (0=no restriction) - * @param User $fuser User object (forced) - * @param string $refname Ref of object to check permission for external users (autodetect if not provided) or for hierarchy - * @param string $mode Check permission for 'read' or 'write' - * @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name) + * @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp'). Exemple: 'medias', 'invoice', 'logs', 'tax-vat', ... + * @param string $original_file Relative path with filename, relative to modulepart. + * @param string $entity Restrict onto entity (0=no restriction) + * @param User|null $fuser User object (forced) + * @param string $refname Ref of object to check permission for external users (autodetect if not provided) or for hierarchy + * @param string $mode Check permission for 'read' or 'write' + * @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name) * @see restrictedArea() */ function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser = '', $refname = '', $mode = 'read') diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 20d216bb948..631f27881aa 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -226,7 +226,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name From 265fff296ceff0ea93b7d074f83a68657844bb63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Feb 2024 15:06:35 +0100 Subject: [PATCH 06/12] Fix warnings Close #27917 --- .../website_template-corporate/containers/wrapper.php | 2 +- .../website_template-homesubmenu/containers/wrapper.php | 2 +- .../website_template-noimg/containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- .../website_template-restaurant/containers/wrapper.php | 2 +- .../website_template-stellar/containers/wrapper.php | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php index 621dee927cb..6958cd2eeda 100644 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php @@ -225,7 +225,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php index 621dee927cb..6958cd2eeda 100644 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php @@ -225,7 +225,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php index 621dee927cb..6958cd2eeda 100644 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php @@ -225,7 +225,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php index 621dee927cb..6958cd2eeda 100644 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php @@ -225,7 +225,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php index 621dee927cb..6958cd2eeda 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php @@ -225,7 +225,7 @@ if ($rss) { } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php index c5f8978a706..321356d20d3 100644 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php @@ -193,10 +193,10 @@ elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file } else { // Find the subdirectory name as the reference include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); - $accessallowed = $check_access['accessallowed']; - $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); + $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; + $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; + $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name if ($hashp) { $accessallowed = 1; // When using hashp, link is public so we force $accessallowed $sqlprotectagainstexternals = ''; From 0790abe5304a789db1d95340bbea3414d50a0d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 9 Feb 2024 11:35:36 +0100 Subject: [PATCH 07/12] fix social networks icons (#28078) --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index c8e753fea10..e4ffe2fda9e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1212,7 +1212,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans($value['label']).''; print ''; if (!empty($value['icon'])) { - print ''; + print ''; } if (!empty($ldap_social[$key])) { print ''; @@ -2625,7 +2625,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans($value['label']).''; print ''; if (!empty($value['icon'])) { - print ''; + print ''; } if ($caneditfield && empty($object->ldap_sid)) { print ''; From 290cb8447ac68709158af712c441eb96a2b0a13e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2024 12:12:54 +0100 Subject: [PATCH 08/12] comment --- htdocs/core/js/lib_notification.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 2f8192a29fe..41839ac3748 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -170,7 +170,7 @@ function check_events() { body: body, lang: 'getDefaultLang(1)); ?>', tag: value.id_agenda, - requireInteraction: true + requireInteraction: true /* wait that the user click or close the notification */ /* only supported for persistent notification shown using ServiceWorkerRegistration.showNotification() so disabled */ /* actions: [{ action: 'action1', title: 'New Button Label' }, { action: 'action2', title: 'Another Button' }] */ }; @@ -185,7 +185,7 @@ function check_events() { if (noti[index]) { noti[index].onclick = function (event) { - /* If the use has clicked on button Activate */ + /* If the user has clicked on button Activate */ console.log("A click on notification on browser has been done for url="+url); event.preventDefault(); // prevent the browser from focusing the Notification's tab window.focus(); From 0f53fe10d167d24fe0ce73964161d572548b8dfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2024 13:32:44 +0100 Subject: [PATCH 09/12] FIX oauth authent must be done only on click on link Better message for notification denied. --- htdocs/core/js/lib_notification.js.php | 2 +- .../modules/oauth/google_oauthcallback.php | 2 +- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/main.inc.php | 24 +++++++++++++------ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 41839ac3748..61ea425edb8 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -212,7 +212,7 @@ function check_events() { result = 1; } else { - console.log("Cancel check_events() with dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page+". Check is useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https)."); + console.log("Cancel check_events() with dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page+". Check is useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https or browser is in Private mode)."); result = 2; // We return a positive so the repeated check will done even if authroization is not yet allowed may be after this check) } diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index b48f9ec54da..be8561fa44d 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -163,7 +163,7 @@ if (!GETPOST('code')) { // Save more data into session // Not required. All data are saved into $_SESSION['datafromloginform'] when form is posted with a click on Login with - // Google with param actionlogin=login and beforeoauthloginredirect=1, by the functions_googleoauth.php. + // Google with param actionlogin=login and beforeoauthloginredirect=google, by the functions_googleoauth.php. /* if (!empty($_POST["tz"])) { $_SESSION["tz"] = $_POST["tz"]; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 05496f0cd57..13edea879ca 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -375,7 +375,7 @@ if (isset($conf->file->main_authentication) && preg_match('/google/', $conf->fil */ print ''; - print ''; + print ''; print '
'; print img_picto('', 'google', 'class="pictofixedwidth"'); print $langs->trans("LoginWith", "Google"); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 763bc15d94e..9b15733c4cf 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -680,10 +680,11 @@ if (is_array($modulepart)) { } - /* - * Phase authentication / login - */ - $login = ''; +/* + * Phase authentication / login + */ + +$login = ''; if (!defined('NOLOGIN')) { // $authmode lists the different method of identification to be tested in order of preference. // Example: 'http', 'dolibarr', 'ldap', 'http,forceuser', '...' @@ -817,7 +818,7 @@ if (!defined('NOLOGIN')) { if (GETPOST('openid_mode', 'alpha', 1)) { // For openid_connect ? $goontestloop = true; } - if (GETPOST('beforeoauthloginredirect', 'int') || GETPOST('afteroauthloginreturn')) { // For oauth login + if (GETPOST('beforeoauthloginredirect') || GETPOST('afteroauthloginreturn')) { // For oauth login $goontestloop = true; } if (!empty($_COOKIE['login_dolibarr'])) { // TODO For ? Remove this ? @@ -827,7 +828,7 @@ if (!defined('NOLOGIN')) { if (!is_object($langs)) { // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages. include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate("", $conf); - $langcode = (GETPOST('lang', 'aZ09', 1) ?GETPOST('lang', 'aZ09', 1) : (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); + $langcode = (GETPOST('lang', 'aZ09', 1) ?GETPOST('lang', 'aZ09', 1) : getDolGlobalString('MAIN_LANG_DEFAULT', 'auto')); if (defined('MAIN_LANG_DEFAULT')) { $langcode = constant('MAIN_LANG_DEFAULT'); } @@ -837,8 +838,17 @@ if (!defined('NOLOGIN')) { // Validation of login/pass/entity // If ok, the variable login will be returned // If error, we will put error message in session under the name dol_loginmesg - // Note authmode is an array for example: array('0'=>'dolibarr', '1'=>'googleoauth'); if ($test && $goontestloop && (GETPOST('actionlogin', 'aZ09') == 'login' || $dolibarr_main_authentication != 'dolibarr')) { + // Loop on each test mode defined into $authmode + // $authmode is an array for example: array('0'=>'dolibarr', '1'=>'googleoauth'); + if (in_array('googleoauth', $authmode)) { + if (GETPOST('beforeoauthloginredirect') != 'google') { + // If we did not click on the link to use OAuth authentication, we do not try it. + dol_syslog("User did not click on link for OAuth so we disable check using googleoauth"); + unset($authmode['googleoauth']); + } + } + $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); if ($login === '--bad-login-validity--') { $login = ''; From 5637dd2f3f57147465f7e416251ff10b34279575 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2024 16:15:08 +0100 Subject: [PATCH 10/12] Fix do not use oauth if link was not clicked --- htdocs/main.inc.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9b15733c4cf..7386d9d54b1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -841,11 +841,17 @@ if (!defined('NOLOGIN')) { if ($test && $goontestloop && (GETPOST('actionlogin', 'aZ09') == 'login' || $dolibarr_main_authentication != 'dolibarr')) { // Loop on each test mode defined into $authmode // $authmode is an array for example: array('0'=>'dolibarr', '1'=>'googleoauth'); - if (in_array('googleoauth', $authmode)) { - if (GETPOST('beforeoauthloginredirect') != 'google') { + $oauthmodetotestarray = array('google'); + foreach ($oauthmodetotestarray as $oauthmodetotest) { + if (in_array($oauthmodetotest.'oauth', $authmode) && GETPOST('beforeoauthloginredirect') != $oauthmodetotest) { // If we did not click on the link to use OAuth authentication, we do not try it. dol_syslog("User did not click on link for OAuth so we disable check using googleoauth"); - unset($authmode['googleoauth']); + foreach ($authmode as $tmpkey => $tmpval) { + if ($tmpval == $oauthmodetotest.'oauth') { + unset($authmode[$tmpkey]); + break; + } + } } } From c1c7b04cba8fab9afd26a3083570eba375b56025 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Feb 2024 12:02:09 +0100 Subject: [PATCH 11/12] Debug v19 --- htdocs/takepos/index.php | 36 ++++++++++++++++++++++++++++-------- htdocs/takepos/invoice.php | 10 ++++++---- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 993b3595863..d240ce40273 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -85,7 +85,7 @@ if ($conf->browser->layout == 'phone') { $maxcategbydefaultforthisdevice = 8; $maxproductbydefaultforthisdevice = 16; //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT FORCED - if (!empty($_SESSION["takeposterminal"]) && getDolGlobalInt('TAKEPOS_PHONE_BASIC_LAYOUT') == 1) { + if (!empty($_SESSION["takeposterminal"]) && getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_PHONE_BASIC_LAYOUT') == 1) { $_SESSION["basiclayout"] = 1; header("Location: phone.php?mobilepage=invoice"); exit; @@ -243,6 +243,7 @@ function PrintCategories(first) { $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); + $("#catdiv"+i).attr("data-rowid",categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).attr('class', 'wrapper'); $("#catwatermark"+i).show(); } @@ -285,6 +286,7 @@ function MoreCategories(moreorless) { $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+( * pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+( * pagecategories)]['rowid']); + $("#catdiv"+i).attr("data-rowid",categories[i+( * pagecategories)]['rowid']); $("#catwatermark"+i).show(); } @@ -293,18 +295,25 @@ function MoreCategories(moreorless) { // LoadProducts function LoadProducts(position, issubcat) { - console.log("LoadProducts"); + console.log("LoadProducts position="+position+" issubcat="+issubcat); var maxproduct = ; - if (position=="supplements") currentcat="supplements"; - else - { + if (position=="supplements") { + currentcat="supplements"; + } else { $('#catimg'+position).animate({opacity: '0.5'}, 1); $('#catimg'+position).animate({opacity: '1'}, 100); - if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); - else currentcat=$('#catdiv'+position).data('rowid'); + if (issubcat == true) { + currentcat=$('#prodiv'+position).data('rowid'); + } else { + console.log('#catdiv'+position); + currentcat=$('#catdiv'+position).data('rowid'); + console.log("currentcat="+currentcat); + } + } + if (currentcat == undefined) { + return; } - if (currentcat == undefined) return; pageproducts=0; ishow=0; //product to show counter @@ -323,7 +332,9 @@ function LoadProducts(position, issubcat) { $("#proprice"+ishow).html(""); $("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid); $("#prodiv"+ishow).data("rowid",val.rowid); + $("#prodiv"+ishow).attr("data-rowid",val.rowid); $("#prodiv"+ishow).data("iscat",1); + $("#prodiv"+ishow).attr("data-iscat",1); $("#prowatermark"+ishow).show(); ishow++; } @@ -354,6 +365,7 @@ function LoadProducts(position, issubcat) { $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); $("#prodiv"+ishow).data("rowid",""); + $("#prodiv"+ishow).attr("data-rowid",""); $("#prodiv"+ishow).attr("class","wrapper2 divempty"); } else { @@ -490,6 +505,7 @@ function MoreProducts(moreorless) { } $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); + $("#prodiv"+ishow).attr("data-rowid",data[idata]['id']); $("#prodiv"+ishow).data("iscat",0); } $("#prowatermark"+ishow).hide(); @@ -655,6 +671,7 @@ function Search2(keyCodeForEnter, moreorless) { $("[id^=proprice]").html(""); $("[id^=proimg]").attr("src", "genimg/empty.png"); $("[id^=prodiv]").data("rowid", ""); + $("[id^=prodiv]").attr("data-rowid", ""); return; } @@ -686,6 +703,7 @@ function Search2(keyCodeForEnter, moreorless) { $("#proprice" + i).html(""); $("#proimg" + i).attr("src", "genimg/empty.png"); $("#prodiv" + i).data("rowid", ""); + $("#prodiv" + i).attr("data-rowid", ""); continue; } load_stock('warehouseopen'); $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; @@ -552,9 +554,8 @@ if (empty($reshook)) { } echo ""; @@ -579,7 +580,7 @@ if (empty($reshook)) { //$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); } $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail .= " "; + $detail .= ' "; $detail .= '
'; print $detail; @@ -596,6 +597,7 @@ if (empty($reshook)) { } } + if (getDolGlobalString('TAKEPOS_SUPPLEMENTS')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $cat = new Categorie($db); From a104fbe7b37ac582f5f5df37087654d98091f045 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Feb 2024 16:59:09 +0100 Subject: [PATCH 12/12] Log --- htdocs/compta/paiement_charge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index a76a3cebbfc..d92cbc2035a 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -160,7 +160,8 @@ if ($action == 'create') { //Add js for AutoFill print ' $(document).ready(function () {'; - print ' $(".AutoFillAmount").on(\'click touchstart\', function(){ + print ' $(".AutoFillAmount").on(\'click touchstart\', function() { + console.log("Click on .AutoFillAmount"); var amount = $(this).data("value"); document.getElementById($(this).data(\'rowid\')).value = amount ; });';