From 3944eb362528d010749f3a33248e0bb1ef1acd12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Feb 2024 15:16:51 +0100 Subject: [PATCH 1/4] NEW Support a date selector with type 'html' --- htdocs/adherents/subscription.php | 2 +- htdocs/core/class/html.form.class.php | 22 ++++++++-------------- htdocs/langs/en_US/main.lang | 3 ++- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index e0c12678e2a..90ee4d4cf74 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -608,7 +608,7 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) { // Public $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : ''); -print ''.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).''.yn($object->public).''; +print ''.$form->textwithpicto($langs->trans("PublicFile"), $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist), 1, 'help', '', 0, 3, 'publicfile').''.yn($object->public).''; // Other attributes $cols = 2; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5bfcbd6587a..33260bc65ff 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6882,6 +6882,10 @@ class Form if (!empty($conf->use_javascript_ajax) && (!getDolGlobalString('MAIN_POPUP_CALENDAR') || getDolGlobalString('MAIN_POPUP_CALENDAR') != "none")) { $usecalendar = ((!getDolGlobalString('MAIN_POPUP_CALENDAR') || getDolGlobalString('MAIN_POPUP_CALENDAR') == 'eldy') ? 'jquery' : $conf->global->MAIN_POPUP_CALENDAR); } + if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { + // If we use a text browser or screen reader, we use the 'combo' date selector + $usecalendar = 'html'; + } if ($d) { // Show date with popup @@ -6916,8 +6920,8 @@ class Form $retstring .= '' . "\n"; $retstring .= '' . "\n"; $retstring .= '' . "\n"; - } elseif ($usecalendar == 'jquery') { - if (!$disabled) { + } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') { + if (!$disabled && $usecalendar != 'html') { // Output javascript for datepicker $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100)); $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100)); @@ -6959,19 +6963,9 @@ class Form $retstring .= '>'; // Icone calendrier - if (!$disabled) { - /* Not required. Managed by option buttonImage of jquery - $retstring.=img_object($langs->trans("SelectDate"),'calendarday','id="'.$prefix.'id" class="datecallink"'); - $retstring.='";*/ - } else { + if ($disabled) { $retstringbutton = ''; - $retsring = $retstringbutton . $retstring; + $retstring = $retstringbutton . $retstring; } $retstring .= ''; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c610fed538a..129a7d0feb0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1275,4 +1275,5 @@ EnterYourAIPromptHere=Enter your AI prompt here UseOrOperatorShort=or GoOnList=Go on list ShowSearchFields=Do a search -MyUserCard=My user file \ No newline at end of file +MyUserCard=My user file +PublicFile=Public file \ No newline at end of file From ef31b0969b3c3ebd2c37b4d9d21dd367f427c8ac Mon Sep 17 00:00:00 2001 From: gti-eu <60189441+gti-eu@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:25:20 +0100 Subject: [PATCH 2/4] Fix entity when creating project (#28519) --- htdocs/projet/class/project.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b071f2db420..dee6d2bcef5 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -494,7 +494,7 @@ class Project extends CommonObject $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); - $sql .= ", ".((int) $conf->entity); + $sql .= ", ".setEntity($this); $sql .= ", ".(!isset($this->ip) ? 'NULL' : "'".$this->db->escape($this->ip)."'"); $sql .= ")"; From 88fde71187195d3d86f0f054da86ae0d139f2a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Feb 2024 15:25:38 +0100 Subject: [PATCH 3/4] Update codespell-dict.txt (#28517) --- dev/tools/codespell/codespell-dict.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index 00764f45d53..c40c7608602 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -9,6 +9,7 @@ aploha->alpha aplohanothtml->alphanohtml aplphanothtml->alphanohtml choosed->chosen +dokument->document dolibar->dolibarr dollibar->dolibarr dollibarr->dolibarr From c5fccd41108e3279d38f08816555733ce1954a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Feb 2024 15:26:53 +0100 Subject: [PATCH 4/4] fix phpstan (#28516) * fix phpstan * fix phpstan * fix phpstan * fix phpstan --- htdocs/compta/deplacement/card.php | 10 +++++----- htdocs/compta/deplacement/class/deplacement.class.php | 4 ++-- htdocs/core/lib/agenda.lib.php | 4 ++-- htdocs/core/lib/barcode.lib.php | 3 ++- htdocs/core/lib/company.lib.php | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 34e00414b43..785bc96edc5 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-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 @@ -97,7 +97,7 @@ if ($action == 'validate' && $user->hasRight('deplacement', 'creer')) { $error = 0; $object->date = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount + $object->km = (float) price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount $object->type = GETPOST('type', 'alpha'); $object->socid = GETPOSTINT('socid'); $object->fk_user = GETPOSTINT('fk_user'); @@ -140,9 +140,9 @@ if ($action == 'validate' && $user->hasRight('deplacement', 'creer')) { if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); - $object->date = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount - $object->type = GETPOST('type', 'alpha'); + $object->date = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); + $object->km = (float) price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount + $object->type = GETPOST('type', 'alpha'); $object->socid = GETPOSTINT('socid'); $object->fk_user = GETPOSTINT('fk_user'); $object->note_private = GETPOST('note_private', 'alpha'); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 8a91ee9b50a..62208f5066c 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2013 Florian Henry - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -215,7 +215,7 @@ class Deplacement extends CommonObject public function update($user) { // Clean parameters - $this->km = price2num($this->km); + $this->km = (float) price2num($this->km); // Check parameters if (!is_numeric($this->km)) { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 73b09437bbb..6e2772e1e59 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2022-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 @@ -46,7 +46,7 @@ * @param int $usergroupid Id of group to filter on users * @param string $excludetype A type to exclude ('systemauto', 'system', '') * @param int $resourceid Preselected value of resource for filter on resource - * @param array $search_categ_cus Tag id + * @param int $search_categ_cus Tag id * @return void */ function print_actions_filter( diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 9f3ce7d3468..a236d108771 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * Copyright (C) 2004-2010 Folke Ashberg: Some lines of code were inspired from work * of Folke Ashberg into PHP-Barcode 0.3pl2, available as GPL * source code at http://www.ashberg.de/bar. @@ -407,7 +408,7 @@ function barcode_encode_genbarcode($code, $encoding) * @param array $space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale; * @return string|void */ -function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = '') +function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = []) { global $bar_color, $bg_color, $text_color; global $font_loc, $filebarcode; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 65373fb5b3e..f09dda32803 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -7,7 +7,7 @@ * Copyright (C) 2013-2014 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2018 Alexandre Spangaro - * Copyright (C) 2015-2021 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Ferran Marcet @@ -596,7 +596,7 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', * Return state translated from an id. Return value is always utf8 encoded and without entities. * * @param int $id id of state (province/departement) - * @param int $withcode '0'=Return label, + * @param string $withcode '0'=Return label, * '1'=Return string code + label, * '2'=Return code, * 'all'=return array('id'=>,'code'=>,'label'=>)