From a4a66e60f8dbdc4bccf37fcad14362e950940cfe Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 09:26:10 +0100 Subject: [PATCH 001/130] Add a substitution Category Of Operations into ODT generation for Invoices --- .../doc/doc_generic_invoice_odt.modules.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index f5dcfb86936..8a10f2d53b8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -338,6 +338,35 @@ class doc_generic_invoice_odt extends ModelePDFFactures $propal_object = $object->linkedObjects['propal'][0]; + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; + foreach ($object->lines as $line) { + + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $line->product_type; + if ($lineProductType == Product::TYPE_PRODUCT) { + $nbProduct++; + } elseif ($lineProductType == Product::TYPE_SERVICE) { + $nbService++; + } + if ($nbProduct > 0 && $nbService > 0) { + // mixed products and services + $categoryOfOperation = 2; + } + } + } + + // determine category of operation + if ($categoryOfOperation <= 0) { + // only services + if ($nbProduct == 0 && $nbService > 0) { + $categoryOfOperation = 1; + } + } + // Make substitution $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, @@ -420,6 +449,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); From 11da2351df75609d3c4b7139e6625a3f76525bd0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 08:32:22 +0000 Subject: [PATCH 002/130] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 8a10f2d53b8..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 0671ec697fda7ea6e6b1ee083370d4745d47cece Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 10:06:58 +0100 Subject: [PATCH 003/130] Add a substitution Category Of Operations into ODT generation for Invoices --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..907808f3479 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,6 +343,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { + // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 25bfd4d855fce4e754968e78ba34a602c784f128 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 09:08:32 +0000 Subject: [PATCH 004/130] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 907808f3479..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 78b383efa4b6257ec63df665ba12d99c8ef83fc2 Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Wed, 4 Jan 2023 08:59:34 +0100 Subject: [PATCH 005/130] Corrections added by Eldy --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..ba1a64f29f6 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -448,7 +448,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); From 4c032f88142a66dcf2dac61358f13a17129f94f3 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 13 Jun 2023 02:13:09 +0200 Subject: [PATCH 006/130] NEW Add possibility to choose separator #21426 --- htdocs/core/class/html.form.class.php | 244 ++++++++++-------- htdocs/core/class/html.formfile.class.php | 18 +- htdocs/core/modules/export/modules_export.php | 1 + htdocs/exports/class/export.class.php | 7 +- htdocs/exports/export.php | 3 +- 5 files changed, 166 insertions(+), 107 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e9ffa3d4bfc..d453cb61bd2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8175,10 +8175,11 @@ class Form * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set * @param int $disablebademail 1=Check if a not valid email, 2=Check string '---', and if found into value, disable and colorize entry * @param int $nohtmlescape No html escaping. + * @param string $input select if we want activate de html part or js * @return string HTML select string. * @see multiselectarray(), selectArrayAjax(), selectArrayFilter() */ - public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0) + public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0, $input = "select") { global $conf, $langs; @@ -8193,126 +8194,161 @@ class Form $out = ''; - if ($addjscombo < 0) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $addjscombo = 1; - } else { - $addjscombo = 0; - } - } - - $idname = str_replace(array('[', ']'), array('', ''), $htmlname); - $out .= 'use_javascript_ajax)) { + $textforempty = ' '; // If we use ajaxcombo, we need   here to avoid to have an empty element that is too small. } - if ($nohtmlescape) { - $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"'; + if (!is_numeric($show_empty)) { + $textforempty = $show_empty; } - if (is_array($tmpvalue)) { - foreach ($tmpvalue as $keyforvalue => $valueforvalue) { - if (preg_match('/^data-/', $keyforvalue)) { - $out .= ' '.$keyforvalue.'="'.dol_escape_htmltag($valueforvalue).'"'; + $out .= '' . "\n"; + } + + if (is_array($array)) { + // Translate + if ($translate) { + foreach ($array as $key => $value) { + if (!is_array($value)) { + $array[$key] = $langs->trans($value); + } else { + $array[$key]['label'] = $langs->trans($value['label']); } } } - $out .= '>'; - //var_dump($selectOptionValue); - $out .= $selectOptionValue; - $out .= "\n"; + + // Sort + if ($sort == 'ASC') { + asort($array); + } elseif ($sort == 'DESC') { + arsort($array); + } + + foreach ($array as $key => $tmpvalue) { + if (is_array($tmpvalue)) { + $value = $tmpvalue['label']; + $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled'; + $style = empty($tmpvalue['css']) ? '' : ' class="' . $tmpvalue['css'] . '"'; + } else { + $value = $tmpvalue; + $disabled = ''; + $style = ''; + } + if (!empty($disablebademail)) { + if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) + || ($disablebademail == 2 && preg_match('/---/', $value))) { + $disabled = ' disabled'; + $style = ' class="warning"'; + } + } + + if ($key_in_label) { + if (empty($nohtmlescape)) { + $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); + } else { + $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); + } + } else { + if (empty($nohtmlescape)) { + $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value); + } else { + $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value; + } + if ($value == '' || $value == '-') { + $selectOptionValue = ' '; + } + } + + $out .= '\n"; + } } + + $out .= ""; + + // Add code for jquery to use multiselect + if ($addjscombo && $jsbeautify) { + // Enhance with select2 + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', ($show_empty < 0 ? (string) $show_empty : '-1'), $morecss); + } + } elseif ($input == "inputSeparator") { + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; } - $out .= ""; - // Add code for jquery to use multiselect - if ($addjscombo && $jsbeautify) { - // Enhance with select2 - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', ($show_empty < 0 ? (string) $show_empty : '-1'), $morecss); - } + + return $out; } - /** * Return a HTML select string, built from an array of key+value, but content returned into select come from an Ajax call of an URL. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index b60e26d2931..b85df064385 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -703,6 +703,9 @@ class FormFile $out .= ''; $out .= ''; + $addcolumforpicto = ($delallowed || $printer || $morepicto); + $colspan = (4 + ($addcolumforpicto ? 1 : 0)); + $colspanmore = 0; $out .= ''; } - if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { print ''; print ''; print ''; @@ -503,7 +503,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; } From 1f19482f97c33b32047a999e67609b12b57bc991 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 25 Aug 2023 14:52:26 +0200 Subject: [PATCH 015/130] review --- htdocs/product/stock/stats/commande_fournisseur.php | 2 +- htdocs/product/stock/stats/expedition.php | 2 +- htdocs/product/stock/stats/reception.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index 432b8965db8..e75a8578bb8 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''; // print ''; // print ''; diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index 01739862433..612b265a0b9 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''; // print ''; // print ''; diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f4bd6f10d87..b6a019ff012 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''; // print ''; // print ''; From 7bebea38e32395555ce144a146387a3bf48700d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Aug 2023 19:42:38 +0200 Subject: [PATCH 016/130] Fix level of skill not visible on file --- htdocs/hrm/lib/hrm_job.lib.php | 2 +- htdocs/hrm/skill_card.php | 41 +++++++++++----------------------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/htdocs/hrm/lib/hrm_job.lib.php b/htdocs/hrm/lib/hrm_job.lib.php index 599ee1c2871..47858460182 100644 --- a/htdocs/hrm/lib/hrm_job.lib.php +++ b/htdocs/hrm/lib/hrm_job.lib.php @@ -61,7 +61,7 @@ function jobPrepareHead($object) $head[$h][2] = 'skill_tab'; $h++; - $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?fk_job=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?id=".$object->id; $head[$h][1] = $langs->trans("PositionsWithThisProfile"); $nbResources = 0; $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_job_user WHERE fk_job = ".((int) $object->id); diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 4b0659bfe5c..ab287ec115d 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -89,10 +89,14 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->hrm->enabled)) accessforbidden(); -if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); +if (empty($conf->hrm->enabled)) { + accessforbidden(); +} +if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) { + accessforbidden(); +} -$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; +$MaxNumberSkill = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL); /* @@ -167,7 +171,7 @@ if (empty($reshook)) { } // Actions to send emails - $triggersendname = 'hrm_SKILL_SENTBYMAIL'; + $triggersendname = 'HRM_SKILL_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_SKILL_TO'; $trackid = 'skill' . $object->id; include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; @@ -182,7 +186,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); -$title = $langs->trans("skill"); +$title = $langs->trans("Skill"); $help_url = ''; llxHeader('', $title, $help_url); @@ -468,9 +472,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } -//*---------------------------------------------------------------------------- -//*---------------------------------------------------------------------------- - //*--------------------------------------------------------------------------- @@ -589,27 +590,11 @@ if ($action != "create" && $action != "edit") { } else { $sql .= " WHERE 1 = 1 "; } + $sql .= " AND fk_skill = ".((int) $id); - if (!empty($id)) { - $sql .= " AND fk_skill = " . ((int) $id) . " "; - } - - // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. - if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; - } else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + $num = $db->num_rows($resql); print '
' . "\n"; if ($optioncss != '') { From 398205145520fa5016d665d1c0f8f508aa64be12 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 27 Aug 2023 20:42:14 +0200 Subject: [PATCH 017/130] Update myobject_document.php edit / sort general defined options --- .../template/myobject_document.php | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index d7eafaa78a3..7919cb33730 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -22,24 +22,26 @@ * \brief Tab for documents linked to MyObject */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +// General defined Options +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value +//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too. +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) + // Load Dolibarr environment $res = 0; @@ -82,13 +84,12 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); - -$action = GETPOST('action', 'aZ09'); +// Get parameters +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -112,6 +113,7 @@ $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array($object->element.'document', 'globalcard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -122,15 +124,16 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".get_exdir(0, 0, 0, 1, $object); } -// There is several ways to check permission. +// Permissions +// (There are several ways to check permission.) // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php + $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php } else { $permissiontoread = 1; - $permissiontoadd = 1; + $permissiontoadd = 1; } // Security check (enable the most restrictive one) @@ -163,10 +166,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); +// Header +// ------ $title = $langs->trans("MyObject")." - ".$langs->trans("Files"); //$title = $object->ref." - ".$langs->trans("Files"); $help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +//Example $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); // Show tabs From fbd262236b4e93929723a84718f734afd427c736 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Aug 2023 07:40:44 +0200 Subject: [PATCH 018/130] FIX Accountancy - List of accounts - Compatibility left column checkbox + Search id_import + Hooks + Undefined variable --- htdocs/accountancy/admin/account.php | 201 ++++++++++++++++++++------- 1 file changed, 154 insertions(+), 47 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index c5db08e73e7..1dc461b8ae6 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2016-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -142,10 +142,13 @@ if (empty($reshook)) { $search_labelshort = ""; $search_accountparent = ""; $search_pcgtype = ""; + $search_import_key = ""; $search_array_options = array(); } if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != getDolGlobalInt('CHARTOFACCOUNTS'))) { // a submit of form is done and chartofaccounts combo has been modified + $error = 0; + if ($chartofaccounts > 0 && $permissiontoadd) { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; @@ -218,14 +221,13 @@ if (empty($reshook)) { /* * View */ - $form = new Form($db); $formaccounting = new FormAccounting($db); llxHeader('', $langs->trans("ListAccounts")); if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -234,11 +236,24 @@ $pcgver = getDolGlobalInt('CHARTOFACCOUNTS'); $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,"; $sql .= " aa.reconcilable, aa.active, aa.import_key,"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; + +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity); $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity); + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE asy.rowid = ".((int) $pcgver); -//print $sql; + if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; if (getDolGlobalInt('ACCOUNTING_LENGTH_GACCOUNT') || getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) { @@ -285,6 +300,15 @@ if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') { if (strlen(trim($search_pcgtype))) { $sql .= natural_search("aa.pcg_type", $search_pcgtype); } +if (strlen(trim($search_import_key))) { + $sql .= natural_search("aa.import_key", $search_import_key); +} + +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= $db->order($sortfield, $sortorder); //print $sql; @@ -299,16 +323,6 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { } } -// List of mass actions available -if ($user->hasRight('accounting', 'chartofaccount')) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete', 'closed'))) { - $arrayofmassactions = array(); -} - -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$arrayofselected = is_array($toselect) ? $toselect : array(); $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql='.$sql); @@ -317,6 +331,8 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); + $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); @@ -339,13 +355,18 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } - if ($optioncss != '') { + if ($search_import_key) { $param .= '&search_import_key='.urlencode($search_import_key); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + if (!empty($conf->use_javascript_ajax)) { print ' '; } + // List of mass actions available + if ($user->hasRight('accounting', 'chartofaccount')) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete', 'closed'))) { + $arrayofmassactions = array(); + } + + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $newcardbutton = ''; + $newcardbutton = dolGetButtonTitle($langs->trans('Addanaccount'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/accountancy/admin/card.php?action=create', '', $permissiontoadd); + print ''; if ($optioncss != '') { @@ -372,10 +405,10 @@ if ($resql) { print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accounting_account', 0, $newcardbutton, '', $limit, 0, 0, 1); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + // Box to select active chart of account print $langs->trans("Selectchartofaccounts")." : "; print '
'; @@ -718,7 +721,8 @@ class FormFile if ($conf->browser->layout == 'phone') { $morecss = 'maxwidth100'; } - $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0, "inputSeparator"); if ($conf->use_javascript_ajax) { $out .= ajax_combobox('model'); } @@ -976,6 +980,18 @@ class FormFile } } $out .= ''."\n"; + + $out .= ''; //return ($i?$i:$headershown); return $out; } diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 0cad4f76509..0ae9379c632 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -72,6 +72,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac require_once $file; if (class_exists($classname)) { $module = new $classname($db); + // var_dump($classname); // Picto $this->picto[$module->id] = $module->picto; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 6563e9d6338..1565390b81b 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -586,9 +586,10 @@ class Export * @param array $array_selected Filter on array of fields to export * @param array $array_filterValue Filter on array of fields with a filter * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) + * @param string $separator separator to fill $objmodel->separator with the new separator * @return int <0 if KO, >0 if OK */ - public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '', $separator = '') { // phpcs:enable global $conf, $langs, $mysoc; @@ -612,6 +613,10 @@ class Export require_once $dir.$file; $objmodel = new $classname($this->db); + if (in_array($model, array('csvutf8', 'csviso')) && !empty($separator)) { + $objmodel->separator = $separator; + } + if (!empty($sqlquery)) { $sql = $sqlquery; } else { diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 8fc16e43963..5b6116d153c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -269,6 +269,7 @@ if ($step == 1 || $action == 'cleanselect') { } if ($action == 'builddoc') { + $separator = GETPOST('delimiter', 'alpha'); $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); if ($max_time && $max_time < $max_execution_time_for_importexport) { @@ -277,7 +278,7 @@ if ($action == 'builddoc') { } // Build export file - $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue); + $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue, '', $separator); if ($result < 0) { setEventMessages($objexport->error, $objexport->errors, 'errors'); $sqlusedforexport = $objexport->sqlusedforexport; From bcd5666e01c25350f14dc12590b21c20383e3db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Sun, 9 Jul 2023 12:16:05 +0200 Subject: [PATCH 007/130] Support extrafields in selectForForms --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39a0d9754e0..59b9c70dca2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8030,6 +8030,7 @@ class Form // Search data $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t"; + $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; if (isset($objecttmp->ismultientitymanaged)) { if (!is_numeric($objecttmp->ismultientitymanaged)) { $tmparray = explode('@', $objecttmp->ismultientitymanaged); From 7442a855146a7070a0b1ec904f797c3a170200b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 11 Jul 2023 06:40:33 +0200 Subject: [PATCH 008/130] check if object has extrafields --- htdocs/core/class/html.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 59b9c70dca2..4d7e41f6501 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8030,7 +8030,9 @@ class Form // Search data $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t"; - $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; + if (!empty($objecttmp->isextrafieldmanaged)) { + $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; + } if (isset($objecttmp->ismultientitymanaged)) { if (!is_numeric($objecttmp->ismultientitymanaged)) { $tmparray = explode('@', $objecttmp->ismultientitymanaged); From a73024bec87517dea55948c7b79f52774187dc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:54:58 +0200 Subject: [PATCH 009/130] add extrafieldmanaged in commande.class.php --- htdocs/commande/class/commande.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 64dd3ad564a..ec23a97acc5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -82,6 +82,11 @@ class Commande extends CommonOrder */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer From bb1aad54c0c3cb218699a064dc5a34d6d1587121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:56:25 +0200 Subject: [PATCH 010/130] add $isextrafieldmanaged to contact.class.php --- htdocs/contact/class/contact.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 3a4128f01cf..728efba79a1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -60,6 +60,11 @@ class Contact extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ From 38037089dd12b52299bb43523054a4f1b3248870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:57:50 +0200 Subject: [PATCH 011/130] add $isextrafieldmanaged to facture.class.php --- htdocs/compta/facture/class/facture.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 851fc3a08b1..5bbf4fadf98 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -90,6 +90,11 @@ class Facture extends CommonInvoice */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer From 6ec130d2e6d6be28c840037a100b9545d547682d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:58:55 +0200 Subject: [PATCH 012/130] add $isextrafieldmanaged to expedition.class.php --- htdocs/expedition/class/expedition.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b62a9a94a5b..dae0b9dc329 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -79,6 +79,11 @@ class Expedition extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ From d4b722959f0cae459a43002692edcb246c6a5fdf Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 2 Aug 2023 20:20:08 +0200 Subject: [PATCH 013/130] edit the function selectarray for remove the script for separator and move it where we want to use this --- htdocs/core/class/html.form.class.php | 231 +++++++++------------- htdocs/core/class/html.formfile.class.php | 32 ++- 2 files changed, 125 insertions(+), 138 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7c4eddeaf13..24122f79cea 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8206,11 +8206,10 @@ class Form * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set * @param int $disablebademail 1=Check if a not valid email, 2=Check string '---', and if found into value, disable and colorize entry * @param int $nohtmlescape No html escaping. - * @param string $input select if we want activate de html part or js * @return string HTML select string. * @see multiselectarray(), selectArrayAjax(), selectArrayFilter() */ - public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0, $input = "select") + public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0) { global $conf, $langs; @@ -8225,152 +8224,110 @@ class Form $out = ''; - if ($input === "select") { - if ($addjscombo < 0) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $addjscombo = 1; + if ($addjscombo < 0) { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $addjscombo = 1; + } else { + $addjscombo = 0; + } + } + $idname = str_replace(array('[', ']'), array('', ''), $htmlname); + $out .= 'use_javascript_ajax)) { - $textforempty = ' '; // If we use ajaxcombo, we need   here to avoid to have an empty element that is too small. - } - if (!is_numeric($show_empty)) { - $textforempty = $show_empty; - } - $out .= '' . "\n"; - } - - if (is_array($array)) { - // Translate - if ($translate) { - foreach ($array as $key => $value) { - if (!is_array($value)) { - $array[$key] = $langs->trans($value); - } else { - $array[$key]['label'] = $langs->trans($value['label']); - } + if (!empty($disablebademail)) { + if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) + || ($disablebademail == 2 && preg_match('/---/', $value))) { + $disabled = ' disabled'; + $style = ' class="warning"'; } } - - // Sort - if ($sort == 'ASC') { - asort($array); - } elseif ($sort == 'DESC') { - arsort($array); - } - - foreach ($array as $key => $tmpvalue) { - if (is_array($tmpvalue)) { - $value = $tmpvalue['label']; - $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled'; - $style = empty($tmpvalue['css']) ? '' : ' class="' . $tmpvalue['css'] . '"'; + if ($key_in_label) { + if (empty($nohtmlescape)) { + $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); } else { - $value = $tmpvalue; - $disabled = ''; - $style = ''; + $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); } - if (!empty($disablebademail)) { - if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) - || ($disablebademail == 2 && preg_match('/---/', $value))) { - $disabled = ' disabled'; - $style = ' class="warning"'; - } - } - - if ($key_in_label) { - if (empty($nohtmlescape)) { - $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); - } else { - $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); - } + } else { + if (empty($nohtmlescape)) { + $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value); } else { - if (empty($nohtmlescape)) { - $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value); - } else { - $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value; - } - if ($value == '' || $value == '-') { - $selectOptionValue = ' '; - } + $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value; } - - $out .= '\n"; } + $out .= '\n"; } - - $out .= ""; - - // Add code for jquery to use multiselect - if ($addjscombo && $jsbeautify) { - // Enhance with select2 - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', ($show_empty < 0 ? (string) $show_empty : '-1'), $morecss); - } - } elseif ($input == "inputSeparator") { - $out .= ''; - $out .= ''; - $out .= ''; - - $out .= ''; + } + $out .= ""; + // Add code for jquery to use multiselect + if ($addjscombo && $jsbeautify) { + // Enhance with select2 + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', ($show_empty < 0 ? (string) $show_empty : '-1'), $morecss); } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 82fab9535d5..a38c418d8ec 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -722,7 +722,37 @@ class FormFile $morecss = 'maxwidth100'; } $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0); - $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0, "inputSeparator"); + // script for select the separator + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; if ($conf->use_javascript_ajax) { $out .= ajax_combobox('model'); } From 17fa595c8835ade04c8cf1ec8922c1048f00e76b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 25 Aug 2023 12:50:13 +0200 Subject: [PATCH 014/130] FIX: review quality managment on product lot --- .../install/mysql/migration/18.0.0-19.0.0.sql | 2 ++ .../install/mysql/tables/llx_product_lot.sql | 2 ++ .../product/stock/class/productlot.class.php | 29 ++++++++++++------- htdocs/product/stock/productlot_card.php | 7 +++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index c9e38a072c4..184cfb84581 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -66,3 +66,5 @@ ALTER TABLE llx_societe_rib ADD COLUMN extraparams varchar(255); ALTER TABLE llx_c_type_container ADD COLUMN position integer DEFAULT 0; +ALTER TABLE llx_product_lot ADD COLUMN qc_frequency integer DEFAULT NULL; +ALTER TABLE llx_product_lot ADD COLUMN lifetime integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_product_lot.sql b/htdocs/install/mysql/tables/llx_product_lot.sql index 4ab7e0865b1..cbd8c634b9a 100644 --- a/htdocs/install/mysql/tables/llx_product_lot.sql +++ b/htdocs/install/mysql/tables/llx_product_lot.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_product_lot ( eol_date datetime NULL, manufacturing_date datetime NULL, -- date for first use of the lot scrapping_date datetime NULL, -- date when we decided to scrap all products of this lot + qc_frequency integer DEFAULT NULL, + lifetime integer DEFAULT NULL, barcode varchar(180) DEFAULT NULL, -- barcode fk_barcode_type integer DEFAULT NULL, -- barcode type model_pdf varchar(255), diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 815d0af1a50..1874bd03cea 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -106,11 +106,12 @@ class Productlot extends CommonObject 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60), - 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1', 'visible'=>5, 'position'=>70), - 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>1, 'visible'=>1, 'position'=>80), - 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>90), - //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100), - //'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_QUALITYCONTROL)?1:0', 'visible'=>5, 'position'=>110), + 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>70), + 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>80), + 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>90), + //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100), + 'qc_frequency' => array('type'=>'integer', 'label'=>'QCFrequency', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110), + 'lifetime' => array('type'=>'integer', 'label'=>'Lifetime', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 215), 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -2, 'position' => 310), @@ -141,7 +142,8 @@ class Productlot extends CommonObject public $manufacturing_date = ''; public $scrapping_date = ''; //public $commissionning_date = ''; - //public $qc_frequency = ''; + public $qc_frequency = ''; + public $lifetime = ''; public $datec = ''; public $tms = ''; @@ -227,7 +229,8 @@ class Productlot extends CommonObject $sql .= 'manufacturing_date,'; $sql .= 'scrapping_date,'; //$sql .= 'commissionning_date,'; - //$sql .= 'qc_frequency,'; + $sql .= 'qc_frequency,'; + $sql .= 'lifetime,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -242,7 +245,8 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) == 0 ? 'NULL' : "'".$this->db->idate($this->manufacturing_date)."'").','; $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; //$sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; - //$sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(!isset($this->lifetime) ? 'NULL' : $this->lifetime).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; @@ -316,7 +320,8 @@ class Productlot extends CommonObject $sql .= " t.manufacturing_date,"; $sql .= " t.scrapping_date,"; //$sql .= " t.commissionning_date,"; - //$sql .= " t.qc_frequency,"; + $sql .= " t.qc_frequency,"; + $sql .= " t.lifetime,"; $sql .= " t.model_pdf,"; $sql .= " t.last_main_doc,"; $sql .= " t.datec,"; @@ -352,7 +357,8 @@ class Productlot extends CommonObject $this->manufacturing_date = $this->db->jdate($obj->manufacturing_date); $this->scrapping_date = $this->db->jdate($obj->scrapping_date); //$this->commissionning_date = $this->db->jdate($obj->commissionning_date); - //$this->qc_frequency = $obj->qc_frequency; + $this->qc_frequency = $obj->qc_frequency; + $this->lifetime = $obj->lifetime; $this->model_pdf = $obj->model_pdf; $this->last_main_doc = $obj->last_main_doc; @@ -434,7 +440,8 @@ class Productlot extends CommonObject $sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').','; $sql .= ' scrapping_date = '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) != 0 ? "'".$this->db->idate($this->scrapping_date)."'" : 'null').','; //$sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; - //$sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; + $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; + $sql .= ' lifetime = '.(!isset($this->lifetime) || dol_strlen($this->lifetime) != 0 ? $this->db->escape($this->lifetime) : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 5fa6afe983c..2da298d7b37 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -485,7 +485,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string').'
'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->rights->stock->creer, 'string').'
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'."\n"; - // Line for search fields + // Fields title search + // -------------------------------------------------------------------- print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } if (!empty($arrayfields['aa.account_number']['checked'])) { print ''; } @@ -452,6 +499,12 @@ if ($resql) { if (!empty($arrayfields['categories']['checked'])) { print ''; } + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Import key if (!empty($arrayfields['aa.import_key']['checked'])) { print ''; @@ -464,44 +517,78 @@ if ($resql) { if (!empty($arrayfields['aa.active']['checked'])) { print ''; } - print ''; - print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ''."\n"; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + + // Fields title label + // -------------------------------------------------------------------- print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + $totalarray['nbfield']++; + } if (!empty($arrayfields['aa.account_number']['checked'])) { print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.label']['checked'])) { print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.labelshort']['checked'])) { print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_parent']['checked'])) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); + $totalarray['nbfield']++; } if (!empty($arrayfields['categories']['checked'])) { print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + $totalarray['nbfield']++; } + + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['aa.import_key']['checked'])) { print_liste_field_titre($arrayfields['aa.import_key']['label'], $_SERVER["PHP_SELF"], 'aa.import_key', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.import_key']['help'], 1); + $totalarray['nbfield']++; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } } if (!empty($arrayfields['aa.active']['checked'])) { print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; + } + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + $totalarray['nbfield']++; } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; + // Loop on record + // -------------------------------------------------------------------- $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -512,6 +599,22 @@ if ($resql) { print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Account number if (!empty($arrayfields['aa.account_number']['checked'])) { print "'; + if (!$i) { + $totalarray['nbfield']++; } - } - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; } print "\n"; @@ -675,9 +775,16 @@ if ($resql) { print ''; } - print "
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ' '; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '"; @@ -589,6 +692,11 @@ if ($resql) { } } + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Import id if (!empty($arrayfields['aa.import_key']['checked'])) { print ""; @@ -600,7 +708,7 @@ if ($resql) { } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - // Activated or not reconciliation on accounting account + // Activated or not reconciliation on an accounting account if (!empty($arrayfields['aa.reconcilable']['checked'])) { print ''; if (empty($obj->reconcilable)) { @@ -637,28 +745,20 @@ if ($resql) { } } - // Action - print ''; - if ($user->hasRight('accounting', 'chartofaccount')) { - print ''; - print img_edit(); - print ''; - print ' '; - print ''; - print img_delete(); - print ''; - print ' '; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; + } + print '
'.$langs->trans("None").'
"; - print ""; - print ''; + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''."\n"; + print ''."\n"; + + print ''."\n"; } else { dol_print_error($db); } From 314b7aa3f8c0c710e86ec009e7590d32f96d3e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 28 Aug 2023 08:03:21 +0200 Subject: [PATCH 019/130] phpstan --- htdocs/core/class/commonobject.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 192f1816c02..9769fe903e2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -673,6 +673,16 @@ abstract class CommonObject */ public $nb = array(); + /** + * @var array array of status string + */ + public $statuts = array(); + + /** + * @var array array of short status string + */ + public $statuts_short = array(); + /** * @var string output */ From 963e4752840ed5e0ac8460613d0a2ea914f8b47f Mon Sep 17 00:00:00 2001 From: Hystepik Date: Mon, 28 Aug 2023 11:35:37 +0200 Subject: [PATCH 020/130] Fix #25452 disable Bom & Mo when product disabled --- htdocs/core/modules/modProduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 9595226f701..9b0a3b1aa8b 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -68,7 +68,7 @@ class modProduct extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(7, 0); // Minimum version of PHP required by module From 52e57f8c8b09a0b8b6db64f554a4ce060f5723bb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Aug 2023 12:40:24 +0200 Subject: [PATCH 021/130] feat: Database change for #25681 --- htdocs/install/mysql/migration/18.0.0-19.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_product_lot.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 447fc69a05d..d471ef37114 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -88,3 +88,5 @@ ALTER TABLE llx_societe DROP COLUMN skype; ALTER TABLE llx_prelevement_demande ADD INDEX idx_prelevement_demande_ext_payment_id (ext_payment_id); +ALTER TABLE llx_product_lot ADD COLUMN qc_frequency integer DEFAULT NULL; +ALTER TABLE llx_product_lot ADD COLUMN lifetime integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_product_lot.sql b/htdocs/install/mysql/tables/llx_product_lot.sql index 4ab7e0865b1..cbd8c634b9a 100644 --- a/htdocs/install/mysql/tables/llx_product_lot.sql +++ b/htdocs/install/mysql/tables/llx_product_lot.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_product_lot ( eol_date datetime NULL, manufacturing_date datetime NULL, -- date for first use of the lot scrapping_date datetime NULL, -- date when we decided to scrap all products of this lot + qc_frequency integer DEFAULT NULL, + lifetime integer DEFAULT NULL, barcode varchar(180) DEFAULT NULL, -- barcode fk_barcode_type integer DEFAULT NULL, -- barcode type model_pdf varchar(255), From bac3c364360933a8914f1dfa1487fc05339ab274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Aug 2023 13:47:00 +0200 Subject: [PATCH 022/130] Fix warning --- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index ac19a73045c..9d96e51fae6 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -519,7 +519,7 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array('type'=>$type); + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; From e500da7b5cec68b53670a53b589e6cf7bc64e18b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Aug 2023 14:12:40 +0200 Subject: [PATCH 023/130] Trans --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- htdocs/langs/en_US/knowledgemanagement.lang | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0194c45b457..a4b493359d5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -396,7 +396,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Tickets and knowledge base + // Tickets and Knowledge base $tmpentry = array( 'enabled'=>(isModEnabled('ticket') || isModEnabled('knowledgemanagement')), 'perms'=>($user->hasRight('ticket', 'read') || $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')), @@ -411,7 +411,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Ticket', 'link' => $link, - 'title' => "Tickets", + 'title' => isModEnabled('ticket') ? "Tickets" : "MenuKnowledgeRecordShort", 'level' => 0, 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index 050ecbcc03a..acf1bd62f11 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -39,6 +39,7 @@ KnowledgeManagementAboutPage = Knowledge Management about page KnowledgeManagementArea = Knowledge Management MenuKnowledgeRecord = Knowledge base +MenuKnowledgeRecordShort = Knowledge base ListKnowledgeRecord = List of articles NewKnowledgeRecord = New article ValidateReply = Validate solution From 833d967ee45bf7bb01e4c742834b7a513d96fcbc Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:16:29 +0200 Subject: [PATCH 024/130] Update myobject_document.php --- htdocs/modulebuilder/template/myobject_document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 7919cb33730..8b97342da44 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -124,7 +124,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".get_exdir(0, 0, 0, 1, $object); } -// Permissions +// Permissions // (There are several ways to check permission.) // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; From e3253cd8d73fac2215caad84ce6cae15b1ce3746 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Aug 2023 14:40:01 +0200 Subject: [PATCH 025/130] fix travis --- htdocs/product/stock/class/productlot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 1874bd03cea..91dc88f76e9 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -440,7 +440,7 @@ class Productlot extends CommonObject $sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').','; $sql .= ' scrapping_date = '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) != 0 ? "'".$this->db->idate($this->scrapping_date)."'" : 'null').','; //$sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; - $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; + $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? $this->db->escape($this->qc_frequency) : 'null').','; $sql .= ' lifetime = '.(!isset($this->lifetime) || dol_strlen($this->lifetime) != 0 ? $this->db->escape($this->lifetime) : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; From 1baff187f28ab9b2e21c15011df564d15f223c6b Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:52:59 +0200 Subject: [PATCH 026/130] Update /htdocs/comm/index.php --- htdocs/comm/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 1ae1ae0a6fb..30fcf10f681 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -34,12 +34,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +if (isModEnabled('contrat')) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } From 9681ff7e17f99dc342556159f7f231d5e2cfcb38 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Aug 2023 14:57:59 +0200 Subject: [PATCH 027/130] fix travis --- htdocs/product/stock/class/productlot.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 91dc88f76e9..ba38a96c220 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -245,8 +245,8 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) == 0 ? 'NULL' : "'".$this->db->idate($this->manufacturing_date)."'").','; $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; //$sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; - $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; - $sql .= ' '.(!isset($this->lifetime) ? 'NULL' : $this->lifetime).','; + $sql .= ' '.(empty($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(empty($this->lifetime) ? 'NULL' : $this->lifetime).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; @@ -440,8 +440,8 @@ class Productlot extends CommonObject $sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').','; $sql .= ' scrapping_date = '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) != 0 ? "'".$this->db->idate($this->scrapping_date)."'" : 'null').','; //$sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; - $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? $this->db->escape($this->qc_frequency) : 'null').','; - $sql .= ' lifetime = '.(!isset($this->lifetime) || dol_strlen($this->lifetime) != 0 ? $this->db->escape($this->lifetime) : 'null').','; + $sql .= ' qc_frequency = '.(!empty($this->qc_frequency) ? (int) $this->qc_frequency : 'null').','; + $sql .= ' lifetime = '.(!empty($this->lifetime) ? (int) $this->lifetime : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; From f57da2b89add8c2a9bca2fb1687628b2b3e0cde0 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:08:34 +0200 Subject: [PATCH 028/130] Update /htdocs/asset/list.php // Get paramaters $mode --- htdocs/asset/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index adbb6afd400..96a09b6507e 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load translation files required by the page $langs->loadLangs(array("assets", "other")); +// Get parameters $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -42,8 +43,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - -$id = GETPOST('id', 'int'); +$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common) +$id = GETPOST('id', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; From 52fce1bf0da8c7b53fd88988ab673997dbd657ec Mon Sep 17 00:00:00 2001 From: vmaury Date: Mon, 28 Aug 2023 16:43:30 +0200 Subject: [PATCH 029/130] Fix #25714 : Totals in propal not rounded according to MAIN_MAX_DECIMALS_SHOWN --- htdocs/comm/propal/card.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 19de5f10068..05da688d2f8 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2799,35 +2799,35 @@ if ($action == 'create') { print ''; print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ht, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; print ''; print '' . $langs->trans('AmountVAT') . ''; - print '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_tva, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { print ''; print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { print ''; print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; } @@ -2835,9 +2835,9 @@ if ($action == 'create') { print ''; print '' . $langs->trans('AmountTTC') . ''; - print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; From dbd65ca2423372784380a10f7f320411ad46ead6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Aug 2023 17:34:05 +0200 Subject: [PATCH 030/130] NEW Option to show label, ref+label or only ref of product in TakePOS --- htdocs/langs/en_US/cashdesk.lang | 2 +- htdocs/takepos/admin/appearance.php | 7 ++++++- htdocs/takepos/index.php | 14 +++++++++----- htdocs/takepos/invoice.php | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 9cde66460d3..f745c0b7cc2 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -141,7 +141,7 @@ HideCategories=Hide categories HideStockOnLine=Hide stock on line ShowOnlyProductInStock=Show the products in stock ShowCategoryDescription=Show category description -ShowProductReference=Show reference of products +ShowProductReference=Show reference or label of products UsePriceHT=Use price excl. taxes and not price incl. taxes TerminalName=Terminal %s TerminalNameDesc=Terminal name diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 54ed2f642a2..cc3f3cd24a8 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -46,6 +46,9 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_LINES_TO_SHOW", GETPOST('TAKEPOS_LINES_TO_SHOW', 'alpha'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('TAKEPOS_SHOW_PRODUCT_REFERENCE')) { + $res = dolibarr_set_const($db, "TAKEPOS_SHOW_PRODUCT_REFERENCE", GETPOST('TAKEPOS_SHOW_PRODUCT_REFERENCE', 'alpha'), 'chaine', 0, '', $conf->entity); + } dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -150,7 +153,9 @@ print "\n"; print ''; print $langs->trans('ShowProductReference'); print ''; -print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0); +$array = array("0"=>$langs->trans("Label"), 1=>$langs->trans("Ref").'+'.$langs->trans("Label"), 2=>$langs->trans("Ref")); +print $form->selectarray('TAKEPOS_SHOW_PRODUCT_REFERENCE', $array, getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE', 2), 0); +//print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0); print "\n"; // Use price excl. taxes (HT) and not price incl. taxes (TTC) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ff6371fe735..32d7301b6fe 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -361,6 +361,8 @@ function LoadProducts(position, issubcat) { echo '$("#prodivdesc"+ishow).show();'; if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);'; + } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { + echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());'; } else { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);'; } @@ -449,9 +451,10 @@ function MoreProducts(moreorless) { $("#prodiv"+ishow).data("rowid",""); } else { $("#prodivdesc"+ishow).show(); - + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); + + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold()); $("#prodesc"+ishow).html(data[parseInt(idata)]['label']); @@ -659,9 +662,10 @@ function Search2(keyCodeForEnter, moreorless) { $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']"; ?> var titlestring = ; - - $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).html(data[i]['ref'].bold()); $("#prodesc" + i).html(data[i]['label']); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c5c34f6a3a4..037f8ed6dad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1560,6 +1560,8 @@ if ($placeid > 0) { } if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { $htmlforlines .= $form->textwithpicto($line->product_label ? '' . $line->product_ref . ' - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); + } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { + $htmlforlines .= $form->textwithpicto($line->product_ref ? ''.$line->product_ref.'' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); } else { $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); } From adcf71717c3683b5ec84866a2c9740ad7280e39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 28 Aug 2023 18:21:35 +0200 Subject: [PATCH 031/130] fix phpstan --- .../modules/export/export_tsv.modules.php | 2 +- .../core/modules/export/exportcsv.modules.php | 2 +- htdocs/core/modules/export/modules_export.php | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 40ee75a1749..956639f0135 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -230,7 +230,7 @@ class ExportTsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/exportcsv.modules.php b/htdocs/core/modules/export/exportcsv.modules.php index fd96bf468f3..5703a098e20 100644 --- a/htdocs/core/modules/export/exportcsv.modules.php +++ b/htdocs/core/modules/export/exportcsv.modules.php @@ -213,7 +213,7 @@ class ExportCsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 0cad4f76509..efc7a299fa7 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -37,12 +37,43 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $driverlabel = array(); + public $driverdesc = array(); + public $driverversion = array(); public $liblabel = array(); public $libversion = array(); + /** + * @var string picto + */ + public $picto; + + /** + * @var string description + */ + public $desc; + + /** + * @var string escape + */ + public $escape; + + /** + * @var string enclosure + */ + public $enclosure; + + /** + * @var int col + */ + public $col; + + /** + * @var int disabled + */ + public $disabled; /** * Load into memory list of available export format From 11fe88471570d060d3a82858ca46a7ed7d23765e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Mon, 28 Aug 2023 18:46:09 +0200 Subject: [PATCH 032/130] fix phpstan --- htdocs/workstation/workstation_agenda.php | 4 +++- htdocs/workstation/workstation_card.php | 14 ++++++++------ htdocs/workstation/workstation_document.php | 4 +++- htdocs/workstation/workstation_list.php | 8 +++++--- htdocs/workstation/workstation_note.php | 2 ++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index 1e181ac46bd..cf5fb59a258 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; +global $conf, $db, $hookmanager, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); @@ -87,7 +89,7 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check $isdraft = 0; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index dfeccf54a87..0a1eb0a4c78 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; +global $conf, $db, $hookmanager, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); @@ -78,11 +80,11 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->workstation->workstation->read; -$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->workstation->workstation->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->workstation->workstation->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); +$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('workstation', 'workstation', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DISABLED); +$permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -161,7 +163,7 @@ llxHeader('', $title, $help_url); // jquery code ?> - '; + */ if ($conf->use_javascript_ajax) { $out .= ajax_combobox('model'); } @@ -1015,7 +1017,7 @@ class FormFile $out .= ''; - - -// Part to create -if ($action == 'create') { - if (empty($permissiontoadd)) { - accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1); - exit; - } - - print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Booking")), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(array(), ''); - - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - print '
'."\n"; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; - - //dol_set_focus('input[name="ref"]'); -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("Booking"), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(); - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); - - print '
'; -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - - $head = bookingPrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Booking"), -1, $object->picto); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBooking'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - - // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...) - if ($action == 'xxx') { - $text = $langs->trans('ConfirmActionBooking', $object->ref); - /*if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOOKING_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - print ''."\n"; - - // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field - //unset($object->fields['fk_project']); // Hide field already shown in banner - //unset($object->fields['fk_soc']); // Hide field already shown in banner - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - - // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
- - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, $soc); - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; - - print "
\n"; - } - - - // Buttons for actions - - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - // Send - if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); - } - - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); - } - - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - - // Validate - if ($object->status == $object::STATUS_DRAFT) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); - } else { - $langs->load("errors"); - print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); - } - } - - // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd); - - /* - if ($permissiontoadd) { - if ($object->status == $object::STATUS_ENABLED) { - print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); - } else { - print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd); - } - } - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); - } else { - print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd); - } - } - */ - - // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); - } - print '
'."\n"; - } - - - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - if ($action != 'presend') { - print '
'; - print ''; // ancre - - $includedocgeneration = 0; - - // Documents - if ($includedocgeneration) { - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content - $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bookcal:Booking', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - } - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('booking')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/booking_agenda.php', 1).'?id='.$object->id); - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); - - print '
'; - } - - //Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - // Presend form - $modelmail = 'booking'; - $defaulttopic = 'InformationMessage'; - $diroutput = $conf->bookcal->dir_output; - $trackid = 'booking'.$object->id; - - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php deleted file mode 100644 index 938e3287c70..00000000000 --- a/htdocs/bookcal/booking_contact.php +++ /dev/null @@ -1,197 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 . - */ - -/** - * \file htdocs/bookcal/booking_contact.php - * \ingroup bookcal - * \brief Tab for contacts linked to Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies", "other", "mails")); - -$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility -$ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingcontact', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permission = $user->rights->bookcal->booking->write; -} else { - $permissiontoread = 1; - $permission = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Add a new contact - */ - -if ($action == 'addcontact' && $permission) { - $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} elseif ($action == 'swapstatut' && $permission) { - // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); -} elseif ($action == 'deletecontact' && $permission) { - // Deletes a contact - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - dol_print_error($db); - } -} - - -/* - * View - */ - -$title = $langs->trans('Booking')." - ".$langs->trans('ContactsAddresses'); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -$form = new Form($db); -$formcompany = new FormCompany($db); -$contactstatic = new Contact($db); -$userstatic = new User($db); - - -/* *************************************************************************** */ -/* */ -/* View and edit mode */ -/* */ -/* *************************************************************************** */ - -if ($object->id) { - /* - * Show tabs - */ - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'contact', $langs->trans("Booking"), -1, $object->picto); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - - print dol_get_fiche_end(); - - print '
'; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php deleted file mode 100644 index d04258d54d2..00000000000 --- a/htdocs/bookcal/booking_document.php +++ /dev/null @@ -1,211 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 . - */ - -/** - * \file htdocs/bookcal/booking_document.php - * \ingroup bookcal - * \brief Tab for documents linked to Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies", "other", "mails")); - - -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -$ref = GETPOST('ref', 'alpha'); - -// Get parameters -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} -//if (! $sortfield) $sortfield="position_name"; - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingdocument', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bookcal->multidir_output[$object->entity ? $object->entity : $conf->entity]."/booking/".get_exdir(0, 0, 0, 1, $object); -} - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - - -/* - * View - */ - -$form = new Form($db); - -$title = $langs->trans("Booking").' - '.$langs->trans("Files"); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -if ($object->id) { - /* - * Show tabs - */ - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'document', $langs->trans("Booking"), -1, $object->picto); - - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - - print '
'; - print ''; - - // Number of files - print ''; - - // Total size - print ''; - - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print '
'; - - print dol_get_fiche_end(); - - $modulepart = 'bookcal'; - //$permissiontoadd = $user->rights->bookcal->booking->write; - $permissiontoadd = 1; - //$permtoedit = $user->rights->bookcal->booking->write; - $permtoedit = 1; - $param = '&id='.$object->id; - - //$relativepathwithnofile='booking/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile = 'booking/'.dol_sanitizeFileName($object->ref).'/'; - - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 0, 1); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php deleted file mode 100644 index a141f33a909..00000000000 --- a/htdocs/bookcal/booking_list.php +++ /dev/null @@ -1,794 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 . - */ - -/** - * \file htdocs/bookcal/booking_list.php - * \ingroup bookcal - * \brief List page for booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load bookcal libraries -require_once __DIR__.'/class/booking.class.php'; - -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "other")); - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); - -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookinglist')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); -//$extrafields->fetch_name_optionals_label($object->table_element_line); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -} -if (!$sortorder) { - $sortorder = "ASC"; -} - -// Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); - $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); - } -} - -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns -$arrayfields = array(); -foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - -$object->fields = dol_sort_array($object->fields, 'position'); -//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); -$arrayfields = dol_sort_array($arrayfields, 'position'); - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; - $permissiontodelete = $user->rights->bookcal->booking->delete; -} else { - $permissiontoread = 1; - $permissiontoadd = 1; - $permissiontodelete = 1; -} - -// Security check (enable the most restrictive one) -if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) accessforbidden(); -//$socid = 0; if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden('Module not enabled'); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { - $search[$key] = ''; - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } - } - $toselect = array(); - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } - - // Mass actions - $objectclass = 'Booking'; - $objectlabel = 'Booking'; - $uploaddir = $conf->bookcal->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; -} - - - -/* - * View - */ - -$form = new Form($db); - -$now = dol_now(); - -//$help_url = "EN:Module_Booking|FR:Module_Booking_FR|ES:Módulo_Booking"; -$help_url = ''; -$title = $langs->trans("Bookings"); -$morejs = array(); -$morecss = array(); - - -// Build and execute select -// -------------------------------------------------------------------- -$sql = 'SELECT '; -$sql .= $object->getFieldList('t'); -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } -} -// Add fields from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql = preg_replace('/,\s*$/', '', $sql); -//$sql .= ", COUNT(rc.rowid) as anotherfield"; -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid"; -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -} else { - $sql .= " WHERE 1 = 1"; -} -foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); - } - } else { - if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); - if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { - if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); -// Add where from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - -/* If a group by is required -$sql .= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql .= "t.".$db->escape($key).", "; -} -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - } -} -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql = preg_replace('/,\s*$/', '', $sql); -*/ - -// Add HAVING from hooks -/* -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -*/ - -// Count total nb of records -$nbtotalofrecords = ''; -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* This old and fast method to get and count full list returns all record so use a high amount of memory. - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - */ - /* The slow method does not consume memory on mysql (not tested on pgsql) */ - /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - if (empty($nbtotalofrecords)) { - $nbtotalofrecords = 1; // We can't make +1 because init value is '' - } else { - $nbtotalofrecords++; - } - }*/ - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; - } - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - - -// Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$id); - exit; -} - - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); - -// Example : Adding jquery code -// print ''; - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$param = ''; -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -// Add $param from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -// Add $param from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; - -// List of mass actions available -$arrayofmassactions = array( - //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -); -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - -print '
'."\n"; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/bookcal/booking_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); - -// Add code for pre mass action (confirmation or email presend form) -$topicmail = "SendBookingRef"; -$modelmail = "booking"; -$objecttmp = new Booking($db); -$trackid = 'xxxx'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; -} - -$moreforfilter = ''; -/*$moreforfilter.='
'; -$moreforfilter.= $langs->trans('MyFilter') . ': '; -$moreforfilter.= '
';*/ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; - - -// Fields title search -// -------------------------------------------------------------------- -print ''; -// Action column -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; -} -foreach ($object->fields as $key => $val) { - $searchkey = empty($search[$key]) ? '' : $search[$key]; - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -/*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; -}*/ -// Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; -} -print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- -print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - $totalarray['nbfield']++; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -/*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; - $totalarray['nbfield']++; -}*/ -// Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -$totalarray['nbfield']++; -print ''."\n"; - - -// Detect if we need a fetch on each output line -$needToFetchEachLine = 0; -if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } - } -} - - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$savnbfield = $totalarray['nbfield']; -$totalarray = array(); -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object - $object->setVarsFromFetchObj($obj); - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - // Show here line of result - $j = 0; - print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; - } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - /*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; - }*/ - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - } - - $i++; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - - -$db->free($resql); - -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); - } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - } elseif ($key == 'lang') { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); - } else { - print ''; - } - print '
'; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'.$langs->trans("AnotherField").'
'; - print '
'; - } - // Output Kanban - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''.$obj->anotherfield.''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("NoRecordFound").'
'."\n"; -print '
'."\n"; - -print '
'."\n"; - -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_bookcal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php deleted file mode 100644 index b72c0fbe6d1..00000000000 --- a/htdocs/bookcal/booking_note.php +++ /dev/null @@ -1,171 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 . - */ - -/** - * \file htdocs/bookcal/booking_note.php - * \ingroup bookcal - * \brief Tab for notes on Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingnote', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; -} - - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; - $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; - $permissionnote = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} - - -/* - * View - */ - -$form = new Form($db); - -//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url = ''; -$title = $langs->trans('Booking').' - '.$langs->trans("Notes"); -llxHeader('', $title, $help_url); - -if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); - - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'note', $langs->trans("Booking"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - - - $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 8fdbfec04b5..40e07b821c5 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -103,7 +103,6 @@ class Availabilities extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), @@ -118,14 +117,12 @@ class Availabilities extends CommonObject 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',), 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,), 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,), - 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '2'=>'Else'),), 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30',), 'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,), 'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,), 'fk_bookcal_calendar' => array('type'=>'integer:Calendar:bookcal/class/calendar.class.php:1', 'label'=>'CalendarId', 'enabled'=>'1', 'position'=>48, 'notnull'=>1, 'visible'=>1,), ); public $rowid; - public $ref; public $label; public $description; public $note_public; @@ -140,7 +137,6 @@ class Availabilities extends CommonObject public $status; public $start; public $end; - public $type; public $duration; public $startHour; public $endHour; diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php deleted file mode 100644 index b3633826271..00000000000 --- a/htdocs/bookcal/class/booking.class.php +++ /dev/null @@ -1,1091 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 . - */ - -/** - * \file class/booking.class.php - * \ingroup bookcal - * \brief This file is a CRUD class file for Booking (Create/Read/Update/Delete) - */ - -// Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - -/** - * Class for Booking - */ -class Booking extends CommonObject -{ - /** - * @var string ID of module. - */ - public $module = 'bookcal'; - - /** - * @var string ID to identify managed object. - */ - public $element = 'booking'; - - /** - * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. - */ - public $table_element = 'bookcal_booking'; - - /** - * @var int Does this object support multicompany module ? - * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table - */ - public $ismultientitymanaged = 0; - - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 1; - - /** - * @var string String with name of icon for booking. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'booking@bookcal' if picto is file 'img/object_booking.png'. - */ - public $picto = 'fa-file'; - - - const STATUS_DRAFT = 0; - const STATUS_VALIDATED = 1; - const STATUS_CANCELED = 9; - - - /** - * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') - * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" - * 'label' the translation key. - * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...) - * 'position' is the sort order of field. - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) - * 'noteditable' says if field is not editable (1 or 0) - * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage) - * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200' - * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. - * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. - * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' - * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. - * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'validate' is 1 if need to validate with $this->validateField() - * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value) - * - * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. - */ - - // BEGIN MODULEBUILDER PROPERTIES - /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. - */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) and (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',), - 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>-1, 'visible'=>-2,), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), - 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',), - 'firstname' => array('type'=>'varchar(128)', 'label'=>'firstname', 'enabled'=>'1', 'position'=>2, 'notnull'=>1, 'visible'=>-1,), - 'lastname' => array('type'=>'varchar(128)', 'label'=>'lastname', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>-1,), - 'email' => array('type'=>'varchar(128)', 'label'=>'email', 'enabled'=>'1', 'position'=>4, 'notnull'=>1, 'visible'=>-1,), - 'start' => array('type'=>'datetime', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>-1,), - 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>6, 'notnull'=>1, 'visible'=>-1,), - 'fk_bookcal_availability' => array('type'=>'integer:Availabilities:bookcal/class/availabilities.class.php', 'label'=>'AvailabilityId', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>-1,), - ); - public $rowid; - public $ref; - public $fk_soc; - public $fk_project; - public $description; - public $note_public; - public $note_private; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $last_main_doc; - public $import_key; - public $model_pdf; - public $status; - public $firstname; - public $lastname; - public $email; - public $start; - public $duration; - public $fk_bookcal_availability; - // END MODULEBUILDER PROPERTIES - - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - // public $table_element_line = 'bookcal_bookingline'; - - // /** - // * @var string Field with ID of parent key if this object has a parent - // */ - // public $fk_element = 'fk_booking'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - // public $class_element_line = 'Bookingline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - // protected $childtables = array(); - - // /** - // * @var array List of child tables. To know object to delete on cascade. - // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will - // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object - // */ - // protected $childtablesoncascade = array('bookcal_bookingdet'); - - // /** - // * @var BookingLine[] Array of subtable lines - // */ - // public $lines = array(); - - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs; - - $this->db = $db; - - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { - $this->fields['rowid']['visible'] = 0; - } - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { - $this->fields['entity']['enabled'] = 0; - } - - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->bookcal->booking->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - - // Unset fields that are disabled - foreach ($this->fields as $key => $val) { - if (isset($val['enabled']) && empty($val['enabled'])) { - unset($this->fields[$key]); - } - } - - // Translate some data of arrayofkeyval - if (is_object($langs)) { - foreach ($this->fields as $key => $val) { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); - } - } - } - } - } - - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - $resultcreate = $this->createCommon($user, $notrigger); - - //$resultvalidate = $this->validate($user, $notrigger); - - return $resultcreate; - } - - /** - * Clone an object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $extrafields; - $error = 0; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); - - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); - - // Clear fields - if (property_exists($object, 'ref')) { - $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; - } - if (property_exists($object, 'label')) { - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; - } - if (property_exists($object, 'status')) { - $object->status = self::STATUS_DRAFT; - } - if (property_exists($object, 'date_creation')) { - $object->date_creation = dol_now(); - } - if (property_exists($object, 'date_modification')) { - $object->date_modification = null; - } - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) { - $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) { - $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } - - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } - - if (!$error) { - // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) { - $error++; - } - } - - if (!$error) { - // copy external contacts if same company - if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { - if ($this->copy_linked_contact($object, 'external') < 0) { - $error++; - } - } - } - - unset($object->context['createfromclone']); - - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } - return $result; - } - - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - $result = $this->fetchLinesCommon(); - return $result; - } - - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = "SELECT "; - $sql .= $this->getFieldList('t'); - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; - } else { - $sql .= " WHERE 1 = 1"; - } - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key." = ".((int) $value); - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; - } else { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= $this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); - } - - /** - * Delete a line of object in database - * - * @param User $user User that delete - * @param int $idline Id of line to delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int >0 if OK, <0 if KO - */ - public function deleteLine(User $user, $idline, $notrigger = false) - { - if ($this->status < 0) { - $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; - return -2; - } - - return $this->deleteLineCommon($user, $idline, $notrigger); - } - - - /** - * Validate object - * - * @param User $user User making status change - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <=0 if OK, 0=Nothing done, >0 if KO - */ - public function validate($user, $notrigger = 0) - { - global $conf, $langs; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $error = 0; - - // Protection - if ($this->status == self::STATUS_VALIDATED) { - dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->booking_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - - $now = dol_now(); - - $this->db->begin(); - - // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life - $num = $this->getNextNumRef(); - } else { - $num = $this->ref; - } - $this->newref = $num; - - if (!empty($num)) { - // Validate - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " status = ".self::STATUS_VALIDATED; - if (!empty($this->fields['date_validation'])) { - $sql .= ", date_validation = '".$this->db->idate($now)."'"; - } - if (!empty($this->fields['fk_user_valid'])) { - $sql .= ", fk_user_valid = ".((int) $user->id); - } - $sql .= " WHERE rowid = ".((int) $this->id); - - dol_syslog(get_class($this)."::validate()", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - dol_print_error($this->db); - $this->error = $this->db->lasterror(); - $error++; - } - - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BOOKING_VALIDATE', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } - } - - if (!$error) { - $this->oldref = $this->ref; - - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'booking/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'booking/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->error = $this->db->lasterror(); - } - - // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->bookcal->dir_output.'/booking/'.$oldref; - $dirdest = $conf->bookcal->dir_output.'/booking/'.$newref; - if (!$error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - - if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->bookcal->dir_output.'/booking/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } - } - - // Set new ref and current status - if (!$error) { - $this->ref = $num; - $this->status = self::STATUS_VALIDATED; - } - - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - /** - * Set draft status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, >0 if OK - */ - public function setDraft($user, $notrigger = 0) - { - // Protection - if ($this->status <= self::STATUS_DRAFT) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOOKING_UNVALIDATE'); - } - - /** - * Set cancel status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function cancel($user, $notrigger = 0) - { - // Protection - if ($this->status != self::STATUS_VALIDATED) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOOKING_CANCEL'); - } - - /** - * Set back to validated status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function reopen($user, $notrigger = 0) - { - // Protection - if ($this->status != self::STATUS_CANCELED) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOOKING_REOPEN'); - } - - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $conf, $langs, $hookmanager; - - if (!empty($conf->dol_no_mouse_hover)) { - $notooltip = 1; // Force disable tooltips - } - - $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("Booking").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - - $url = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$this->id; - - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values = 1; - } - if ($url && $add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; - } - } - - $linkclose = ''; - if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowBooking"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - } - - if ($option == 'nolink' || empty($url)) { - $linkstart = ''; - if ($option == 'nolink' || empty($url)) { - $linkend = ''; - } else { - $linkend = ''; - } - - $result .= $linkstart; - - if (empty($this->showphoto_on_popup)) { - if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - } - } else { - if ($withpicto) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); - $filearray = dol_dir_list($upload_dir, "files"); - $filename = $filearray[0]['name']; - if (!empty($filename)) { - $pospoint = strpos($filearray[0]['name'], '.'); - - $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { - $result .= '
No photo
'; - } else { - $result .= '
No photo
'; - } - - $result .= ''; - } else { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - } - } - } - - if ($withpicto != 2) { - $result .= $this->ref; - } - - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - global $action, $hookmanager; - $hookmanager->initHooks(array('bookingdao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); - $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - $result = $hookmanager->resPrint; - } else { - $result .= $hookmanager->resPrint; - } - - return $result; - } - - /** - * Return the label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLabelStatus($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } - - /** - * Return the label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - global $langs; - //$langs->load("agenda"); - $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); - $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); - $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); - } - - $statusType = 'status'.$status; - //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_CANCELED) { - $statusType = 'status6'; - } - - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } - - /** - * Load the info information in the object - * - * @param int $id Id of object - * @return void - */ - public function info($id) - { - $sql = "SELECT rowid,"; - $sql .= " date_creation as datec, tms as datem,"; - $sql .= " fk_user_creat, fk_user_modif"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " WHERE t.rowid = ".((int) $id); - - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - $this->user_creation_id = $obj->fk_user_creat; - $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); - if (!empty($obj->datev)) { - $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); - } - } - - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } - - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - // Set here init that are not commonf fields - // $this->property1 = ... - // $this->property2 = ... - - $this->initAsSpecimenCommon(); - } - - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - $objectline = new BookingLine($this->db); - $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_booking = '.((int) $this->id))); - - if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; - return $result; - } else { - $this->lines = $result; - return $this->lines; - } - } - - /** - * Returns the reference to the following non used object depending on the active numbering module. - * - * @return string Object free reference - */ - public function getNextNumRef() - { - global $langs, $conf; - $langs->load("agenda"); - - if (empty($conf->global->BOOKCAL_BOOKING_ADDON)) { - $conf->global->BOOKCAL_BOOKING_ADDON = 'mod_booking_standard'; - } - - if (!empty($conf->global->BOOKCAL_BOOKING_ADDON)) { - $mybool = false; - - $file = $conf->global->BOOKCAL_BOOKING_ADDON.".php"; - $classname = $conf->global->BOOKCAL_BOOKING_ADDON; - - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/bookcal/"); - - // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; - } - - if ($mybool === false) { - dol_print_error('', "Failed to include file ".$file); - return ''; - } - - if (class_exists($classname)) { - $obj = new $classname(); - $numref = $obj->getNextValue($this); - - if ($numref != '' && $numref != '-1') { - return $numref; - } else { - $this->error = $obj->error; - //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); - return ""; - } - } else { - print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; - return ""; - } - } else { - print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); - return ""; - } - } - - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force template to use ('' to not force) - * @param Translate $outputlangs objet lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; - - $result = 0; - $includedocgeneration = 0; - - $langs->load("agenda"); - - if (!dol_strlen($modele)) { - $modele = 'standard_booking'; - - if (!empty($this->model_pdf)) { - $modele = $this->model_pdf; - } elseif (!empty($conf->global->BOOKING_ADDON_PDF)) { - $modele = $conf->global->BOOKING_ADDON_PDF; - } - } - - $modelpath = "core/modules/bookcal/doc/"; - - if ($includedocgeneration && !empty($modele)) { - $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } - - return $result; - } - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * Use public function doScheduledJob($param1, $param2, ...) to get parameters - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function doScheduledJob() - { - global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error = ''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } -} - - -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; - -/** - * Class BookingLine. You can also remove this and generate a CRUD class for lines objects. - */ -class BookingLine extends CommonObjectLine -{ - // To complete with content of an object BookingLine - // We should have a field rowid, fk_booking and position - - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } -} diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 60ea456541a..a8669bebae4 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -128,6 +128,8 @@ class Calendar extends CommonObject 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax150',), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'), 'validate'=>'1',), + 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'Client', '1'=>'Supplier', '3'=>'Autre'),), + 'visibility' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Visibility', 'enabled'=>'1', 'position'=>41, 'notnull'=>1, 'visible'=>1,), ); public $rowid; public $ref; @@ -143,6 +145,8 @@ class Calendar extends CommonObject public $fk_user_modif; public $import_key; public $status; + public $type; + public $visibility; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/bookcal/lib/bookcal_booking.lib.php b/htdocs/bookcal/lib/bookcal_booking.lib.php deleted file mode 100644 index c0dec7d6d2e..00000000000 --- a/htdocs/bookcal/lib/bookcal_booking.lib.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * 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 . - */ - -/** - * \file lib/bookcal_booking.lib.php - * \ingroup bookcal - * \brief Library files with common functions for Booking - */ - -/** - * Prepare array of tabs for Booking - * - * @param Booking $object Booking - * @return array Array of tabs - */ -function bookingPrepareHead($object) -{ - global $db, $langs, $conf; - - $langs->load("agenda"); - - $showtabofpagecontact = 1; - $showtabofpagenote = 1; - $showtabofpagedocument = 1; - $showtabofpageagenda = 1; - - $h = 0; - $head = array(); - - $head[$h][0] = dol_buildpath("/bookcal/booking_card.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'card'; - $h++; - - if ($showtabofpagecontact) { - $head[$h][0] = dol_buildpath("/bookcal/booking_contact.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Contacts"); - $head[$h][2] = 'contact'; - $h++; - } - - if ($showtabofpagenote) { - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { - $nbNote = 0; - if (!empty($object->note_private)) { - $nbNote++; - } - if (!empty($object->note_public)) { - $nbNote++; - } - $head[$h][0] = dol_buildpath('/bookcal/booking_note.php', 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) { - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); - } - $head[$h][2] = 'note'; - $h++; - } - } - - if ($showtabofpagedocument) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bookcal->dir_output."/booking/".dol_sanitizeFileName($object->ref); - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/bookcal/booking_document.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) { - $head[$h][1] .= ''.($nbFiles + $nbLinks).''; - } - $head[$h][2] = 'document'; - $h++; - } - - if ($showtabofpageagenda) { - $head[$h][0] = dol_buildpath("/bookcal/booking_agenda.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Events"); - $head[$h][2] = 'agenda'; - $h++; - } - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - //$this->tabs = array( - // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__' - //); // to add new tab - //$this->tabs = array( - // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__' - //); // to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal'); - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal', 'remove'); - - return $head; -} diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 447fc69a05d..0155cd1223d 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -88,3 +88,5 @@ ALTER TABLE llx_societe DROP COLUMN skype; ALTER TABLE llx_prelevement_demande ADD INDEX idx_prelevement_demande_ext_payment_id (ext_payment_id); +ALTER TABLE llx_actioncomm ADD COLUMN fk_bookcal_availability integer DEFAULT NULL; + diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index a64513d5d9e..ba77e531f54 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -82,6 +82,8 @@ create table llx_actioncomm ip varchar(250), --ip used to create record (for public submission page) + fk_bookcal_availability integer DEFAULT NULL, --fk_bookcal_availability used to link booking to bookcal availability + import_key varchar(14), extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql index 786665a2545..738dea0090e 100644 --- a/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql +++ b/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql @@ -17,7 +17,6 @@ CREATE TABLE llx_bookcal_availabilities( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) NOT NULL, label varchar(255), description text, note_public text, @@ -32,7 +31,6 @@ CREATE TABLE llx_bookcal_availabilities( status integer NOT NULL, start date NOT NULL, end date NOT NULL, - type integer NOT NULL, duration integer DEFAULT 30 NOT NULL, startHour integer NOT NULL, endHour integer NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql b/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql deleted file mode 100644 index 5055cc59f1f..00000000000 --- a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql +++ /dev/null @@ -1,28 +0,0 @@ --- Copyright (C) 2022 Alice Adminson --- --- 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 https://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_rowid (rowid); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_ref (ref); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_fk_soc (fk_soc); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_fk_project (fk_project); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_status (status); --- END MODULEBUILDER INDEXES - ---ALTER TABLE llx_bookcal_booking ADD UNIQUE INDEX uk_bookcal_booking_fieldxy(fieldx, fieldy); - ---ALTER TABLE llx_bookcal_booking ADD CONSTRAINT llx_bookcal_booking_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bookcal_myotherobject(rowid); - diff --git a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql deleted file mode 100644 index 3457487aeb9..00000000000 --- a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (C) 2022 Alice Adminson --- --- 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 https://www.gnu.org/licenses/. - - -CREATE TABLE llx_bookcal_booking( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) NOT NULL, - fk_soc integer, - fk_project integer, - description text, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_user_creat integer, - fk_user_modif integer, - last_main_doc varchar(255), - import_key varchar(14), - model_pdf varchar(255), - status integer NOT NULL, - firstname varchar(128) NOT NULL, - lastname varchar(128) NOT NULL, - email varchar(128) NOT NULL, - start datetime NOT NULL, - duration integer NOT NULL, - fk_bookcal_availability integer NOT NULL - -- END MODULEBUILDER FIELDS -) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql index 061d3dbe01a..daf01d69999 100644 --- a/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql +++ b/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_bookcal_calendar( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL + status integer NOT NULL, + type integer NOT NULL, + visibility integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From ea91aadbdc0bf78c36e1e61e79ea3d29f1ba8029 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 31 Aug 2023 15:33:17 +0200 Subject: [PATCH 077/130] Fix #25752 fatal error on supplier payment --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 04182b53a66..aab16079aef 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7072,7 +7072,7 @@ class Form $arrayofdateof = $adddateof; } foreach ($arrayofdateof as $valuedateof) { - $tmpadddateof = $valuedateof['adddateof']; + $tmpadddateof = $valuedateof['adddateof'] != '' ? $valuedateof['adddateof'] : 0; $tmplabeladddateof = $valuedateof['labeladddateof']; $tmparray = dol_getdate($tmpadddateof); if (empty($tmplabeladddateof)) { From 66a8e41e7e4d9848ab8a80cb7a2b9f6dedf5d35d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 16:13:48 +0200 Subject: [PATCH 078/130] FIX fatal error with some parameters --- htdocs/core/tpl/extrafields_list_search_param.tpl.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index 7e58e106882..2ab5749b4e0 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -31,8 +31,14 @@ if (!empty($search_array_options) && is_array($search_array_options)) { // $extr $param .= '&'.$search_options_pattern.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M'); $val = ''; } - if ($val != '') { - $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + if ($val !== '') { + if (is_array($val)) { + foreach ($val as $val2) { + $param .= '&'.$search_options_pattern.$tmpkey.'[]='.urlencode($val2); + } + } else { + $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + } } } } From d6c331e950edaa65d2fa8eaefb47bc8c08ab8fd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 18:26:38 +0200 Subject: [PATCH 079/130] Fix warning --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 91f4d123f09..4028726096a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1270,7 +1270,7 @@ if (!empty($arrayfields['p.duration']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { - print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', $arrayfields['pac.fk_product_parent']['help']); + print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', empty($arrayfields['pac.fk_product_parent']['help']) ? '' : $arrayfields['pac.fk_product_parent']['help']); } if (!empty($arrayfields['p.finished']['checked'])) { print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center '); From 392f7415d7979c65da452ac8e6db5b211e9105ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 22:25:43 +0200 Subject: [PATCH 080/130] css --- htdocs/opensurvey/wizard/index.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index 4542ecfa3bd..ef7a35dd303 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2013 Laurent Destailleur * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Regis Houssin - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 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 @@ -55,13 +55,18 @@ print '
'; print '
'; print '
'; print '
'; -print ''; +print ''; print '
'; print '
'; print '
'; -print ''; +print ''; print '
'; print '
'; +print '
'; print '
'; print ''; From a16dc7ac5cc40318dd222d9b807462ef8fa9ea17 Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 30 Aug 2023 11:46:33 +0200 Subject: [PATCH 081/130] FIX date survey : button to add dates would not work. Session would store cells numbers which would stay to 10 for next surveys created. --- htdocs/opensurvey/wizard/choix_date.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index d8f89b18e16..d2e76cb0f18 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -179,6 +179,7 @@ if (GETPOST('confirmation')) { // Add survey into database if (!$erreur && $erreurNb == 0) { $_SESSION["toutchoix"] = substr("$choixdate", 1); + unset($_SESSION["nbrecaseshoraires"]); ajouter_sondage(); } @@ -215,7 +216,7 @@ llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss //nombre de cases par défaut if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; -} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { +} elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; } From d0c5fc77322857bebc75d72911ae02a0dded50fc Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 30 Aug 2023 12:18:06 +0200 Subject: [PATCH 082/130] FIX: when adding new times on a survey, all hours would be erased. --- htdocs/opensurvey/wizard/choix_date.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index d2e76cb0f18..d7bbe577734 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -218,8 +218,20 @@ if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; } elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; + //On sauvegarde les heures deja entrées + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { + $nbofchoice = count($_SESSION["totalchoixjour"]); + for ($i = 0; $i < $nbofchoice; $i++) { + //affichage des 5 cases horaires + for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { + $horairesi = GETPOST("horaires".$i); + $_SESSION["horaires$i"][$j] = $horairesi[$j]; + } + } + } } + //valeurs de la date du jour actuel $jourAJ = date("j"); $moisAJ = date("n"); @@ -408,7 +420,7 @@ if (issetAndNoEmpty('choixjourajout')) { $k = $i + 1; if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) { for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { - $horairesi = GETPOST("horaires".$i); + $horairesi = GETPOST("horaires".$i, 'array'); $_SESSION["horaires$i"][$j] = $horairesi[$j]; } } @@ -453,7 +465,7 @@ if (issetAndNoEmpty('reporterhoraires')) { } } -//report des horaires dans toutes les cases +//effacer les horaires dans toutes les cases if (issetAndNoEmpty('resethoraires')) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { From fdfa9ca39df1dd51c29c69266c93f9062e9aaaa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 22:48:13 +0200 Subject: [PATCH 083/130] Fix CSS --- htdocs/opensurvey/wizard/choix_date.php | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index d7bbe577734..62e262ca6f9 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -360,11 +360,13 @@ print ''."\n"; print '
'."\n"; print '
'."\n"; print ''."\n"; // The div class=center has no effect on table, so we must keep the align=center for table -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''."\n"; print '
'.$motmois.' '.$_SESSION["annee"].'
'; -print ''; -print '
'; +print '
'.$motmois.' '.$_SESSION["annee"].'
'; +print ''; +print '
'; print '
'."\n"; print '
'."\n"; @@ -493,7 +495,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { for ($j = 0; $j < $nbofchoice; $j++) { // show red buttons if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) { - print ''."\n"; + print ''."\n"; $dejafait = $numerojour; } } @@ -503,10 +505,10 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { if (isset($dejafait) === false || $dejafait != $numerojour) { // green button if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) { - print ''."\n"; + print ''."\n"; } else { // grey button - print ''.$numerojour.''."\n"; + print ''.$numerojour.''."\n"; } } } @@ -543,12 +545,13 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { print ''."\n"; - //affichage de la liste des jours choisis + // Show list of selected days + $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { print ''."\n"; - print ''.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')'; + print ''.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')'; //affichage des cases d'horaires for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { @@ -568,7 +571,9 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { // show buttons to cancel, delete days or create survey print ''."\n"; print ''."\n"; - print ''."\n"; + print ''; + print ''; + print ''."\n"; print''."\n"; print ''."\n"; print '


'."\n"; From 73463765d5917f63ba4abd78b7cb85543fc8ebc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 16:13:48 +0200 Subject: [PATCH 084/130] FIX fatal error with some parameters --- htdocs/core/tpl/extrafields_list_search_param.tpl.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index 7e58e106882..2ab5749b4e0 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -31,8 +31,14 @@ if (!empty($search_array_options) && is_array($search_array_options)) { // $extr $param .= '&'.$search_options_pattern.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M'); $val = ''; } - if ($val != '') { - $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + if ($val !== '') { + if (is_array($val)) { + foreach ($val as $val2) { + $param .= '&'.$search_options_pattern.$tmpkey.'[]='.urlencode($val2); + } + } else { + $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + } } } } From 86b77b507e4b1e42b562e393fa1213318b3654b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Aug 2023 23:42:45 +0200 Subject: [PATCH 085/130] Fix reposition --- htdocs/admin/mails_templates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6976682dc1f..6d0267f802a 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1185,7 +1185,7 @@ if ($num) { print ''.img_edit().''; } if ($iserasable) { - print ''.img_delete().''; + print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin } print ''; @@ -1290,7 +1290,7 @@ if ($num) { print ''.img_edit().''; } if ($iserasable) { - print ''.img_delete().''; + print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin } print ''; From 21a03edafd52b84f0eb882dfb66741c67428bea7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 22:51:21 +0200 Subject: [PATCH 086/130] Clean code --- htdocs/install/upgrade2.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 522f8c40c17..0f7b20d3f19 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4122,7 +4122,12 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/menus/standard/auguria_frontoffice.php', '/core/menus/standard/eldy_backoffice.php', '/core/menus/standard/eldy_frontoffice.php', - '/core/modules/export/exports_csv.modules.php', + '/core/modules/export/export_excel.modules.php', + '/core/modules/export/export_csv.modules.php', + '/core/modules/export/exportcsv.modules.php', + '/core/modules/export/export_excel2007new.modules.php', + '/core/modules/facture/pdf_crabe.modules.php', + '/core/modules/facture/pdf_oursin.modules.php', '/core/modules/mailings/contacts2.modules.php', '/core/modules/mailings/contacts3.modules.php', '/core/modules/mailings/contacts4.modules.php', @@ -4131,12 +4136,6 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/peche.modules.php', '/core/modules/mailings/poire.modules.php', '/core/modules/mailings/kiwi.modules.php', - '/core/modules/facture/pdf_crabe.modules.php', - '/core/modules/facture/pdf_oursin.modules.php', - '/core/modules/export/export_excel.modules.php', - '/core/modules/export/export_csv.modules.php', - '/core/modules/export/exportcsv.modules.php', - '/core/modules/export/export_excel2007new.modules.php', '/core/boxes/box_members.php', '/api/class/api_generic.class.php', From 07925d8f23c4d232466cd15692a1c5ae7dc55483 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 22:54:33 +0200 Subject: [PATCH 087/130] css --- htdocs/opensurvey/css/style.css | 2 +- htdocs/opensurvey/results.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/opensurvey/css/style.css b/htdocs/opensurvey/css/style.css index e7f0d279a14..b4b2b69514a 100644 --- a/htdocs/opensurvey/css/style.css +++ b/htdocs/opensurvey/css/style.css @@ -363,7 +363,7 @@ div.cadre td.ok { } /*Case de tableau NON dans affichage de sondage*/ div.cadre td.non { - background-color: #FF7777; + background-color: #FFBBBB; min-width: 60px; } /*Case de tableau VIDE dans affichage de sondage*/ diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index d9191278edd..764ca877c58 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -331,7 +331,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox // Security check - if (!$user->rights->opensurvey->write) { + if (!$user->hasRight('opensurvey', 'write')) { accessforbidden(); } @@ -673,7 +673,7 @@ print ''; print '
'."\n"; // Start to show survey result -print ''."\n"; +print '
'."\n"; //reformatage des données des sujets du sondage $toutsujet = explode(",", $object->sujet); @@ -684,9 +684,9 @@ print ''."\n"; print ''."\n"; // loop to show the delete link -if ($user->rights->opensurvey->write) { +if ($user->hasRight('opensurvey', 'write')) { for ($i = 0; isset($toutsujet[$i]); $i++) { - print ''."\n"; + print ''."\n"; } } From a6cf5db71884c7ef852dafe3e283bf7bfb40dc2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 23:26:07 +0200 Subject: [PATCH 088/130] Doc --- htdocs/modulebuilder/template/myobject_list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 03976b562b0..972a2322a23 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -87,6 +87,7 @@ require_once __DIR__.'/class/myobject.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); +// Get parameters $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? From c311086c9de0fbebf3e9cbb6287abeaf5e7dd584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 31 Aug 2023 23:59:14 +0200 Subject: [PATCH 089/130] clean code --- htdocs/product/stock/productlot_card.php | 118 +++++++++++------------ 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 2da298d7b37..42adc0a471a 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -34,6 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +global $conf, $db, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('stocks', 'other', 'productbatch')); @@ -69,9 +71,9 @@ if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } -$batch = GETPOST('batch', 'alpha'); -$productid = GETPOST('productid', 'int'); -$ref = GETPOST('ref', 'alpha'); // ref is productid_batch +$batch = GETPOST('batch', 'alpha'); +$productid = GETPOST('productid', 'int'); +$ref = GETPOST('ref', 'alpha'); // ref is productid_batch $search_entity = GETPOST('search_entity', 'int'); $search_fk_product = GETPOST('search_fk_product', 'int'); @@ -106,13 +108,13 @@ if ($id || $ref) { $hookmanager->initHooks(array('productlotcard', 'globalcard')); -$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('stock', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; +$usercanread = $user->hasRight('produit', 'lire'); +$usercancreate = $user->hasRight('produit', 'creer'); +$usercandelete = $user->hasRight('produit', 'supprimer'); $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; @@ -121,7 +123,7 @@ $permissiontoadd = $usercancreate; $permissiontodelete = $usercandelete; // Security check -if (empty($conf->productbatch->enabled)) { +if (!isModEnabled('productbatch')) { accessforbidden('Module not enabled'); } $socid = 0; @@ -130,7 +132,9 @@ if ($user->socid > 0) { // Protection if external user accessforbidden(); } //$result = restrictedArea($user, 'productbatch'); -if (!$permissiontoread) accessforbidden(); +if (!$permissiontoread) { + accessforbidden(); +} /* @@ -148,7 +152,7 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - if ($action == 'seteatby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'seteatby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -159,7 +163,7 @@ if (empty($reshook)) { } } - if ($action == 'setsellby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setsellby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -170,7 +174,7 @@ if (empty($reshook)) { } } - if ($action == 'seteol_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'seteol_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int')); $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -181,7 +185,7 @@ if (empty($reshook)) { } } - if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setmanufacturing_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int')); $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -192,7 +196,7 @@ if (empty($reshook)) { } } - if ($action == 'setscrapping_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setscrapping_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int')); $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -203,7 +207,7 @@ if (empty($reshook)) { } } - /* if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + /* if ($action == 'setcommissionning_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -214,7 +218,7 @@ if (empty($reshook)) { } } */ - if ($action == 'setqc_frequency' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setqc_frequency' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { // Prévoir un test de format de durée setEventMessages($object->error, null, 'errors'); @@ -229,20 +233,17 @@ if (empty($reshook)) { // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; /* - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); if ($ret < 0) $error++; - if (!$error) - { + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -254,10 +255,8 @@ if (empty($reshook)) { } // Action to add record - if ($action == 'add') - { - if (GETPOST('cancel', 'alpha')) - { + if ($action == 'add') { + if (GETPOST('cancel', 'alpha')) { $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; @@ -272,17 +271,14 @@ if (empty($reshook)) { $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); $object->import_key = GETPOST('import_key', 'int'); - if (empty($object->ref)) - { + if (empty($object->ref)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Creation OK $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); @@ -303,8 +299,7 @@ if (empty($reshook)) { if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view'; // Action to update record - if ($action == 'update' && !GETPOST('cancel', 'alpha')) - { + if ($action == 'update' && !GETPOST('cancel', 'alpha')) { $error = 0; $object->entity = GETPOST('entity', 'int'); @@ -314,17 +309,14 @@ if (empty($reshook)) { $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); $object->import_key = GETPOST('import_key', 'int'); - if (empty($object->ref)) - { + if (empty($object->ref)) { $error++; setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { $action = 'view'; } else { // Creation KO @@ -338,11 +330,9 @@ if (empty($reshook)) { } // Action to delete - if ($action == 'confirm_delete') - { + if ($action == 'confirm_delete') { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".dol_buildpath('/stock/list.php', 1)); @@ -468,9 +458,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Sell by if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''; print ''; } @@ -478,35 +468,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Eat by if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ''; print ''; } if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { - print ''; - print ''; + print ''; + print ''; print ''; - // print ''; - // print ''; + // print ''; + // print ''; // print ''; - print ''; - print ''; + print ''; + print ''; print ''; } // Quality control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; } @@ -539,8 +529,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (empty($reshook)) { - /*TODO if ($user->rights->stock->lire) - { + /*TODO + if ($user->hasRight('stock', 'lire')) { print ''."\n"; } */ From 2f698f8521e74c4ec35c772b7f1fed31385c9943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Fri, 1 Sep 2023 00:01:43 +0200 Subject: [PATCH 090/130] clean code --- htdocs/product/stock/productlot_document.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 38c5b0503d8..0f4cb68df98 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -26,7 +26,7 @@ /** * \file htdocs/product/stock/productlot_document.php * \ingroup product - * \brief Page of attached documents for porudct lots + * \brief Page of attached documents for product lots */ // Load Dolibarr environment @@ -38,11 +38,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +global $conf, $db, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('other', 'products')); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -97,9 +99,9 @@ if ($id || $ref) { } } -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; +$usercanread = $user->hasRight('produit', 'lire'); +$usercancreate = $user->hasRight('produit', 'creer'); +$usercandelete = $user->hasRight('produit', 'supprimer'); if (empty($upload_dir)) { $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; @@ -111,7 +113,7 @@ $permtoedit = $user->rights->produit->creer; //$permissiontodelete = $usercandelete; // Security check -if (empty($conf->productbatch->enabled)) { +if (!isModEnabled('productbatch')) { accessforbidden('Module not enabled'); } $socid = 0; From f9f5affbd2b353e84b9903c36623d88f7f5d95e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:02:16 +0200 Subject: [PATCH 091/130] Clean code, remove use of $statuts and $statuts_short --- .../deplacement/class/deplacement.class.php | 27 +++++++++-------- htdocs/core/class/commonobject.class.php | 29 +++++++++++++------ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index badb8acc5f8..d5d2cc191e2 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -103,10 +103,6 @@ class Deplacement extends CommonObject public $statut; public $extraparams = array(); - public $statuts = array(); - public $statuts_short = array(); - public $statuts_logo = array(); - /** * Draft status @@ -131,10 +127,6 @@ class Deplacement extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); } /** @@ -222,8 +214,6 @@ class Deplacement extends CommonObject */ public function update($user) { - global $langs; - // Clean parameters $this->km = price2num($this->km); @@ -366,12 +356,21 @@ class Deplacement extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatus[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatusShort[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + } - $statusType = $this->statuts_logo[$status]; + $status_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); + $statusType = $status_logo[$status]; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9769fe903e2..78a98f77c6e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -659,10 +659,30 @@ abstract class CommonObject */ public $alreadypaid; + /** + * @var array Array with label of status + */ public $labelStatus; + /** + * @var array array of status string + * @deprecated Use instead labelStatus + */ + public $statuts = array(); + + /** + * @var array Array with short label of status + */ protected $labelStatusShort; + /** + * @var array array of short status string + * @deprecated Use instead labelStatusShort + */ + public $statuts_short = array(); + + + /** * @var int show photo on popup */ @@ -673,15 +693,6 @@ abstract class CommonObject */ public $nb = array(); - /** - * @var array array of status string - */ - public $statuts = array(); - - /** - * @var array array of short status string - */ - public $statuts_short = array(); /** * @var string output From 40e739dab6e6060148698ff819dac29aba2cefdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:08:31 +0200 Subject: [PATCH 092/130] Clean dead code --- htdocs/ticket/card.php | 21 +++------------------ htdocs/ticket/class/ticket.class.php | 2 +- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d55526054cb..09473a8c617 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -449,8 +449,6 @@ if (empty($reshook)) { if (!$error) { // Log action in ticket logs table $object->fetch_user($usertoassign); - //$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); - setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); header("Location: card.php?track_id=".$object->track_id); @@ -500,9 +498,6 @@ if (empty($reshook)) { if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) { $object->close($user); - // Log action in ticket logs table - //$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); @@ -589,9 +584,6 @@ if (empty($reshook)) { if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) { $res = $object->setStatut(Ticket::STATUS_ASSIGNED); if ($res) { - // Log action in ticket logs table - //$log_action = $langs->trans('TicketLogReopen'); - $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); @@ -620,15 +612,13 @@ if (empty($reshook)) { } elseif ($action == "set_message" && $user->rights->ticket->manage) { if (!GETPOST('cancel')) { $object->fetch('', '', GETPOST('track_id', 'alpha')); - $oldvalue_message = $object->message; + //$oldvalue_message = $object->message; $fieldtomodify = GETPOST('message_initial', 'restricthtml'); $object->message = $fieldtomodify; $ret = $object->update($user); if ($ret > 0) { - //$log_action = $langs->trans('TicketInitialMessageModified')." \n"; - // include the Diff class - include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; + //include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; // output the result of comparing two files as plain text //$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); @@ -644,12 +634,9 @@ if (empty($reshook)) { // Reopen ticket if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); - $old_status = $object->status; + //$old_status = $object->status; $res = $object->setStatut($new_status); if ($res) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); @@ -694,8 +681,6 @@ if (empty($reshook)) { $ret = $object->update($user); if ($ret > 0) { - //$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); } else { $error++; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 86b9333e9a5..152520ae0b4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1401,7 +1401,7 @@ class Ticket extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->libStatut($this->fk_statut, $mode, 0, $this->progress); + return $this->LibStatut($this->fk_statut, $mode, 0, $this->progress); } From 2f6f99b9c5052a9d39438954a06f5c315f44891d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:12:22 +0200 Subject: [PATCH 093/130] Disabled a duplicate github action --- .github/workflows/{phpcsfixer.yml => phpcsfixer.yml.disabled} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{phpcsfixer.yml => phpcsfixer.yml.disabled} (100%) diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml.disabled similarity index 100% rename from .github/workflows/phpcsfixer.yml rename to .github/workflows/phpcsfixer.yml.disabled From 509384e319a64d27f9bdaef1f2b042dc0a4f2977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 00:28:47 +0200 Subject: [PATCH 094/130] remove duplicate line --- htdocs/core/class/conf.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index bb7ff52a9f9..bbaed873c6a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -287,7 +287,6 @@ class Conf $this->commande = new stdClass(); $this->propal = new stdClass(); $this->facture = new stdClass(); - $this->contrat = new stdClass(); $this->user = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); From 5581deed7e71e78fbc05695bd0223e2d3792eb22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:34:40 +0200 Subject: [PATCH 095/130] FIX Bad message on menu to go to setup of accounting custom groups --- htdocs/accountancy/admin/categories_list.php | 5 ++++- htdocs/admin/dict.php | 1 - htdocs/core/class/html.formaccounting.class.php | 4 ++-- htdocs/langs/en_US/accountancy.lang | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index e77b97fe92d..7b7148f89ce 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2023 Laurent Destailleur * Copyright (C) 2011-2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -852,6 +852,9 @@ if ($resql) { print "\n"; $i++; } + } else { + $colspan = 11; + print '
'; } } else { dol_print_error($db); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9a68194f28c..267c1da4159 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2639,7 +2639,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $maxlength = ''; if (in_array($fieldlist[$field], array('libelle', 'label'))) { switch ($tabname) { - case 'c_accounting_category': case 'c_ecotaxe': case 'c_email_senderprofile': case 'c_forme_juridique': diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index d4d618586e5..9c72c98721c 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -235,7 +235,7 @@ class FormAccounting extends Form public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) { // phpcs:enable - global $db, $langs, $user, $mysoc; + global $db, $langs, $mysoc; if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); @@ -293,7 +293,7 @@ class FormAccounting extends Form $out .= ''; //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } else { - $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code); + $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code, $langs->trans("Accounting"), $langs->trans("Setup"), $langs->trans("AccountingCategories")); } } else { dol_print_error($this->db); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 6f573f0f7d2..6e40a75854a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -450,7 +450,7 @@ ConfirmMassDeleteBookkeepingWritingQuestion=This will delete the transaction fro ## Error SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them -ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) +ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See %s - %s - %s) ErrorInvoiceContainsLinesNotYetBounded=You try to journalize some lines of the invoice %s, but some other lines are not yet bounded to accounting account. Journalization of all invoice lines for this invoice are refused. ErrorInvoiceContainsLinesNotYetBoundedShort=Some lines on invoice are not bound to accounting account. ExportNotSupported=The export format setuped is not supported into this page From d2a9fe70c61d658ac40b4f8fa874890d1cf7ae2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:36:53 +0200 Subject: [PATCH 096/130] Fix phpcs --- htdocs/compta/paiement/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 004de242952..91045ae3370 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -523,9 +523,8 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { } $params = array(); - if (! empty($title_button)) { - $params['attr'] = array('title' => $title_button); + $params['attr'] = array('title' => $title_button); } if ($user->socid == 0 && $action == '') { From 9132529b691d0f6f18c582743f3acae045365b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Fri, 1 Sep 2023 00:50:15 +0200 Subject: [PATCH 097/130] clean numbering module --- .../partnership/mod_partnership_advanced.php | 35 +++---- .../partnership/mod_partnership_standard.php | 8 +- .../partnership/modules_partnership.php | 91 +------------------ 3 files changed, 25 insertions(+), 109 deletions(-) diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php index 821a9e67303..c3b3a888b54 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2023 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 @@ -26,7 +26,7 @@ * \brief File containing class for advanced numbering model of Partnership */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership /** * Returns the description of the numbering model * + * @param Translate $langs Lang object to use for output * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $db; $langs->load("bills"); $form = new Form($db); - $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte .= '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= '
'; - print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print '
'; - print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').'
'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->rights->stock->creer, 'string').'
'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').'
'.$langs->trans("None").'
'; + $text = $langs->trans('GenericNumRefModelDesc')."
\n"; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership")); $tooltip .= $langs->trans("GenericMaskCodes2"); @@ -78,17 +79,17 @@ class mod_partnership_advanced extends ModeleNumRefPartnership $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte .= ''; - $texte .= ''; + $text .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte .= ''; + $text .= ''; + $text .= ''; - return $texte; + return $text; } /** diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index 5de4b07f215..c7409aba85e 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -22,7 +22,7 @@ * \ingroup partnership * \brief File of class to manage Partnership numbering rules standard */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Text with description */ - public function info() + public function info($langs) { - global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); } diff --git a/htdocs/partnership/core/modules/partnership/modules_partnership.php b/htdocs/partnership/core/modules/partnership/modules_partnership.php index 4d1f6c0b107..dafab0cc8ed 100644 --- a/htdocs/partnership/core/modules/partnership/modules_partnership.php +++ b/htdocs/partnership/core/modules/partnership/modules_partnership.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -66,93 +67,7 @@ abstract class ModelePDFPartnership extends CommonDocGenerator /** * Parent class to manage numbering of Partnership */ -abstract class ModeleNumRefPartnership +abstract class ModeleNumRefPartnership extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } From 69f070d8fdb4538db40069cbf1bcdeb861d2670d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 09:18:23 +0200 Subject: [PATCH 098/130] phpstan --- htdocs/paypal/lib/paypal.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 79003956f12..db949620440 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -145,7 +145,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); if ($ErrorCode == 10729) { - $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + $mesg = "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; } else { $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
\n"; $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n"; From eaf63b60c5e6e69a894de6ff95a689c3df6bfa33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 14:54:35 +0200 Subject: [PATCH 099/130] phpstan --- htdocs/reception/class/reception.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index c9cf763882c..9fb6a0cb6a9 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -93,6 +93,7 @@ class Reception extends CommonObject public $depth_units; // A denormalized value public $trueSize; + public $size_units; public $date_delivery; // Date delivery planed @@ -121,6 +122,11 @@ class Reception extends CommonObject public $meths; public $listmeths; // List of carriers + /** + * @var CommandeFournisseur + */ + public $commandeFournisseur; + /** * @var CommandeFournisseurDispatch[] */ From 022c7f0dc37caf33c1df63d4ad30a97a5ba1c7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Sep 2023 15:38:00 +0200 Subject: [PATCH 100/130] doc --- htdocs/core/class/html.form.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 13d5775196b..0169ea235b2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6606,7 +6606,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. - * @param datetime $adddateof Add a link "Date of invoice" using the following date. + * @param int|string $adddateof Add a link "Date of invoice" using the following date. * @return string '' or HTML component string if nooutput is 1 * @deprecated * @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek() @@ -6614,6 +6614,7 @@ class Form public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') { // phpcs:enable + dol_syslog(__METHOD__ . ': using select_date is deprecated. Use selectDate instead.', LOG_WARNING); $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); if (!empty($nooutput)) { return $retstring; @@ -6668,7 +6669,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. - * @param datetime|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) + * @param int|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) * @param string $openinghours Specify hour start and hour end for the select ex 8,20 * @param int $stepminutes Specify step for minutes between 1 and 30 * @param string $labeladddateof Label to use for the $adddateof parameter. Deprecated. Used only when $adddateof is not an array. From 725d870669c02df44044afbbe553e3257b9fa485 Mon Sep 17 00:00:00 2001 From: Roger Dueck Date: Fri, 1 Sep 2023 09:26:13 -0600 Subject: [PATCH 101/130] Fix attempt to access stdClass::$* on query result --- htdocs/core/class/commonobject.class.php | 31 ++++++++++++++++++++++++ htdocs/core/lib/project.lib.php | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2ee3fd3aa48..e220f5aa98d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4256,6 +4256,10 @@ abstract class CommonObject return -1; } + if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) { + error_log("ERROR: Invalid value '$field_select' for parameter \$field_select in call to getAllItemsLinkedByObjectID(). Must be a single field name."); + } + global $db; $sql = "SELECT ".$field_select." FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); @@ -4271,6 +4275,33 @@ abstract class CommonObject return $TRes; } + /** + * Count items linked to an object id in association table + * + * @param int $fk_object_where id of object we need to get linked items + * @param string $field_where name of field of object we need to get linked items + * @param string $table_element name of association table + * @return array|int Array of record, -1 if empty + */ + public static function getCountOfItemsLinkedByObjectID($fk_object_where, $field_where, $table_element) + { + if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { + return -1; + } + + global $db; + + $sql = "SELECT COUNT(*) n FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); + $resql = $db->query($sql); + $n = 0; + if ($resql) { + $res = $db->fetch_object($resql); + if ($res) $n = $res->n; + } + + return $n; + } + /** * Function used to remove all items linked to an object id in association table * diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 43b2c136044..07519ea55d2 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '') if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) { require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; $Tickettatic = new Ticket($db); - $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket')); + $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket'); $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); $head[$h][1] = $langs->trans("Ticket"); if ($nbTicket > 0) { From 49d7fd7b734b8762330e9766174d18b4614dfc77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 19:38:47 +0200 Subject: [PATCH 102/130] Look of apstats --- dev/tools/apstats.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 6c45c68b617..4bdf2fc45c3 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -230,6 +230,15 @@ th,td { .trgroup { background-color: #EEE; } +.seedetail { + color: #000088; +} +.box { + padding: 20px; + font-size: 1.2em; + margin-top: 10px; + maring-bottom: 10px; +} '; $html .= ''; @@ -303,10 +312,12 @@ $html .= ''; $html .= '
'; $html .= '

Project value


'; -$html .= 'COCOMO (Basic organic model) value: $'; -$html .= formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2); -$html .= '
'; -$html .= 'COCOMO (Basic organic model) effort: '; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) value:
'; +$html .= '$'.formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2); +$html .= '
'; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) effort
'; $html .= formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); $html .= ' monthes people
'; $html .= '
'; From ca1e139c6a3856a3218c6ec84862fb2e707e1558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 20:28:42 +0200 Subject: [PATCH 103/130] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e220f5aa98d..c5d2c5f123b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4255,9 +4255,8 @@ abstract class CommonObject if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { return -1; } - if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) { - error_log("ERROR: Invalid value '$field_select' for parameter \$field_select in call to getAllItemsLinkedByObjectID(). Must be a single field name."); + dol_syslog('Invalid value $field_select for parameter '.$field_select.' in call to getAllItemsLinkedByObjectID(). Must be a single field name.', LOG_ERR); } global $db; From df4781a521f001ae8c3e72dd9c0f536a9ec465bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 20:30:43 +0200 Subject: [PATCH 104/130] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c5d2c5f123b..364de5092d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4290,12 +4290,14 @@ abstract class CommonObject global $db; - $sql = "SELECT COUNT(*) n FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); + $sql = "SELECT COUNT(*) as nb FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); $resql = $db->query($sql); $n = 0; if ($resql) { $res = $db->fetch_object($resql); - if ($res) $n = $res->n; + if ($res) { + $n = $res->nb; + } } return $n; From 0a3bb161f84bb419e955e6d0756788739ea996ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 2 Sep 2023 10:14:25 +0200 Subject: [PATCH 105/130] phpstan --- htdocs/core/class/html.formmail.class.php | 9 +++++++++ htdocs/core/class/html.formsms.class.php | 1 + 2 files changed, 10 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d117140e156..264ed21b512 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -134,6 +134,7 @@ class FormMail extends Form public $withtocc; public $withtoccc; public $withtopic; + public $witherrorsto; /** * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -150,13 +151,21 @@ class FormMail extends Form public $withreplytoreadonly; public $withtoreadonly; public $withtoccreadonly; + public $witherrorstoreadonly; public $withtocccreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withfilereadonly; public $withdeliveryreceipt; public $withcancel; + public $withdeliveryreceiptreadonly; public $withfckeditor; + /** + * @var string ckeditortoolbar + */ + public $ckeditortoolbar; + public $substit = array(); public $substit_lines = array(); public $param = array(); diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 940f76d0ae8..8e20cb8d33c 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -62,6 +62,7 @@ class FormSms public $withreplytoreadonly; public $withtoreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withcancel; public $substit = array(); From e0189c654c16749c0e46dbd183b50a3ffed5504d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 2 Sep 2023 10:18:46 +0200 Subject: [PATCH 106/130] phpcs --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index ec8d8b5f68d..aaa8bad5ee7 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -430,7 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding // property of object and use the xxxx to know how to format it. // Before that, we hard code this substitution as if we have found them into the template. - + $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m'); $tmparray['object_MONTH'] = dol_print_date($object->date, '%m'); $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m'); @@ -440,7 +440,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y'); - $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook From ae2e383b0ed3bba27a63ac7dddf285e9e38d149d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 11:17:47 +0200 Subject: [PATCH 107/130] Test on $error --- htdocs/accountancy/journal/purchasesjournal.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 1170a20b969..cc7655d28f3 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -72,6 +72,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -341,7 +343,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -712,7 +714,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'journal'; From de72f6d7eb26512152778304c09bcfbd726fa3c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 11:18:43 +0200 Subject: [PATCH 108/130] Add test on $error --- htdocs/accountancy/journal/sellsjournal.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 6ee2ae461ed..31986312388 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -74,6 +74,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -360,7 +362,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -764,7 +766,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! // Note that to have the button to get this feature enabled, you must enable ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); From bd008d78b521c5279335eb6b41e9230a4a0667f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 11:36:03 +0200 Subject: [PATCH 109/130] Fix label of cron --- htdocs/core/modules/modPartnership.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index b8aafc853fb..48244ae0455 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -253,8 +253,8 @@ class modPartnership extends DolibarrModules $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), - 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Add a warning on partnership record if the backlink keyword is not found on the partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), ); // Permissions provided by this module From 1ac364af6b6533c0d8df651822a7f9937dd0a544 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 20:36:16 +0200 Subject: [PATCH 110/130] FIX url to check keyword not saved on partnership from public form --- htdocs/install/repair.php | 2 +- htdocs/partnership/class/partnership.class.php | 2 +- htdocs/public/partnership/new.php | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index e599dd336ab..8e0d3218df7 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -241,7 +241,7 @@ if ($ok && GETPOST('standard', 'alpha')) { 'fichinter'=>'fichinter', 'fichinterdet'=>'fichinterdet', 'inventory'=>'inventory', 'actioncomm'=>'actioncomm', 'bom_bom'=>'bom_bom', 'mrp_mo'=>'mrp_mo', - 'adherent_type'=>'adherent_type', 'user'=>'user', 'projet'=>'projet', 'projet_task'=>'projet_task', 'ticket'=>'ticket'); + 'adherent_type'=>'adherent_type', 'user'=>'user', 'partnershiap'=>'partnershiap', 'projet'=>'projet', 'projet_task'=>'projet_task', 'ticket'=>'ticket'); //$listofmodulesextra = array('fichinter'=>'fichinter'); print '
*** Check fields into extra table structure match table of definition. If not add column into table'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 45487771da5..ded6bcd9aac 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,7 +120,7 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1,), + 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 174b35dc9b8..2bd0247a965 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -229,6 +229,7 @@ if (empty($reshook) && $action == 'add') { $partnership->date_partnership_start = dol_now(); $partnership->fk_user_creat = 0; $partnership->fk_type = GETPOST('partnershiptype', 'int'); + $partnership->url = GETPOST('url'); //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); $partnership->ip = getUserRemoteIP(); @@ -253,16 +254,16 @@ if (empty($reshook) && $action == 'add') { } } } - // test if societe already exist + // test if thirdparty already exists $company = new Societe($db); $result = $company->fetch(0, GETPOST('societe')); - if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email + if ($result == 0) { // if entry with name not found, we search using the email $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email')); if ($result1 > 0) { $error++; $errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName"); } else { - //create thirdparty + // create thirdparty $company = new Societe($db); $company->name = GETPOST('societe'); From db58d01cdaace934b62176e8ebe3228394291521 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 21:10:59 +0200 Subject: [PATCH 111/130] Fix type of field --- htdocs/partnership/class/partnership.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index ded6bcd9aac..b20cea56c2e 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,7 +120,7 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), + 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), From f72c22f6b7e6862c9a1b70e9731651c59d80bf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Sep 2023 21:15:42 +0200 Subject: [PATCH 112/130] phpstan --- htdocs/core/modules/project/doc/pdf_beluga.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 0afff52ee73..a7cf4c50b96 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -88,10 +88,10 @@ class pdf_beluga extends ModelePDFProjects public $posxref; public $posxdate; - public $posxsociete; + public $posxsociety; public $posxamountht; public $posxamountttc; - public $posstatut; + public $posxstatut; /** @@ -156,10 +156,10 @@ class pdf_beluga extends ModelePDFProjects if ($this->page_largeur < 210) { // To work with US executive format $this->posxref -= 20; $this->posxdate -= 20; - $this->posxsociete -= 20; + $this->posxsociety -= 20; $this->posxamountht -= 20; $this->posxamountttc -= 20; - $this->posstatut -= 20; + $this->posxstatut -= 20; } } From 3a6b56160579ea95121fc0960bc111218f422732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Sep 2023 21:23:15 +0200 Subject: [PATCH 113/130] phpstan --- htdocs/core/class/commondocgenerator.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e1bbbba56e0..bfec5a6c199 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -155,7 +155,10 @@ abstract class CommonDocGenerator public $posxdesc; // For description public $posxqty; public $posxpuht; - + public $posxtva; + public $atleastonephoto; + public $atleastoneratenotnull; + public $atleastonediscount; /** * Constructor From 455a1dcc667b33d8198fb7bfecfe217fbcb38318 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 22:38:07 +0200 Subject: [PATCH 114/130] Type ip is ip --- htdocs/partnership/class/partnership.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index bb71d053dfe..5fcbcc39bf5 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -124,7 +124,7 @@ class Partnership extends CommonObject 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), - 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), + 'ip' => array('type'=>'ip', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),), ); public $rowid; From 51e364c1571c284667831214addb431f7f2dee0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 22:40:41 +0200 Subject: [PATCH 115/130] Update ChangeLog --- ChangeLog | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index cb1720cf8cb..23670207cbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,42 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 18.0.1 compared to 18.0.0 ***** +FIX: Adding a product in recurring invoice does not use the correct VAT +FIX: API /product/getAttributes +FIX: avoid php8 warnings +FIX: bad balance of TR tag in multicurrency price view +FIX: Bad calculation of localtax when price_base_type not defined. +FIX: Bad link into message +FIX: Bad message on menu to go to setup of accounting custom groups +FIX: Bank receipt was empty +FIX: Billing massaction should possible on Processed Reception. +FIX: clone when cloning object with ->lines containing not object +FIX: Condition to show column POSModule and POSTerminal in invoice list +FIX: CSS +FIX: date survey : button to add dates would not work. Session would store cells numbers which would stay to 10 for next surveys created. +FIX: dir output path for ODT models on reception card +FIX: Duplicate tooltip on ref of an agenda event +FIX: encrypt sensitive data not be done for const MAIN_AGENDA_ACTIONAUTO +FIX: Export when old file export_csv.modules.php +FIX: fatal error with bad definition of dictionaries +FIX: fatal error with some parameters +FIX: hook formBuilddocOptions was broken when used by 2 modules +FIX: Line for revenuestamp in accountancy transfer only if it exists +FIX: navigation +FIX: Navigation between bank receipts +FIX: payment card: misleading message when delete button disabled +FIX: reception odt dir output path +FIX: SQL request parenthesis +FIX: Suppliers addlines never have VAT if buyprice for this supplier +FIX: TakePOS receipt preview in admin +FIX: TakePOS receipt preview in admin #25648 +FIX: technical error on conciliation of lines +FIX: the account in chart of account to use for revenue stamp is on dict +FIX: url to check keyword not saved on partnership from public form +FIX: when adding new times on a survey, all hours would be erased. + + ***** ChangeLog for 18.0.0 compared to 17.0.0 ***** For uses: From 33857630b4dae439a26fcd21017b220e03e5697d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2023 22:43:29 +0200 Subject: [PATCH 116/130] Doc --- ChangeLog | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23670207cbd..c84c2e3198d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,26 +12,24 @@ FIX: Bad calculation of localtax when price_base_type not defined. FIX: Bad link into message FIX: Bad message on menu to go to setup of accounting custom groups FIX: Bank receipt was empty -FIX: Billing massaction should possible on Processed Reception. +FIX: Billing massaction should be possible on Processed Reception. FIX: clone when cloning object with ->lines containing not object FIX: Condition to show column POSModule and POSTerminal in invoice list FIX: CSS FIX: date survey : button to add dates would not work. Session would store cells numbers which would stay to 10 for next surveys created. FIX: dir output path for ODT models on reception card FIX: Duplicate tooltip on ref of an agenda event -FIX: encrypt sensitive data not be done for const MAIN_AGENDA_ACTIONAUTO -FIX: Export when old file export_csv.modules.php +FIX: encrypt sensitive data must not be done for const MAIN_AGENDA_ACTIONAUTO +FIX: Export when old file export_csv.modules.php is still present FIX: fatal error with bad definition of dictionaries FIX: fatal error with some parameters FIX: hook formBuilddocOptions was broken when used by 2 modules -FIX: Line for revenuestamp in accountancy transfer only if it exists -FIX: navigation +FIX: Line for revenuestamp in accountancy transfer must appear only if it exists FIX: Navigation between bank receipts FIX: payment card: misleading message when delete button disabled FIX: reception odt dir output path FIX: SQL request parenthesis -FIX: Suppliers addlines never have VAT if buyprice for this supplier -FIX: TakePOS receipt preview in admin +FIX: Suppliers addlines never have VAT if buyprice for this supplier not set FIX: TakePOS receipt preview in admin #25648 FIX: technical error on conciliation of lines FIX: the account in chart of account to use for revenue stamp is on dict From f2d8246581c46cc650c72d19b0c9c29a5af5f33a Mon Sep 17 00:00:00 2001 From: Mamisoa Date: Sun, 3 Sep 2023 00:11:47 +0200 Subject: [PATCH 117/130] FIX delete deprecated file Object.php Delete deprecated file Object.php that cause REST API to crash --- htdocs/install/upgrade2.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index fd1f2f9bc1e..f0aa54fd362 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4137,7 +4137,8 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/poire.modules.php', '/core/modules/mailings/kiwi.modules.php', '/core/boxes/box_members.php', - + '/includes/restler/framework/Luracast/Restler/Data/Object.php', + '/api/class/api_generic.class.php', '/asterisk/cidlookup.php', '/categories/class/api_category.class.php', From e3a86e327e9787f68398183598075d5a68f3b03d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 02:05:43 +0200 Subject: [PATCH 118/130] Fix warning --- .../class/partnershiputils.class.php | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 86722ed1da2..c73bc4230d4 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -233,6 +233,8 @@ class PartnershipUtils $this->output = ''; $this->error = ''; $partnershipsprocessed = array(); + $emailnotfound = ''; + $websitenotfound = ''; $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; if ($gracedelay < 1) { @@ -251,21 +253,16 @@ class PartnershipUtils $sql = "SELECT p.rowid, p.status, p.".$fk_partner; $sql .= ", p.last_check_backlink"; - $sql .= ', partner.url, partner.email'; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; } - - $sql .= " WHERE 1 = 1"; - $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled - $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= " WHERE p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted and not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 24 * 3600)."')"; // Never more than 1 check every day to check that website contains a referal link. $sql .= $this->db->order('p.rowid', 'ASC'); // Limit is managed into loop later @@ -274,7 +271,6 @@ class PartnershipUtils $numofexpiredmembers = $this->db->num_rows($resql); $somethingdoneonpartnership = 0; $ifetchpartner = 0; - $websitenotfound = ''; while ($ifetchpartner < $numofexpiredmembers) { $ifetchpartner++; @@ -376,18 +372,16 @@ class PartnershipUtils if (!$error) { $this->db->commit(); - $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output = ""; } else { $this->db->rollback(); $this->output = "Rollback after error\n"; - $this->output .= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; } + $this->output .= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output .= "\nSQL used to find partnerships to scan: ".$sql; return ($error ? 1 : 0); } From 0dfdeecea2e3c03ac380953bf88af45f1f69d23e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 02:37:21 +0200 Subject: [PATCH 119/130] Trans --- htdocs/langs/en_US/partnership.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 105456dc719..31e2f5000bb 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -82,10 +82,10 @@ YourPartnershipRefusedTopic=Partnership refused YourPartnershipAcceptedTopic=Partnership accepted YourPartnershipCanceledTopic=Partnership canceled -YourPartnershipWillSoonBeCanceledContent=We inform you that your partnership will soon be canceled (Backlink not found) -YourPartnershipRefusedContent=We inform you that your partnership request has been refused. +YourPartnershipWillSoonBeCanceledContent=We would like to inform you that your partnership will soon be canceled (we did not get renewal or a prerequisite for our partnership is missing). Contact us by email if this is an error. +YourPartnershipRefusedContent=We inform you that your partnership request has been refused. May be a prerequisite is missing. Contact us if you need more information. YourPartnershipAcceptedContent=We inform you that your partnership request has been accepted. -YourPartnershipCanceledContent=We inform you that your partnership has been canceled. +YourPartnershipCanceledContent=We inform you that your partnership has been canceled. May be a prerequisite is missing. Contact us if you need more information. CountLastUrlCheckError=Number of errors for last URL check LastCheckBacklink=Date of last URL check From f5526698be83bb28733fb60af48544073f472ca2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 02:52:42 +0200 Subject: [PATCH 120/130] Fix missing migration order to match first install data --- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index c80229393a8..3e44428b286 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -60,6 +60,17 @@ ALTER TABLE llx_c_action_trigger ADD COLUMN contexts varchar(255) NULL; insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CLOSE','Project closed','Executed when a project is closed','project',145); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_CREATE','Template invoices created','Executed when a Template invoices is created','facturerec',900); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_MODIFY','Template invoices update','Executed when a Template invoices is updated','facturerec',901); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_DELETE','Template invoices deleted','Executed when a Template invoices is deleted','facturerec',902); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_AUTOCREATEBILL','Template invoices use to create invoices with auto batch','Executed when a Template invoices is use to create invoice with auto batch','facturerec',903); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_CREATE','Partnership created','Executed when a partnership is created','partnership',58000); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_MODIFY','Partnership modified','Executed when a partnership is modified','partnership',58002); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_SENTBYMAIL','Mails sent from partnership file','Executed when you send email from partnership file','partnership',58004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_DELETE','Partnership deleted','Executed when a partnership is deleted','partnership',58006); + + -- amount was removed in v12 ALTER TABLE llx_facture DROP COLUMN amount; From 32fcc4cd1788809b40ad88728451f1df45cd13f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 02:05:43 +0200 Subject: [PATCH 121/130] Fix warning --- .../class/partnershiputils.class.php | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 86722ed1da2..c73bc4230d4 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -233,6 +233,8 @@ class PartnershipUtils $this->output = ''; $this->error = ''; $partnershipsprocessed = array(); + $emailnotfound = ''; + $websitenotfound = ''; $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; if ($gracedelay < 1) { @@ -251,21 +253,16 @@ class PartnershipUtils $sql = "SELECT p.rowid, p.status, p.".$fk_partner; $sql .= ", p.last_check_backlink"; - $sql .= ', partner.url, partner.email'; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; } - - $sql .= " WHERE 1 = 1"; - $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled - $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= " WHERE p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted and not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 24 * 3600)."')"; // Never more than 1 check every day to check that website contains a referal link. $sql .= $this->db->order('p.rowid', 'ASC'); // Limit is managed into loop later @@ -274,7 +271,6 @@ class PartnershipUtils $numofexpiredmembers = $this->db->num_rows($resql); $somethingdoneonpartnership = 0; $ifetchpartner = 0; - $websitenotfound = ''; while ($ifetchpartner < $numofexpiredmembers) { $ifetchpartner++; @@ -376,18 +372,16 @@ class PartnershipUtils if (!$error) { $this->db->commit(); - $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output = ""; } else { $this->db->rollback(); $this->output = "Rollback after error\n"; - $this->output .= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; } + $this->output .= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output .= "\nSQL used to find partnerships to scan: ".$sql; return ($error ? 1 : 0); } From 573b9dd77a2fa73ecdd8e06b0906bbdcec735602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 3 Sep 2023 09:54:56 +0200 Subject: [PATCH 122/130] phpstan --- htdocs/core/class/lessc.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index f1620898028..29feea57f29 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -56,8 +56,12 @@ class Lessc public $scope; public $formatter; + public $formatterName; + public $parser; + public $_parseFile; public $env; public $count; + public $inExp; protected $numberPrecision = null; @@ -2640,7 +2644,15 @@ class lessc_parser protected static $literalCache = array(); public $env; + public $buffer; public $count; + public $line; + public $eatWhiteDefault; + public $lessc; + public $sourceName; + public $writeComments; + public $seenComments; + public $currentProperty; public function __construct($lessc, $sourceName = null) @@ -4245,6 +4257,7 @@ class lessc_formatter_classic public $breakSelectors = false; public $compressColors = false; + public $indentLevel; public function __construct() { From 345668b2ca6746ce96f6f1ad940fb6e1f0a074e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 17:31:50 +0200 Subject: [PATCH 123/130] Default html for an url is no more a 'float' div --- htdocs/core/class/commonobject.class.php | 14 +++++++------- htdocs/core/lib/functions.lib.php | 3 ++- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f0f349bd3bd..c5b3011e3bb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7525,13 +7525,13 @@ abstract class CommonObject * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields * - * @param array $val Array of properties of field to show - * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) - * @param string $moreparam To add more parametes on html input tag - * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @param mixed $morecss Value for css to define size. May also be a numeric. + * @param array $val Array of properties of field to show + * @param string $key Key of attribute + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $moreparam To add more parameters on html tag + * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param mixed $morecss Value for CSS to use (Old usage: May also be a numeric to define a size). * @return string */ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '') diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 67fcd857293..710ad9f3dce 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3150,6 +3150,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor if ($target) { $linkstart .= ' target="'.$target.'"'; } + $linkstart .= ' title="'.$langs->trans("URL").': '.$url.'"'; $linkstart .= '>'; $link = ''; @@ -3163,7 +3164,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor if ($morecss == 'float') { // deprecated return '
'.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } else { - return $linkstart.''.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.''.$linkend; + return $linkstart.''.($withpicto ?img_picto('', 'globe').' ' : '').$link.''.$linkend; } } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 972a2322a23..a174dc9ffad 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -756,7 +756,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { + if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) { print ' title="'.dol_escape_htmltag($object->$key).'"'; } print '>'; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 98d78e0a2b2..27821a2b799 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -914,7 +914,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { + if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) { print ' title="'.dol_escape_htmltag($object->$key).'"'; } print '>'; From 4d17c6441ac15fd87969ba27c90d30ccbb440675 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 17:36:23 +0200 Subject: [PATCH 124/130] CSS --- htdocs/partnership/class/partnership.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 6976cb8e587..871ddfaff2d 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,7 +120,7 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), + 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), From 92fd69b84b771227d0baf49c830a2f3571743e07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 18:06:38 +0200 Subject: [PATCH 125/130] Fix warnings --- htdocs/bookmarks/class/bookmark.class.php | 5 ----- htdocs/don/class/don.class.php | 1 - htdocs/projet/class/project.class.php | 1 - 3 files changed, 7 deletions(-) diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 389603fb161..afac3563dee 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -49,11 +49,6 @@ class Bookmark extends CommonObject */ public $picto = 'bookmark'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Last error code on a local method * @var int Error number diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c730c7d0b08..aad080fad2b 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -443,7 +443,6 @@ class Don extends CommonObject } } else { $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); $error++; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4466138e006..99f0f375b4f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -495,7 +495,6 @@ class Project extends CommonObject } } else { $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); $error++; } From 3f25ff69bcaa26a6c796bcb07c6086af0e640899 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 18:09:32 +0200 Subject: [PATCH 126/130] Clean code --- htdocs/public/bookcal/booking.php | 5 ++--- htdocs/public/bookcal/index.php | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php index d478046d143..74972cfc8f0 100644 --- a/htdocs/public/bookcal/booking.php +++ b/htdocs/public/bookcal/booking.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/public/onlinesign/newonlinesign.php + * \file htdocs/public/bookcal/booking.php * \ingroup core * \brief File to offer a way to make an online signature for a particular Dolibarr entity * Example of URL: https://localhost/public/bookcal/booking.php?ref=PR... @@ -44,7 +44,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies")); @@ -175,7 +174,7 @@ if ($action == 'add') { $user = new User($db); } - $booking = new Booking($db); + $booking = new ActionComm($db); $db->begin(); if (!GETPOST("lastname")) { diff --git a/htdocs/public/bookcal/index.php b/htdocs/public/bookcal/index.php index 530f37fc91e..cd4db57da4d 100644 --- a/htdocs/public/bookcal/index.php +++ b/htdocs/public/bookcal/index.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/public/onlinesign/newonlinesign.php + * \file htdocs/public/bookcal/index.php * \ingroup core * \brief File to offer a way to make an online signature for a particular Dolibarr entity * Example of URL: https://localhost/public/bookcal/booking.php?ref=PR... @@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "bookcal")); From 3675ec0b426b5ed0cef6f4d14aae77e71b137147 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 18:51:34 +0200 Subject: [PATCH 127/130] Enhance look of apstats --- dev/tools/apstats.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 4bdf2fc45c3..271bd264270 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -237,7 +237,21 @@ th,td { padding: 20px; font-size: 1.2em; margin-top: 10px; - maring-bottom: 10px; + margin-bottom: 10px; + width: 200px; +} +.box.inline-box { + display: inline-block; + text-align: center; + margin-left: 10px; +} +.back1 { + background-color: #888800; + color: #FFF; +} +.back1 { + background-color: #880088; + color: #FFF; } '; @@ -312,14 +326,14 @@ $html .= ''; $html .= '
'; $html .= '

