From 0914d623495b3a1255c391497773b60f269f8427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 10:07:41 +0100 Subject: [PATCH 01/16] fix phpstan --- build/phpstan/phpstan-baseline.neon | 60 ----------------------- htdocs/adherents/class/adherent.class.php | 16 +++--- htdocs/adherents/list.php | 8 +-- htdocs/adherents/messaging.php | 5 +- htdocs/adherents/subscription.php | 44 ++++++++--------- htdocs/adherents/subscription/list.php | 17 ++++--- 6 files changed, 46 insertions(+), 104 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 9b055ffc31c7f..2f99b81a599ca 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -1014,12 +1014,6 @@ parameters: count: 1 path: ../../htdocs/adherents/class/adherent.class.php - - - message: '#^Property Adherent\:\:\$first_subscription_amount \(int\|string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - message: '#^Property Adherent\:\:\$last_subscription_amount \(int\|string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -1170,12 +1164,6 @@ parameters: count: 1 path: ../../htdocs/adherents/messaging.php - - - message: '#^Variable \$socid might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/adherents/messaging.php - - message: '#^Property Partnership\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -1188,54 +1176,12 @@ parameters: count: 1 path: ../../htdocs/adherents/partnership.php - - - message: '#^Variable \$label might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/adherents/stats/geo.php - - - - message: '#^Variable \$theme_datacolor might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../htdocs/adherents/stats/geo.php - - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../htdocs/adherents/subscription.php - - message: '#^Variable \$bankline in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable count: 1 path: ../../htdocs/adherents/subscription/card.php - - - message: '#^Empty array passed to foreach\.$#' - identifier: foreach.emptyArray - count: 1 - path: ../../htdocs/adherents/subscription/list.php - - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 2 - path: ../../htdocs/adherents/subscription/list.php - - - - message: '#^Result of && is always false\.$#' - identifier: booleanAnd.alwaysFalse - count: 1 - path: ../../htdocs/adherents/subscription/list.php - - - - message: '#^Right side of && is always false\.$#' - identifier: booleanAnd.rightAlwaysFalse - count: 1 - path: ../../htdocs/adherents/subscription/list.php - - message: '#^Variable \$object might not be defined\.$#' identifier: variable.undefined @@ -7626,12 +7572,6 @@ parameters: count: 3 path: ../../htdocs/compta/tva/payments.php - - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/compta/tva/quadri_detail.php - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7ad5ee54ee71b..35558e6f4febb 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -236,12 +236,12 @@ class Adherent extends CommonObject public $need_subscription; /** - * @var int user_id + * @var int|null user_id */ public $user_id; /** - * @var string user_login + * @var string|null user_login */ public $user_login; @@ -254,32 +254,32 @@ class Adherent extends CommonObject // Fields loaded by fetch_subscriptions() from member table /** - * @var int|string date + * @var int|string|null date */ public $first_subscription_date; /** - * @var int|string date + * @var int|string|null date */ public $first_subscription_date_start; /** - * @var int|string date + * @var int|string|null date */ public $first_subscription_date_end; /** - * @var int|string date + * @var int|string|null date */ public $first_subscription_amount; /** - * @var int|string date + * @var int|string|null date */ public $last_subscription_date; /** - * @var int|string date + * @var int|string|null date */ public $last_subscription_date_start; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 8769e9916ccdc..acc6ceb4dcdf6 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -235,10 +235,10 @@ $massaction = ''; } -$permissiontoread = ($user->hasRight('adherent', 'lire') == 1); -$permissiontodelete = ($user->hasRight('adherent', 'supprimer') == 1); -$permissiontoadd = ($user->hasRight('adherent', 'creer') == 1); -$uploaddir = $conf->adherent->dir_output; +$permissiontoread = $user->hasRight('adherent', 'lire'); +$permissiontodelete = $user->hasRight('adherent', 'supprimer'); +$permissiontoadd = $user->hasRight('adherent', 'creer'); +$uploaddir = $conf->member->dir_output; $error = 0; $parameters = array('socid' => isset($socid) ? $socid : null, 'arrayfields' => &$arrayfields); diff --git a/htdocs/adherents/messaging.php b/htdocs/adherents/messaging.php index af48d7cf822c1..de637315753f4 100644 --- a/htdocs/adherents/messaging.php +++ b/htdocs/adherents/messaging.php @@ -81,7 +81,10 @@ if (!$sortorder) { $sortorder = 'DESC,DESC'; } - +$socid = GETPOSTINT('socid'); +if ($user->socid > 0) { + $socid = $user->socid; +} // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('agendathirdparty', 'globalcard')); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 3b7b80d6935cf..069f89de048c0 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -179,35 +179,33 @@ if (empty($reshook) && $action == 'setsocid' && $permissiontoaddmember) { $error = 0; - if (!$error) { - if (GETPOSTINT('socid') != $object->socid) { // If link differs from currently in database - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE fk_soc = ".((int) GETPOSTINT('socid')); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) { - $othermember = new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty = new Societe($db); - $thirdparty->fetch(GETPOSTINT('socid')); - $error++; - setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); - } + if (GETPOSTINT('socid') != $object->socid) { // If link differs from currently in database + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; + $sql .= " WHERE fk_soc = " . ((int) GETPOSTINT('socid')); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) { + $othermember = new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty = new Societe($db); + $thirdparty->fetch(GETPOSTINT('socid')); + $error++; + setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); } + } - if (!$error) { - $result = $object->setThirdPartyId(GETPOSTINT('socid')); - if ($result < 0) { - dol_print_error(null, $object->error); - } - $action = ''; + if (!$error) { + $result = $object->setThirdPartyId(GETPOSTINT('socid')); + if ($result < 0) { + dol_print_error(null, $object->error); } + $action = ''; } } } -if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) { +if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) { $error = 0; $langs->load("banks"); @@ -701,7 +699,7 @@ if ($action != 'addsubscription' && $action != 'create_thirdparty') { print '
'; - if ($object->statut > 0) { + if ($object->status > 0) { print '"; } else { print ''; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index aa50ccc6a4f58..c34a84824cc32 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -63,7 +63,7 @@ $search_note = GETPOST('search_note', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -$search_all = ''; +$search_all = trim(GETPOST('search_all', 'alphanohtml')); $date_select = GETPOST("date_select", 'alpha'); @@ -98,6 +98,8 @@ // List of fields to search into when doing a "search in all" $fieldstosearchall = array( + 'c.rowid' => 'Ref', + 'c.note' => "Label", ); $arrayfields = array( 'd.ref' => array('label' => "Ref", 'checked' => 1), @@ -105,7 +107,7 @@ 'd.lastname' => array('label' => "Lastname", 'checked' => 1), 'd.firstname' => array('label' => "Firstname", 'checked' => 1), 'd.login' => array('label' => "Login", 'checked' => 1), - 't.libelle' => array('label' => "Label", 'checked' => 1), + 'c.note' => array('label' => "Label", 'checked' => 1), 'd.bank' => array('label' => "BankAccount", 'checked' => 1, 'enabled' => (isModEnabled('bank'))), /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0), 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/ @@ -166,7 +168,7 @@ // Mass actions $objectclass = 'Subscription'; $objectlabel = 'Subscription'; - $uploaddir = $conf->adherent->dir_output; + $uploaddir = $conf->member->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -395,7 +397,6 @@ if ($search_all) { $setupstring = ''; - // @phan-suppress-next-line PhanEmptyForeach foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; @@ -474,7 +475,7 @@ print ''; } -if (!empty($arrayfields['t.libelle']['checked'])) { +if (!empty($arrayfields['c.note']['checked'])) { print ''; print ''; print ''; @@ -557,8 +558,8 @@ print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; } -if (!empty($arrayfields['t.libelle']['checked'])) { - print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); +if (!empty($arrayfields['c.note']['checked'])) { + print_liste_field_titre($arrayfields['c.note']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); $totalarray['nbfield']++; } if (!empty($arrayfields['d.bank']['checked'])) { @@ -725,7 +726,7 @@ } // Label - if (!empty($arrayfields['t.libelle']['checked'])) { + if (!empty($arrayfields['c.note']['checked'])) { print ''; print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private)); print ''; From f3abc3825f2add4a84acc81bd98a6a77f7d9663f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 10:38:30 +0100 Subject: [PATCH 02/16] fix phpstan doc ui --- build/phpstan/phpstan-baseline.neon | 18 ----------- htdocs/admin/tools/ui/components/badges.php | 28 +++++++++-------- htdocs/admin/tools/ui/components/buttons.php | 24 ++++++++------- .../tools/ui/components/event-message.php | 23 +++++++------- htdocs/admin/tools/ui/components/index.php | 30 +++++++++++-------- .../tools/ui/components/progress-bars.php | 24 ++++++++------- .../admin/tools/ui/components/test_arrays.php | 29 +++++++++++++++--- .../tools/ui/components/test_buttons.php | 29 +++++++++++++++++- .../admin/tools/ui/components/test_forms.php | 12 +++++++- htdocs/admin/tools/ui/content/tables.php | 22 +++++++------- htdocs/admin/tools/ui/index.php | 27 +++++++++-------- phpstan.neon.dist | 1 - 12 files changed, 164 insertions(+), 103 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 9b055ffc31c7f..6b70662a01d25 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -1188,18 +1188,6 @@ parameters: count: 1 path: ../../htdocs/adherents/partnership.php - - - message: '#^Variable \$label might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/adherents/stats/geo.php - - - - message: '#^Variable \$theme_datacolor might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../htdocs/adherents/stats/geo.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -7626,12 +7614,6 @@ parameters: count: 3 path: ../../htdocs/compta/tva/payments.php - - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/compta/tva/quadri_detail.php - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/admin/tools/ui/components/badges.php b/htdocs/admin/tools/ui/components/badges.php index e47b8090ce4fc..b698113dac572 100644 --- a/htdocs/admin/tools/ui/components/badges.php +++ b/htdocs/admin/tools/ui/components/badges.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,20 +18,23 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); @@ -49,7 +53,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -310,4 +314,4 @@ docFooter(); -?> \ No newline at end of file +?> diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index 1ad142730f09f..62de3b23fce14 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,20 +18,23 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); diff --git a/htdocs/admin/tools/ui/components/event-message.php b/htdocs/admin/tools/ui/components/event-message.php index 98e3080c7d30f..6065237d90b36 100644 --- a/htdocs/admin/tools/ui/components/event-message.php +++ b/htdocs/admin/tools/ui/components/event-message.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,21 +18,23 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../../main.inc.php'; +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); diff --git a/htdocs/admin/tools/ui/components/index.php b/htdocs/admin/tools/ui/components/index.php index 32af131fb91c0..e6023af16c71e 100644 --- a/htdocs/admin/tools/ui/components/index.php +++ b/htdocs/admin/tools/ui/components/index.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,20 +18,23 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); @@ -48,7 +52,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -56,11 +60,11 @@

