diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index f301d5c4b4a45..5a23163c6d920 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -948,12 +948,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 @@ -1104,12 +1098,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 @@ -1122,42 +1110,12 @@ parameters: count: 1 path: ../../htdocs/adherents/partnership.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 @@ -1818,6 +1776,48 @@ 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: '#^Variable \$massactionbutton in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 26833536fee8d..a401823fc3c1c 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 26c7594192c41..21f24487c24c3 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 '
'.$langs->trans("AddSubscription")."
"; } else { print '
'.$langs->trans("AddSubscription").'
'; 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 ''; diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index 584f6c36a7f9c..4de7133c9e620 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) { @@ -75,7 +77,6 @@ public function __construct(DoliDB $db) */ private function setMenu() { - global $hookmanager; @@ -223,7 +224,8 @@ public function docFooter() } /** - * Output sidebar + * Output sidebar + * * @return void */ public function showSidebar() @@ -312,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 @@ -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) { @@ -384,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) . "\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/badges.php b/htdocs/admin/tools/ui/components/badges.php index e47b8090ce4fc..0d147b603bea2 100644 --- a/htdocs/admin/tools/ui/components/badges.php +++ b/htdocs/admin/tools/ui/components/badges.php @@ -1,36 +1,39 @@ + * 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 . */ -$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'); @@ -38,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 @@ -49,7 +57,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -310,4 +318,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..0fe09e06d027a 100644 --- a/htdocs/admin/tools/ui/components/buttons.php +++ b/htdocs/admin/tools/ui/components/buttons.php @@ -1,45 +1,52 @@ + * 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 . */ -$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'); // $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 @@ -128,7 +135,7 @@ ' */', 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?>
@@ -144,7 +151,7 @@ $id = 'button-id-7'; $url = '#'.$id; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -170,7 +177,7 @@ $id = 'button-id-9'; $url = '#'.$id; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); ?>
@@ -179,7 +186,7 @@ ' true', + ' \'confirm\' => [],', ');', '', '// Custom parameters', @@ -189,13 +196,13 @@ ' \'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);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?>
@@ -214,13 +221,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(); @@ -250,7 +259,7 @@ ');', 'print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);' ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -277,7 +286,7 @@ 'print \' \';', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -313,18 +322,16 @@ 'print dolGetButtonTitle($btnLabel, \'\', \'fa fa-file\', \'#\', \'\', $status);', ); - echo $documentation->showCode($lines); ?>
+ echo $documentation->showCode($lines, 'php'); ?>
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 print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', -1, ['forcenohideoftext'=>1]); // Functionality is disabled print dolGetButtonTitle($btnLabel, '', 'fa fa-download', '#', '', -2, ['forcenohideoftext'=>1]); // Disabled without info - ?>
@@ -343,15 +350,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 98e3080c7d30f..f612f05a0c2dd 100644 --- a/htdocs/admin/tools/ui/components/event-message.php +++ b/htdocs/admin/tools/ui/components/event-message.php @@ -1,37 +1,39 @@ + * 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 . */ -$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'); @@ -55,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 @@ -121,7 +127,7 @@ 'setEventMessages("message", null);', 'setEventMessages(null, messages[]);', ); - echo $documentation->showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> @@ -156,11 +162,12 @@ showCode($lines); ?> + echo $documentation->showCode($lines, 'php'); ?> diff --git a/htdocs/admin/tools/ui/components/index.php b/htdocs/admin/tools/ui/components/index.php index 32af131fb91c0..409d96d22a73c 100644 --- a/htdocs/admin/tools/ui/components/index.php +++ b/htdocs/admin/tools/ui/components/index.php @@ -1,36 +1,39 @@ + * 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 . */ -$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 +51,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -56,11 +59,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..fda0b0527fc42 100644 --- a/htdocs/admin/tools/ui/components/progress-bars.php +++ b/htdocs/admin/tools/ui/components/progress-bars.php @@ -1,36 +1,39 @@ + * 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 . */ -$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'); @@ -38,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 @@ -247,6 +255,7 @@ '
', '', '', + '', ); echo $documentation->showCode($lines); ?> diff --git a/htdocs/admin/tools/ui/components/test_arrays.php b/htdocs/admin/tools/ui/components/test_arrays.php index 8954e0cd7a309..0e02e1b88855d 100644 --- a/htdocs/admin/tools/ui/components/test_arrays.php +++ b/htdocs/admin/tools/ui/components/test_arrays.php @@ -1,17 +1,43 @@ + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // Load Dolibarr environment -@include '../../main.inc.php'; +require '../../../../main.inc.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'); } +// Protection if external user +if ($user->socid > 0) { + accessforbidden(); +} - +$optioncss = GETPOST('optioncsss', 'alpha'); /* * View @@ -19,7 +45,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 //-------- @@ -163,15 +191,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'; @@ -242,18 +269,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 8eef7aa0b6cd9..449196c25a233 100644 --- a/htdocs/admin/tools/ui/components/test_buttons.php +++ b/htdocs/admin/tools/ui/components/test_buttons.php @@ -1,4 +1,20 @@ + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } @@ -25,9 +41,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(); @@ -129,7 +154,7 @@ $url = '#'.$id; $userRight = 1; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -142,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
' - ) + 'content' => 'Content to display with HTML compatible
  • test 01
  • test 02
  • test 03
', + ) ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -168,7 +193,7 @@ $url = '#'.$id; $userRight = 0; $params = array( - 'confirm' => true + 'confirm' => [], ); print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params); @@ -181,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); 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..9ab70ba6f3826 100644 --- a/htdocs/admin/tools/ui/content/tables.php +++ b/htdocs/admin/tools/ui/content/tables.php @@ -1,32 +1,31 @@ + * 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 . */ -$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 +33,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..76baca72436c7 100644 --- a/htdocs/admin/tools/ui/index.php +++ b/htdocs/admin/tools/ui/index.php @@ -1,36 +1,38 @@ + * 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 . */ -$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 +50,7 @@ $documentation->showSidebar(); ?>
- + showBreadCrumb(); ?>
@@ -61,4 +63,4 @@ docFooter(); -?> \ No newline at end of file +?> 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; + } } 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"; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 22c1ad326ba7f..9cc8d48b56bc7 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1112,7 +1112,9 @@ public function delete(User $user) $this->db->begin(); // Stock control - if (isModEnabled('stock') && !getDolGlobalInt('STOCK_CALCULATE_ON_RECEPTION') && $this->statut > 0) { + if (isModEnabled('stock') && ((getDolGlobalInt('STOCK_CALCULATE_ON_RECEPTION') && $this->status > Reception::STATUS_DRAFT) + || (getDolGlobalInt('STOCK_CALCULATE_ON_RECEPTION_CLOSE') && $this->status == Reception::STATUS_CLOSED)) + ) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; $langs->load("agenda"); @@ -1136,7 +1138,7 @@ public function delete(User $user) // we do not log origin because it will be deleted $mouvS->origin = null; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby ? $this->db->jdate($obj->eatby) : null, $obj->sellby ? $this->db->jdate($obj->sellby) : null, $obj->batch); // Price is set to 0, because we don't want to see WAP changed if ($result < 0) { $error++; $this->error = $mouvS->error; 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/*