Project value


'; -$html .= '
'; +$html .= '
'; $html .= 'COCOMO (Basic organic model) value:
'; -$html .= '$'.formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2); +$html .= '$'.formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2).''; $html .= '
'; -$html .= '
'; +$html .= '
'; $html .= 'COCOMO (Basic organic model) effort
'; -$html .= formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); -$html .= ' monthes people
'; +$html .= ''.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); +$html .= ' monthes people
'; $html .= '
'; $html .= '
'; From d1ea2743158fbd3a6e5187ded503efdfb47eb5d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 23:06:48 +0200 Subject: [PATCH 128/130] Update upgrade2.php --- htdocs/install/upgrade2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f0aa54fd362..dfe1c7d9bc6 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4138,7 +4138,7 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/kiwi.modules.php', '/core/boxes/box_members.php', '/includes/restler/framework/Luracast/Restler/Data/Object.php', - + '/api/class/api_generic.class.php', '/asterisk/cidlookup.php', '/categories/class/api_category.class.php', From c3ee677256bb0f589fef916e808b2b2331bd471e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2023 02:29:15 +0200 Subject: [PATCH 129/130] Ignore rule --- .github/workflows/exakat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 26ea74183e4..d1bdffc71a6 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -22,7 +22,7 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/NestedTernary,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' ignore_dirs: '/htdocs/includes/,/htdocs/install/doctemplates/,/build/,/dev/,/doc/,/scripts/,/test/' file_extensions: php project_reports: Perfile \ No newline at end of file From 59112707035bf4f1c691d5e8e5502f201b83fc7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2023 02:36:20 +0200 Subject: [PATCH 130/130] Dict must extends CommonDict --- .../compta/paiement/class/cpaiement.class.php | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 683e9fc3679..7c7a275e8b6 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -25,17 +25,15 @@ * \brief This file is to manage CRUD function of type of payments */ +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php'; + /** * Class Cpaiement */ -class Cpaiement +class Cpaiement extends CommonDict { - /** - * @var DoliDB Database handler. - */ - public $db; - /** * @var string Id to identify managed objects */ @@ -46,18 +44,6 @@ class Cpaiement */ public $table_element = 'c_paiement'; - public $code; - - /** - * @var int ID - */ - public $id; - - /** - * @var string[] array of errors messages - */ - public $errors; - /** * @var string * @deprecated @@ -65,11 +51,6 @@ class Cpaiement */ public $libelle; - /** - * @var string - */ - public $label; - public $type; public $active; public $accountancy_code;