trans('DocComponentsTitle'); ?>

trans('DocComponentsMainDescription'); ?>

- showSummary(); ?> + showSummary(); ?>
docFooter(); -?> \ No newline at end of file +?> diff --git a/htdocs/admin/tools/ui/components/progress-bars.php b/htdocs/admin/tools/ui/components/progress-bars.php index f860fabb5798d..b53bb335d6e62 100644 --- a/htdocs/admin/tools/ui/components/progress-bars.php +++ b/htdocs/admin/tools/ui/components/progress-bars.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,20 +18,23 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; -if (! $res && file_exists("../../../../main.inc.php")) : $res=@include '../../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 8954e0cd7a309..14792a0353ac7 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -1,14 +1,35 @@ + * + * This program and files/directory inner it is free software: you can + * redistribute it and/or modify it under the terms of the + * GNU Affero General Public License (AGPL) as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AGPL for more details. + * + * You should have received a copy of the GNU AGPL + * along with this program. If not, see . */ // Load Dolibarr environment -@include '../../main.inc.php'; +require '../../../../main.inc.php'; -// Security -if ($dolibarr_main_prod) { - accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1'); +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + +// Protection if external user +if ($user->socid > 0) { + accessforbidden(); } diff --git a/htdocs/admin/tools/ui/components/test_buttons.php b/htdocs/admin/tools/ui/components/test_buttons.php index 8eef7aa0b6cd9..619e91b392266 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -1,4 +1,22 @@ + */ +/* + * This program and files/directory inner it is free software: you can + * redistribute it and/or modify it under the terms of the + * GNU Affero General Public License (AGPL) as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AGPL for more details. + * + * You should have received a copy of the GNU AGPL + * along with this program. If not, see . + */ + if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } @@ -25,9 +43,18 @@ } session_cache_limiter('public'); -require_once '../../main.inc.php'; +require '../../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + * + * @var int $dolibarr_main_prod + */ + // Security if ($dolibarr_main_prod) { accessforbidden(); diff --git a/htdocs/admin/tools/ui/components/test_forms.php b/htdocs/admin/tools/ui/components/test_forms.php index 60f351eb9948d..60c32389b0de7 100644 --- a/htdocs/admin/tools/ui/components/test_forms.php +++ b/htdocs/admin/tools/ui/components/test_forms.php @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. //define("NOLOGIN",1); // This means this output page does not require to be logged. /*if (!defined('NOSESSION')) { @@ -21,9 +22,18 @@ }*/ // Load Dolibarr environment -require '../../main.inc.php'; +require '../../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + * + * @var int $dolibarr_main_prod + */ + // Security if ($dolibarr_main_prod) { accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1'); diff --git a/htdocs/admin/tools/ui/content/tables.php b/htdocs/admin/tools/ui/content/tables.php index 00fd9bbf666f0..2423fb690a6bc 100644 --- a/htdocs/admin/tools/ui/content/tables.php +++ b/htdocs/admin/tools/ui/content/tables.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,16 +18,15 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../../main.inc.php")) { - $res=@include '../../main.inc.php'; -} -if (! $res && file_exists("../../../main.inc.php")) { - $res=@include '../../../main.inc.php'; -} -if (! $res && file_exists("../../../../main.inc.php")) { - $res=@include '../../../../main.inc.php'; -} +// Load Dolibarr environment +require '../../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Protection if external user if ($user->socid > 0) { @@ -34,7 +34,7 @@ } // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); diff --git a/htdocs/admin/tools/ui/index.php b/htdocs/admin/tools/ui/index.php index 2e64da27e4ed0..548b6020e91a3 100644 --- a/htdocs/admin/tools/ui/index.php +++ b/htdocs/admin/tools/ui/index.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the @@ -17,20 +18,22 @@ * along with this program. If not, see . */ -$res=0; -if (! $res && file_exists("../main.inc.php")) : $res=@include '../main.inc.php'; -endif; -if (! $res && file_exists("../../main.inc.php")) : $res=@include '../../main.inc.php'; -endif; -if (! $res && file_exists("../../../main.inc.php")) : $res=@include '../../../main.inc.php'; -endif; +// Load Dolibarr environment +require '../../../main.inc.php'; + +/** + * @var DoliDB $db + * @var Translate $langs + * @var User $user + */ // Protection if external user -if ($user->socid > 0) : accessforbidden(); -endif; +if ($user->socid > 0) { + accessforbidden(); +} // Includes -dol_include_once('admin/tools/ui/class/documentation.class.php'); +require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); @@ -48,7 +51,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -61,4 +64,4 @@ docFooter(); -?> \ No newline at end of file +?> diff --git a/phpstan.neon.dist b/phpstan.neon.dist index de1271a36e158..a21273cea0809 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -19,7 +19,6 @@ parameters: - scripts excludePaths: analyseAndScan: - - htdocs/admin/tools/ui/* - htdocs/custom/* - htdocs/documents/* - htdocs/install/doctemplates/* From a5dde7fe83b0ca17a32715184f14a2fb04e21948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 10:53:07 +0100 Subject: [PATCH 03/16] fix phpstan doc ui --- htdocs/admin/tools/ui/class/documentation.class.php | 6 +++++- htdocs/admin/tools/ui/components/test_arrays.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index 584f6c36a7f9c..3d5128cc16b26 100644 --- a/htdocs/admin/tools/ui/class/documentation.class.php +++ b/htdocs/admin/tools/ui/class/documentation.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -57,6 +58,7 @@ class Documentation * Constructor * * @param DoliDB $db Database handler + * @return void */ public function __construct(DoliDB $db) { @@ -223,7 +225,8 @@ public function docFooter() } /** - * Output sidebar + * Output sidebar + * * @return void */ public function showSidebar() @@ -320,6 +323,7 @@ public function showBreadcrumb() public function showSummary($showsubmenu = 1, $showsubmenu_summary = 1) { $i = 0; + $menu_entry = []; if (!empty($this->view)) : // On se place au bon niveau foreach ($this->view as $view) { diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 14792a0353ac7..0cfaf86994292 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -40,7 +40,9 @@ $form = new Form($db); -$usedolheader = 1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header +// 1 = Test inside a dolibarr page, 0 = Use hard coded header +// Using a dolibarr constant avoid phpstan hardcoded value always true or false +$usedolheader = getDolGlobalInt('MAIN_TEST_UI_IN_DOLIBARR_PAGE', 1); // HEADER //-------- From 7c4ddc4c3cbe205e403f21360e4eb3cd04709d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 11:07:41 +0100 Subject: [PATCH 04/16] fix phpstan doc ui --- .../tools/ui/class/documentation.class.php | 4 +-- .../admin/tools/ui/components/test_arrays.php | 35 +++++++++---------- .../tools/ui/components/test_buttons.php | 3 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index 3d5128cc16b26..06a919d274fca 100644 --- a/htdocs/admin/tools/ui/class/documentation.class.php +++ b/htdocs/admin/tools/ui/class/documentation.class.php @@ -77,7 +77,6 @@ public function __construct(DoliDB $db) */ private function setMenu() { - global $hookmanager; @@ -315,7 +314,8 @@ public function showBreadcrumb() } /** - * Output summary + * Output summary + * * @param int $showsubmenu Show Sub menus: 0 = No, 1 = Yes * @param int $showsubmenu_summary Show summary of sub menus: 0 = No, 1 = Yes * @return void diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 0cfaf86994292..553816c58d56e 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -32,7 +32,7 @@ accessforbidden(); } - +$optioncss = GETPOST('optioncsss', 'alpha'); /* * View @@ -186,15 +186,14 @@ $productspecimen->initAsSpecimen(); $object = $productspecimen; $param = ''; -$actioncode = ''; -$status = ''; -$filter = ''; -$filtert = ''; -$socid = 0; -$type = 0; -$usergroup = 0; - -$sortfield = 'aaa'; +$actioncode = getDolGlobalString('MAIN_TEST_UI_ACTION_CODE'); // '' by default +$status = getDolGlobalString('MAIN_TEST_UI_STATUS'); // '' by default; +$filter = getDolGlobalString('MAIN_TEST_UI_FILTER'); // '' by default; +$filtert = getDolGlobalString('MAIN_TEST_UI_FILTERT'); // '' by default; +$socid = getDolGlobalInt('MAIN_TEST_UI_SOCID', 0); // 0 by default; +$type = getDolGlobalInt('MAIN_TEST_UI_TYPE', 0); // 0 by default; +$usergroup = getDolGlobalInt('MAIN_TEST_UI_USERGROUP', 0); // 0 by default; +$sortfield = getDolGlobalString('MAIN_TEST_UI_SORTFIELD', 'aaa'); // 'aaa' by default; $sortorder = 'ASC'; $tasksarray = array(1, 2, 3); // To force having several lines $tagidfortablednd = 'tablelines3'; @@ -265,18 +264,16 @@ $moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 1); // List with js combo forced $moreforfilter .= '
'; -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; -} +print '
'; +print $moreforfilter; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print '
'; ?> -" id="tablelines3"> +
" id="tablelines3"> trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder); ?> diff --git a/htdocs/admin/tools/ui/components/test_buttons.php b/htdocs/admin/tools/ui/components/test_buttons.php index 619e91b392266..dbeba208def8b 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -1,7 +1,6 @@ - */ -/* + * * This program and files/directory inner it is free software: you can * redistribute it and/or modify it under the terms of the * GNU Affero General Public License (AGPL) as published by From ecd90383054e6e325085713e6f35e1dd4e40507d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 11:14:13 +0100 Subject: [PATCH 05/16] fix phpstan doc ui --- htdocs/admin/tools/ui/components/badges.php | 13 ++++++------- htdocs/admin/tools/ui/components/buttons.php | 13 ++++++------- htdocs/admin/tools/ui/components/event-message.php | 13 ++++++------- htdocs/admin/tools/ui/components/index.php | 13 ++++++------- htdocs/admin/tools/ui/components/progress-bars.php | 13 ++++++------- htdocs/admin/tools/ui/components/test_arrays.php | 13 ++++++------- htdocs/admin/tools/ui/components/test_buttons.php | 13 ++++++------- htdocs/admin/tools/ui/content/tables.php | 13 ++++++------- htdocs/admin/tools/ui/index.php | 13 ++++++------- 9 files changed, 54 insertions(+), 63 deletions(-) diff --git a/htdocs/admin/tools/ui/components/badges.php b/htdocs/admin/tools/ui/components/badges.php index b698113dac572..1fbe2947b253e 100644 --- a/htdocs/admin/tools/ui/components/badges.php +++ b/htdocs/admin/tools/ui/components/badges.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index 62de3b23fce14..777bef5d7d53c 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/components/event-message.php b/htdocs/admin/tools/ui/components/event-message.php index 6065237d90b36..78a038e0141ef 100644 --- a/htdocs/admin/tools/ui/components/event-message.php +++ b/htdocs/admin/tools/ui/components/event-message.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/components/index.php b/htdocs/admin/tools/ui/components/index.php index e6023af16c71e..409d96d22a73c 100644 --- a/htdocs/admin/tools/ui/components/index.php +++ b/htdocs/admin/tools/ui/components/index.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/components/progress-bars.php b/htdocs/admin/tools/ui/components/progress-bars.php index b53bb335d6e62..1e29058442356 100644 --- a/htdocs/admin/tools/ui/components/progress-bars.php +++ b/htdocs/admin/tools/ui/components/progress-bars.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 553816c58d56e..4a4fdf6bacaf9 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -1,19 +1,18 @@ * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ diff --git a/htdocs/admin/tools/ui/components/test_buttons.php b/htdocs/admin/tools/ui/components/test_buttons.php index dbeba208def8b..0c7412ed71925 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -1,19 +1,18 @@ * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ if (!defined('NOREQUIRESOC')) { diff --git a/htdocs/admin/tools/ui/content/tables.php b/htdocs/admin/tools/ui/content/tables.php index 2423fb690a6bc..9ab70ba6f3826 100644 --- a/htdocs/admin/tools/ui/content/tables.php +++ b/htdocs/admin/tools/ui/content/tables.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment diff --git a/htdocs/admin/tools/ui/index.php b/htdocs/admin/tools/ui/index.php index 548b6020e91a3..76baca72436c7 100644 --- a/htdocs/admin/tools/ui/index.php +++ b/htdocs/admin/tools/ui/index.php @@ -3,19 +3,18 @@ * Copyright (C) 2024 Anthony Damhet * Copyright (C) 2024 Frédéric France * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the - * GNU Affero General Public License (AGPL) as published by - * the Free Software Foundation, either version 3 of the License, or + * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AGPL for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU AGPL - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment From 649051be6fc272181030f2e5cdb21cd809b69225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 11:24:51 +0100 Subject: [PATCH 06/16] clean baseline --- build/phpstan/phpstan-baseline.neon | 54 +++++++++++++++++++ htdocs/admin/tools/ui/components/buttons.php | 6 ++- .../tools/ui/components/test_buttons.php | 14 ++--- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 6b70662a01d25..c5a090e5a2a54 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -1962,6 +1962,60 @@ parameters: count: 2 path: ../../htdocs/admin/tools/purge.php + - + message: '#^Method Documentation\:\:displayMenu\(\) has parameter \$menu with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Method Documentation\:\:displaySummary\(\) has parameter \$menu with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Method Documentation\:\:setMenu\(\) should return mixed but return statement is missing\.$#' + identifier: return.missing + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Method Documentation\:\:showCode\(\) has parameter \$lines with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Property Documentation\:\:\$menu type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Property Documentation\:\:\$summary type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Property Documentation\:\:\$view type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../../htdocs/admin/tools/ui/class/documentation.class.php + + - + message: '#^Parameter \#7 \$params of function dolGetButtonAction expects array\{confirm\?\: array\{url\?\: string, title\?\: string, content\?\: string, action\-btn\-label\?\: string, cancel\-btn\-label\?\: string, modal\?\: bool\}, attr\?\: array\, areDropdownButtons\?\: bool, backtopage\?\: string, lang\?\: string, enabled\?\: bool, perm\?\: int\<0, 1\>, label\?\: string, \.\.\.\}, array\{confirm\: true\} given\.$#' + identifier: argument.type + count: 2 + path: ../../htdocs/admin/tools/ui/components/buttons.php + + - + message: '#^Parameter \#7 \$params of function dolGetButtonAction expects array\{confirm\?\: array\{url\?\: string, title\?\: string, content\?\: string, action\-btn\-label\?\: string, cancel\-btn\-label\?\: string, modal\?\: bool\}, attr\?\: array\, areDropdownButtons\?\: bool, backtopage\?\: string, lang\?\: string, enabled\?\: bool, perm\?\: int\<0, 1\>, label\?\: string, \.\.\.\}, array\{confirm\: true\} given\.$#' + identifier: argument.type + count: 2 + path: ../../htdocs/admin/tools/ui/components/test_buttons.php + - message: '#^Variable \$massactionbutton in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index 777bef5d7d53c..fcea0cf0358d4 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -217,13 +217,15 @@ 'lang'=>'documentation@documentation', 'url'=> $submenu_url.'#'.$id, 'label' => 'My SubAction 1', - 'perm' => 1 + 'perm' => true, + 'enabled' => true, ), array( 'lang'=>'documentation@documentation', 'url'=> $submenu_url.'#'.$id, 'label' => 'My SubAction 2', - 'perm' => 0 + 'perm' => false, + 'enabled' => true, ), ); $params = array(); diff --git a/htdocs/admin/tools/ui/components/test_buttons.php b/htdocs/admin/tools/ui/components/test_buttons.php index 0c7412ed71925..5fbe11b06769f 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -154,7 +154,7 @@ $url = '#'.$id; $userRight = 1; $params = array( - 'confirm' => true + 'confirm' => true ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -167,13 +167,13 @@ $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id; $params = array( - 'confirm' => array( + 'confirm' => array( 'url' => 'your confirm action url', 'title' => 'Your title to display', 'action-btn-label' => 'Your confirm label', 'cancel-btn-label' => 'Your cancel label', 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
' - ) + ) ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -193,7 +193,7 @@ $url = '#'.$id; $userRight = 0; $params = array( - 'confirm' => true + 'confirm' => true, ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -206,13 +206,13 @@ $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id; $params = array( - 'confirm' => array( + 'confirm' => array( 'url' => 'your confirm action url', 'title' => 'Your title to display', 'action-btn-label' => 'Your confirm label', 'cancel-btn-label' => 'Your cancel label', - 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
' - ) + 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
', + ) ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); From 4a300cfdf0d1856eeeffdb7cf13887ce9a1ee827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 12:50:49 +0100 Subject: [PATCH 07/16] clean baseline --- build/phpstan/phpstan-baseline.neon | 6 ------ htdocs/admin/tools/ui/components/test_buttons.php | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index c5a090e5a2a54..53d18a78fc19c 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -2010,12 +2010,6 @@ parameters: count: 2 path: ../../htdocs/admin/tools/ui/components/buttons.php - - - message: '#^Parameter \#7 \$params of function dolGetButtonAction expects array\{confirm\?\: array\{url\?\: string, title\?\: string, content\?\: string, action\-btn\-label\?\: string, cancel\-btn\-label\?\: string, modal\?\: bool\}, attr\?\: array\, areDropdownButtons\?\: bool, backtopage\?\: string, lang\?\: string, enabled\?\: bool, perm\?\: int\<0, 1\>, label\?\: string, \.\.\.\}, array\{confirm\: true\} given\.$#' - identifier: argument.type - count: 2 - path: ../../htdocs/admin/tools/ui/components/test_buttons.php - - message: '#^Variable \$massactionbutton in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable diff --git a/htdocs/admin/tools/ui/components/test_buttons.php b/htdocs/admin/tools/ui/components/test_buttons.php index 5fbe11b06769f..449196c25a233 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -154,7 +154,7 @@ $url = '#'.$id; $userRight = 1; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -172,7 +172,7 @@ 'title' => 'Your title to display', 'action-btn-label' => 'Your confirm label', 'cancel-btn-label' => 'Your cancel label', - 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
' + 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
', ) ); @@ -193,7 +193,7 @@ $url = '#'.$id; $userRight = 0; $params = array( - 'confirm' => true, + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); From e285982eaee6bd0d99ab670545f08295edaa87e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 12:52:07 +0100 Subject: [PATCH 08/16] clean baseline --- htdocs/admin/tools/ui/components/buttons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index fcea0cf0358d4..b33eecfa6fcb7 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -147,7 +147,7 @@ $id = 'button-id-7'; $url = '#'.$id; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -173,7 +173,7 @@ $id = 'button-id-9'; $url = '#'.$id; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); ?> From 71d532062aae5bd04a4d7a1452ef7af60bf8ac1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 12:52:34 +0100 Subject: [PATCH 09/16] clean baseline --- build/phpstan/phpstan-baseline.neon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 53d18a78fc19c..b79a2dd241959 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -2004,12 +2004,6 @@ parameters: count: 1 path: ../../htdocs/admin/tools/ui/class/documentation.class.php - - - message: '#^Parameter \#7 \$params of function dolGetButtonAction expects array\{confirm\?\: array\{url\?\: string, title\?\: string, content\?\: string, action\-btn\-label\?\: string, cancel\-btn\-label\?\: string, modal\?\: bool\}, attr\?\: array\, areDropdownButtons\?\: bool, backtopage\?\: string, lang\?\: string, enabled\?\: bool, perm\?\: int\<0, 1\>, label\?\: string, \.\.\.\}, array\{confirm\: true\} given\.$#' - identifier: argument.type - count: 2 - path: ../../htdocs/admin/tools/ui/components/buttons.php - - message: '#^Variable \$massactionbutton in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable From 793ca018670ebe9f752d4c016b091266b5f8c806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 12:57:30 +0100 Subject: [PATCH 10/16] clean baseline --- htdocs/admin/tools/ui/components/buttons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index b33eecfa6fcb7..b2a947ebe17ce 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -182,7 +182,7 @@ ' true', + ' \'confirm\' => [],', ');', '', '// Custom parameters', @@ -192,7 +192,7 @@ ' \'title\' => \'Your title to display\',', ' \'action-btn-label\' => \'Your confirm label\',', ' \'cancel-btn-label\' => \'Your cancel label\',', - ' \'content\' => \'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
\'', + ' \'content\' => \'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
\',', ' )', ');', '', From 49846ca14912282ebd1978f91e73e6a3a1c4396f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 13:34:37 +0100 Subject: [PATCH 11/16] use ace editor to display source code --- .../tools/ui/class/documentation.class.php | 16 ++++++------ htdocs/admin/tools/ui/components/badges.php | 7 ++++- htdocs/admin/tools/ui/components/buttons.php | 26 +++++++++---------- .../tools/ui/components/event-message.php | 13 +++++++--- .../tools/ui/components/progress-bars.php | 8 +++++- 5 files changed, 42 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index 06a919d274fca..437c762c0c62e 100644 --- a/htdocs/admin/tools/ui/class/documentation.class.php +++ b/htdocs/admin/tools/ui/class/documentation.class.php @@ -388,16 +388,16 @@ public function displaySummary($menu, $level = 0, $showsubmenu = 1, $showsubmenu * Output a View Code area * * @param array $lines Lines of code to show + * @param string $option Source code language ('html', 'php' etc) * @return void */ - public function showCode($lines = array()) + public function showCode($lines = array(), $option = 'html') { - print '
';
-		if (!empty($lines)) {
-			foreach ($lines as $lineofcode) {
-				print dol_htmlentities($lineofcode).'
'; - } - } - print '
'; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + print '
'; + $content = implode("\n", $lines); + $doleditor = new DolEditor(md5($content), $content, '', 0, 'Basic', 'In', true, false, 'ace', 0, '99%', 1); + print $doleditor->Create(1, '', false, '', $option); + print '
'; } } diff --git a/htdocs/admin/tools/ui/components/badges.php b/htdocs/admin/tools/ui/components/badges.php index 1fbe2947b253e..0d147b603bea2 100644 --- a/htdocs/admin/tools/ui/components/badges.php +++ b/htdocs/admin/tools/ui/components/badges.php @@ -41,8 +41,13 @@ // $documentation = new Documentation($db); +$morejs = [ + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', +]; // Output html head + body - Param is Title -$documentation->docHeader('Badges'); +$documentation->docHeader('Badges', $morejs); // Set view for menu and breadcrumb // Menu must be set in constructor of documentation class diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index b2a947ebe17ce..63aabb3c58693 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -40,9 +40,13 @@ // $documentation = new Documentation($db); - +$morejs = [ + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', +]; // Output html head + body - Param is Title -$documentation->docHeader('Buttons'); +$documentation->docHeader('Buttons', $morejs); // Set view for menu and breadcrumb // Menu must be set in constructor of documentation class @@ -131,7 +135,7 @@ ' */', 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -198,7 +202,7 @@ '', 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -255,7 +259,7 @@ ');', 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);' ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -282,7 +286,7 @@ 'print \' \';', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -322,7 +326,7 @@ trans('Label'); + $btnLabel = $langs->trans('Label', 'php'); print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', 0, ['forcenohideoftext'=>1]); // Not Enough Permissions print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', 1, ['forcenohideoftext'=>1]); // Active print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', 2, ['forcenohideoftext'=>1]); // Active and selected @@ -348,15 +352,9 @@ '$status = -2; // Disabled without info', 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-download\', \'#\', \'\', $status, [\'forcenohideoftext\'=>1]);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> - - - - - - diff --git a/htdocs/admin/tools/ui/components/event-message.php b/htdocs/admin/tools/ui/components/event-message.php index 78a038e0141ef..f612f05a0c2dd 100644 --- a/htdocs/admin/tools/ui/components/event-message.php +++ b/htdocs/admin/tools/ui/components/event-message.php @@ -57,9 +57,13 @@ // $documentation = new Documentation($db); - +$morejs = [ + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', +]; // Output html head + body - Param is Title -$documentation->docHeader('SetEventMessages'); +$documentation->docHeader('SetEventMessages', $morejs); // Set view for menu and breadcrumb // Menu must be set in constructor of documentation class @@ -123,7 +127,7 @@ 'setEventMessages("message", null);', 'setEventMessages(null, messages[]);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -158,11 +162,12 @@ showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> diff --git a/htdocs/admin/tools/ui/components/progress-bars.php b/htdocs/admin/tools/ui/components/progress-bars.php index 1e29058442356..fda0b0527fc42 100644 --- a/htdocs/admin/tools/ui/components/progress-bars.php +++ b/htdocs/admin/tools/ui/components/progress-bars.php @@ -41,8 +41,13 @@ // $documentation = new Documentation($db); +$morejs = [ + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', +]; // Output html head + body - Param is Title -$documentation->docHeader('Progress-bars'); +$documentation->docHeader('Progress-bars', $morejs); // Set view for menu and breadcrumb // Menu must be set in constructor of documentation class @@ -250,6 +255,7 @@ '
', '', '', + '', ); echo $documentation->showCode($lines); ?> From f1adc0fe828a2985cd1fadade82d3b178360504b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 13:55:12 +0100 Subject: [PATCH 12/16] can set ace editor to readonly --- htdocs/core/class/doleditor.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 8d287b33a81dc..94edfbce43c1b 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -394,9 +394,10 @@ public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $ $out .= ''."\n"; } From c272a1242cf4cabb956b977e13c6013847c28bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 23 Nov 2024 14:19:29 +0100 Subject: [PATCH 13/16] can set ace editor to readonly --- htdocs/admin/tools/ui/class/documentation.class.php | 2 +- htdocs/admin/tools/ui/components/buttons.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index 437c762c0c62e..4de7133c9e620 100644 --- a/htdocs/admin/tools/ui/class/documentation.class.php +++ b/htdocs/admin/tools/ui/class/documentation.class.php @@ -395,7 +395,7 @@ public function showCode($lines = array(), $option = 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; print '
'; - $content = implode("\n", $lines); + $content = implode("\n", $lines) . "\n"; $doleditor = new DolEditor(md5($content), $content, '', 0, 'Basic', 'In', true, false, 'ace', 0, '99%', 1); print $doleditor->Create(1, '', false, '', $option); print '
'; diff --git a/htdocs/admin/tools/ui/components/buttons.php b/htdocs/admin/tools/ui/components/buttons.php index 63aabb3c58693..0fe09e06d027a 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -322,10 +322,9 @@ 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);', ); - echo $documentation->showCode($lines); ?>
+ echo $documentation->showCode($lines, 'php'); ?>
trans('Label', 'php'); print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', 0, ['forcenohideoftext'=>1]); // Not Enough Permissions print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', 1, ['forcenohideoftext'=>1]); // Active @@ -333,7 +332,6 @@ print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', -1, ['forcenohideoftext'=>1]); // Functionality is disabled print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', -2, ['forcenohideoftext'=>1]); // Disabled without info - ?>
From 8a50ddaf9207cb8865e4e8b810949ed0f58eb86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Tue, 26 Nov 2024 08:12:27 +0100 Subject: [PATCH 14/16] restore code --- htdocs/admin/tools/ui/components/test_arrays.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 4a4fdf6bacaf9..0e02e1b88855d 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -24,8 +24,14 @@ * @var HookManager $hookmanager * @var Translate $langs * @var User $user + * + * @var int $dolibarr_main_prod */ +// Security +if ($dolibarr_main_prod) { + accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1'); +} // Protection if external user if ($user->socid > 0) { accessforbidden(); From fb3067a1a49a7840a83a330576de28f1d19dca3e Mon Sep 17 00:00:00 2001 From: matthieu-michou-wattandsea <70541072+matthieu-michou-wattandsea@users.noreply.github.com> Date: Sun, 22 Dec 2024 12:07:17 +0100 Subject: [PATCH 15/16] Update api_bankaccounts.class.php NEW API REST : bank : add function to get bank account balance --- .../bank/class/api_bankaccounts.class.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 1726f6395a730..f36faead44b99 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -691,4 +691,29 @@ public function deleteLine($id, $line_id) ) ); } + + /** + * Get current account balance by ID + * + * @param int $id ID of account + * @return float $balance balance + * @url GET {id}/balance + * + * @throws RestException + */ + public function getBalance($id) + { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { + throw new RestException(403); + } + + $account = new Account($this->db); + $result = $account->fetch($id); + + if (!$result) { + throw new RestException(404, 'account not found'); + } + $balance = $account->solde(1); //1=Exclude future operation date (this is to exclude input made in advance and have real account sold) + return $balance; + } } From 7a825d59ab8d4a9d27cd1a19e8e498918505a7a5 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 24 Dec 2024 03:10:47 +0100 Subject: [PATCH 16/16] Debug v21 --- htdocs/fourn/class/fournisseur.product.class.php | 6 +++--- htdocs/product/list.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index d7db51a8523a1..f76e2ce690fcd 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1133,8 +1133,8 @@ public function display_price_product_fournisseur($showunitprice = 1, $showsupti $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= '
'; - $out .= ''; + $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').'
'; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -1142,7 +1142,7 @@ public function display_price_product_fournisseur($showunitprice = 1, $showsupti $out .= ''; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; } $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ? price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'.dolPrintHTML($productFourn->fourn_ref).'
'; } else { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 287e00cd4c96c..895e804968ecd 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -2033,7 +2033,7 @@ } } - // Number of buy prices + // Number of buy prices - Vendor prices if (!empty($arrayfields['p.numbuyprice']['checked'])) { print ''; if ($product_static->status_buy && $usercancreadprice) {