diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5829696c3e8..6fefa14ed25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,6 @@ repos: - id: trailing-whitespace exclude_types: [markdown] - id: end-of-file-fixer - types: [yaml] - id: check-merge-conflict - id: check-executables-have-shebangs - id: check-shebang-scripts-are-executable @@ -77,7 +76,7 @@ repos: - css - yaml - # Check format of yam files + # Check format of yaml files - repo: https://github.com/adrienverge/yamllint.git rev: v1.32.0 hooks: diff --git a/ChangeLog b/ChangeLog index 7766fc58f58..5a045136113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,26 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 19.0.0 compared to 18.0.0 ***** + +For users: +---------- +NEW: Compatibility with PHP 8.3 +... + +For developers or integrators: +------------------------------ +... + +WARNING: +-------- + +The following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* More class properties (with old name in french) are now deprecated in favor of the property name in english. +* Some API HTTP return code were moved from 401 to 403 to better follow REST specification. + + + ***** ChangeLog for 19.0.0 compared to 18.0.0 ***** For users: diff --git a/SECURITY.md b/SECURITY.md index f004cea7c86..a10c1eb15b7 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -48,12 +48,16 @@ Reports are processed around once a month. ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid": -* The version to analyze must be the last version available in the "develop" branch or in the last stable "vX.Y" released version. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated. +* The version to analyze must be the last version available in the "develop" branch. Reports on vulnerabilities already fixed (so already reported) in the develop branch will not be validated. * $dolibarr_main_prod must be set to 1 in conf.php * $dolibarr_nocsrfcheck must be kept to the value 0 in conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 in the backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default). CSRF attacks are accepted but - double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. +* Some constant must be set in the backoffice menu Home - Setup - Other + - MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 + - MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1 + - MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1 + - MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1 + CSRF attacks and HTML injections are accepted but double check this setup that is experimental setup that already fix a lot of case and soon enabled by default. * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles in "experimental", "development" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only. @@ -87,12 +91,10 @@ Scope is the web application (backoffice) and the APIs. * Logout and other instances of low-severity Cross-Site Request Forgery * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Reports on features on modules flagged as "deprecated", "experimental" or "development" if the module needs to be enabled for that (this is not the case on production). -* Software or libraries versions or private IP disclosure when logged-in user is admin -* Stack traces or path disclosure when logged-in user is admin +* Software or libraries versions, private IP disclosure, Stack traces or path disclosure when logged-in user is admin. * Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities". * Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself. * Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed. * SSL/TLS best practices -* Denial of Service attacks * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device diff --git a/dev/setup/README.md b/dev/setup/README.md new file mode 100644 index 00000000000..5bc8fc08a99 --- /dev/null +++ b/dev/setup/README.md @@ -0,0 +1,10 @@ +# Setting up for Dolibarr development + +Check out the +[online documentation](https://wiki.dolibarr.org/index.php?title=Environment_and_development_tools) +for recommendations (to be updated). + +If anything, install `pre-commit` - it will help run the tools to format and +make some basic verifications on your submission before committing and pushing +to github for a PR. See [a quick start guide](./pre-commit/README.md) in this +Dolibarr repository. diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md new file mode 100644 index 00000000000..d0124e23b16 --- /dev/null +++ b/dev/setup/pre-commit/README.md @@ -0,0 +1,85 @@ +## 'pre-commit' ("replaces" precommit) + +### Introduction + +[`pre-commit`](https://pre-commit.org) is a framework for managing and +maintaining multi-language pre-commit hooks. + +"pre-commit hooks" integrate with `git` and are run when you perform a +`git commit` for instance. + +Historically there was `precommit` for Dolibarr which you can find in this +directory. That script runs `phplint`, `phpcs` and `phpcbf` upon commit. + +`pre-commit` is not specific to Dolibarr and is deployed on many projects - +mostly Python projects, but it is applicable to most (or *all*) code and +documentation development. + +You can find documentation at https://pre-commit.com/ . + +Now you can use `pre-commit` which uses the configuration found at the root of +the project: `pre-commit-config.yaml`. + +### How to + +1. Install `pre-commit`.\ + If you do not have python installed, install + [python](https://www.python.org) first.\ + If you do not have + [`pip`](https://pypi.org/project/pip), install that as well.\\ + + Then you can install pre-commit: `python -m pip install pre-commit`. + +1. In you local git clone of the project, run `pre-commit install`. That will + add the hooks. + +### Tips + +After installing `pre-commit` onto your local git clone, pre-commit will run +on every commit. + +When it finds some issue, the git commit will be aborted, so you can fix it, +or verify it. + +The tools run by `pre-commit` may modify your code: format PHP code +(`phpcbf`), fix line endings, end of files, etc. + +They may also alert about potential issues: syntax errors, spelling errors, +code quality, an execute bit that was (not) set in the git repository, etc. + +One way to use it is this: + +```bash +cd PROJECT_DIR +pre-commit install # Only needed once +# Repeat until success. +git commit -a -m "My message" +# `pre-commit` is run and reports +# Check the results, make fixes, and re-commit (=repeat above line). +``` + +In some cases you may want to commit despite the changes.\ +You can just add +`--no-verify` to your git command: + +```bash +git commit -a -m "My message" --no-verify +``` + +If you want to skip certain checks for whatever reason, you can set the SKIP +environment variable: + +```bash +SKIP=no-commit-to-branch git commit -a -m "My message" + +or + +export SKIP=no-commit-to-branch # In your .bashrc or session. +``` + +There is much more you can do with pre-commit, check out its +[documentation](https://pre-commit.com). + +Now your commit is less likely to fail in the Continuous Intagration (CI) run +on github.\ +CI also runs pre-commit to help maintain code quality. diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index ee587a31f96..477fac08eee 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,7 +109,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->date_start = $date_start; $object->date_end = $date_end; $object->label = GETPOST('label', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOSTINT('status'); $object->datec = dol_now(); if (empty($object->date_start) && empty($object->date_end)) { @@ -152,7 +152,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $object->date_start = GETPOST("fiscalyear") ? $date_start : ''; $object->date_end = GETPOST("fiscalyearend") ? $date_end : ''; $object->label = GETPOST('label', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOSTINT('status'); $result = $object->update($user); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7d42cb64a00..0e4abdaebd4 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -663,7 +663,7 @@ if ($action == 'create') { if (!empty($object->linesmvt[0])) { $tmpline = $object->linesmvt[0]; if (!empty($tmpline->numero_compte)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($db); $object->linesmvt[] = $line; } } diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 498a8ee2ed3..f92c3aee5f0 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -1087,7 +1087,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print "\n"; -$line = new BookKeepingLine(); +$line = new BookKeepingLine($db); // Loop on record // -------------------------------------------------------------------- diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ed00a185230..be1c5a34fcd 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1037,7 +1037,7 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print "\n"; -$line = new BookKeepingLine(); +$line = new BookKeepingLine($db); // Loop on record // -------------------------------------------------------------------- diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a479ce52bc2..554f4390510 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -26,6 +26,7 @@ // Class require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; @@ -986,7 +987,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1140,7 +1141,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1275,7 +1276,7 @@ class BookKeeping extends CommonObject $i = 0; while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->numero_compte = $obj->numero_compte; //$line->label_compte = $obj->label_compte; @@ -1881,7 +1882,7 @@ class BookKeeping extends CommonObject $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -1951,7 +1952,7 @@ class BookKeeping extends CommonObject $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { - $line = new BookKeepingLine(); + $line = new BookKeepingLine($this->db); $line->id = $obj->rowid; @@ -2976,7 +2977,7 @@ class BookKeeping extends CommonObject /** * Class BookKeepingLine */ -class BookKeepingLine +class BookKeepingLine extends CommonObjectLine { /** * @var int ID diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 2b9d86c3bbd..515c0bd46af 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -307,8 +307,8 @@ if (empty($reshook)) { $object->address = trim(GETPOST("address", 'alphanohtml')); $object->zip = trim(GETPOST("zipcode", 'alphanohtml')); $object->town = trim(GETPOST("town", 'alphanohtml')); - $object->state_id = GETPOST("state_id", 'int'); - $object->country_id = GETPOST("country_id", 'int'); + $object->state_id = GETPOSTINT("state_id"); + $object->country_id = GETPOSTINT("country_id"); $object->phone = trim(GETPOST("phone", 'alpha')); $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); @@ -334,9 +334,9 @@ if (empty($reshook)) { } // Get status and public property - $object->statut = GETPOST("statut", 'alpha'); - $object->status = GETPOST("statut", 'alpha'); - $object->public = GETPOST("public", 'alpha'); + $object->statut = GETPOSTINT("statut"); + $object->status = GETPOSTINT("statut"); + $object->public = GETPOSTINT("public"); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 90200347a3a..90b1cec79a9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García - * Copyright (C) 2015-2023 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART @@ -1121,7 +1121,7 @@ class Adherent extends CommonObject * @param int $isencrypted 0 ou 1 if the password needs to be encrypted in the DB (default: 0) * @param int $notrigger 1=Does not raise the triggers * @param int $nosyncuser Do not synchronize linked user - * @return string If OK return clear password, 0 if no change, < 0 if error + * @return string|int Clear password if change ok, 0 if no change, <0 if error */ public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { @@ -2461,15 +2461,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb in state board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf; $this->nb = array(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 2155f8e0872..2b5dd23b7d8 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -80,6 +80,10 @@ $socid = GETPOST('socid', 'int'); $search_filter = GETPOST("search_filter", 'alpha'); $search_status = GETPOST("search_status", 'intcomma'); // statut +$search_datec_start = dol_mktime(0, 0, 0, GETPOST('search_datec_start_month', 'int'), GETPOST('search_datec_start_day', 'int'), GETPOST('search_datec_start_year', 'int')); +$search_datec_end = dol_mktime(23, 59, 59, GETPOST('search_datec_end_month', 'int'), GETPOST('search_datec_end_day', 'int'), GETPOST('search_datec_end_year', 'int')); +$search_datem_start = dol_mktime(0, 0, 0, GETPOST('search_datem_start_month', 'int'), GETPOST('search_datem_start_day', 'int'), GETPOST('search_datem_start_year', 'int')); +$search_datem_end = dol_mktime(23, 59, 59, GETPOST('search_datem_end_month', 'int'), GETPOST('search_datem_end_day', 'int'), GETPOST('search_datem_end_year', 'int')); $filter = GETPOST("filter", 'alpha'); if ($filter) { @@ -258,6 +262,10 @@ if (empty($reshook)) { $catid = ""; $search_all = ""; $toselect = array(); + $search_datec_start = ''; + $search_datec_end = ''; + $search_datem_start = ''; + $search_datem_end = ''; $search_array_options = array(); } @@ -513,6 +521,18 @@ if ($search_country) { if ($search_import_key) { $sql .= natural_search("d.import_key", $search_import_key); } +if ($search_datec_start) { + $sql .= " AND d.datec >= '".$db->idate($search_datec_start)."'"; +} +if ($search_datec_end) { + $sql .= " AND d.datec <= '".$db->idate($search_datec_end)."'"; +} +if ($search_datem_start) { + $sql .= " AND d.tms >= '".$db->idate($search_datem_start)."'"; +} +if ($search_datem_end) { + $sql .= " AND d.tms <= '".$db->idate($search_datem_end)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -659,6 +679,12 @@ if ($search_import_key != '') { if ($search_type > 0) { $param .= "&search_type=".urlencode($search_type); } +if ($search_datec_start) { + $param .= '&search_datec_start_day='.dol_print_date($search_datec_start, '%d').'&search_datec_start_month='.dol_print_date($search_datec_start, '%m').'&search_datec_start_year='.dol_print_date($search_datec_start, '%Y'); +} +if ($search_datem_end) { + $param .= '&search_datem_end_day='.dol_print_date($search_datem_end, '%d').'&search_datem_end_month='.dol_print_date($search_datem_end, '%m').'&search_datem_end_year='.dol_print_date($search_datem_end, '%Y'); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -914,6 +940,12 @@ print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['d.datec']['checked'])) { print ''; + print '
'; + print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } @@ -926,6 +958,12 @@ if (!empty($arrayfields['d.birth']['checked'])) { // Date modification if (!empty($arrayfields['d.tms']['checked'])) { print ''; + print '
'; + print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index abdcb33770b..dd7f6033221 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -93,12 +93,12 @@ if (empty($conf->use_javascript_ajax)) { } else { print ''; $arrval = array( - '0'=>$langs->trans("No"), - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', - '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', - '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', + $langs->trans("No"), + $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', + $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', + $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', ); - print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalInt('RESOURCE_USE_SEARCH_TO_SELECT')); print ''; print ''; print ''; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index fe9e885dcc8..3bb8c08e892 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -63,7 +63,9 @@ class Setup extends DolibarrApi * * @return array [List of ordering methods] * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 401 Access denied + * @throws RestException 503 Error retrieving list of ordering methods */ public function getOrderingMethods($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -81,7 +83,7 @@ class Setup extends DolibarrApi $errormessage = ''; $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); if ($errormessage) { - throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage); } } @@ -106,7 +108,7 @@ class Setup extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -125,7 +127,9 @@ class Setup extends DolibarrApi * * @url GET dictionary/ordering_origins * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 401 Access denied + * @throws RestException 503 Error retrieving list of ordering origins */ public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -168,7 +172,7 @@ class Setup extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -188,7 +192,9 @@ class Setup extends DolibarrApi * * @return array [List of payment types] * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 401 Access denied + * @throws RestException 503 Error retrieving list of payment types */ public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -232,7 +238,7 @@ class Setup extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -253,7 +259,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/regions * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error retrieving list of regions */ public function getListOfRegions($sortfield = "code_region", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '') { @@ -316,7 +323,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/regions/{id} * - * @throws RestException + * @throws RestException 404 Region not found + * @throws RestException 503 Error retrieving region */ public function getRegionByID($id) { @@ -331,7 +339,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/regions/byCode/{code} * - * @throws RestException + * @throws RestException 404 Region not found + * @throws RestException 503 Error when retrieving region */ public function getRegionByCode($code) { @@ -357,7 +366,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/states * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error retrieving list of states */ public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '') { @@ -422,7 +432,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/states/{id} * - * @throws RestException + * @throws RestException 404 State not found + * @throws RestException 503 Error retrieving state */ public function getStateByID($id) { @@ -437,7 +448,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/states/byCode/{code} * - * @throws RestException + * @throws RestException 404 State not found + * @throws RestException 503 Error retrieving state */ public function getStateByCode($code) { @@ -463,7 +475,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/countries * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error retrieving list of countries */ public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') { @@ -527,7 +540,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/countries/{id} * - * @throws RestException + * @throws RestException 404 Country not found + * @throws RestException 503 Error retrieving country */ public function getCountryByID($id, $lang = '') { @@ -543,7 +557,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/countries/byCode/{code} * - * @throws RestException + * @throws RestException 404 Country not found + * @throws RestException 503 Error retrieving country */ public function getCountryByCode($code, $lang = '') { @@ -559,7 +574,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/countries/byISO/{iso} * - * @throws RestException + * @throws RestException 404 Country not found + * @throws RestException 503 Error retrieving country */ public function getCountryByISO($iso, $lang = '') { @@ -654,7 +670,9 @@ class Setup extends DolibarrApi * * @return array [List of availability] * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 401 Access denied + * @throws RestException 503 Error when retrieving list of availabilities */ public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -697,7 +715,7 @@ class Setup extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -766,7 +784,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/event_types * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of events types */ public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') { @@ -832,7 +851,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/expensereport_types * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of expense report types */ public function getListOfExpenseReportsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') { @@ -897,7 +917,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/contact_types * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of contacts types */ public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang = '', $sqlfilters = '') { @@ -965,7 +986,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/civilities * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of civilities */ public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $lang = '', $sqlfilters = '') { @@ -1029,7 +1051,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/currencies * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of currencies */ public function getListOfCurrencies($multicurrency = 0, $sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -1098,7 +1121,8 @@ class Setup extends DolibarrApi * * @url GET extrafields * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of extra fields */ public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') { @@ -1175,7 +1199,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/towns * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of towns */ public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') { @@ -1240,7 +1265,8 @@ class Setup extends DolibarrApi * * @return array List of payment terms * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of payments terms */ public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -1284,7 +1310,7 @@ class Setup extends DolibarrApi $list[] = $this->db->fetch_object($result); } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -1303,7 +1329,8 @@ class Setup extends DolibarrApi * * @return array List of shipping methods * - * @throws RestException 400 + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of shipping modes */ public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { @@ -1345,7 +1372,7 @@ class Setup extends DolibarrApi $list[] = $method; } } else { - throw new RestException(400, $this->db->lasterror()); + throw new RestException(503, $this->db->lasterror()); } return $list; @@ -1364,7 +1391,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/units * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of measuring units */ public function getListOfMeasuringUnits($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -1423,7 +1451,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/legal_form * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of legal form */ public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters = '') { @@ -1484,7 +1513,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/staff * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of staff */ public function getListOfStaff($sortfield = "id", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -1542,7 +1572,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/socialnetworks * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of social networks */ public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { @@ -1608,7 +1639,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/ticket_categories * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of tickets categories */ public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { @@ -1670,7 +1702,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/ticket_severities * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of tickets severities */ public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { @@ -1732,7 +1765,8 @@ class Setup extends DolibarrApi * * @url GET dictionary/ticket_types * - * @throws RestException + * @throws RestException 400 Bad value for sqlfilters + * @throws RestException 503 Error when retrieving list of tickets types */ public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { @@ -1795,7 +1829,7 @@ class Setup extends DolibarrApi * * @url GET dictionary/incoterms * - * @throws RestException + * @throws RestException 503 Error when retrieving list of incoterms types */ public function getListOfIncoterms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { @@ -1905,7 +1939,7 @@ class Setup extends DolibarrApi * * @url GET /establishments * - * @throws RestException + * @throws RestException 503 Error when retrieving list of establishments */ public function getEstablishments() { @@ -1943,7 +1977,8 @@ class Setup extends DolibarrApi * * @url GET establishments/{id} * - * @throws RestException + * @throws RestException 404 Establishment not found + * @throws RestException 503 Error when retrieving establishment */ public function getEtablishmentByID($id) { @@ -1969,8 +2004,8 @@ class Setup extends DolibarrApi * * @url GET conf/{constantname} * + * @throws RestException 400 Error Bad or unknown value for constantname * @throws RestException 403 Forbidden - * @throws RestException 404 Error Bad or unknown value for constantname */ public function getConf($constantname) { @@ -1982,7 +2017,7 @@ class Setup extends DolibarrApi } if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) { - throw new RestException(404, 'Error Bad or unknown value for constantname'); + throw new RestException(400, 'Error Bad or unknown value for constantname'); } if (isASecretKey($constantname)) { throw new RestException(403, 'Forbidden. This parameter can not be read with APIs'); @@ -2002,7 +2037,6 @@ class Setup extends DolibarrApi * @throws RestException 403 Forbidden * @throws RestException 404 Signature file not found * @throws RestException 500 Technical error - * @throws RestException 503 Forbidden */ public function getCheckIntegrity($target) { diff --git a/htdocs/api/index.php b/htdocs/api/index.php index a2c7328aa21..f1c98e7b146 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -411,19 +411,19 @@ Luracast\Restler\Defaults::$returnResponse = $usecompression; // Call API (we suppose we found it). // The handle will use the file api/temp/routes.php to get data to run the API. If the file exists and the entry for API is not found, it will return 404. -$result = $api->r->handle(); +$responsedata = $api->r->handle(); if (Luracast\Restler\Defaults::$returnResponse) { // We try to compress the data received data if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) { header('Content-Encoding: br'); - $result = brotli_compress($result, 11, constant('BROTLI_TEXT')); + $result = brotli_compress($responsedata, 11, constant('BROTLI_TEXT')); } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) { header('Content-Encoding: bz'); - $result = bzcompress($result, 9); + $result = bzcompress($responsedata, 9); } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) { header('Content-Encoding: gzip'); - $result = gzencode($result, 9); + $result = gzencode($responsedata, 9); } else { header('Content-Encoding: text/html'); print "No compression method found. Try to disable compression by adding API_DISABLE_COMPRESSION=1"; @@ -434,4 +434,20 @@ if (Luracast\Restler\Defaults::$returnResponse) { echo $result; } +// Call API termination method +$apiMethodInfo = &$api->r->apiMethodInfo; +$terminateCall = '_terminate_' . $apiMethodInfo->methodName . '_' . $api->r->responseFormat->getExtension(); +if (method_exists($apiMethodInfo->className, $terminateCall)) { + // Now flush output buffers so that response data is sent to the client even if we still have action to do in a termination method. + ob_end_flush(); + + // If you're using PHP-FPM, this function will allow you to send the response and then continue processing + if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); + } + + // Call a termination method. Warning: This method can do I/O, sync but must not make output. + call_user_func(array(Luracast\Restler\Scope::get($apiMethodInfo->className), $terminateCall), $responsedata); +} + //session_destroy(); diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index d84b25d7225..2f68b565394 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -61,7 +61,9 @@ class Boms extends DolibarrApi * @return Object Object with cleaned properties * * @url GET {id} - * @throws RestException + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found */ public function get($id) { @@ -95,7 +97,9 @@ class Boms extends DolibarrApi * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects * - * @throws RestException + * @throws RestException 400 Bad sqlfilters + * @throws RestException 401 Access denied + * @throws RestException 503 Error retrieving list of boms */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { @@ -176,6 +180,9 @@ class Boms extends DolibarrApi * * @param array $request_data Request datas * @return int ID of bom + * + * @throws RestException 401 Access denied + * @throws RestException 500 Error retrieving list of boms */ public function post($request_data = null) { @@ -210,6 +217,10 @@ class Boms extends DolibarrApi * @param array $request_data Datas * * @return int + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found + * @throws RestException 500 Error updating bom */ public function put($id, $request_data = null) { @@ -253,6 +264,10 @@ class Boms extends DolibarrApi * * @param int $id BOM ID * @return array + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found + * @throws RestException 500 Error deleting bom */ public function delete($id) { @@ -288,6 +303,9 @@ class Boms extends DolibarrApi * @url GET {id}/lines * * @return array + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found */ public function getLines($id) { @@ -320,6 +338,10 @@ class Boms extends DolibarrApi * @url POST {id}/lines * * @return int + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found + * @throws RestException 500 Error adding bom line */ public function postLine($id, $request_data = null) { @@ -353,7 +375,7 @@ class Boms extends DolibarrApi if ($updateRes > 0) { return $updateRes; } else { - throw new RestException(400, $this->bom->error); + throw new RestException(500, $this->bom->error); } } @@ -367,6 +389,9 @@ class Boms extends DolibarrApi * @url PUT {id}/lines/{lineid} * * @return object|bool + * + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found */ public function putLine($id, $lineid, $request_data = null) { @@ -415,9 +440,9 @@ class Boms extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws RestException 401 Access denied + * @throws RestException 404 BOM not found + * @throws RestException 500 Error deleting bom line */ public function deleteLine($id, $lineid) { @@ -450,7 +475,7 @@ class Boms extends DolibarrApi if ($updateRes > 0) { return $this->get($id); } else { - throw new RestException(405, $this->bom->error); + throw new RestException(500, $this->bom->error); } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 11d31aaa031..139ed636366 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -220,6 +220,11 @@ class Categorie extends CommonObject */ public $color; + /** + * @var int Position + */ + public $position; + /** * @var int Visible */ @@ -352,7 +357,7 @@ class Categorie extends CommonObject $type = $this->MAP_ID[$type]; } - $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; + $sql = "SELECT rowid, fk_parent, entity, label, description, color, position, fk_soc, visible, type, ref_ext"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id) { @@ -378,6 +383,7 @@ class Categorie extends CommonObject $this->label = $res['label']; $this->description = $res['description']; $this->color = $res['color']; + $this->position = $res['position']; $this->socid = (int) $res['fk_soc']; $this->visible = (int) $res['visible']; $this->type = (int) $res['type']; @@ -440,6 +446,7 @@ class Categorie extends CommonObject $this->label = trim($this->label); $this->description = trim($this->description); $this->color = trim($this->color); + $this->position = trim($this->position); $this->import_key = trim($this->import_key); $this->ref_ext = trim($this->ref_ext); if (empty($this->visible)) { @@ -461,6 +468,7 @@ class Categorie extends CommonObject $sql .= " label,"; $sql .= " description,"; $sql .= " color,"; + $sql .= " position,"; if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) { $sql .= "fk_soc,"; } @@ -476,6 +484,7 @@ class Categorie extends CommonObject $sql .= "'".$this->db->escape($this->label)."', "; $sql .= "'".$this->db->escape($this->description)."', "; $sql .= "'".$this->db->escape($this->color)."', "; + $sql .= (int) $this->position.","; if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) { $sql .= ($this->socid > 0 ? $this->socid : 'null').", "; } @@ -566,6 +575,7 @@ class Categorie extends CommonObject $sql .= " description = '".$this->db->escape($this->description)."',"; $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; + $sql .= ", position = ".(int) $this->position; if (getDolGlobalString('CATEGORY_ASSIGNED_TO_A_CUSTOMER')) { $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : 'null'); } @@ -1028,6 +1038,7 @@ class Categorie extends CommonObject $categories[$i]['label'] = $category_static->label; $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; + $categories[$i]['position'] = $category_static->position; $categories[$i]['socid'] = $category_static->socid; $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; @@ -1163,7 +1174,7 @@ class Categorie extends CommonObject $current_lang = $langs->getDefaultLang(); // Init $this->cats array - $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates + $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.position, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= ", t.label as label_trans, t.description as description_trans"; } @@ -1185,6 +1196,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label; $this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description; $this->cats[$obj->rowid]['color'] = $obj->color; + $this->cats[$obj->rowid]['position'] = $obj->position; $this->cats[$obj->rowid]['visible'] = $obj->visible; $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; $this->cats[$obj->rowid]['picto'] = 'category'; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 43510b10241..fd82b212feb 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -45,6 +45,7 @@ $socid = (int) GETPOST('socid', 'int'); $label = (string) GETPOST('label', 'alphanohtml'); $description = (string) GETPOST('description', 'restricthtml'); $color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml')); +$position = (int) GETPOST('position', 'int'); $visible = (int) GETPOST('visible', 'int'); $parent = (int) GETPOST('parent', 'int'); @@ -80,7 +81,7 @@ $error = 0; /* * Actions */ -$parameters = array('id' => $id, 'ref' => $ref, 'cancel'=> $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'visible' => $visible, 'parent' => $parent); +$parameters = array('id' => $id, 'ref' => $ref, 'cancel'=> $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'position' => $position, 'visible' => $visible, 'parent' => $parent); // Note that $action and $object may be modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { @@ -105,6 +106,7 @@ if (empty($reshook)) { $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; + $object->position = $position; $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; $object->fk_parent = $parent != -1 ? $parent : 0; @@ -186,6 +188,12 @@ print ''; print $formother->selectColor($object->color, 'color'); print ''; +// Position +print ''; +print $langs->trans("Position").''; +print ''; +print ''; + // Parent category print ''.$langs->trans("In").''; print img_picto('', 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5d1d44738fe..19459aa6806 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -301,6 +301,12 @@ print $langs->trans("Color").''; print $formother->showColor($object->color); print ''; +// Position +print ''; +print $langs->trans("Position").''; +print $object->position; +print ''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9b9c7d0dc15..30cc87f0df4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3685,15 +3685,13 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @return int Return integer <0 if ko, >0 if ok */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $this->nb = array(); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5a0081baf88..e0b71e06fa5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4062,15 +4062,13 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $user; $this->nb = array(); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7609c4018df..a9cf49be3dc 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1346,16 +1346,14 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the indicators this->nb for the state board * * @param int $filteraccountid To get info for a particular account id * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board($filteraccountid = 0) + public function loadStateBoard($filteraccountid = 0) { - // phpcs:enable global $user; if ($user->socid) { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b477efe653f..e6266ebf387 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -57,8 +57,8 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search // Security check -$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); -$lineid = GETPOST('lineid', 'int'); +$id = (GETPOSTINT('facid') ? GETPOSTINT('facid') : GETPOSTINT('id')); +$lineid = GETPOSTINT('lineid'); $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; @@ -67,13 +67,13 @@ $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") { $objecttype = ''; } -$projectid = GETPOST('projectid', 'int'); +$projectid = GETPOSTINT('projectid'); $year_date_when = GETPOST('year_date_when'); $month_date_when = GETPOST('month_date_when'); $selectedLines = GETPOST('toselect', 'array'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -181,16 +181,16 @@ if (empty($reshook)) { $error++; } - $frequency = GETPOST('frequency', 'int'); - $reyear = GETPOST('reyear', 'int'); - $remonth = GETPOST('remonth', 'int'); - $reday = GETPOST('reday', 'int'); - $rehour = GETPOST('rehour', 'int'); - $remin = GETPOST('remin', 'int'); - $nb_gen_max = GETPOST('nb_gen_max', 'int'); + $frequency = GETPOSTINT('frequency'); + $reyear = GETPOSTINT('reyear'); + $remonth = GETPOSTINT('remonth'); + $reday = GETPOSTINT('reday'); + $rehour = GETPOSTINT('rehour'); + $remin = GETPOSTINT('remin'); + $nb_gen_max = GETPOSTINT('nb_gen_max'); //if (empty($nb_gen_max)) $nb_gen_max =0; - if (GETPOST('frequency', 'int')) { + if (GETPOSTINT('frequency')) { if (empty($reyear) || empty($remonth) || empty($reday)) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); $action = "create"; @@ -204,21 +204,21 @@ if (empty($reshook)) { } if (!$error) { - $object->subtype = GETPOST('subtype'); + $object->subtype = GETPOSTINT('subtype'); $object->title = GETPOST('title', 'alphanohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->model_pdf = GETPOST('modelpdf', 'alphanohtml'); $object->usenewprice = GETPOST('usenewprice', 'alphanohtml'); - $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); - $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); + $object->mode_reglement_id = GETPOSTINT('mode_reglement_id'); + $object->cond_reglement_id = GETPOSTINT('cond_reglement_id'); $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; - $object->auto_validate = GETPOST('auto_validate', 'int'); - $object->generate_pdf = GETPOST('generate_pdf', 'int'); + $object->auto_validate = GETPOSTINT('auto_validate'); + $object->generate_pdf = GETPOSTINT('generate_pdf'); $object->fk_project = $projectid; $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); @@ -230,9 +230,9 @@ if (empty($reshook)) { } // Get first contract linked to invoice used to generate template (facid is id of source invoice) - if (GETPOST('facid', 'int') > 0) { + if (GETPOSTINT('facid') > 0) { $srcObject = new Facture($db); - $srcObject->fetch(GETPOST('facid', 'int')); + $srcObject->fetch(GETPOSTINT('facid')); $srcObject->fetchObjectLinked(); @@ -248,7 +248,7 @@ if (empty($reshook)) { $db->begin(); $oldinvoice = new Facture($db); - $oldinvoice->fetch(GETPOST('facid', 'int')); + $oldinvoice->fetch(GETPOSTINT('facid')); $onlylines = GETPOST('toselect', 'array'); @@ -292,15 +292,15 @@ if (empty($reshook)) { if ($action == 'setconditions' && $user->hasRight('facture', 'creer')) { // Set condition $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentTerm")); - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_id')); } elseif ($action == 'setmode' && $user->hasRight('facture', 'creer')) { // Set mode $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("PaymentMode")); - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id')); } elseif ($action == 'classin' && $user->hasRight('facture', 'creer')) { // Set project $object->context['actionmsg'] = $langs->trans("FieldXModified", $langs->transnoentitiesnoconv("Project")); - $object->setProject(GETPOST('projectid', 'int')); + $object->setProject(GETPOSTINT('projectid')); } elseif ($action == 'setref' && $user->hasRight('facture', 'creer')) { // Set bank account $object->context['actionmsg'] = $langs->trans("FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv("Title"), $object->title, $ref); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e9b6e54ee67..7b6ea28961a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5152,15 +5152,13 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int Return integer <0 if KO, >0 if OK */ - public function load_state_board() + public function loadStateBoard() { - // phpcs:enable global $conf, $user; $this->nb = array(); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 5595b2b935a..a48c399bb8d 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -524,16 +524,14 @@ class RemiseCheque extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators this->nb for the state board * * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) * @return int Return integer <0 if ko, >0 if ok */ - public function load_state_board($type = 'CHQ') + public function loadStateBoard($type = 'CHQ') { - // phpcs:enable global $user; if ($user->socid) { diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index bfeebc0abbb..62b86621a6a 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -215,12 +215,12 @@ if (isModEnabled('accounting')) { $calcmode .= ''; $calcmode .= '
'; } -$calcmode .= '