From 05e09ccc17bd713d5ae2af13c31f79d8c7b00d22 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 16 Jul 2021 17:46:21 +0200 Subject: [PATCH 001/159] Filter reassortlot with warehouse tags --- htdocs/product/reassortlot.php | 53 ++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index ea9901a3794..bc93503a3c7 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2019 Juanjo Menent + * Copyright (C) 2021 Noé Cendrier * * 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 @@ -72,6 +73,7 @@ $offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); +$search_warehouse_categ = GETPOST("search_warehouse_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); @@ -101,6 +103,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $tobuy = ""; $search_sale = ""; $search_categ = ""; + $search_warehouse_categ = ""; $type = ""; $catid = ''; $toolowstock = ''; @@ -132,16 +135,17 @@ $sql .= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_product'; // Detail for each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_warehouse as cw on e.rowid = cw.fk_warehouse'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ if ($search_categ) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { - $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -} +// if ($search_categ) { +// $sql .= " AND "; // Join for the needed table to filter by categ +// } if ($sall) { $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); } @@ -178,9 +182,13 @@ if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_categ); } +if ($search_warehouse_categ > 0) { + // $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_warehouse_categ); + $sql .= " AND cw.fk_categorie = " . (int) $search_warehouse_categ; +} if ($search_warehouse) { $sql .= natural_search("e.ref", $search_warehouse); } @@ -280,6 +288,9 @@ if ($resql) { if ($search_categ) { $param .= "&search_categ=".urlencode($search_categ); } + if ($search_warehouse_categ) { + $param .= "&search_warehouse_categ=".urlencode($search_warehouse_categ); + } /*if ($eatby) $param.="&eatby=".$eatby; if ($sellby) $param.="&sellby=".$sellby;*/ @@ -303,28 +314,32 @@ if ($resql) { print "
"; } - // Filter on categories + // Filter on product categories $moreforfilter = ''; if (!empty($conf->categorie->enabled)) { - $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter .= '
'; + $moreforfilter .= ''; + $moreforfilter .= ''.img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ').''; + + // Filter on warehouse categories + $moreforfilter .= ''.img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_WAREHOUSE, $search_warehouse_categ, 'search_warehouse_categ').''; + $moreforfilter .= ''; } //$moreforfilter.=$langs->trans("StockTooLow").' '; - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - print '
'; print ''; + if (!empty($moreforfilter)) { + // print '
'; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // print '
'; + } + // Fields title search print ''; From d8551da83f77eab4998f9b732d937dcdb953c427 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Mon, 19 Jul 2021 09:36:58 +0200 Subject: [PATCH 002/159] correction after review --- htdocs/product/reassortlot.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index bc93503a3c7..751c47fd2d2 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -135,17 +135,16 @@ $sql .= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_product'; // Detail for each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_warehouse as cw on e.rowid = cw.fk_warehouse'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) { +if ($search_categ > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } +if ($search_warehouse_categ > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_warehouse as cw on e.rowid = cw.fk_warehouse'; +} $sql .= " WHERE p.entity IN (".getEntity('product').")"; -// if ($search_categ) { -// $sql .= " AND "; // Join for the needed table to filter by categ -// } if ($sall) { $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); } @@ -186,7 +185,6 @@ if ($search_categ > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_categ); } if ($search_warehouse_categ > 0) { - // $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_warehouse_categ); $sql .= " AND cw.fk_categorie = " . (int) $search_warehouse_categ; } if ($search_warehouse) { @@ -285,10 +283,10 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } - if ($search_warehouse_categ) { + if ($search_warehouse_categ > 0) { $param .= "&search_warehouse_categ=".urlencode($search_warehouse_categ); } /*if ($eatby) $param.="&eatby=".$eatby; @@ -332,12 +330,10 @@ if ($resql) { print '
'; print '
'; if (!empty($moreforfilter)) { - // print '
'; print $moreforfilter; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // print '
'; } From fdbef33d9c24e3127a694d6f43c84b1013a44c15 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Mon, 19 Jul 2021 11:22:41 +0200 Subject: [PATCH 003/159] indet linter --- htdocs/product/reassortlot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 751c47fd2d2..7558597057f 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -319,7 +319,7 @@ if ($resql) { $moreforfilter .= ''; - // Filter on warehouse categories + // Filter on warehouse categories $moreforfilter .= ''; $moreforfilter .= ''; From ad878cb12e57eec9daf29d273361d352e070fc4e Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Thu, 3 Nov 2022 18:43:26 +0300 Subject: [PATCH 004/159] Add OpenID Connect impl --- .../core/login/functions_openid_connect.php | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 htdocs/core/login/functions_openid_connect.php diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php new file mode 100644 index 00000000000..32f7f934117 --- /dev/null +++ b/htdocs/core/login/functions_openid_connect.php @@ -0,0 +1,120 @@ + + * + * 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/core/login/functions_openid_connect.php + * \ingroup core + * \brief OpenID Connect: Authorization Code flow authentication + */ + +include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + +/** + * Check validity of user/password/entity + * If test is ko, reason must be filled into $_SESSION["dol_loginmesg"] + * + * @param string $usertotest Login + * @param string $passwordtotest Password + * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) + * @return string Login if OK, '' if KO + */ +function check_user_password_openid_connect($usertotest, $passwordtotest, $entitytotest) +{ + global $conf; + + dol_syslog("functions_openid_connect::check_user_password_openid_connect"); + + $login = ''; + + // Step 1 is done by user: request an authorization code + + if (GETPOSTISSET('username')) { + + // OIDC does not require credentials here: pass on to next auth handler + $_SESSION["dol_loginmesg"] = "Not an OpenID Connect flow"; + dol_syslog("functions_openid_connect::check_user_password_openid_connect not an OIDC flow"); + + } elseif (GETPOSTISSET['code']) { + $auth_code = GETPOST('code', 'aZ09'); + dol_syslog("functions_openid_connect::check_user_password_openid_connect code=".$auth_code); + + // Step 2: turn the authorization code into an access token, using client_secret + $auth_param = [ + 'grant_type' => 'authorization_code', + 'client_id' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_ID, + 'client_secret' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET, + 'code' => $auth_code, + 'redirect_uri' => $conf->global->MAIN_AUTHENTICATION_OIDC_REDIRECT_URL + ]; + + $token_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_TOKEN_URL, 'POST', http_build_query($auth_param)); + $token_content = json_decode($token_response['content']); + dol_syslog("functions_openid_connect::check_user_password_openid_connect /token=".print_r($token_response, true), LOG_DEBUG); + + if ($token_content->access_token) { + + // Step 3: retrieve user info using token + $userinfo_headers = array('Authorization: Bearer '.$token_content->access_token); + $userinfo_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_USERINFO_URL, 'GET', '', 1, $userinfo_headers); + $userinfo_content = json_decode($userinfo_response['content']); + dol_syslog("functions_openid_connect::check_user_password_openid_connect /userinfo=".print_r($userinfo_response, true), LOG_DEBUG); + + // Get the user attribute (claim) matching the Dolibarr login + $login_claim = 'email'; // default + if (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM)) { + $login_claim = $conf->global->MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM; + } + + if (array_key_exists($login_claim, $userinfo_content)) { + // Success: retrieve claim to return to Dolibarr as login + $login = $userinfo_content->$login_claim; + $_SESSION["dol_loginmesg"] = ""; + } elseif ($userinfo_content->error) { + // Got user info response but content is an error + $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (".$userinfo_content->error_description.")"; + } elseif ($userinfo_response['http_code'] == 200) { + // Claim does not exist + $_SESSION["dol_loginmesg"] = "OpenID Connect claim not found: ".$login_claim; + } elseif ($userinfo_response['curl_error_no']) { + // User info request error + $_SESSION["dol_loginmesg"] = "Network error: ".$userinfo_response['curl_error_msg']." (".$userinfo_response['curl_error_no'].")"; + } else { + // Other user info request error + $_SESSION["dol_loginmesg"] = "Userinfo request error (".$userinfo_response['http_code'].")"; + } + + } elseif ($token_content->error) { + // Got token response but content is an error + $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (".$token_content->error_description.")"; + } elseif ($token_response['curl_error_no']) { + // Token request error + $_SESSION["dol_loginmesg"] = "Network error: ".$token_response['curl_error_msg']." (".$token_response['curl_error_no'].")"; + } else { + // Other token request error + $_SESSION["dol_loginmesg"] = "Token request error (".$token_response['http_code'].")"; + } + + } else { + // No code received + $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (no code received)"; + } + + dol_syslog("functions_openid_connect::check_user_password_openid_connect END"); + + return !empty($login) ? $login : false; +} + From 8ba94e7294f55625a728e156be500b24165f89c5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Nov 2022 15:45:53 +0000 Subject: [PATCH 005/159] Fixing style errors. --- htdocs/core/login/functions_openid_connect.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 32f7f934117..5be96b213ea 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -43,11 +43,9 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit // Step 1 is done by user: request an authorization code if (GETPOSTISSET('username')) { - // OIDC does not require credentials here: pass on to next auth handler $_SESSION["dol_loginmesg"] = "Not an OpenID Connect flow"; dol_syslog("functions_openid_connect::check_user_password_openid_connect not an OIDC flow"); - } elseif (GETPOSTISSET['code']) { $auth_code = GETPOST('code', 'aZ09'); dol_syslog("functions_openid_connect::check_user_password_openid_connect code=".$auth_code); @@ -58,7 +56,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit 'client_id' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_ID, 'client_secret' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET, 'code' => $auth_code, - 'redirect_uri' => $conf->global->MAIN_AUTHENTICATION_OIDC_REDIRECT_URL + 'redirect_uri' => $conf->global->MAIN_AUTHENTICATION_OIDC_REDIRECT_URL ]; $token_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_TOKEN_URL, 'POST', http_build_query($auth_param)); @@ -66,7 +64,6 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit dol_syslog("functions_openid_connect::check_user_password_openid_connect /token=".print_r($token_response, true), LOG_DEBUG); if ($token_content->access_token) { - // Step 3: retrieve user info using token $userinfo_headers = array('Authorization: Bearer '.$token_content->access_token); $userinfo_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_USERINFO_URL, 'GET', '', 1, $userinfo_headers); @@ -96,7 +93,6 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit // Other user info request error $_SESSION["dol_loginmesg"] = "Userinfo request error (".$userinfo_response['http_code'].")"; } - } elseif ($token_content->error) { // Got token response but content is an error $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (".$token_content->error_description.")"; @@ -107,14 +103,12 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit // Other token request error $_SESSION["dol_loginmesg"] = "Token request error (".$token_response['http_code'].")"; } - - } else { + } else { // No code received $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (no code received)"; - } + } dol_syslog("functions_openid_connect::check_user_password_openid_connect END"); return !empty($login) ? $login : false; } - From f1c14316937459ac26077a69b5effde90070bbbf Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Thu, 17 Nov 2022 17:09:13 +0100 Subject: [PATCH 006/159] FIX: Set extrafield value of multiselect type --- htdocs/core/class/commonobject.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 27b00377411..95bf1085637 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5988,6 +5988,12 @@ abstract class CommonObject dol_syslog('Error bad setup of extrafield', LOG_WARNING); } break; + case 'checkbox': + case 'chkbxlst': + if (is_array($this->array_options[$key])) { + $new_array_options[$key] = implode(',', $this->array_options[$key]); + } + break; } } @@ -6333,6 +6339,12 @@ abstract class CommonObject } break; */ + case 'checkbox': + case 'chkbxlst': + if (is_array($this->array_options[$key])) { + $new_array_options[$key] = implode(',', $this->array_options[$key]); + } + break; } $this->db->begin(); From 1c659c6ae8c02c51b83bddab176f36be966a6221 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 11 Jan 2023 15:38:13 +0100 Subject: [PATCH 007/159] feature(#21426) Added in the export module the possibility to choose between utf-8 and iso format --- ....modules.php => export_csviso.modules.php} | 20 +- .../modules/export/export_csvutf8.modules.php | 379 ++++++++++++++++++ 2 files changed, 386 insertions(+), 13 deletions(-) rename htdocs/core/modules/export/{export_csv.modules.php => export_csviso.modules.php} (94%) create mode 100644 htdocs/core/modules/export/export_csvutf8.modules.php diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csviso.modules.php similarity index 94% rename from htdocs/core/modules/export/export_csv.modules.php rename to htdocs/core/modules/export/export_csviso.modules.php index 26f20378b23..00759d3de55 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -74,9 +74,8 @@ class ExportCsv extends ModeleExports } $this->escape = '"'; $this->enclosure = '"'; - - $this->id = 'csv'; // Same value then xxx in file name export_xxx.modules.php - $this->label = 'CSV'; // Label of driver + $this->id = 'csviso'; // Same value then xxx in file name export_xxx.modules.php + $this->label = 'CSV ISO-8859-1'; // Label of driver $this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); $this->extension = 'csv'; // Extension for generated file by this driver $this->picto = 'mime/other'; // Picto @@ -215,11 +214,9 @@ class ExportCsv extends ModeleExports // phpcs:enable global $conf; - if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) { - $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; - } else { - $outputlangs->charset_output = 'ISO-8859-1'; - } + $outputlangs->charset_output = 'ISO-8859-1'; + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; + $selectlabel = array(); foreach ($array_selected_sorted as $code => $value) { @@ -256,11 +253,8 @@ class ExportCsv extends ModeleExports // phpcs:enable global $conf; - if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) { - $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; - } else { - $outputlangs->charset_output = 'ISO-8859-1'; - } + $outputlangs->charset_output = 'ISO-8859-1'; + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; $this->col = 0; diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php new file mode 100644 index 00000000000..75958fb7b35 --- /dev/null +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -0,0 +1,379 @@ + + * + * 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/core/modules/export/export_csv.modules.php + * \ingroup export + * \brief File of class to build exports with CSV format + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; + +// avoid timeout for big export +set_time_limit(0); + +/** + * Class to build export files with format CSV + */ +class ExportCsvUtf8 extends ModeleExports +{ + /** + * @var string ID ex: csv, tsv, excel... + */ + public $id; + + /** + * @var string export files label + */ + public $label; + + public $extension; + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + public $label_lib; + + public $version_lib; + + public $separator; + + public $handle; // Handle fichier + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs; + $this->db = $db; + + $this->separator = ','; + if (!empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) { + $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE; + } + $this->escape = '"'; + $this->enclosure = '"'; + + $this->id = 'csvutf8'; // Same value then xxx in file name export_xxx.modules.php + $this->label = 'CSV UTF-8'; // Label of driver + $this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); + $this->extension = 'csv'; // Extension for generated file by this driver + $this->picto = 'mime/other'; // Picto + $this->version = '1.32'; // Driver version + + // If driver use an external library, put its name here + $this->label_lib = 'Dolibarr'; + $this->version_lib = DOL_VERSION; + } + + /** + * getDriverId + * + * @return string + */ + public function getDriverId() + { + return $this->id; + } + + /** + * getDriverLabel + * + * @return string Return driver label + */ + public function getDriverLabel() + { + return $this->label; + } + + /** + * getDriverDesc + * + * @return string + */ + public function getDriverDesc() + { + return $this->desc; + } + + /** + * getDriverExtension + * + * @return string + */ + public function getDriverExtension() + { + return $this->extension; + } + + /** + * getDriverVersion + * + * @return string + */ + public function getDriverVersion() + { + return $this->version; + } + + /** + * getLabelLabel + * + * @return string + */ + public function getLibLabel() + { + return $this->label_lib; + } + + /** + * getLibVersion + * + * @return string + */ + public function getLibVersion() + { + return $this->version_lib; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Open output file + * + * @param string $file Path of filename to generate + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >=0 if OK + */ + public function open_file($file, $outputlangs) + { + // phpcs:enable + global $langs; + + dol_syslog("ExportCsv::open_file file=".$file); + + $ret = 1; + + $outputlangs->load("exports"); + $this->handle = fopen($file, "wt"); + if (!$this->handle) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorFailToCreateFile", $file); + $ret = -1; + } + + return $ret; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output header into file + * + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >0 if OK + */ + public function write_header($outputlangs) + { + // phpcs:enable + return 0; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output title line into file + * + * @param array $array_export_fields_label Array with list of label of fields + * @param array $array_selected_sorted Array with list of field to export + * @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 + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + { + // phpcs:enable + global $conf; + + $outputlangs->charset_output = 'UTF-8'; + // var_dump($outputlangs->charset_output);exit; + // var_dump($conf->global->EXPORT_CSV_FORCE_CHARSET, "here");exit; + $selectlabel = array(); + + foreach ($array_selected_sorted as $code => $value) { + $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded + $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + + fwrite($this->handle, $newvalue.$this->separator); + $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; + + if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { + $selectlabel[$code."_label"] = $newvalue."_label"; + } + } + foreach ($selectlabel as $key => $value) { + fwrite($this->handle, $value.$this->separator); + } + fwrite($this->handle, "\n"); + return 0; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * 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 Translate $outputlangs Object lang to translate values + * @param array $array_types Array with types of fields + * @return int <0 if KO, >0 if OK + */ + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + { + // phpcs:enable + global $conf; + + $outputlangs->charset_output = 'UTF-8'; + // var_dump($conf->global->EXPORT_CSV_FORCE_CHARSET, "here");exit; + $this->col = 0; + + $reg = array(); + $selectlabelvalues = array(); + foreach ($array_selected_sorted as $code => $value) { + if (strpos($code, ' as ') == 0) { + $alias = str_replace(array('.', '-', '(', ')'), '_', $code); + } else { + $alias = substr($code, strpos($code, ' as ') + 4); + } + if (empty($alias)) { + dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.'); + } + + $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded + $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; + + // Translation newvalue + if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) { + $newvalue = $outputlangs->transnoentities($reg[1]); + } + + // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) + $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + + if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { + $array = jsonOrUnserialize($typefield); + if (is_array($array) && !empty($newvalue)) { + $array = $array['options']; + $selectlabelvalues[$code."_label"] = $array[$newvalue]; + } else { + $selectlabelvalues[$code."_label"] = ""; + } + } + + fwrite($this->handle, $newvalue.$this->separator); + $this->col++; + } + foreach ($selectlabelvalues as $key => $value) { + fwrite($this->handle, $value.$this->separator); + $this->col++; + } + + fwrite($this->handle, "\n"); + return 0; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output footer into file + * + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >0 if OK + */ + public function write_footer($outputlangs) + { + // phpcs:enable + return 0; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Close file handle + * + * @return int <0 if KO, >0 if OK + */ + public function close_file() + { + // phpcs:enable + fclose($this->handle); + return 0; + } + + + /** + * Clean a cell to respect rules of CSV file cells + * Note: It uses $this->separator + * Note: We keep this function public to be able to test + * + * @param string $newvalue String to clean + * @param string $charset Input AND Output character set + * @return string Value cleaned + */ + public function csvClean($newvalue, $charset) + { + global $conf; + $addquote = 0; + + // Rule Dolibarr: No HTML + //print $charset.' '.$newvalue."\n"; + //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); + $newvalue = dol_htmlcleanlastbr($newvalue); + //print $charset.' '.$newvalue."\n"; + + // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) + $oldvalue = $newvalue; + $newvalue = str_replace("\r", '', $newvalue); + $newvalue = str_replace("\n", '\n', $newvalue); + if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue) { + // If we must use enclusure on text with CR/LF) + if ($conf->global->USE_STRICT_CSV_RULES == 1) { + // If we use strict CSV rules (original value must remain but we add quote) + $newvalue = $oldvalue; + } + $addquote = 1; + } + + // Rule 2 CSV: If value contains ", we must escape with ", and add " + if (preg_match('/"/', $newvalue)) { + $addquote = 1; + $newvalue = str_replace('"', '""', $newvalue); + } + + // Rule 3 CSV: If value contains separator, we must add " + if (preg_match('/'.$this->separator.'/', $newvalue)) { + $addquote = 1; + } + + return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); + } +} From c5d3474e10b87d7cccf8546c12a06da49a5a8054 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 17 Jan 2023 18:25:49 +0100 Subject: [PATCH 008/159] Create class module export csv for extend csv utf-8 and iso --- .../modules/export/export_csviso.modules.php | 328 +---------------- .../modules/export/export_csvutf8.modules.php | 328 +---------------- .../core/modules/export/module_export_csv.php | 348 ++++++++++++++++++ 3 files changed, 362 insertions(+), 642 deletions(-) create mode 100644 htdocs/core/modules/export/module_export_csv.php diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index 00759d3de55..b477868c09c 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -21,43 +21,17 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/module_export_csv.php'; // avoid timeout for big export set_time_limit(0); /** - * Class to build export files with format CSV + * Class to build export files with format CSV iso */ -class ExportCsv extends ModeleExports +class ExportCsvIso extends ExportCsv { - /** - * @var string ID ex: csv, tsv, excel... - */ - public $id; - - /** - * @var string export files label - */ - public $label; - - public $extension; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - public $label_lib; - - public $version_lib; - - public $separator; - - public $handle; // Handle fichier - - + /** * Constructor * @@ -72,6 +46,9 @@ class ExportCsv extends ModeleExports if (!empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) { $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE; } + + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; + $this->escape = '"'; $this->enclosure = '"'; $this->id = 'csviso'; // Same value then xxx in file name export_xxx.modules.php @@ -85,295 +62,4 @@ class ExportCsv extends ModeleExports $this->label_lib = 'Dolibarr'; $this->version_lib = DOL_VERSION; } - - /** - * getDriverId - * - * @return string - */ - public function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Return driver label - */ - public function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string - */ - public function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string - */ - public function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string - */ - public function getDriverVersion() - { - return $this->version; - } - - /** - * getLabelLabel - * - * @return string - */ - public function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string - */ - public function getLibVersion() - { - return $this->version_lib; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Open output file - * - * @param string $file Path of filename to generate - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >=0 if OK - */ - public function open_file($file, $outputlangs) - { - // phpcs:enable - global $langs; - - dol_syslog("ExportCsv::open_file file=".$file); - - $ret = 1; - - $outputlangs->load("exports"); - $this->handle = fopen($file, "wt"); - if (!$this->handle) { - $langs->load("errors"); - $this->error = $langs->trans("ErrorFailToCreateFile", $file); - $ret = -1; - } - - return $ret; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output header into file - * - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >0 if OK - */ - public function write_header($outputlangs) - { - // phpcs:enable - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output title line into file - * - * @param array $array_export_fields_label Array with list of label of fields - * @param array $array_selected_sorted Array with list of field to export - * @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 - */ - public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - $outputlangs->charset_output = 'ISO-8859-1'; - $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; - - $selectlabel = array(); - - foreach ($array_selected_sorted as $code => $value) { - $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); - - fwrite($this->handle, $newvalue.$this->separator); - $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; - - if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { - $selectlabel[$code."_label"] = $newvalue."_label"; - } - } - foreach ($selectlabel as $key => $value) { - fwrite($this->handle, $value.$this->separator); - } - fwrite($this->handle, "\n"); - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * 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 Translate $outputlangs Object lang to translate values - * @param array $array_types Array with types of fields - * @return int <0 if KO, >0 if OK - */ - public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - $outputlangs->charset_output = 'ISO-8859-1'; - $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; - - $this->col = 0; - - $reg = array(); - $selectlabelvalues = array(); - foreach ($array_selected_sorted as $code => $value) { - if (strpos($code, ' as ') == 0) { - $alias = str_replace(array('.', '-', '(', ')'), '_', $code); - } else { - $alias = substr($code, strpos($code, ' as ') + 4); - } - if (empty($alias)) { - dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.'); - } - - $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded - $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; - - // Translation newvalue - if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) { - $newvalue = $outputlangs->transnoentities($reg[1]); - } - - // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); - - if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { - $array = jsonOrUnserialize($typefield); - if (is_array($array) && !empty($newvalue)) { - $array = $array['options']; - $selectlabelvalues[$code."_label"] = $array[$newvalue]; - } else { - $selectlabelvalues[$code."_label"] = ""; - } - } - - fwrite($this->handle, $newvalue.$this->separator); - $this->col++; - } - foreach ($selectlabelvalues as $key => $value) { - fwrite($this->handle, $value.$this->separator); - $this->col++; - } - - fwrite($this->handle, "\n"); - return 0; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output footer into file - * - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >0 if OK - */ - public function write_footer($outputlangs) - { - // phpcs:enable - return 0; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Close file handle - * - * @return int <0 if KO, >0 if OK - */ - public function close_file() - { - // phpcs:enable - fclose($this->handle); - return 0; - } - - - /** - * Clean a cell to respect rules of CSV file cells - * Note: It uses $this->separator - * Note: We keep this function public to be able to test - * - * @param string $newvalue String to clean - * @param string $charset Input AND Output character set - * @return string Value cleaned - */ - public function csvClean($newvalue, $charset) - { - global $conf; - $addquote = 0; - - // Rule Dolibarr: No HTML - //print $charset.' '.$newvalue."\n"; - //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); - $newvalue = dol_htmlcleanlastbr($newvalue); - //print $charset.' '.$newvalue."\n"; - - // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) - $oldvalue = $newvalue; - $newvalue = str_replace("\r", '', $newvalue); - $newvalue = str_replace("\n", '\n', $newvalue); - if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue) { - // If we must use enclusure on text with CR/LF) - if ($conf->global->USE_STRICT_CSV_RULES == 1) { - // If we use strict CSV rules (original value must remain but we add quote) - $newvalue = $oldvalue; - } - $addquote = 1; - } - - // Rule 2 CSV: If value contains ", we must escape with ", and add " - if (preg_match('/"/', $newvalue)) { - $addquote = 1; - $newvalue = str_replace('"', '""', $newvalue); - } - - // Rule 3 CSV: If value contains separator, we must add " - if (preg_match('/'.$this->separator.'/', $newvalue)) { - $addquote = 1; - } - - return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); - } } diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index 75958fb7b35..f8b254cabe9 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -21,43 +21,17 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/module_export_csv.php'; // avoid timeout for big export set_time_limit(0); /** - * Class to build export files with format CSV + * Class to build export files with format CSV utf-8 */ -class ExportCsvUtf8 extends ModeleExports +class ExportCsvUtf8 extends ExportCsv { - /** - * @var string ID ex: csv, tsv, excel... - */ - public $id; - - /** - * @var string export files label - */ - public $label; - - public $extension; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - public $label_lib; - - public $version_lib; - - public $separator; - - public $handle; // Handle fichier - - + /** * Constructor * @@ -72,9 +46,11 @@ class ExportCsvUtf8 extends ModeleExports if (!empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) { $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE; } + + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'UTF-8'; + $this->escape = '"'; $this->enclosure = '"'; - $this->id = 'csvutf8'; // Same value then xxx in file name export_xxx.modules.php $this->label = 'CSV UTF-8'; // Label of driver $this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); @@ -86,294 +62,4 @@ class ExportCsvUtf8 extends ModeleExports $this->label_lib = 'Dolibarr'; $this->version_lib = DOL_VERSION; } - - /** - * getDriverId - * - * @return string - */ - public function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Return driver label - */ - public function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string - */ - public function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string - */ - public function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string - */ - public function getDriverVersion() - { - return $this->version; - } - - /** - * getLabelLabel - * - * @return string - */ - public function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string - */ - public function getLibVersion() - { - return $this->version_lib; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Open output file - * - * @param string $file Path of filename to generate - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >=0 if OK - */ - public function open_file($file, $outputlangs) - { - // phpcs:enable - global $langs; - - dol_syslog("ExportCsv::open_file file=".$file); - - $ret = 1; - - $outputlangs->load("exports"); - $this->handle = fopen($file, "wt"); - if (!$this->handle) { - $langs->load("errors"); - $this->error = $langs->trans("ErrorFailToCreateFile", $file); - $ret = -1; - } - - return $ret; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output header into file - * - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >0 if OK - */ - public function write_header($outputlangs) - { - // phpcs:enable - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output title line into file - * - * @param array $array_export_fields_label Array with list of label of fields - * @param array $array_selected_sorted Array with list of field to export - * @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 - */ - public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - $outputlangs->charset_output = 'UTF-8'; - // var_dump($outputlangs->charset_output);exit; - // var_dump($conf->global->EXPORT_CSV_FORCE_CHARSET, "here");exit; - $selectlabel = array(); - - foreach ($array_selected_sorted as $code => $value) { - $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); - - fwrite($this->handle, $newvalue.$this->separator); - $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; - - if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { - $selectlabel[$code."_label"] = $newvalue."_label"; - } - } - foreach ($selectlabel as $key => $value) { - fwrite($this->handle, $value.$this->separator); - } - fwrite($this->handle, "\n"); - return 0; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * 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 Translate $outputlangs Object lang to translate values - * @param array $array_types Array with types of fields - * @return int <0 if KO, >0 if OK - */ - public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) - { - // phpcs:enable - global $conf; - - $outputlangs->charset_output = 'UTF-8'; - // var_dump($conf->global->EXPORT_CSV_FORCE_CHARSET, "here");exit; - $this->col = 0; - - $reg = array(); - $selectlabelvalues = array(); - foreach ($array_selected_sorted as $code => $value) { - if (strpos($code, ' as ') == 0) { - $alias = str_replace(array('.', '-', '(', ')'), '_', $code); - } else { - $alias = substr($code, strpos($code, ' as ') + 4); - } - if (empty($alias)) { - dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.'); - } - - $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded - $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; - - // Translation newvalue - if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) { - $newvalue = $outputlangs->transnoentities($reg[1]); - } - - // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) - $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); - - if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { - $array = jsonOrUnserialize($typefield); - if (is_array($array) && !empty($newvalue)) { - $array = $array['options']; - $selectlabelvalues[$code."_label"] = $array[$newvalue]; - } else { - $selectlabelvalues[$code."_label"] = ""; - } - } - - fwrite($this->handle, $newvalue.$this->separator); - $this->col++; - } - foreach ($selectlabelvalues as $key => $value) { - fwrite($this->handle, $value.$this->separator); - $this->col++; - } - - fwrite($this->handle, "\n"); - return 0; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output footer into file - * - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >0 if OK - */ - public function write_footer($outputlangs) - { - // phpcs:enable - return 0; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Close file handle - * - * @return int <0 if KO, >0 if OK - */ - public function close_file() - { - // phpcs:enable - fclose($this->handle); - return 0; - } - - - /** - * Clean a cell to respect rules of CSV file cells - * Note: It uses $this->separator - * Note: We keep this function public to be able to test - * - * @param string $newvalue String to clean - * @param string $charset Input AND Output character set - * @return string Value cleaned - */ - public function csvClean($newvalue, $charset) - { - global $conf; - $addquote = 0; - - // Rule Dolibarr: No HTML - //print $charset.' '.$newvalue."\n"; - //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); - $newvalue = dol_htmlcleanlastbr($newvalue); - //print $charset.' '.$newvalue."\n"; - - // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) - $oldvalue = $newvalue; - $newvalue = str_replace("\r", '', $newvalue); - $newvalue = str_replace("\n", '\n', $newvalue); - if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue) { - // If we must use enclusure on text with CR/LF) - if ($conf->global->USE_STRICT_CSV_RULES == 1) { - // If we use strict CSV rules (original value must remain but we add quote) - $newvalue = $oldvalue; - } - $addquote = 1; - } - - // Rule 2 CSV: If value contains ", we must escape with ", and add " - if (preg_match('/"/', $newvalue)) { - $addquote = 1; - $newvalue = str_replace('"', '""', $newvalue); - } - - // Rule 3 CSV: If value contains separator, we must add " - if (preg_match('/'.$this->separator.'/', $newvalue)) { - $addquote = 1; - } - - return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); - } } diff --git a/htdocs/core/modules/export/module_export_csv.php b/htdocs/core/modules/export/module_export_csv.php new file mode 100644 index 00000000000..442c7cb628f --- /dev/null +++ b/htdocs/core/modules/export/module_export_csv.php @@ -0,0 +1,348 @@ + + * + * 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/core/modules/export/export_csv.modules.php + * \ingroup export + * \brief File of class to build exports with CSV format + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; + +// avoid timeout for big export +set_time_limit(0); + +/** + * Class to build export files with format CSV + */ +class ExportCsv extends ModeleExports +{ + /** + * @var string ID ex: csv, tsv, excel... + */ + public $id; + + /** + * @var string export files label + */ + public $label; + + public $extension; + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + public $label_lib; + + public $version_lib; + + public $separator; + + public $handle; // Handle fichier + + /** + * getDriverId + * + * @return string + */ + public function getDriverId() + { + return $this->id; + } + + /** + * getDriverLabel + * + * @return string Return driver label + */ + public function getDriverLabel() + { + return $this->label; + } + + /** + * getDriverDesc + * + * @return string + */ + public function getDriverDesc() + { + return $this->desc; + } + + /** + * getDriverExtension + * + * @return string + */ + public function getDriverExtension() + { + return $this->extension; + } + + /** + * getDriverVersion + * + * @return string + */ + public function getDriverVersion() + { + return $this->version; + } + + /** + * getLabelLabel + * + * @return string + */ + public function getLibLabel() + { + return $this->label_lib; + } + + /** + * getLibVersion + * + * @return string + */ + public function getLibVersion() + { + return $this->version_lib; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Open output file + * + * @param string $file Path of filename to generate + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >=0 if OK + */ + public function open_file($file, $outputlangs) + { + // phpcs:enable + global $langs; + + dol_syslog("ExportCsv::open_file file=".$file); + + $ret = 1; + + $outputlangs->load("exports"); + $this->handle = fopen($file, "wt"); + if (!$this->handle) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorFailToCreateFile", $file); + $ret = -1; + } + + return $ret; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output header into file + * + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >0 if OK + */ + public function write_header($outputlangs) + { + // phpcs:enable + return 0; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output title line into file + * + * @param array $array_export_fields_label Array with list of label of fields + * @param array $array_selected_sorted Array with list of field to export + * @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 + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + { + // phpcs:enable + global $conf; + + $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; + + $selectlabel = array(); + + foreach ($array_selected_sorted as $code => $value) { + $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded + $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + + fwrite($this->handle, $newvalue.$this->separator); + $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; + + if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { + $selectlabel[$code."_label"] = $newvalue."_label"; + } + } + foreach ($selectlabel as $key => $value) { + fwrite($this->handle, $value.$this->separator); + } + fwrite($this->handle, "\n"); + return 0; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * 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 Translate $outputlangs Object lang to translate values + * @param array $array_types Array with types of fields + * @return int <0 if KO, >0 if OK + */ + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + { + // phpcs:enable + global $conf; + + $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; + + $this->col = 0; + + $reg = array(); + $selectlabelvalues = array(); + foreach ($array_selected_sorted as $code => $value) { + if (strpos($code, ' as ') == 0) { + $alias = str_replace(array('.', '-', '(', ')'), '_', $code); + } else { + $alias = substr($code, strpos($code, ' as ') + 4); + } + if (empty($alias)) { + dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.'); + } + + $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded + $typefield = isset($array_types[$code]) ? $array_types[$code] : ''; + + // Translation newvalue + if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) { + $newvalue = $outputlangs->transnoentities($reg[1]); + } + + // Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES) + $newvalue = $this->csvClean($newvalue, $outputlangs->charset_output); + + if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) { + $array = jsonOrUnserialize($typefield); + if (is_array($array) && !empty($newvalue)) { + $array = $array['options']; + $selectlabelvalues[$code."_label"] = $array[$newvalue]; + } else { + $selectlabelvalues[$code."_label"] = ""; + } + } + + fwrite($this->handle, $newvalue.$this->separator); + $this->col++; + } + foreach ($selectlabelvalues as $key => $value) { + fwrite($this->handle, $value.$this->separator); + $this->col++; + } + + fwrite($this->handle, "\n"); + return 0; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output footer into file + * + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >0 if OK + */ + public function write_footer($outputlangs) + { + // phpcs:enable + return 0; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Close file handle + * + * @return int <0 if KO, >0 if OK + */ + public function close_file() + { + // phpcs:enable + fclose($this->handle); + return 0; + } + + + /** + * Clean a cell to respect rules of CSV file cells + * Note: It uses $this->separator + * Note: We keep this function public to be able to test + * + * @param string $newvalue String to clean + * @param string $charset Input AND Output character set + * @return string Value cleaned + */ + public function csvClean($newvalue, $charset) + { + global $conf; + $addquote = 0; + + // Rule Dolibarr: No HTML + //print $charset.' '.$newvalue."\n"; + //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); + $newvalue = dol_htmlcleanlastbr($newvalue); + //print $charset.' '.$newvalue."\n"; + + // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes) + $oldvalue = $newvalue; + $newvalue = str_replace("\r", '', $newvalue); + $newvalue = str_replace("\n", '\n', $newvalue); + if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue) { + // If we must use enclusure on text with CR/LF) + if ($conf->global->USE_STRICT_CSV_RULES == 1) { + // If we use strict CSV rules (original value must remain but we add quote) + $newvalue = $oldvalue; + } + $addquote = 1; + } + + // Rule 2 CSV: If value contains ", we must escape with ", and add " + if (preg_match('/"/', $newvalue)) { + $addquote = 1; + $newvalue = str_replace('"', '""', $newvalue); + } + + // Rule 3 CSV: If value contains separator, we must add " + if (preg_match('/'.$this->separator.'/', $newvalue)) { + $addquote = 1; + } + + return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : ''); + } +} From 28d0f492f487922e59a042ff36142da37b9d4477 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 17 Jan 2023 18:26:19 +0100 Subject: [PATCH 009/159] Create class module export csv --- htdocs/core/modules/export/export_csviso.modules.php | 2 +- htdocs/core/modules/export/export_csvutf8.modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index b477868c09c..573dbdcadd0 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -31,7 +31,7 @@ set_time_limit(0); */ class ExportCsvIso extends ExportCsv { - + /** * Constructor * diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index f8b254cabe9..13000c00e25 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -31,7 +31,7 @@ set_time_limit(0); */ class ExportCsvUtf8 extends ExportCsv { - + /** * Constructor * From cb9e2a1bdfba1bf7a74d2d181c7799e575d5730f Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:05:56 +0300 Subject: [PATCH 010/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- htdocs/core/login/functions_openid_connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 5be96b213ea..53741347e66 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -46,7 +46,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit // OIDC does not require credentials here: pass on to next auth handler $_SESSION["dol_loginmesg"] = "Not an OpenID Connect flow"; dol_syslog("functions_openid_connect::check_user_password_openid_connect not an OIDC flow"); - } elseif (GETPOSTISSET['code']) { + } elseif (GETPOSTISSET('code')) { $auth_code = GETPOST('code', 'aZ09'); dol_syslog("functions_openid_connect::check_user_password_openid_connect code=".$auth_code); From 1d962a40ecbecf9824670b1a11ace23f52db13a0 Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:06:09 +0300 Subject: [PATCH 011/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- htdocs/core/login/functions_openid_connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 53741347e66..93fea1bb566 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -56,7 +56,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit 'client_id' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_ID, 'client_secret' => $conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET, 'code' => $auth_code, - 'redirect_uri' => $conf->global->MAIN_AUTHENTICATION_OIDC_REDIRECT_URL + 'redirect_uri' => $conf->global->MAIN_AUTHENTICATION_OIDC_REDIRECT_URL ]; $token_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_TOKEN_URL, 'POST', http_build_query($auth_param)); From b1ea162104c9fb7091a5be6fca9d2539b70e2689 Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:06:23 +0300 Subject: [PATCH 012/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- htdocs/core/login/functions_openid_connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 93fea1bb566..7bc459902b1 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -76,7 +76,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $login_claim = $conf->global->MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM; } - if (array_key_exists($login_claim, $userinfo_content)) { + if (property_exists($userinfo_content, $login_claim)) { // Success: retrieve claim to return to Dolibarr as login $login = $userinfo_content->$login_claim; $_SESSION["dol_loginmesg"] = ""; From 37bd06d9bcc9b69f579658f92fb9c3f81f6ff4fa Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:06:36 +0300 Subject: [PATCH 013/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- htdocs/core/login/functions_openid_connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 7bc459902b1..db6281f14d1 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -63,7 +63,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $token_content = json_decode($token_response['content']); dol_syslog("functions_openid_connect::check_user_password_openid_connect /token=".print_r($token_response, true), LOG_DEBUG); - if ($token_content->access_token) { + if (property_exists($token_content, 'access_token')) { // Step 3: retrieve user info using token $userinfo_headers = array('Authorization: Bearer '.$token_content->access_token); $userinfo_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_USERINFO_URL, 'GET', '', 1, $userinfo_headers); From 881c2f833fb41c2d04a9c77eab0535fb32681cba Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:06:48 +0300 Subject: [PATCH 014/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- htdocs/core/login/functions_openid_connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index db6281f14d1..fbdca8a8706 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -34,7 +34,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; */ function check_user_password_openid_connect($usertotest, $passwordtotest, $entitytotest) { - global $conf; + global $db, $conf, $langs; dol_syslog("functions_openid_connect::check_user_password_openid_connect"); From dc12fdbef447dbb9ecca9fc6dc6c014fb704fa39 Mon Sep 17 00:00:00 2001 From: Jeritiana Ravelojaona Date: Sat, 21 Jan 2023 14:06:58 +0300 Subject: [PATCH 015/159] Update htdocs/core/login/functions_openid_connect.php Co-authored-by: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> --- .../core/login/functions_openid_connect.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index fbdca8a8706..ea72235ec29 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -78,8 +78,33 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit if (property_exists($userinfo_content, $login_claim)) { // Success: retrieve claim to return to Dolibarr as login - $login = $userinfo_content->$login_claim; - $_SESSION["dol_loginmesg"] = ""; + $sql = 'SELECT login, entity, datestartvalidity, dateendvalidity'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; + $sql .= " WHERE login = '".$userinfo_content->$login_claim."'"; + $sql .= ' AND entity IN (0,'.(array_key_exists('dol_entity', $_SESSION) ? ((int) $_SESSION["dol_entity"]) : 1).')'; + + dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $now = dol_now(); + if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) { + // Load translation files required by the page + $langs->loadLangs(array('main', 'errors')); + $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); + return '--bad-login-validity--'; + } + if ($obj->dateendvalidity && $db->jdate($obj->dateendvalidity) < dol_get_first_hour($now)) { + // Load translation files required by the page + $langs->loadLangs(array('main', 'errors')); + $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); + return '--bad-login-validity--'; + } + + $login = $obj->login; + } + } } elseif ($userinfo_content->error) { // Got user info response but content is an error $_SESSION["dol_loginmesg"] = "Error in OAuth 2.0 flow (".$userinfo_content->error_description.")"; From 8e1a753e3f6ab12f221e279edcf89768dad58e33 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 21 Jan 2023 11:07:27 +0000 Subject: [PATCH 016/159] Fixing style errors. --- htdocs/core/login/functions_openid_connect.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index ea72235ec29..dcff99adaad 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -82,7 +82,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; $sql .= " WHERE login = '".$userinfo_content->$login_claim."'"; $sql .= ' AND entity IN (0,'.(array_key_exists('dol_entity', $_SESSION) ? ((int) $_SESSION["dol_entity"]) : 1).')'; - + dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -101,7 +101,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); return '--bad-login-validity--'; } - + $login = $obj->login; } } From c8c998044b3ada2e4d0f4a7c312af34d2324d6c8 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 7 Feb 2023 12:13:34 +0100 Subject: [PATCH 017/159] feature renamed the module_export_csv file and edited the iso and utf files to override the write_title and write_record functions to initialize EXPORT_CSV_FORCE_CHARSET --- ..._export_csv.php => export_csv.modules.php} | 0 .../modules/export/export_csviso.modules.php | 38 +++++++++++++++++- .../modules/export/export_csvutf8.modules.php | 40 +++++++++++++++++-- 3 files changed, 74 insertions(+), 4 deletions(-) rename htdocs/core/modules/export/{module_export_csv.php => export_csv.modules.php} (100%) diff --git a/htdocs/core/modules/export/module_export_csv.php b/htdocs/core/modules/export/export_csv.modules.php similarity index 100% rename from htdocs/core/modules/export/module_export_csv.php rename to htdocs/core/modules/export/export_csv.modules.php diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index 573dbdcadd0..ad40e7ae807 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/module_export_csv.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_csv.modules.php'; // avoid timeout for big export set_time_limit(0); @@ -62,4 +62,40 @@ class ExportCsvIso extends ExportCsv $this->label_lib = 'Dolibarr'; $this->version_lib = DOL_VERSION; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output title line into file + * + * @param array $array_export_fields_label Array with list of label of fields + * @param array $array_selected_sorted Array with list of field to export + * @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 + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + { + global $conf; + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; + + parent::write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * 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 Translate $outputlangs Object lang to translate values + * @param array $array_types Array with types of fields + * @return int <0 if KO, >0 if OK + */ + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + { + global $conf; + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'ISO-8859-1'; + + parent::write_record($array_selected_sorted, $objp, $outputlangs, $array_types); + } } diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index 13000c00e25..bc6a7d70d49 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/module_export_csv.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_csv.modules.php'; // avoid timeout for big export set_time_limit(0); @@ -47,8 +47,6 @@ class ExportCsvUtf8 extends ExportCsv $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE; } - $conf->global->EXPORT_CSV_FORCE_CHARSET = 'UTF-8'; - $this->escape = '"'; $this->enclosure = '"'; $this->id = 'csvutf8'; // Same value then xxx in file name export_xxx.modules.php @@ -62,4 +60,40 @@ class ExportCsvUtf8 extends ExportCsv $this->label_lib = 'Dolibarr'; $this->version_lib = DOL_VERSION; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output title line into file + * + * @param array $array_export_fields_label Array with list of label of fields + * @param array $array_selected_sorted Array with list of field to export + * @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 + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + { + global $conf; + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'UTF-8'; + + parent::write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * 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 Translate $outputlangs Object lang to translate values + * @param array $array_types Array with types of fields + * @return int <0 if KO, >0 if OK + */ + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + { + global $conf; + + $conf->global->EXPORT_CSV_FORCE_CHARSET = 'UTF-8'; + parent::write_record($array_selected_sorted, $objp, $outputlangs, $array_types); + } } From c000eeeecf18c5fdb5890e1f1332270c703c4c5c Mon Sep 17 00:00:00 2001 From: FLIO Date: Thu, 16 Feb 2023 01:00:39 +0100 Subject: [PATCH 018/159] feature (#21426) edit ExportTest for resolve error and add test for utf8 --- test/phpunit/ExportTest.php | 102 ++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index cf2f0520908..0a0a1c867ba 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -149,6 +149,94 @@ class ExportTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } + /** + * Other tests + * + * @return void + */ + public function testExportCsvUtf() + { + global $conf,$user,$langs,$db; + + $model='csvutf8'; + + $conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ','; + print 'EXPORT_CSV_SEPARATOR_TO_USE = '.$conf->global->EXPORT_CSV_SEPARATOR_TO_USE; + + // Creation of class to export using model ExportXXX + $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; + $file = "export_".$model.".modules.php"; + $classname = "Export".$model; + require_once $dir.$file; + $objmodel = new $classname($db); + + // First test without option USE_STRICT_CSV_RULES + unset($conf->global->USE_STRICT_CSV_RULES); + + $valtotest='A simple string'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, 'A simple string'); + + $valtotest='A string with , and ; inside'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file); + + $valtotest='A string with " inside'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with "" inside"'); + + $valtotest='A string with " inside and '."\r\n".' carriage returns'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with "" inside and \n carriage returns"'); + + $valtotest='A string with html
content
inside
'."\n"; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with html
content
inside"'); + + // Same tests with strict mode + $conf->global->USE_STRICT_CSV_RULES = 1; + + $valtotest='A simple string'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, 'A simple string'); + + $valtotest='A string with , and ; inside'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with , and ; inside"'); + + $valtotest='A string with " inside'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with "" inside"'); + + $valtotest='A string with " inside and '."\r\n".' carriage returns'; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\""); + + $valtotest='A string with html
content
inside
'."\n"; + print __METHOD__." valtotest=".$valtotest."\n"; + $result = $objmodel->csvClean($valtotest, $langs->charset_output); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, '"A string with html
content
inside"'); + } + /** * Other tests @@ -159,7 +247,7 @@ class ExportTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - $model='csv'; + $model='csviso'; $conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ','; print 'EXPORT_CSV_SEPARATOR_TO_USE = '.$conf->global->EXPORT_CSV_SEPARATOR_TO_USE; @@ -263,7 +351,15 @@ class ExportTest extends PHPUnit\Framework\TestCase dol_mkdir($conf->export->dir_temp); - $model='csv'; + $model='csviso'; + + // Build export file + print "Process build_file for model = ".$model."\n"; + $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); + $expectedresult = 1; + $this->assertEquals($expectedresult, $result, 'Error in CSV export'); + + $model='csvutf8'; // Build export file print "Process build_file for model = ".$model."\n"; @@ -353,7 +449,7 @@ class ExportTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - $model='csv'; + $model='csviso'; $filterdatatoexport=''; //$filterdatatoexport=''; From cfe6ebfeee54fc313bb6ae58504ec03e377c6385 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 22 Feb 2023 10:29:47 +0100 Subject: [PATCH 019/159] fix (#21426) edit file name of export_csv.modules because it adds an export type when choosing the export type --- htdocs/core/modules/export/export_csviso.modules.php | 2 +- htdocs/core/modules/export/export_csvutf8.modules.php | 2 +- .../export/{export_csv.modules.php => exports_csv.modules.php} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename htdocs/core/modules/export/{export_csv.modules.php => exports_csv.modules.php} (100%) diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index ad40e7ae807..29a9e24e76a 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exports_csv.modules.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index bc6a7d70d49..f517dd00839 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exports_csv.modules.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/exports_csv.modules.php similarity index 100% rename from htdocs/core/modules/export/export_csv.modules.php rename to htdocs/core/modules/export/exports_csv.modules.php From 91f39fb4f412b10b964c7be3c38407bddf3bb8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Mon, 20 Mar 2023 11:36:28 +0100 Subject: [PATCH 020/159] FIX: Correct Evaluation for extrafields --- htdocs/core/class/commonobject.class.php | 6 +++--- htdocs/core/class/extrafields.class.php | 14 +++++++------- htdocs/core/tpl/extrafields_view.tpl.php | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e7d2c61bd4c..9bda1575d37 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8110,7 +8110,7 @@ abstract class CommonObject // Test on 'enabled' ('enabled' is different than 'list' = 'visibility') $enabled = 1; if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { - $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '1'); + $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); } if (empty($enabled)) { continue; @@ -8118,12 +8118,12 @@ abstract class CommonObject $visibility = 1; if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) { - $visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '1'); + $visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); } $perms = 1; if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { - $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); } if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5d91febc65d..a1150fb97fc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -958,9 +958,9 @@ class ExtraFields $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '2'); $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1'); + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '2'); $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) @@ -1591,9 +1591,9 @@ class ExtraFields $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1, 1, '2'); $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '1'); + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1, 1, '2'); $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) @@ -2080,17 +2080,17 @@ class ExtraFields $enabled = 1; if (isset($this->attributes[$object->table_element]['enabled'][$key])) { // 'enabled' is often a condition on module enabled or not - $enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'); + $enabled = dol_eval($this->attributes[$object->table_element]['enabled'][$key], 1, 1, '2'); } $visibility = 1; if (isset($this->attributes[$object->table_element]['list'][$key])) { // 'list' is option for visibility - $visibility = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1')); + $visibility = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '2')); } $perms = 1; if (isset($this->attributes[$object->table_element]['perms'][$key])) { - $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '1'); + $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '2'); } if (empty($enabled) || ( diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 7d99a021f69..c75317471fb 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -72,15 +72,15 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l $enabled = 1; if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra])) { - $enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra], 1); + $enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$tmpkeyextra], 1, 1, '2'); } if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra])) { - $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra], 1); + $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$tmpkeyextra], 1, 1, '2'); } $perms = 1; if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra])) { - $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra], 1); + $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra], 1, 1, '2'); } //print $tmpkeyextra.'-'.$enabled.'-'.$perms.'
'."\n"; From 620cbf398ab1790f489ff2fadfa5d68ff1b9fcdb Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Thu, 30 Mar 2023 11:10:22 +0200 Subject: [PATCH 021/159] Correction --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 95bf1085637..6380730816f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5992,6 +5992,8 @@ abstract class CommonObject case 'chkbxlst': if (is_array($this->array_options[$key])) { $new_array_options[$key] = implode(',', $this->array_options[$key]); + } else { + $new_array_options[$key] = $this->array_options[$key]; } break; } @@ -6343,6 +6345,8 @@ abstract class CommonObject case 'chkbxlst': if (is_array($this->array_options[$key])) { $new_array_options[$key] = implode(',', $this->array_options[$key]); + } else { + $new_array_options[$key] = $this->array_options[$key]; } break; } From 99d121232fb2d21ccb20e01581cc0dad81f7fe49 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 8 Apr 2023 15:08:37 +0200 Subject: [PATCH 022/159] FIX missing mrp module dependency --- htdocs/core/modules/modMrp.class.php | 2 +- htdocs/core/modules/modWorkstation.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 58e7791845a..593a5611de0 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -119,7 +119,7 @@ class modMrp extends DolibarrModules $this->hidden = false; // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) $this->depends = array('modBom'); - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->requiredby = array('modWorkstation'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); $this->phpmin = array(7, 0); // Minimum version of PHP required by module diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index a8be0f23226..6bba7b1807a 100644 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -120,7 +120,7 @@ class modWorkstation extends DolibarrModules // A condition to hide module $this->hidden = false; // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = array(); + $this->depends = array('modMrp'); $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); From fa8b6ecd552bf6bd4e42c2a324169ef1c85e655f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Apr 2023 16:53:18 +0200 Subject: [PATCH 023/159] css --- htdocs/projet/class/project.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 701d43d24e8..582e062f68a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -287,7 +287,7 @@ class Project extends CommonObject 'date_close' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'fk_user_close' =>array('type'=>'integer', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'opp_amount' =>array('type'=>'double(24,8)', 'label'=>'OpportunityAmountShort', 'enabled'=>1, 'visible'=>'getDolGlobalString("PROJECT_USE_OPPORTUNITIES")', 'position'=>115), - 'budget_amount' =>array('type'=>'double(24,8)', 'label'=>'Budget', 'enabled'=>1, 'visible'=>1, 'position'=>119), + 'budget_amount' =>array('type'=>'double(24,8)', 'label'=>'Budget', 'enabled'=>1, 'visible'=>-1, 'position'=>119), 'usage_bill_time' =>array('type'=>'integer', 'label'=>'UsageBillTimeShort', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'usage_opportunity' =>array('type'=>'integer', 'label'=>'UsageOpportunity', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'usage_task' =>array('type'=>'integer', 'label'=>'UsageTasks', 'enabled'=>1, 'visible'=>-1, 'position'=>140), From 6e93503898950038d4bf44223cc123e4bf23d5f2 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sun, 9 Apr 2023 14:18:31 +0200 Subject: [PATCH 024/159] Fix #24355 Update price with discount --- htdocs/contrat/card.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4e52941063d..7839d8ac241 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -744,12 +744,22 @@ if (empty($reshook)) { $fk_unit = GETPOST('unit', 'alpha'); + // update price_ht with discount + // TODO Use object->updateline instead objedtline->update + + $price_ht = price2num(GETPOST('elprice'), 'MU'); + $remise_percent = price2num(GETPOST('elremise_percent'), 2); + if ($remise_percent > 0) { + $remise = round(($price_ht * $remise_percent / 100), 2); + $price_ht = ($price_ht - $remise); + } + $objectline->fk_product = GETPOST('idprod', 'int'); $objectline->description = GETPOST('product_desc', 'restricthtml'); - $objectline->price_ht = price2num(GETPOST('elprice'), 'MU'); + $objectline->price_ht = $price_ht; $objectline->subprice = price2num(GETPOST('elprice'), 'MU'); $objectline->qty = price2num(GETPOST('elqty'), 'MS'); - $objectline->remise_percent = price2num(GETPOST('elremise_percent'), 2); + $objectline->remise_percent = $remise_percent; $objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0 $objectline->vat_src_code = $vat_src_code; $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0; From 976c2d76f260d73cd5508fe837e487675228d156 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Apr 2023 22:10:56 +0200 Subject: [PATCH 025/159] Try fix MS OAuth2 Imap (from feedback at dolibarr.org/forum/t/emailcollectors-with-microsoft-365-oauth2) --- htdocs/core/lib/oauth.lib.php | 2 +- htdocs/includes/OAuth/OAuth2/Service/Microsoft.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 8a81d9a80e5..aaac40a525f 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -32,7 +32,7 @@ if (isModEnabled('stripe')) { $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'availablescopes'=>'read_write', 'returnurl'=>'/core/modules/oauth/stripelive_oauthcallback.php'); } $supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'availablescopes'=>'user,public_repo', 'returnurl'=>'/core/modules/oauth/github_oauthcallback.php'); -$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office365.com/IMAP.AccessAsUser.All,https://outlook.office365.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php'); +$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office.com/IMAP.AccessAsUser.All,https://outlook.office.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php'); if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'availablescopes'=>'Standard', 'returnurl'=>'/core/modules/oauth/generic_oauthcallback.php'); // See https://learn.microsoft.com/fr-fr/azure/active-directory/develop/quickstart-register-app#register-an-application diff --git a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php index 6c3b18b3c0f..90c20405e6b 100644 --- a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php +++ b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php @@ -38,8 +38,8 @@ class Microsoft extends AbstractService const SCOPE_APPLICATIONS = 'applications'; const SCOPE_APPLICATIONS_CREATE = 'applications_create'; const SCOPE_IMAP = 'imap'; - const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office365.com/IMAP.AccessAsUser.All'; - const SOCPE_SMTPSEND = 'https://outlook.office365.com/SMTP.Send'; + const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office.com/IMAP.AccessAsUser.All'; + const SOCPE_SMTPSEND = 'https://outlook.office.com/SMTP.Send'; const SOCPE_USERREAD = 'User.Read'; const SOCPE_MAILREAD = 'Mail.Read'; const SOCPE_MAILSEND = 'Mail.Send'; From df27824249bb8e9d026f487707f9adb02eaf8e49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 10:58:49 +0200 Subject: [PATCH 026/159] css --- htdocs/expensereport/card.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index b7a6cb662d6..1f7326ed40a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2025,6 +2025,7 @@ if ($action == 'create') { print ''; print ''; print ''; + print ''; print '
'; print '
'.img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ').''.img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_WAREHOUSE, $search_warehouse_categ, 'search_warehouse_categ').'
'; @@ -2043,7 +2044,7 @@ if ($action == 'create') { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } - print ''; + print ''; print ''; print ''; print ''; @@ -2082,7 +2083,7 @@ if ($action == 'create') { // Project if (isModEnabled('project')) { - print ''; } - print ''; + print ''; print ''; print ''; print ''; @@ -2554,7 +2555,7 @@ if ($action == 'create') { } print ''; print ''; From 3f3e8a84ff552c921c2f427b937437efa45a8d90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 11:23:18 +0200 Subject: [PATCH 027/159] FIX Report of date of task suggested only if there is tasks --- htdocs/projet/card.php | 16 ++++++++++++---- htdocs/projet/class/project.class.php | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7fddc12b7c9..3b5a0175d03 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1153,11 +1153,14 @@ if ($action == 'create' && $user->rights->projet->creer) { print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print ' '.$langs->trans("to").' '; print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0); - print '     getLinesArray(null, 0); + if (!empty($object->usage_task) && !empty($object->lines)) { + print ' '; } - print '/>'; print ''; if (isModEnabled('eventorganization')) { @@ -1379,6 +1382,11 @@ if ($action == 'create' && $user->rights->projet->creer) { jQuery("#usage_task").prop("checked", true); } }); + + jQuery("#projectstart").change(function() { + console.log("We modify the start date"); + jQuery("#divreportdate").show(); + }); }); '; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 582e062f68a..1e4c6862c58 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2305,11 +2305,11 @@ class Project extends CommonObject /** - * Create an array of tasks of current project + * Create an array of tasks of current project * - * @param User $user Object user we want project allowed to + * @param User $user Object user we want project allowed to * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action - * @return int >0 if OK, <0 if KO + * @return int >0 if OK, <0 if KO */ public function getLinesArray($user, $loadRoleMode = 1) { From eb187052e8badbcc73694cab3d00f7a0d9dd9821 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 11:44:19 +0200 Subject: [PATCH 028/159] Fix column alignment/balance --- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/projet/tasks/time.php | 67 +++++++++++++++++---- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index e05931f437d..dfbc2aa65a1 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -378,7 +378,7 @@ class FormProjets include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $out .= $comboenhancement; - $morecss .= ' minwidth200 maxwidth500'; + $morecss .= ' minwidth150'; } if (empty($option_only)) { diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b98e9298732..3f1413ea3f2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1750,7 +1750,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($projectstatic->public) { $contactsofproject = array(); } - print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth250'); + print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); } else { if ($nboftasks) { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).' '.$langs->trans('FirstAddRessourceToAllocateTime'); @@ -1783,8 +1783,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { - print ''; } } @@ -1796,7 +1797,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; @@ -2004,7 +2005,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Thirdparty if (!empty($arrayfields['p.fk_soc']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Value spent @@ -2270,9 +2274,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; // Date @@ -2328,6 +2333,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } + // Thirdparty + if (!empty($arrayfields['p.fk_soc']['checked'])) { + print ''; + } + + // Thirdparty alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + // Project ref if (!empty($allprojectforuser)) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task @@ -2359,7 +2376,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // User if (!empty($arrayfields['author']['checked'])) { - print ''; } + // Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + } + // Value spent if (!empty($arrayfields['value']['checked'])) { print ''; + print ''; // Date if (!empty($arrayfields['t.task_date']['checked'])) { @@ -2466,6 +2489,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } + // Thirdparty + if (!empty($arrayfields['p.fk_soc']['checked'])) { + print ''; + } + + // Thirdparty alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + // Project ref if (!empty($allprojectforuser)) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task @@ -2490,14 +2525,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_label']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; } } // User if (!empty($arrayfields['author']['checked'])) { - print ''; } + // Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + } + // Value spent if (!empty($arrayfields['value']['checked'])) { print ''; From 6143a1336b7c97bab8d49411a5d9591a608ef72b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 12:31:31 +0200 Subject: [PATCH 030/159] Look and feel v17 --- htdocs/admin/stock.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 8aaf76d310b..ac516b00d8e 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -217,7 +217,7 @@ if (isModEnabled('facture')) { print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).''; } print "\n\n"; $found++; @@ -234,7 +234,7 @@ if (isModEnabled('commande')) { print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).''; } print "\n\n"; $found++; @@ -253,7 +253,7 @@ if (isModEnabled("expedition")) { print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).''; } print "\n\n"; $found++; @@ -270,7 +270,7 @@ if (isModEnabled("expedition")) { print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).''; } print "\n\n"; $found++; @@ -301,7 +301,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; @@ -319,7 +319,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; @@ -364,7 +364,7 @@ if (isModEnabled("reception")) { print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).''; } print "\n\n"; $found++; From 9283b7af7497525723f31ed35d36f5a69412a72c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 13:03:09 +0200 Subject: [PATCH 031/159] Fix better setup tooltip for shipment/reception module --- htdocs/admin/stock.php | 17 +++++++++++++---- htdocs/core/class/conf.class.php | 9 +++++---- htdocs/core/modules/modExpedition.class.php | 6 ++++-- htdocs/core/modules/modReception.class.php | 6 ++++-- htdocs/langs/en_US/productbatch.lang | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 7a7e49a3129..2cd4985fdb1 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -181,16 +181,25 @@ $formproduct = new FormProduct($db); $disabled = ''; if (isModEnabled('productbatch')) { + // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE $langs->load("productbatch"); $disabled = ' disabled'; - print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced")); + + // STOCK_CALCULATE_ON_SHIPMENT_CLOSE + $descmode = $langs->trans('DeStockOnShipmentOnClosing'); + if (!isModEnabled('reception')) { + // STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER + $incmode = $langs->trans('ReStockOnDispatchOrder'); + } else { + // STOCK_CALCULATE_ON_RECEPTION_CLOSE + $incmode = $langs->trans('StockOnReceptionOnClosing'); + } + print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced", $descmode, $incmode)); } -//if (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) -//{ + print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); print '
'; -//} print '
'; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 589d28453fc..756b2771e39 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -635,18 +635,19 @@ class Conf unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); } - if (!empty($this->productbatch->enabled)) { + if (isModEnabled('productbatch')) { + // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE $this->global->STOCK_CALCULATE_ON_BILL = 0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0; - if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1; + if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0; - if (empty($this->reception->enabled)) { + if (!isModEnabled('reception')) { $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; } else { - if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1; if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1; + if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1; } } diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 2ff117404ee..590e5b6b488 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -360,9 +360,11 @@ class modExpedition extends DolibarrModules $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'shipping' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','shipping',".((int) $conf->entity).")", + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'shipping', ".((int) $conf->entity).")", "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'delivery' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','delivery',".((int) $conf->entity).")", + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."', 'delivery', ".((int) $conf->entity).")", + //"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name IN ('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') AND entity = ".((int) $conf->entity), + //"INSERT INTO ".MAIN_DB_PREFIX."const (name, value, entity) VALUES ('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', 1, ".((int) $conf->entity).")" ); return $this->_init($sql, $options); diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 6e7cba2b053..d6341e6279d 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -282,8 +282,10 @@ class modReception extends DolibarrModules $sql = array(); $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".((int) $conf->entity), - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".((int) $conf->entity).")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".((int) $conf->entity), + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".((int) $conf->entity).")", + //"DELETE FROM ".MAIN_DB_PREFIX."const WHERE name IN ('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE') AND entity = ".((int) $conf->entity), + //"INSERT INTO ".MAIN_DB_PREFIX."const (name, value, entity) VALUES ('STOCK_CALCULATE_ON_RECEPTION_CLOSE', 1, ".((int) $conf->entity).")" ); return $this->_init($sql, $options); diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index a1039e05e62..c51d94b8acd 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -19,7 +19,7 @@ printSellby=Sell-by: %s printQty=Qty: %d printPlannedWarehouse=Warehouse: %s AddDispatchBatchLine=Add a line for Shelf Life dispatching -WhenProductBatchModuleOnOptionAreForced=When module Lot/Serial is on, automatic stock decrease is forced to 'Decrease real stocks on shipping validation' and automatic increase mode is forced to 'Increase real stocks on manual dispatching into warehouses' and can't be edited. Other options can be defined as you want. +WhenProductBatchModuleOnOptionAreForced=When module Lot/Serial is on, automatic stock decrease is forced to '%s' and automatic increase mode is forced to '%s'. Some choices may be not available. Other options can be defined as you want. ProductDoesNotUseBatchSerial=This product does not use lot/serial number ProductLotSetup=Setup of module lot/serial ShowCurrentStockOfLot=Show current stock for couple product/lot From 569320424b1e3570f24509f3030475e412bebb8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 13:59:19 +0200 Subject: [PATCH 032/159] Fix sql error --- htdocs/expedition/class/expedition.class.php | 8 ++++---- htdocs/expedition/shipment.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0f7bedc19d3..8a5a84dbb78 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2209,8 +2209,8 @@ class Expedition extends CommonObject $sql = "SELECT cd.fk_product, cd.subprice,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql .= " e.ref,"; - $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; - $sql .= " ,cd.rowid as cdid, ed.rowid as edid"; + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock,"; + $sql .= " cd.rowid as cdid, ed.rowid as edid"; $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet as cd,"; $sql .= " " . MAIN_DB_PREFIX . "expeditiondet as ed"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; @@ -2264,8 +2264,8 @@ class Expedition extends CommonObject // If some stock lines are now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; - $resql = $this->db->query($sql); + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; + $resqldelete = $this->db->query($sqldelete); // We do not test error, it can fails if there is child in batch details } } else { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 325559882d8..0470da549e5 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -773,7 +773,7 @@ if ($id > 0 || !empty($ref)) { $toBeShippedTotal += $toBeShipped[$objp->fk_product]; print $toBeShipped[$objp->fk_product]; } else { - print '0 ('.$langs->trans("Service").')'; + print '0 ('.$langs->trans("Service").')'; } print ($objp->unit_order ? ' '.$objp->unit_order : '').''; From f26b5b58c907ccdd87ab5ecfa33c6b66947ed6d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 14:27:39 +0200 Subject: [PATCH 033/159] Fix error management --- htdocs/expedition/card.php | 3 +++ htdocs/expedition/class/expedition.class.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index dcc50eff7dc..ec615119c67 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -161,6 +161,9 @@ if (empty($reshook)) { if ($action == 'reopen' && $user->rights->expedition->creer) { $object->fetch($id); $result = $object->reOpen(); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Set incoterm diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8a5a84dbb78..4eb81a980bb 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2388,7 +2388,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $this->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2399,7 +2399,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $this->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; From f57dfd14c3bff9571d69d381d0d2838820ca3bd8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 15:00:46 +0200 Subject: [PATCH 034/159] Fix label of warehouse no more visible --- htdocs/expedition/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ec615119c67..81620632772 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -352,6 +352,7 @@ if (empty($reshook)) { if ($totalqty > 0 && !$error) { // There is at least one thing to ship and no error for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; + if (!isset($batch_line[$i])) { // not batch mode if (isset($stockLine[$i])) { @@ -403,7 +404,7 @@ if (empty($reshook)) { } if (!$error) { - $ret = $object->create($user); // This create shipment (like Odoo picking) and lines of shipments. Stock movement will be done when validating shipment. + $ret = $object->create($user); // This create shipment (like Odoo picking) and lines of shipments. Stock movement will be done when validating or closing shipment. if ($ret <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -2393,7 +2394,7 @@ if ($action == 'create') { if ($detail_entrepot->entrepot_id > 0) { $entrepot = new Entrepot($db); $entrepot->fetch($detail_entrepot->entrepot_id); - $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; + $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->label, $detail_entrepot->qty_shipped).'
'; } } print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); From 8ba802ed5d5b34cef9f441a29b6bfa99587d74bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 15:34:13 +0200 Subject: [PATCH 035/159] Fix when reverting a shipment validation or closing and stock empty --- htdocs/expedition/card.php | 5 +++++ htdocs/langs/en_US/agenda.lang | 2 +- htdocs/langs/en_US/stocks.lang | 2 ++ htdocs/langs/fr_FR/agenda.lang | 2 +- htdocs/product/stock/class/mouvementstock.class.php | 10 ++++++++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 81620632772..dfa33478e66 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1739,6 +1739,11 @@ if ($action == 'create') { } $text = $langs->trans("ConfirmValidateSending", $numref); + if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { + $text .= ' '.$langs->trans("StockMovementWillBeRecorded").'.'; + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { + $text .= ' '.$langs->trans("StockMovementNotYetRecorded").'.'; + } if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index adc9c4177ad..43718271919 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -62,7 +62,7 @@ MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted ShipmentValidatedInDolibarr=Shipment %s validated -ShipmentClassifyClosedInDolibarr=Shipment %s classified billed +ShipmentClassifyClosedInDolibarr=Shipment %s classified closed ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified re-open ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status ShipmentDeletedInDolibarr=Shipment %s deleted diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 6a8821de833..62ebfc53ef9 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -318,3 +318,5 @@ StockTransferRightRead=Read stocks transfers StockTransferRightCreateUpdate=Create/Update stocks transfers StockTransferRightDelete=Delete stocks transfers BatchNotFound=Lot / serial not found for this product +StockMovementWillBeRecorded=Stock movement will be recorded +StockMovementNotYetRecorded=Stock movement will not be affected by this step \ No newline at end of file diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 86e97805dd5..33d925ac777 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -62,7 +62,7 @@ MemberSubscriptionAddedInDolibarr=Cotisation %s pour l'adhérent %s ajoutée MemberSubscriptionModifiedInDolibarr=Cotisation %s pour l'adhérent %s modifié MemberSubscriptionDeletedInDolibarr=Cotisation %s pour l'adhérent %s supprimé ShipmentValidatedInDolibarr=Expédition %s validée -ShipmentClassifyClosedInDolibarr=Expédition %s classée payée +ShipmentClassifyClosedInDolibarr=Expédition %s classée close ShipmentUnClassifyCloseddInDolibarr=Expédition %s réouverte ShipmentBackToDraftInDolibarr=Expédition %s remise au statut brouillon ShipmentDeletedInDolibarr=Expédition %s supprimée diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 083ea381015..b596ac551b1 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -301,7 +301,9 @@ class MouvementStock extends CommonObject // If not found, we add record $sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".$this->db->prefix()."product_lot as pb"; $sql .= " WHERE pb.fk_product = ".((int) $fk_product)." AND pb.batch = '".$this->db->escape($batch)."'"; + dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -560,6 +562,10 @@ class MouvementStock extends CommonObject if (!$error && isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) { if ($id_product_batch > 0) { $result = $this->createBatch($id_product_batch, $qty); + if ($result == -2 && $fk_product_stock > 0) { // The entry for this product batch does not exists anymore, bu we already have a llx_product_stock, so we recreate the batch entry in product_batch + $param_batch = array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch); + $result = $this->createBatch($param_batch, $qty); + } } else { $param_batch = array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch); $result = $this->createBatch($param_batch, $qty); @@ -863,10 +869,10 @@ class MouvementStock extends CommonObject * Create or update batch record (update table llx_product_batch). No check is done here, done by parent. * * @param array|int $dluo Could be either - * - int if row id of product_batch table + * - int if row id of product_batch table (for update) * - or complete array('fk_product_stock'=>, 'batchnumber'=>) * @param int $qty Quantity of product with batch number. May be a negative amount. - * @return int <0 if KO, else return productbatch id + * @return int <0 if KO, -2 if we try to update a product_batchid that does not exist, else return productbatch id */ private function createBatch($dluo, $qty) { From 90bca8b4d7dd411cda5de4eb6847839fc45774b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 15:55:58 +0200 Subject: [PATCH 036/159] NEW Can go back to draft on shipment when stock change not on validate --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/html.form.class.php | 30 ++++++++--------- htdocs/expedition/card.php | 35 ++++++++++++++------ htdocs/expedition/class/expedition.class.php | 19 ++++++++++- 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e53cc85c21f..10a85c3a16f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9982,7 +9982,7 @@ abstract class CommonObject $this->db->begin(); $statusfield = 'status'; - if ($this->element == 'don' || $this->element == 'donation') { + if (in_array($this->element, array('don', 'donation', 'shipping'))) { $statusfield = 'fk_statut'; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index eea1047bc51..5484fea6663 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5087,21 +5087,21 @@ class Form * print '});'."\n"; * print ''."\n"; * - * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) - * @param string $title Title - * @param string $question Question - * @param string $action Action - * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) - * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', - * 'other', 'onecolumn' or 'hidden'... - * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 - * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx - * @param int|string $height Force height of box (0 = auto) - * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. - * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a section. - * @param string $labelbuttonyes Label for Yes - * @param string $labelbuttonno Label for No - * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form + * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) + * @param string $title Title + * @param string $question Question + * @param string $action Action + * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) + * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss', + * 'other', 'onecolumn' or 'hidden'... + * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 + * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx + * @param int|string $height Force height of box (0 = auto) + * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. + * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a section. + * @param string $labelbuttonyes Label for Yes + * @param string $labelbuttonno Label for No + * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes = 'Yes', $labelbuttonno = 'No') { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index dfa33478e66..34ed7f80f84 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -157,6 +157,14 @@ if (empty($reshook)) { $upload_dir = $conf->expedition->dir_output.'/sending'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Back to draft + if ($action == 'setdraft' && $user->rights->expedition->creer) { + $object->fetch($id); + $result = $object->setDraft($user, 0); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Reopen if ($action == 'reopen' && $user->rights->expedition->creer) { $object->fetch($id); @@ -1740,9 +1748,9 @@ if ($action == 'create') { $text = $langs->trans("ConfirmValidateSending", $numref); if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { - $text .= ' '.$langs->trans("StockMovementWillBeRecorded").'.'; + $text .= '
'.$langs->trans("StockMovementWillBeRecorded").'.'; } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { - $text .= ' '.$langs->trans("StockMovementNotYetRecorded").'.'; + $text .= '
'.$langs->trans("StockMovementNotYetRecorded").'.'; } if (isModEnabled('notification')) { @@ -1752,7 +1760,7 @@ if ($action == 'create') { $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); } - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1, 250); } // Confirm cancelation if ($action == 'cancel') { @@ -2540,13 +2548,20 @@ if ($action == 'create') { } } - // TODO add alternative status - // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) - if ($object->statut == Expedition::STATUS_CLOSED && $user->rights->expedition->creer) { - if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? - print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); - } else { - print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); + // 0=draft, 1=validated/delivered, 2=closed/delivered + // If WORKFLOW_BILL_ON_SHIPMENT: 0=draft, 1=validated, 2=billed (no status delivered) + if ($object->statut == Expedition::STATUS_VALIDATED && !getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { + if ($user->hasRight('expedition', 'creer')) { + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=setdraft&token='.newToken().'&id='.$object->id, ''); + } + } + if ($object->statut == Expedition::STATUS_CLOSED) { + if ($user->hasRight('expedition', 'creer')) { + if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); + } else { + print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); + } } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4eb81a980bb..c3ddf973049 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2318,6 +2318,23 @@ class Expedition extends CommonObject } } + /** + * 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->statut <= self::STATUS_DRAFT) { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'SHIPMENT_UNVALIDATE'); + } + /** * Classify the shipping as validated/opened * @@ -2338,7 +2355,7 @@ class Expedition extends CommonObject $oldbilled = $this->billed; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut = 1'; $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0'; $resql = $this->db->query($sql); From 6914e2bb2abaa796e97edfbd86b8dd13ddcc6df6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 16:58:38 +0200 Subject: [PATCH 037/159] NEW Can receive more than qty ordered on reception --- htdocs/fourn/js/lib_dispatch.js.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index ff822543ddb..6bd2d39ce21 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -69,13 +69,15 @@ function addDispatchLine(index, type, mode) { mode = mode || 'qtymissing' - console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode); var $row0 = $("tr[name='"+type+'_0_'+index+"']"); var $dpopt = $row0.find('.hasDatepicker').first().datepicker('option', 'all'); // get current datepicker options to apply the same to the cloned datepickers var $row = $row0.clone(true); // clone first batch line to jQuery object var nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; // position of line for batch var qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // Qty ordered is same for all rows var qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()); + + console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode+" qtyOrdered="+qtyOrdered+" qty="+qty); + var qtyDispatched; if (mode === 'lessone') @@ -93,9 +95,17 @@ function addDispatchLine(index, type, mode) } console.log("qtyDispatched="+qtyDispatched+" qtyOrdered="+qtyOrdered); - if (qtyDispatched >= qtyOrdered || qtyOrdered <= 1) { + if (qty <= 1) { window.alert("Remain quantity to dispatch is too low to be split"); - } else if (qtyDispatched < qtyOrdered) { + } else { + oldlineqty = qtyDispatched; + newlineqty = qtyOrdered - qtyDispatched; + if (newlineqty <= 0) { + newlineqty = qty - 1; + oldlineqty = 1; + $("#qty_"+(nbrTrs - 1)+"_"+index).val(oldlineqty); + } + //replace tr suffix nbr $row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_")); @@ -127,7 +137,7 @@ function addDispatchLine(index, type, mode) /* Suffix of lines are: _ trs.length _ index */ $("#qty_"+nbrTrs+"_"+index).focus(); - $("#qty_dispatched_0_"+index).val(qtyDispatched); + $("#qty_dispatched_0_"+index).val(oldlineqty); //hide all buttons then show only the last one $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); @@ -138,7 +148,7 @@ function addDispatchLine(index, type, mode) qty = 1; // keep 1 in old line $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); } - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + $("#qty_"+nbrTrs+"_"+index).val(newlineqty); // Store arbitrary data for dispatch qty input field change event $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); From 3e372602d884a31848866a2d4ddc68132cfe8f2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 17:07:20 +0200 Subject: [PATCH 038/159] Trans --- htdocs/core/modules/modStockTransfer.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modStockTransfer.class.php b/htdocs/core/modules/modStockTransfer.class.php index 279add98bad..34de040fdb8 100644 --- a/htdocs/core/modules/modStockTransfer.class.php +++ b/htdocs/core/modules/modStockTransfer.class.php @@ -61,7 +61,7 @@ class modStockTransfer extends DolibarrModules // Module description, used if translation string 'ModuleStockTransferDesc' not found (StockTransfer is name of module). $this->description = $langs->trans("ModuleStockTransferDesc"); // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "StockTransfer description (Long)"; + $this->descriptionlong = "Advanced management of stock transfer orders with generation of stock transfer sheets"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = 'experimental'; // Url to the file with your last numberversion of this module diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9fb7a487118..a493b104036 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -573,7 +573,7 @@ Module50Desc=Management of Products Module51Name=Mass mailings Module51Desc=Mass paper mailing management Module52Name=Stocks -Module52Desc=Stock management +Module52Desc=Stock management (stock movement tracking and inventory) Module53Name=Services Module53Desc=Management of Services Module54Name=Contracts/Subscriptions From 18b78d28abfcdb47c0071ddcfd7f5698dd70fcdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 18:56:33 +0200 Subject: [PATCH 039/159] Clean content of column "Already shipped into other shipment" --- htdocs/expedition/card.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 34ed7f80f84..f2947e9b09f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2285,6 +2285,8 @@ if ($action == 'create') { // Qty in other shipments (with shipment and warehouse used) if ($origin && $origin_id > 0) { print '
'; } From 5184f7c168ff892b4a02356ce90f8a9d89aad8da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 19:13:41 +0200 Subject: [PATCH 040/159] css --- htdocs/core/tpl/objectline_title.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index cbe5d0dee10..f7afa80bf55 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -134,14 +134,14 @@ if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { if ($usemargins && isModEnabled('margin') && empty($user->socid)) { if (!empty($user->rights->margins->creer)) { if ($conf->global->MARGIN_TYPE == "1") { - print ''; + print ''; } else { - print ''; + print ''; } } if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { - print ''; } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { - print ''; + print ''; } } From 8747cc142349f28dcb94fb22a02535ac4fb5f9be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 19:17:37 +0200 Subject: [PATCH 041/159] Fix phpunit --- htdocs/product/reassortlot.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 4346854460a..a25fadede1d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -532,7 +532,6 @@ print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort /* if ($search_categ > 0) { - var_dump($search_categ); print "
"; $c = new Categorie($db); $c->fetch($search_categ); From 6d18cdb062ffc86ec30c9ec5f44876ea26886ace Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 19:22:38 +0200 Subject: [PATCH 042/159] First test with PHP 8.2 --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f4fc328a49..ee378d191dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,10 @@ addons: - php8.1-mysqli - php8.1-xml - php8.1-intl + - php8.2-pgsql + - php8.2-mysqli + - php8.2-xml + - php8.2-intl env: global: @@ -73,8 +77,8 @@ jobs: php: '8.1' env: DB=mysql - stage: PHP Dev - if: type = push AND branch = 17.0 - php: nightly + if: type = push AND branch = develop + php: '8.2' env: DB=mysql notifications: @@ -120,7 +124,7 @@ install: squizlabs/php_codesniffer ^3 fi # phpunit 9 is required for php 8 - if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer self-update 2.4.4 composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ @@ -260,7 +264,7 @@ before_script: # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf fi From 1964a020aa3696a991a53af6921ff1f2e8945b21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 19:35:58 +0200 Subject: [PATCH 043/159] Look and feel v18 --- htdocs/product/stock/movement_list.php | 413 +++++++++++++++---------- 1 file changed, 257 insertions(+), 156 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 56d39ae0e88..72f36220185 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -50,20 +50,23 @@ if (isModEnabled('productbatch')) { $langs->load("productbatch"); } -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$msid = GETPOST('msid', 'int'); -$product_id = GETPOST("product_id", 'int'); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $backtopage = GETPOST("backtopage", "alpha"); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$msid = GETPOST('msid', 'int'); $idproduct = GETPOST('idproduct', 'int'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$product_id = GETPOST("product_id", 'int'); + +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startyear = GETPOST('search_date_startyear', 'int'); @@ -83,7 +86,7 @@ $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $search_fk_projet=GETPOST("search_fk_projet", 'int'); -$optioncss = GETPOST('optioncss', 'alpha'); + $type = GETPOST("type", "int"); // Load variable for pagination @@ -108,15 +111,15 @@ if (!$sortorder) { $pdluoid = GETPOST('pdluoid', 'int'); -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +// Initialize technical objects $object = new MouvementStock($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('movementlist')); +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes $formfile = new FormFile($db); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -224,7 +227,7 @@ if (empty($reshook)) { $search_batch = ""; $search_qty = ''; $search_fk_projet=0; - $sall = ""; + $search_all = ""; $toselect = array(); $search_array_options = array(); } @@ -588,18 +591,21 @@ if ($action == "transfert_stock" && !$cancel) { * View */ -$productlot = new ProductLot($db); -$productstatic = new Product($db); -$warehousestatic = new Entrepot($db); -$movement = new MouvementStock($db); -$userstatic = new User($db); $form = new Form($db); $formproduct = new FormProduct($db); if (!empty($conf->project->enabled)) { $formproject = new FormProjets($db); } +$productlot = new ProductLot($db); +$productstatic = new Product($db); +$warehousestatic = new Entrepot($db); +$movement = new MouvementStock($db); +$userstatic = new User($db); + +$now = dol_now(); // Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,"; $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,"; $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; @@ -616,7 +622,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$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); @@ -697,7 +703,7 @@ if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Count total nb of records @@ -714,7 +720,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -733,6 +739,9 @@ if (!$resql) { exit; } +$num = $db->num_rows($resql); + + $product = new Product($db); $object = new Entrepot($db); @@ -746,8 +755,6 @@ if ($id > 0 || $ref) { } } -$num = $db->num_rows($resql); - // Output page // -------------------------------------------------------------------- @@ -767,9 +774,11 @@ if ($msid) { } } -llxHeader('', $title, $help_url); -$arrayofselected = is_array($toselect) ? $toselect : array(); +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); /* * Show tab only if we ask a particular warehouse @@ -939,7 +948,12 @@ if ((empty($action) || $action == 'list') && $id > 0) { 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); } @@ -996,6 +1010,10 @@ if ($idproduct > 0) { } // 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, $action); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array(); @@ -1023,10 +1041,15 @@ print ''; print ''; print ''; print ''; +print ''; +print ''; if ($id > 0) { print ''; } + +$newcardbutton = ''; + if ($id > 0) { print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } else { @@ -1040,17 +1063,20 @@ $objecttmp = new MouvementStock($db); $trackid = 'mov'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { +if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; $parameters = array('arrayfields'=>&$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { @@ -1064,7 +1090,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = ($mode != 'kanban' ? $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 @@ -1073,6 +1099,13 @@ print '
'.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''; + print ''; if ($line->fk_project > 0) { $projecttmp->id = $line->fk_project; $projecttmp->ref = $line->projet_ref; @@ -2475,7 +2476,7 @@ if ($action == 'create') { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''; - print $form->buttonsSaveCancel("Add", '', '', 1); + print $form->buttonsSaveCancel("Add", '', '', 1, 'reposition'); print '
'; - print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); + print ''; + print img_picto('', 'product'); + print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1); print ''; $form->buttonsSaveCancel(); - print ''; + print ''; print ''; print '
'; + print ''; if ($task_time->fk_soc > 0) { if (empty($conf->cache['thridparty'][$task_time->fk_soc])) { $tmpsociete = new Societe($db); @@ -2185,9 +2186,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } - //Product + // Product if (!empty($arrayfields['t.fk_product']['checked'])) { - print ''; + print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); } elseif (!empty($task_time->fk_product)) { @@ -2200,6 +2201,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } print ''; if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) { print ''; - print ''; + print ''; print ' '; - print ''; + print ''; } elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) { @@ -2311,6 +2315,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Add line to split if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { + print ''; print '
'; + print ''; + print ''; + print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { if (empty($object->id)) { $object->fetch($id); @@ -2410,6 +2427,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; + print ''; @@ -2449,7 +2472,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Line for second dispatching - print '
'; + print ''; + print ''; - print $task_time->label; + print dol_escape_htmltag($task_time->label); print ''; + print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { if (empty($object->id)) { $object->fetch($id); @@ -2548,6 +2583,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; + print ''; From 89f69068515f04d023b2e86226e5d026ee710534 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 12:09:52 +0200 Subject: [PATCH 029/159] Trans --- htdocs/langs/en_US/commercial.lang | 4 ++-- htdocs/projet/card.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index eba95a8aabb..a2f5c6d21ce 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -65,8 +65,8 @@ ActionAC_SUP_ORD=Send purchase order by mail ActionAC_SUP_INV=Send vendor invoice by mail ActionAC_OTH=Other ActionAC_OTH_AUTO=Other auto -ActionAC_MANUAL=Manually inserted events -ActionAC_AUTO=Automatically inserted events +ActionAC_MANUAL=Events inserted manually (by a user) +ActionAC_AUTO=Events inserted automatically ActionAC_OTH_AUTOShort=Other ActionAC_EVENTORGANIZATION=Event organization events Stats=Sales statistics diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 3b5a0175d03..040b3ea2772 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1157,9 +1157,9 @@ if ($action == 'create' && $user->rights->projet->creer) { if (!empty($object->usage_task) && !empty($object->lines)) { print ' '; + print '/>'; } print '
'; + $htmltooltip = ''; + $qtyalreadysent = 0; foreach ($alreadysent as $key => $val) { if ($lines[$i]->fk_origin_line == $key) { $j = 0; @@ -2295,20 +2297,23 @@ if ($action == 'create') { $j++; if ($j > 1) { - print '
'; + $htmltooltip .= '
'; } $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { + $htmltooltip .= $shipment_static->getNomUrl(1, '', 0, 0, 1); + $htmltooltip .= ' - '.$shipmentline_var['qty_shipped']; + $htmltooltip .= ' - '.$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + /*if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); + }*/ + //print ' '.$form->textwithpicto('', $htmltext, 1); + + $qtyalreadysent += $shipmentline_var['qty_shipped']; } } } + print $form->textwithpicto($qtyalreadysent, $htmltooltip, 1, 'info', '', 0, 3, 'tooltip'.$lines[$i]->id); print '
'.$langs->trans('BuyingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('CostPrice').''.$langs->trans('MarginRate'); + print ''.$langs->trans('MarginRate'); if ($user->hasRight("propal", "creer")) { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; if (GETPOST('mode', 'aZ09') == 'marginforalllines') { @@ -154,7 +154,7 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { print ''.$langs->trans('MarkRate').''.$langs->trans('MarkRate').'
'; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } // Action column -print ''; +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 getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); } @@ -1262,8 +1304,8 @@ if (!empty($arrayfields['m.price']['checked'])) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['m.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); @@ -1272,7 +1314,10 @@ if (!empty($arrayfields['m.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } // Action column -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} print ''."\n"; @@ -1282,9 +1327,11 @@ $arrayofuniqueproduct = array(); // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -1346,139 +1393,193 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $origin = ''; } - print ''; - // Id movement - if (!empty($arrayfields['m.rowid']['checked'])) { - print ''; // This is primary not movement id - } - if (!empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; - } - if (!empty($arrayfields['p.ref']['checked'])) { - // Product ref - print '\n"; - } - if (!empty($arrayfields['p.label']['checked'])) { - // Product label - print '\n"; - } - if (!empty($arrayfields['m.batch']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; - } - // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) { - print '\n"; - } - // Author - if (!empty($arrayfields['m.fk_user_author']['checked'])) { - print '\n"; - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { - // Inventory code - print ''; - } - if (!empty($arrayfields['m.label']['checked'])) { - // Label of movement - print ''; - } - if (!empty($arrayfields['origin']['checked'])) { - // Origin of movement - print ''; - } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print ''; - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - print ''; - } - if (!empty($arrayfields['m.value']['checked'])) { - // Qty - print ''; } - print ''; - } - if (!empty($arrayfields['m.price']['checked'])) { - // Price - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Id movement + if (!empty($arrayfields['m.rowid']['checked'])) { + print ''; // This is primary not movement id + } + if (!empty($arrayfields['m.datem']['checked'])) { + // Date + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) { + // Product ref + print '\n"; + } + if (!empty($arrayfields['p.label']['checked'])) { + // Product label + print '\n"; + } + if (!empty($arrayfields['m.batch']['checked'])) { + print ''; + } + if (!empty($arrayfields['pl.eatby']['checked'])) { + print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) { + print ''; + } + // Warehouse + if (!empty($arrayfields['e.ref']['checked'])) { + print '\n"; + } + // Author + if (!empty($arrayfields['m.fk_user_author']['checked'])) { + print '\n"; + } + if (!empty($arrayfields['m.inventorycode']['checked'])) { + // Inventory code + print ''; + } + if (!empty($arrayfields['m.label']['checked'])) { + // Label of movement + print ''; + } + if (!empty($arrayfields['origin']['checked'])) { + // Origin of movement + print ''; + } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + // fk_project + print ''; + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) { + // Type of movement + print ''; + } + if (!empty($arrayfields['m.value']['checked'])) { + // Qty + print ''; + } + if (!empty($arrayfields['m.price']['checked'])) { + // Price + print ''; } - print ''; - } - // Extra fields - $object = $movement; - 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; + // Extra fields + $object = $movement; + 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, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Action column - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; + } $i++; } +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + $db->free($resql); -print "
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; @@ -1185,7 +1218,7 @@ 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 +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['m.datec']['checked'])) { @@ -1198,16 +1231,25 @@ if (!empty($arrayfields['m.tms']['checked'])) { print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print $obj->mid; - print ''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''; - print $productstatic->getNomUrl(1, 'stock', 16); - print "'; - print $productstatic->label; - print "'; - if ($productlot->id > 0) { - print $productlot->getNomUrl(1); - } else { - print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - print '
'.dol_print_date($obj->eatby, 'day').''.dol_print_date($obj->sellby, 'day').''; - print $warehousestatic->getNomUrl(1); - print "'; - print $userstatic->getNomUrl(-1); - print "inventorycode.'$').'&search_type_mouvement='.urlencode($obj->type_mouvement).'">'.$obj->inventorycode.''.$obj->label.''.$origin.''; - if ($obj->fk_project != 0) { - print $movement->get_origin($obj->fk_project, 'project'); + // Output Kanban + 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 $movement->getTypeMovement(); - print ''; - if ($obj->qty > 0) { - print ''; - print '+'; - print $obj->qty; - print ''; - } else { - print ''; - print $obj->qty; - print ''; + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print ''; + print '
'; - if ($obj->price != 0) { - print price($obj->price); + } else { + // Show here line of result + $j = 0; + 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->mid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print $obj->mid; + print ''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''; + print $productstatic->getNomUrl(1, 'stock', 16); + print "'; + print $productstatic->label; + print "'; + if ($productlot->id > 0) { + print $productlot->getNomUrl(1); + } else { + print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + } + print ''.dol_print_date($obj->eatby, 'day').''.dol_print_date($obj->sellby, 'day').''; + print $warehousestatic->getNomUrl(1); + print "'; + print $userstatic->getNomUrl(-1); + print "inventorycode.'$').'&search_type_mouvement='.urlencode($obj->type_mouvement).'">'.$obj->inventorycode.''.$obj->label.''.$origin.''; + if ($obj->fk_project != 0) { + print $movement->get_origin($obj->fk_project, 'project'); + } + print ''; + print $movement->getTypeMovement(); + print ''; + if ($obj->qty > 0) { + print ''; + print '+'; + print $obj->qty; + print ''; + } else { + print ''; + print $obj->qty; + print ''; + } + print ''; + if ($obj->price != 0) { + print price($obj->price); + } + 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->mid, $arrayofselected)) { - $selected = 1; + // 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->mid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
"; -print '
'; -print ""; +$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"; // Add number of product when there is a filter on period if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { @@ -1527,7 +1628,7 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $genallowed = $permissiontoread; $delallowed = $permissiontoadd; - print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page From 84a81fde360cc83608b59c18bdc0791cd29ed88e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Apr 2023 19:39:56 +0200 Subject: [PATCH 044/159] Debug v18 --- htdocs/product/reassortlot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index a25fadede1d..8c655df44ff 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; // Load translation files required by the page -$langs->loadLangs(array('products', 'stocks', 'productbatch')); +$langs->loadLangs(array('products', 'stocks', 'productbatch', 'categories')); $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) @@ -545,7 +545,7 @@ if ($search_categ > 0) { $moreforfilter = ''; if (isModEnabled('categorie')) { $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('ProductsCategoryShort'), 'category', 'class="pictofixedwidth"'); + $moreforfilter .= img_picto($langs->trans('ProductsCategoriesShort'), 'category', 'class="pictofixedwidth"'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, $langs->trans("ProductsCategoryShort"), 'maxwidth400'); $moreforfilter .= '
'; } From 7fc2b2e8b1f252d2ec624d1cb2e7828ac324e57d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 10 Apr 2023 22:30:16 +0200 Subject: [PATCH 045/159] Fix error on call function print_liste_field_titre --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3362755d962..007d4f232cc 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1510,7 +1510,7 @@ if (!empty($arrayfields['s.import_key']['checked'])) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); $totalarray['nbfield']++; // For the column action } print ''."\n"; From 0f58368d5d8215387e28bc8d6456baa47a6da8b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 10:13:15 +0200 Subject: [PATCH 046/159] Fix do imap expunge only if no error --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7da3da4e83a..1b7c7ef2f27 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2888,7 +2888,7 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $client->disconnect(); } else { - if (empty($mode)) { + if (empty($mode) && empty($error)) { imap_expunge($connection); // To validate any move } imap_close($connection); From a1e6fe7f5050500ab580ac969b2d27cba9adcfef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 10:34:03 +0200 Subject: [PATCH 047/159] Revert "Try fix MS OAuth2 Imap (from feedback at dolibarr.org/forum/t/emailcollectors-with-microsoft-365-oauth2)" This reverts commit 976c2d76f260d73cd5508fe837e487675228d156. --- htdocs/core/lib/oauth.lib.php | 2 +- htdocs/includes/OAuth/OAuth2/Service/Microsoft.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index aaac40a525f..8a81d9a80e5 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -32,7 +32,7 @@ if (isModEnabled('stripe')) { $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'availablescopes'=>'read_write', 'returnurl'=>'/core/modules/oauth/stripelive_oauthcallback.php'); } $supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'availablescopes'=>'user,public_repo', 'returnurl'=>'/core/modules/oauth/github_oauthcallback.php'); -$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office.com/IMAP.AccessAsUser.All,https://outlook.office.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php'); +$supportedoauth2array['OAUTH_MICROSOFT_NAME'] = array('callbackfile' => 'microsoft', 'picto' => 'microsoft', 'urlforapp' => 'OAUTH_MICROSOFT_DESC', 'name'=>'Microsoft', 'urlforcredentials'=>'https://portal.azure.com/', 'availablescopes'=>'openid,offline_access,profile,email,User.Read,https://outlook.office365.com/IMAP.AccessAsUser.All,https://outlook.office365.com/SMTP.Send', 'returnurl'=>'/core/modules/oauth/microsoft_oauthcallback.php'); if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'availablescopes'=>'Standard', 'returnurl'=>'/core/modules/oauth/generic_oauthcallback.php'); // See https://learn.microsoft.com/fr-fr/azure/active-directory/develop/quickstart-register-app#register-an-application diff --git a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php index 90c20405e6b..6c3b18b3c0f 100644 --- a/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php +++ b/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php @@ -38,8 +38,8 @@ class Microsoft extends AbstractService const SCOPE_APPLICATIONS = 'applications'; const SCOPE_APPLICATIONS_CREATE = 'applications_create'; const SCOPE_IMAP = 'imap'; - const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office.com/IMAP.AccessAsUser.All'; - const SOCPE_SMTPSEND = 'https://outlook.office.com/SMTP.Send'; + const SOCPE_IMAP_ACCESSASUSERALL = 'https://outlook.office365.com/IMAP.AccessAsUser.All'; + const SOCPE_SMTPSEND = 'https://outlook.office365.com/SMTP.Send'; const SOCPE_USERREAD = 'User.Read'; const SOCPE_MAILREAD = 'Mail.Read'; const SOCPE_MAILSEND = 'Mail.Send'; From c14471e41980d0ff5fa03244cd914d4cd450c533 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 15:39:38 +0200 Subject: [PATCH 048/159] css --- htdocs/projet/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 26119927fda..e7e8cc40b68 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1858,8 +1858,8 @@ while ($i < $imaxinloop) { } // Email MsgID if (!empty($arrayfields['p.email_msgid']['checked'])) { - print ''; - print $obj->email_msgid; + print ''; + print dol_escape_htmltag($obj->email_msgid); print ''; if (!$i) $totalarray['nbfield']++; } From ce8a8c617c750ef4f66843eb725325d1b901289d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 17:24:19 +0200 Subject: [PATCH 049/159] Fix Move of message with PHP-IMAP, Fix substitution for fetch thirdparty Fix php8 compatibility --- .../class/emailcollector.class.php | 130 +++++++++++++++--- 1 file changed, 111 insertions(+), 19 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 1b7c7ef2f27..ac1f1cf4cab 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -868,7 +868,7 @@ class EmailCollector extends CommonObject /** * overwitePropertiesOfObject * - * @param object $object Current object + * @param object $object Current object we will set ->properties * @param string $actionparam Action parameters * @param string $messagetext Body * @param string $subject Subject @@ -883,8 +883,13 @@ class EmailCollector extends CommonObject // Overwrite values with values extracted from source email // $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); + + $tmp = array(); + + // Loop on each property set into actionparam foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $tmpclass = ''; $tmpproperty = ''; + $tmpclass = ''; + $tmpproperty = ''; $tmparray = explode('.', $propertytooverwrite); if (count($tmparray) == 2) { $tmpclass = $tmparray[0]; @@ -939,13 +944,21 @@ class EmailCollector extends CommonObject if (preg_match('/^options_/', $tmpproperty)) { $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted); } else { - $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + if (property_exists($object, $tmpproperty)) { + $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + } else { + $tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted); + } } } else { // extract from BODY if (preg_match('/^options_/', $tmpproperty)) { $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted); } else { - $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + if (property_exists($object, $tmpproperty)) { + $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + } else { + $tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted); + } } } if (preg_match('/^options_/', $tmpproperty)) { @@ -955,7 +968,11 @@ class EmailCollector extends CommonObject } } else { // Regex not found - $object->$tmpproperty = null; + if (property_exists($object, $tmpproperty)) { + $object->$tmpproperty = null; + } else { + $tmp[$tmpproperty] = null; + } $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> not found, so property '.dol_escape_htmltag($tmpproperty).' is set to null.'; } @@ -970,7 +987,11 @@ class EmailCollector extends CommonObject if (preg_match('/^options_/', $tmpproperty)) { $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; } else { - $valuecurrent = $object->$tmpproperty; + if (property_exists($object, $tmpproperty)) { + $valuecurrent = $object->$tmpproperty; + } else { + $valuecurrent = $tmp[$tmpproperty]; + } } if ($regforregex[1] == 'SET' || empty($valuecurrent)) { @@ -979,24 +1000,38 @@ class EmailCollector extends CommonObject $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); - if (is_array($matcharray[1])) { // $matcharray[1] is array with list of substitution key found without the __ + if (is_array($matcharray[1])) { // $matcharray[1] is an array with the list of substitution key found without the __X__ syntax into the SET entry foreach ($matcharray[1] as $keytoreplace) { - if ($keytoreplace && isset($object->$keytoreplace)) { - $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace; + if ($keytoreplace) { + if (preg_match('/^options_/', $keytoreplace)) { + $substitutionarray['__'.$keytoreplace.'__'] = $object->array_options[preg_replace('/^options_/', '', $keytoreplace)]; + } else { + if (property_exists($object, $keytoreplace)) { + $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace; + } else { + $substitutionarray['__'.$keytoreplace.'__'] = $tmp[$keytoreplace]; + } + } } } } //var_dump($substitutionarray); - dol_syslog(var_export($substitutionarray, true)); + dol_syslog('substitutionarray='.var_export($substitutionarray, true)); //var_dump($substitutionarray); $valuetouse = make_substitutions($valuetouse, $substitutionarray); if (preg_match('/^options_/', $tmpproperty)) { $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse; - } else { - $object->$tmpproperty = $valuetouse; - } - $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into variable '.dol_escape_htmltag($tmpproperty); + $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into object->array_options['.dol_escape_htmltag(preg_replace('/^options_/', '', $tmpproperty)).']'; + } else { + if (property_exists($object, $tmpproperty)) { + $object->$tmpproperty = $valuetouse; + } else { + $tmp[$tmpproperty] = $valuetouse; + } + + $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into object->'.dol_escape_htmltag($tmpproperty); + } } } else { $errorforthisaction++; @@ -1411,6 +1446,9 @@ class EmailCollector extends CommonObject try { //var_dump($Query->count()); + if ($mode > 0) { + $Query->leaveUnread(); + } $arrayofemail = $Query->limit($this->maxemailpercollect)->setFetchOrder("asc")->get(); //var_dump($arrayofemail); } catch (Exception $e) { @@ -1957,6 +1995,7 @@ class EmailCollector extends CommonObject $result = $contactstatic->fetch(0, null, '', $from); if ($result > 0) { + dol_syslog("We found a contact with the email ".$from); $contactid = $contactstatic->id; $contactfoundby = 'email of contact ('.$from.')'; if (empty($thirdpartyid) && $contactstatic->socid > 0) { @@ -1972,12 +2011,44 @@ class EmailCollector extends CommonObject if (empty($thirdpartyid)) { // Try to find thirdparty using email $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from); if ($result > 0) { + dol_syslog("We found a thirdparty with the email ".$from); + $thirdpartyid = $thirdpartystatic->id;; $thirdpartyfoundby = 'email ('.$from.')'; } } - // Do operations - if ($mode < 2) { + /* + if ($replyto) { + if (empty($contactid)) { // Try to find contact using email + $result = $contactstatic->fetch(0, null, '', $replyto); + + if ($result > 0) { + dol_syslog("We found a contact with the email ".$replyto); + $contactid = $contactstatic->id; + $contactfoundby = 'email of contact ('.$replyto.')'; + if (empty($thirdpartyid) && $contactstatic->socid > 0) { + $result = $thirdpartystatic->fetch($contactstatic->socid); + if ($result > 0) { + $thirdpartyid = $thirdpartystatic->id; + $thirdpartyfoundby = 'email of contact ('.$replyto.')'; + } + } + } + } + + if (empty($thirdpartyid)) { // Try to find thirdparty using email + $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); + if ($result > 0) { + dol_syslog("We found a thirdparty with the email ".$replyto); + $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyfoundby = 'email ('.$replyto.')'; + } + } + } + */ + + // Do operations (extract variables and creating data) + if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates foreach ($this->actions as $operation) { $errorforthisaction = 0; @@ -2118,6 +2189,23 @@ class EmailCollector extends CommonObject } if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty || $namealiastouseforthirdparty)) { + // We make another search on thirdparty + //$namealiastouseforthirdparty + + $tmpobject = new stdClass(); + $tmpobject->element == 'generic'; + $tmpobject->id = $idtouseforthirdparty; + $tmpobject->name = $nametouseforthirdparty; + $tmpobject->name_alias = $namealiastouseforthirdparty; + $tmpobject->email = $emailtouseforthirdparty; + + $this->overwritePropertiesOfObject($tmpobject, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + $idtouseforthirdparty = $tmpobject->id; + $nametouseforthirdparty = $tmpobject->name; + $namealiastouseforthirdparty = $tmpobject->name_alias; + $emailtouseforthirdparty = $tmpobject->name_alias; + $result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty, $namealiastouseforthirdparty); if ($result < 0) { $errorforactions++; @@ -2555,6 +2643,8 @@ class EmailCollector extends CommonObject } } } else { + dol_syslog("Project already exists for msgid = ".dol_escape_htmltag($msgid).", so we do not recreate it."); + $operationslog .= '
Project already exists for msgid ='.dol_escape_htmltag($msgid); } } elseif ($operation['type'] == 'ticket') { @@ -2824,9 +2914,9 @@ class EmailCollector extends CommonObject // Error for email or not ? if (!$errorforactions) { - if ($targetdir && empty($mode)) { + if (!empty($targetdir) && empty($mode)) { if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); $res = imap_mail_move($connection, $imapemail, $targetdir, 0); if ($res == false) { $errorforemail++; @@ -2835,7 +2925,9 @@ class EmailCollector extends CommonObject dol_syslog(imap_last_error()); } } else { - // TODO Move mail using PHP-IMAP + // Move mail using PHP-IMAP + dol_syslog("EmailCollector::doCollectOneCollector move message ".($imapemail->getHeader()->get('subject'))." to ".$targetdir, LOG_DEBUG); + $imapemail->move($targetdir); } } else { if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { From 1b19a30386a38e23c0520f313408a3771ea6af33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 18:00:46 +0200 Subject: [PATCH 050/159] Debug email collector --- .../class/emailcollector.class.php | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index ac1f1cf4cab..97dbc20551d 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -964,7 +964,11 @@ class EmailCollector extends CommonObject if (preg_match('/^options_/', $tmpproperty)) { $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->array_options[preg_replace('/^options_/', '', $tmpproperty)], 128)); } else { - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->$tmpproperty, 128)); + if (property_exists($object, $tmpproperty)) { + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->$tmpproperty, 128)); + } else { + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($tmp[$tmpproperty], 128)); + } } } else { // Regex not found @@ -2059,6 +2063,8 @@ class EmailCollector extends CommonObject continue; } + $operationslog .= '
* Process operation '.$operation['type']; + // Make Operation dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id); dol_syslog("Execute action fk_element_id=".$fk_element_id." fk_element_type=".$fk_element_type); // If a Dolibarr tracker id is found, we should now the id of object @@ -2096,6 +2102,8 @@ class EmailCollector extends CommonObject $emailtouseforthirdparty = ''; $namealiastouseforthirdparty = ''; + $operationslog .= '
Loop on each property to set into actionparam'; + // $actionparam = 'param=SET:aaa' or 'param=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { @@ -2127,21 +2135,21 @@ class EmailCollector extends CommonObject if ($propertytooverwrite == 'id') { $idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found idtouseforthirdparty='.dol_escape_htmltag($idtouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found idtouseforthirdparty='.dol_escape_htmltag($idtouseforthirdparty); } elseif ($propertytooverwrite == 'email') { $emailtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found emailtouseforthirdparty='.dol_escape_htmltag($emailtouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found emailtouseforthirdparty='.dol_escape_htmltag($emailtouseforthirdparty); } elseif ($propertytooverwrite == 'name') { $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); } elseif ($propertytooverwrite == 'name_alias') { - $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + $namealiastouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); } else { - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not used to search existing thirdparty'; + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not used to search existing thirdparty'; } } else { // Regex not found @@ -2150,7 +2158,7 @@ class EmailCollector extends CommonObject $emailtouseforthirdparty = null; $namealiastouseforthirdparty = null; - $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found'; + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found'; } //var_dump($object->$tmpproperty);exit; } else { @@ -2166,19 +2174,19 @@ class EmailCollector extends CommonObject if ($propertytooverwrite == 'id') { $idtouseforthirdparty = $reg[2]; - $operationslog .= '
We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty); } elseif ($propertytooverwrite == 'email') { $emailtouseforthirdparty = $reg[2]; - $operationslog .= '
We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty); } elseif ($propertytooverwrite == 'name') { $nametouseforthirdparty = $reg[2]; - $operationslog .= '
We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); } elseif ($propertytooverwrite == 'name_alias') { $namealiastouseforthirdparty = $reg[2]; - $operationslog .= '
We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); + $operationslog .= '
propertytooverwrite='.$propertytooverwrite.'We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); } } else { $errorforactions++; @@ -2190,7 +2198,7 @@ class EmailCollector extends CommonObject if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty || $namealiastouseforthirdparty)) { // We make another search on thirdparty - //$namealiastouseforthirdparty + $operationslog .= '
We have this data to search thirdparty: '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty; $tmpobject = new stdClass(); $tmpobject->element == 'generic'; @@ -2204,7 +2212,9 @@ class EmailCollector extends CommonObject $idtouseforthirdparty = $tmpobject->id; $nametouseforthirdparty = $tmpobject->name; $namealiastouseforthirdparty = $tmpobject->name_alias; - $emailtouseforthirdparty = $tmpobject->name_alias; + $emailtouseforthirdparty = $tmpobject->email; + + $operationslog .= '
We try to search existing thirdparty with '.$idtouseforthirdparty.' '.$emailtouseforthirdparty.' '.$nametouseforthirdparty.' '.$namealiastouseforthirdparty; $result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty, $namealiastouseforthirdparty); if ($result < 0) { @@ -2224,6 +2234,7 @@ class EmailCollector extends CommonObject dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." name_alias=".$namealiastouseforthirdparty." was not found. We try to create it."); // Create thirdparty + $thirdpartystatic = new Societe($db); $thirdpartystatic->name = $nametouseforthirdparty; if (!empty($namealiastouseforthirdparty)) { if ($namealiastouseforthirdparty != $nametouseforthirdparty) { @@ -2259,6 +2270,8 @@ class EmailCollector extends CommonObject } } else { dol_syslog("One and only one existing third party has been found"); + + $operationslog .= '
Thirdparty already exists with id = '.dol_escape_htmltag($thirdpartystatic->id); } } } From 5f1503d7eacfae0691c3b135d8d5e9ffb1e6d21c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 18:05:47 +0200 Subject: [PATCH 051/159] Log --- htdocs/emailcollector/class/emailcollector.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 97dbc20551d..7391d6e6acd 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1066,7 +1066,7 @@ class EmailCollector extends CommonObject require_once DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php'; } - dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id." - ".$this->ref, LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id." - ".$this->ref, LOG_INFO); $langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda", "commercial")); @@ -2994,6 +2994,7 @@ class EmailCollector extends CommonObject $client->disconnect(); } else { if (empty($mode) && empty($error)) { + dol_syslog("Expunge", LOG_DEBUG); imap_expunge($connection); // To validate any move } imap_close($connection); @@ -3022,7 +3023,7 @@ class EmailCollector extends CommonObject $this->update($user); } - dol_syslog("EmailCollector::doCollectOneCollector end", LOG_DEBUG); + dol_syslog("EmailCollector::doCollectOneCollector end", LOG_INFO); return $error ? -1 : 1; } From 66923ccf8c609cd3ec1ab32fd0b43cdee386abbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 18:47:54 +0200 Subject: [PATCH 052/159] Code comment --- htdocs/includes/webklex/php-imap/vendor/autoload.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/includes/webklex/php-imap/vendor/autoload.php b/htdocs/includes/webklex/php-imap/vendor/autoload.php index 298bedf9b9c..12f2cb6cb45 100644 --- a/htdocs/includes/webklex/php-imap/vendor/autoload.php +++ b/htdocs/includes/webklex/php-imap/vendor/autoload.php @@ -17,6 +17,13 @@ return ComposerAutoloaderInit4da13270269c89a28e472e1f7324e6d1::getLoader(); // Add class/method of PHP8 for compatibility with older versions of PHP require_once(__DIR__.'/symfony/polyfill-php80/bootstrap.php'); +//'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', +//'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', +//'60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php', +//'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', +//'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', +require_once(__DIR__.'/illuminate/collections/helpers.php'); + spl_autoload_register(function ($class_name) { // Enable this to detect what we need for require_once From 9ffc86a8726974001f33f631b076aa686b8d1882 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 18:49:15 +0200 Subject: [PATCH 053/159] Remove warning 8.2 --- htdocs/core/class/conf.class.php | 19 ++++++++++++++++++- test/phpunit/AllTests.php | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 756b2771e39..b3991ecfcf2 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -109,6 +109,24 @@ class Conf public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + // TODO Remove this part. + public $fournisseur; + public $product; + public $service; + public $contrat; + public $actions; + public $agenda; + public $commande; + public $propal; + public $facture; + public $user; + public $adherent; + public $bank; + public $notification; + public $expensereport; + public $productbatch; + + /** * Constructor @@ -165,7 +183,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(); diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index ba4d743f603..84ea7a42a6e 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -24,7 +24,7 @@ * \remarks To run this script as CLI: phpunit filename.php */ print "PHP Version: ".phpversion()."\n"; -print "Memory: ". ini_get('memory_limit')."\n"; +print "Memory limit: ". ini_get('memory_limit')."\n"; global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver From 45d79232d20c5275696132d9829ae0d66d381d90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 19:36:19 +0200 Subject: [PATCH 054/159] Clean code --- htdocs/product/class/product.class.php | 1 + test/phpunit/MouvementStockTest.php | 35 ++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 67002e48efb..db5ebf7bf4c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -871,6 +871,7 @@ class Product extends CommonObject $langs->load("products"); $error++; $this->error = "ErrorProductAlreadyExists"; + dol_syslog(get_class($this)."::Create fails, ref ".$this->ref." already exists"); } } else { $error++; diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index a781ea78e12..d084f50d6e0 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -146,41 +146,44 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase // We create a product for tests $product0=new Product($db); $product0->initAsSpecimen(); - $product0->ref.=' 0'; - $product0->label.=' 0'; + $product0->ref.=' phpunit 0'; + $product0->label.=' phpunit 0'; $product0->status_batch = 1; $product0id=$product0->create($user); + print __METHOD__." product0id=".$product0id."\n"; + $this->assertGreaterThan(0, $product0id, 'Failed to create product'); + $product1=new Product($db); $product1->initAsSpecimen(); - $product1->ref.=' 1'; - $product1->label.=' 1'; + $product1->ref.=' phpunit 1'; + $product1->label.=' phpunit 1'; $product1id=$product1->create($user); $product2=new Product($db); $product2->initAsSpecimen(); - $product2->ref.=' 2'; - $product2->label.=' 2'; + $product2->ref.=' phpunit 2'; + $product2->label.=' phpunit 2'; $product2id=$product2->create($user); // We create a product for tests $warehouse0=new Entrepot($db); $warehouse0->initAsSpecimen(); - $warehouse0->label.=' 0'; - $warehouse0->description.=' 0'; + $warehouse0->label.=' phpunit 0'; + $warehouse0->description.=' phpunit 0'; $warehouse0->statut = 0; $warehouse0id=$warehouse0->create($user); $warehouse1=new Entrepot($db); $warehouse1->initAsSpecimen(); - $warehouse1->label.=' 1'; - $warehouse1->description.=' 1'; + $warehouse1->label.=' phpunit 1'; + $warehouse1->description.=' phpunit 1'; $warehouse1id=$warehouse1->create($user); $warehouse2=new Entrepot($db); $warehouse2->initAsSpecimen(); - $warehouse2->label.=' 2'; - $warehouse2->description.=' 2'; + $warehouse2->label.=' phpunit 2'; + $warehouse2->description.=' phpunit 2'; $warehouse2id=$warehouse2->create($user); $localobject=new MouvementStock($this->savdb); @@ -188,10 +191,10 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $datetest1 = dol_mktime(0, 0, 0, 1, 1, 2000); $datetest2 = dol_mktime(0, 0, 0, 1, 2, 2000); - // Create an input movement movement (type = 3) with value for eatby date and a lot + // Create an input movement movement (type = 3) with value for eatby date and a lot $datetest1 $result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch'); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThan(0, $result, 'Failed to create a movement with a lot number of product with status_batch=1'); + $this->assertGreaterThan(0, $result, 'Failed to create a movement with a lot number '.$datetest1.' for product id='.$product0id.' with status_batch=1'); $result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberB', '', 0, 'Inventory Code Test with batch'); print __METHOD__." result=".$result."\n"; @@ -250,12 +253,12 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThan(0, $result); + $this->assertGreaterThan(0, $result, 'Test create A'); // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThan(0, $result); + $this->assertGreaterThan(0, $result, 'Test create B'); return $localobject; } From a8cd44cafccff61845b15f335840865a31bacc59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 22:17:15 +0200 Subject: [PATCH 055/159] Clean code --- test/phpunit/CategorieTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 3bd870914e3..1faab723bb2 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -259,11 +259,12 @@ class CategorieTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - $localobject->note='New note after update'; + $localobject->note_private ='New note after update'; $result=$localobject->update($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertGreaterThan(0, $result); + return $localobject; } @@ -288,8 +289,6 @@ class CategorieTest extends PHPUnit\Framework\TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); */ - $localobject2=new Categorie($db); - $localobject2->initAsSpecimen(); $retarray=$localobject->liste_photos('/'); print __METHOD__." retarray size=".count($retarray)."\n"; From bc711b05040315220a359cbb0bcc772cae49ff02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Apr 2023 22:20:54 +0200 Subject: [PATCH 056/159] FIX Deployment of external module failed with copy dir error. --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ac8ff6161a9..f6e281f5e2d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -231,7 +231,7 @@ if ($action == 'install') { if (!$error) { @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the target directory $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulenameval; - if (!dol_is_dir($modulenamedir)) { + if (!dol_is_dir($submodulenamedir)) { $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval; } dol_syslog("We copy now directory ".$submodulenamedir." into target dir ".$dirins.'/'.$modulenameval); From c552633095140f68ece17b3d6a6b715a15e1964a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 00:13:06 +0200 Subject: [PATCH 057/159] Log --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index f6e281f5e2d..226ab6d70b3 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -443,7 +443,7 @@ foreach ($modulesdir as $dir) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } else { - print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; + print "admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); From 28c625dc6b286835c09e5660e1b83232131c3fbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 03:38:25 +0200 Subject: [PATCH 058/159] NEW Show main currency in company info user tooltip --- htdocs/main.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ce7a7a9ec8d..8ca8d5e06af 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2312,7 +2312,9 @@ function top_menu_user($hideloginname = 0, $urllogout = '') } $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA"), 'VAT').''; $dropdownBody .= '
'.$langs->trans("Country").': '.($mysoc->country_code ? $langs->trans("Country".$mysoc->country_code) : '').''; - + if (isModEnabled('multicurrency')) { + $dropdownBody .= '
'.$langs->trans("Currency").': '.$conf->currency.''; + } $dropdownBody .= ''; $dropdownBody .= '
'; From 8e63baeeab889e7f5c93152ef251566af1c28935 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 04:50:40 +0200 Subject: [PATCH 059/159] Debug v18 --- htdocs/compta/bank/transfer.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 724e09554db..62e85558ed1 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -114,13 +114,13 @@ if ($action == 'add') { if (!$errori[$n]) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountfrom = new Account($db); - $accountfrom->fetch(GETPOST($n.'_account_from', 'int')); + $tmpaccountfrom = new Account($db); + $tmpaccountfrom->fetch(GETPOST($n.'_account_from', 'int')); - $accountto = new Account($db); - $accountto->fetch(GETPOST($n.'_account_to', 'int')); + $tmpaccountto = new Account($db); + $tmpaccountto->fetch(GETPOST($n.'_account_to', 'int')); - if ($accountto->currency_code == $accountfrom->currency_code) { + if ($tmpaccountto->currency_code == $tmpaccountfrom->currency_code) { $amountto[$n] = $amount[$n]; } else { if (!$amountto[$n]) { @@ -133,7 +133,7 @@ if ($action == 'add') { setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors'); } - if ($accountto->id == $accountfrom->id) { + if ($tmpaccountto->id == $tmpaccountfrom->id) { $errori[$n]++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors'); } @@ -149,45 +149,45 @@ if ($action == 'add') { // By default, electronic transfert from bank to bank $typefrom = $type[$n]; $typeto = $type[$n]; - if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { + if ($tmpaccountto->courant == Account::TYPE_CASH || $tmpaccountfrom->courant == Account::TYPE_CASH) { // This is transfer of change $typefrom = 'LIQ'; $typeto = 'LIQ'; } if (!$errori[$n]) { - $bank_line_id_from = $accountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); + $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); } if (!($bank_line_id_from > 0)) { $errori[$n]++; } if (!$errori[$n]) { - $bank_line_id_to = $accountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user); + $bank_line_id_to = $tmpaccountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user); } if (!($bank_line_id_to > 0)) { $errori[$n]++; } if (!$errori[$n]) { - $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + $result = $tmpaccountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { $errori++; } if (!$errori[$n]) { - $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + $result = $tmpaccountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { $errori[$n]++; } if (!$errori[$n]) { $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); - $mesgs = str_replace('{s1}', ''.$accountfrom->label.'', $mesgs); - $mesgs = str_replace('{s2}', ''.$accountto->label.'', $mesgs); + $mesgs = str_replace('{s1}', ''.$tmpaccountfrom->label.'', $mesgs); + $mesgs = str_replace('{s2}', ''.$tmpaccountto->label.'', $mesgs); setEventMessages($mesgs, null, 'mesgs'); $db->commit(); } else { - setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors'); + setEventMessages($tmpaccountfrom->error.' '.$tmpaccountto->error, null, 'errors'); $db->rollback(); } } From 0d8d2528b040008c1767a13b0b07a5ce8a37de9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 06:08:06 +0200 Subject: [PATCH 060/159] Clean code --- htdocs/compta/bank/transfer.php | 93 +++++++++---------------- htdocs/core/ajax/getaccountcurrency.php | 66 ------------------ 2 files changed, 34 insertions(+), 125 deletions(-) delete mode 100644 htdocs/core/ajax/getaccountcurrency.php diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 62e85558ed1..2e7425dca98 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -76,7 +76,7 @@ if ($action == 'add') { $errori[$i] = 0; $tabnum[$i] = 0; - if (!empty($label[$i]) || !empty($type[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) { + if (!empty($label[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) { $tabnum[$i] = 1; } $i++; @@ -124,7 +124,7 @@ if ($action == 'add') { $amountto[$n] = $amount[$n]; } else { if (!$amountto[$n]) { - $error[$n]++; + $errori[$n]++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors'); } } @@ -172,7 +172,7 @@ if ($action == 'add') { $result = $tmpaccountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { - $errori++; + $errori[$n]++; } if (!$errori[$n]) { $result = $tmpaccountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); @@ -211,68 +211,38 @@ llxHeader('', $title, $help_url); print ' '; @@ -298,16 +268,18 @@ print ''.$langs->trans("Type").''; print ''.$langs->trans("Date").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("Amount").''; -//print ''.$langs->trans("AmountToOthercurrency").''; +print ''.$langs->trans("AmountToOthercurrency").''; print ''; for ($i = 1 ; $i < $MAXLINES; $i++) { $label = ''; $amount = ''; + $amounto = ''; if ($errori[$i]) { $label = GETPOST($i.'_label', 'alpha'); $amount = GETPOST($i.'_amount', 'alpha'); + $amountto = GETPOST($i.'_amountto', 'alpha'); } if ($i == 1) { @@ -339,11 +311,14 @@ for ($i = 1 ; $i < $MAXLINES; $i++) { print $form->selectDate((!empty($dateo[$i]) ? $dateo[$i] : ''), $i.'_', '', '', '', 'add'); print "\n"; + // Description print ''; + // Amount print ''; - print ''; + // AmountToOthercurrency + print ''; print ''; } @@ -352,7 +327,7 @@ print ''; print ''; print ''; print '
'; -print ' +print ' '; diff --git a/htdocs/core/ajax/getaccountcurrency.php b/htdocs/core/ajax/getaccountcurrency.php deleted file mode 100644 index 20061dcdf2b..00000000000 --- a/htdocs/core/ajax/getaccountcurrency.php +++ /dev/null @@ -1,66 +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 htdocs/core/ajax/getaccountcurrency.php - * \brief File to load currency rates - */ - -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Disables token renewal -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} - -// Load Dolibarr environment -require '../../main.inc.php'; - -$id = GETPOST('id', 'int'); - -// Security check -$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account'); - - -/* - * View - */ - -top_httphead(); - -//print ''."\n"; - -// Load original field value -if (!empty($id)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account = new Account($db); - $result = $account->fetch($id); - if ($result < 0) { - $return['value'] = ''; - $return['num'] = $result; - $return['error'] = $account->errors[0]; - } else { - $return['value'] = $account->currency_code; - $return['num'] = $result; - $return['error'] = ''; - } - - echo json_encode($return); -} From a2d9de14acb53f1f984155bac8e2d9b33d935e2c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 12 Apr 2023 12:03:27 +0200 Subject: [PATCH 061/159] FIX: Propagate vat-reverse charge when supplier invoice is created from reception list --- htdocs/reception/list.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index fe47b95fb1e..d348252efeb 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -2,7 +2,8 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2023 Alexandre Spangaro * * 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 @@ -345,6 +346,9 @@ if (empty($reshook)) { $objecttmp->remise_absolue = $remise_absolue; $objecttmp->transport_mode_id = $transport_mode_id; + // if the VAT reverse-charge is activated by default in supplier card to resume the information + $objecttmp->vat_reverse_charge = $soc->vat_reverse_charge; + $objecttmp->fk_project = $rcp->fk_project; //$objecttmp->multicurrency_code = $rcp->multicurrency_code; if (empty($createbills_onebythird)) { From b577457c86c5693e9f7b71c26b491cb2ed4682a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 14:50:19 +0200 Subject: [PATCH 062/159] css --- htdocs/projet/class/project.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 1e4c6862c58..edf26bcd292 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -307,7 +307,7 @@ class Project extends CommonObject 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>410), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModification', 'enabled'=>1, 'visible'=>0, 'position'=>415), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'position'=>420), - 'email_msgid'=>array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'enabled'=>1, 'visible'=>-1, 'position'=>450, 'help'=>'EmailMsgIDWhenSourceisEmail'), + 'email_msgid'=>array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'enabled'=>1, 'visible'=>-1, 'position'=>450, 'help'=>'EmailMsgIDWhenSourceisEmail', 'csslist'=>'tdoverflowmax125'), 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), ); // END MODULEBUILDER PROPERTIES From 24fdec736bd72d0f58bfc85b98590deb0653820e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 14:53:54 +0200 Subject: [PATCH 063/159] Fix missing escape html --- htdocs/projet/list.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 671f528483b..a85817704a5 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1793,10 +1793,12 @@ while ($i < $imaxinloop) { } // Email MsgID if (!empty($arrayfields['p.email_msgid']['checked'])) { - print ''; - print $obj->email_msgid; + print ''; + print dol_escape_htmltag($obj->email_msgid); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Import key if (!empty($arrayfields['p.import_key']['checked'])) { From 949e288ce03fe1554bb4c1992e9455b3334a51de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 16:01:07 +0200 Subject: [PATCH 064/159] Fix search on not with imapv2 --- .../class/emailcollector.class.php | 500 ++++++++++-------- 1 file changed, 269 insertions(+), 231 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f7d8ea37649..0452e74f6d1 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -440,15 +440,15 @@ class EmailCollector extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ /* - public function fetchLines() - { - $this->lines=array(); + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - } - */ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -1096,6 +1096,8 @@ class EmailCollector extends CommonObject $searchfilterisanswer = 0; $searchfilterisnotanswer = 0; $searchfilterreplyto = 0; + $searchfilterexcludebody = ''; + $searchfilterexcludesubject = ''; $operationslog = ''; $now = dol_now(); @@ -1154,7 +1156,7 @@ class EmailCollector extends CommonObject getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE') - ); + ); $serviceFactory = new \OAuth\ServiceFactory(); $oauthname = explode('-', $OAUTH_SERVICENAME); // ex service is Google-Emails we need only the first part Google @@ -1285,10 +1287,20 @@ class EmailCollector extends CommonObject array_push($criteria, array($not."CC" => $rule['rulevalue'])); } if ($rule['type'] == 'subject') { - array_push($criteria, array($not."SUBJECT" => $rule['rulevalue'])); + if (strpos($rule['rulevalue'], '!') === 0) { + //array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue'])); + $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + array_push($criteria, array("SUBJECT" => $rule['rulevalue'])); + } } if ($rule['type'] == 'body') { - array_push($criteria, array($not."BODY" => $rule['rulevalue'])); + if (strpos($rule['rulevalue'], '!') === 0) { + //array_push($criteria, array("NOT BODY" => $rule['rulevalue'])); + $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + array_push($criteria, array("BODY" => $rule['rulevalue'])); + } } if ($rule['type'] == 'header') { array_push($criteria, array($not."HEADER" => $rule['rulevalue'])); @@ -1296,12 +1308,12 @@ class EmailCollector extends CommonObject /* seems not used */ /* - if ($rule['type'] == 'notinsubject') { - array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue'])); - } - if ($rule['type'] == 'notinbody') { - array_push($criteria, array($not."BODY NOT" => $rule['rulevalue'])); - }*/ + if ($rule['type'] == 'notinsubject') { + array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue'])); + } + if ($rule['type'] == 'notinbody') { + array_push($criteria, array($not."BODY NOT" => $rule['rulevalue'])); + }*/ if ($rule['type'] == 'seen') { array_push($criteria, array($not."SEEN")); @@ -1406,10 +1418,20 @@ class EmailCollector extends CommonObject $search .= ($search ? ' ' : '').$not.'CC'; } if ($rule['type'] == 'subject') { - $search .= ($search ? ' ' : '').$not.'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if (strpos($rule['rulevalue'], '!') === 0) { + //$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + } } if ($rule['type'] == 'body') { - $search .= ($search ? ' ' : '').$not.'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if (strpos($rule['rulevalue'], '!') === 0) { + //$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + } } if ($rule['type'] == 'header') { $search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue']; @@ -1417,12 +1439,12 @@ class EmailCollector extends CommonObject /* seems not used */ /* - if ($rule['type'] == 'notinsubject') { - $search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; - } - if ($rule['type'] == 'notinbody') { - $search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; - }*/ + if ($rule['type'] == 'notinsubject') { + $search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + } + if ($rule['type'] == 'notinbody') { + $search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + }*/ if ($rule['type'] == 'seen') { $search .= ($search ? ' ' : '').$not.'SEEN'; @@ -1538,19 +1560,19 @@ class EmailCollector extends CommonObject if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) { // Loop to get part html and plain /* - 0 multipart/mixed - 1 multipart/alternative - 1.1 text/plain - 1.2 text/html - 2 message/rfc822 - 2 multipart/mixed - 2.1 multipart/alternative - 2.1.1 text/plain - 2.1.2 text/html - 2.2 message/rfc822 - 2.2 multipart/alternative - 2.2.1 text/plain - 2.2.2 text/html + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html */ dol_syslog("Start of loop on email", LOG_INFO, 1); @@ -1684,8 +1706,6 @@ class EmailCollector extends CommonObject $ticketfoundby = ''; $candidaturefoundby = ''; - $this->db->begin(); - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']); @@ -1719,7 +1739,7 @@ class EmailCollector extends CommonObject $attachments = []; } } else { - $this->getmsg($connection, $imapemail); + $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments } //print $plainmsg; //var_dump($plainmsg); exit; @@ -1729,6 +1749,15 @@ class EmailCollector extends CommonObject // Removed emojis $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + if ($searchfilterexcludebody) { + if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email body contains string '.$searchfilterexcludebody; + dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody); + continue; // Exclude email + } + } + //var_dump($plainmsg); //var_dump($htmlmsg); //var_dump($messagetext); @@ -1738,45 +1767,45 @@ class EmailCollector extends CommonObject // Parse IMAP email structure /* - $structure = imap_fetchstructure($connection, $imapemail, 0); + $structure = imap_fetchstructure($connection, $imapemail, 0); - $partplain = $parthtml = -1; - $encodingplain = $encodinghtml = ''; + $partplain = $parthtml = -1; + $encodingplain = $encodinghtml = ''; - $result = createPartArray($structure, ''); + $result = createPartArray($structure, ''); - foreach($result as $part) - { - // $part['part_object']->type seems 0 for content - // $part['part_object']->type seems 5 for attachment - if (empty($part['part_object'])) continue; - if ($part['part_object']->subtype == 'HTML') - { - $parthtml=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodinghtml = 'aaa'; - } - } - if ($part['part_object']->subtype == 'PLAIN') - { - $partplain=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodingplain = 'rr'; - } - } - } - //var_dump($result); - //var_dump($partplain); - //var_dump($parthtml); + foreach($result as $part) + { + // $part['part_object']->type seems 0 for content + // $part['part_object']->type seems 5 for attachment + if (empty($part['part_object'])) continue; + if ($part['part_object']->subtype == 'HTML') + { + $parthtml=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodinghtml = 'aaa'; + } + } + if ($part['part_object']->subtype == 'PLAIN') + { + $partplain=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodingplain = 'rr'; + } + } + } + //var_dump($result); + //var_dump($partplain); + //var_dump($parthtml); - //var_dump($structure); - //var_dump($parthtml); - //var_dump($partplain); + //var_dump($structure); + //var_dump($parthtml); + //var_dump($partplain); - $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); - */ + $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); + */ //var_dump($messagetext); //var_dump($structure->parts[0]->parts); @@ -1812,6 +1841,14 @@ class EmailCollector extends CommonObject //var_dump($msgid);exit; } + if ($searchfilterexcludesubject) { + if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email subject contains string '.$searchfilterexcludesubject; + dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject); + continue; // Exclude email + } + } $reg = array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { @@ -1830,6 +1867,7 @@ class EmailCollector extends CommonObject } $fk_element_id = 0; $fk_element_type = ''; + $this->db->begin(); $contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0; @@ -1918,11 +1956,11 @@ class EmailCollector extends CommonObject $objectemail = new Adherent($this->db); } /*if ($reg[1] == 'leav') { // Leave / Holiday - $objectemail = new Holiday($db); - } - if ($reg[1] == 'exp') { // ExpenseReport - $objectemail = new ExpenseReport($db); - }*/ + $objectemail = new Holiday($db); + } + if ($reg[1] == 'exp') { // ExpenseReport + $objectemail = new ExpenseReport($db); + }*/ } elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) { // This is an external reference, we check if we have it in our database if (!is_object($objectemail)) { @@ -2081,34 +2119,34 @@ class EmailCollector extends CommonObject } /* - if ($replyto) { - if (empty($contactid)) { // Try to find contact using email - $result = $contactstatic->fetch(0, null, '', $replyto); + if ($replyto) { + if (empty($contactid)) { // Try to find contact using email + $result = $contactstatic->fetch(0, null, '', $replyto); - if ($result > 0) { - dol_syslog("We found a contact with the email ".$replyto); - $contactid = $contactstatic->id; - $contactfoundby = 'email of contact ('.$replyto.')'; - if (empty($thirdpartyid) && $contactstatic->socid > 0) { - $result = $thirdpartystatic->fetch($contactstatic->socid); - if ($result > 0) { - $thirdpartyid = $thirdpartystatic->id; - $thirdpartyfoundby = 'email of contact ('.$replyto.')'; - } - } - } - } + if ($result > 0) { + dol_syslog("We found a contact with the email ".$replyto); + $contactid = $contactstatic->id; + $contactfoundby = 'email of contact ('.$replyto.')'; + if (empty($thirdpartyid) && $contactstatic->socid > 0) { + $result = $thirdpartystatic->fetch($contactstatic->socid); + if ($result > 0) { + $thirdpartyid = $thirdpartystatic->id; + $thirdpartyfoundby = 'email of contact ('.$replyto.')'; + } + } + } + } - if (empty($thirdpartyid)) { // Try to find thirdparty using email - $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); - if ($result > 0) { - dol_syslog("We found a thirdparty with the email ".$replyto); - $thirdpartyid = $thirdpartystatic->id;; - $thirdpartyfoundby = 'email ('.$replyto.')'; - } - } - } - */ + if (empty($thirdpartyid)) { // Try to find thirdparty using email + $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); + if ($result > 0) { + dol_syslog("We found a thirdparty with the email ".$replyto); + $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyfoundby = 'email ('.$replyto.')'; + } + } + } + */ // Do operations (extract variables and creating data) if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates @@ -2549,98 +2587,98 @@ class EmailCollector extends CommonObject $this->errors[] = 'User Not allowed to add documents'; } $arrayobject = array( - 'propale' => array('table' => 'propal', - 'fields' => array('ref'), - 'class' => 'comm/propal/class/propal.class.php', - 'object' => 'Propal'), - 'holiday' => array('table' => 'holiday', - 'fields' => array('ref'), - 'class' => 'holiday/class/holiday.class.php', - 'object' => 'Holiday'), - 'expensereport' => array('table' => 'expensereport', - 'fields' => array('ref'), - 'class' => 'expensereport/class/expensereport.class.php', - 'object' => 'ExpenseReport'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentjobposition.class.php', - 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentcandidature.class.php', - 'object' => ' RecruitmentCandidature'), - 'societe' => array('table' => 'societe', - 'fields' => array('code_client', 'code_fournisseur'), - 'class' => 'societe/class/societe.class.php', - 'object' => 'Societe'), - 'commande' => array('table' => 'commande', - 'fields' => array('ref'), - 'class' => 'commande/class/commande.class.php', - 'object' => 'Commande'), - 'expedition' => array('table' => 'expedition', - 'fields' => array('ref'), - 'class' => 'expedition/class/expedition.class.php', - 'object' => 'Expedition'), - 'contract' => array('table' => 'contrat', - 'fields' => array('ref'), - 'class' => 'contrat/class/contrat.class.php', - 'object' => 'Contrat'), - 'fichinter' => array('table' => 'fichinter', - 'fields' => array('ref'), - 'class' => 'fichinter/class/fichinter.class.php', - 'object' => 'Fichinter'), - 'ticket' => array('table' => 'ticket', - 'fields' => array('ref'), - 'class' => 'ticket/class/ticket.class.php', - 'object' => 'Ticket'), - 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', - 'fields' => array('ref'), - 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', - 'object' => 'KnowledgeRecord'), - 'supplier_proposal' => array('table' => 'supplier_proposal', - 'fields' => array('ref'), - 'class' => 'supplier_proposal/class/supplier_proposal.class.php', - 'object' => 'SupplierProposal'), - 'fournisseur/commande' => array('table' => 'commande_fournisseur', - 'fields' => array('ref', 'ref_supplier'), - 'class' => 'fourn/class/fournisseur.commande.class.php', - 'object' => 'SupplierProposal'), - 'facture' => array('table' => 'facture', - 'fields' => array('ref'), - 'class' => 'compta/facture/class/facture.class.php', - 'object' => 'Facture'), - 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', 'ref_client'), - 'class' => 'fourn/class/fournisseur.facture.class.php', - 'object' => 'FactureFournisseur'), - 'produit' => array('table' => 'product', - 'fields' => array('ref'), - 'class' => 'product/class/product.class.php', - 'object' => 'Product'), - 'productlot' => array('table' => 'product_lot', - 'fields' => array('batch'), - 'class' => 'product/stock/class/productlot.class.php', - 'object' => 'Productlot'), - 'projet' => array('table' => 'projet', - 'fields' => array('ref'), - 'class' => 'projet/class/projet.class.php', - 'object' => 'Project'), - 'projet_task' => array('table' => 'projet_task', - 'fields' => array('ref'), - 'class' => 'projet/class/task.class.php', - 'object' => 'Task'), - 'ressource' => array('table' => 'resource', - 'fields' => array('ref'), - 'class' => 'ressource/class/dolressource.class.php', - 'object' => 'Dolresource'), - 'bom' => array('table' => 'bom_bom', - 'fields' => array('ref'), - 'class' => 'bom/class/bom.class.php', - 'object' => 'BOM'), - 'mrp' => array('table' => 'mrp_mo', - 'fields' => array('ref'), - 'class' => 'mrp/class/mo.class.php', - 'object' => 'Mo'), + 'propale' => array('table' => 'propal', + 'fields' => array('ref'), + 'class' => 'comm/propal/class/propal.class.php', + 'object' => 'Propal'), + 'holiday' => array('table' => 'holiday', + 'fields' => array('ref'), + 'class' => 'holiday/class/holiday.class.php', + 'object' => 'Holiday'), + 'expensereport' => array('table' => 'expensereport', + 'fields' => array('ref'), + 'class' => 'expensereport/class/expensereport.class.php', + 'object' => 'ExpenseReport'), + 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentjobposition.class.php', + 'object' => 'RecruitmentJobPosition'), + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentcandidature.class.php', + 'object' => ' RecruitmentCandidature'), + 'societe' => array('table' => 'societe', + 'fields' => array('code_client', 'code_fournisseur'), + 'class' => 'societe/class/societe.class.php', + 'object' => 'Societe'), + 'commande' => array('table' => 'commande', + 'fields' => array('ref'), + 'class' => 'commande/class/commande.class.php', + 'object' => 'Commande'), + 'expedition' => array('table' => 'expedition', + 'fields' => array('ref'), + 'class' => 'expedition/class/expedition.class.php', + 'object' => 'Expedition'), + 'contract' => array('table' => 'contrat', + 'fields' => array('ref'), + 'class' => 'contrat/class/contrat.class.php', + 'object' => 'Contrat'), + 'fichinter' => array('table' => 'fichinter', + 'fields' => array('ref'), + 'class' => 'fichinter/class/fichinter.class.php', + 'object' => 'Fichinter'), + 'ticket' => array('table' => 'ticket', + 'fields' => array('ref'), + 'class' => 'ticket/class/ticket.class.php', + 'object' => 'Ticket'), + 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', + 'fields' => array('ref'), + 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', + 'object' => 'KnowledgeRecord'), + 'supplier_proposal' => array('table' => 'supplier_proposal', + 'fields' => array('ref'), + 'class' => 'supplier_proposal/class/supplier_proposal.class.php', + 'object' => 'SupplierProposal'), + 'fournisseur/commande' => array('table' => 'commande_fournisseur', + 'fields' => array('ref', 'ref_supplier'), + 'class' => 'fourn/class/fournisseur.commande.class.php', + 'object' => 'SupplierProposal'), + 'facture' => array('table' => 'facture', + 'fields' => array('ref'), + 'class' => 'compta/facture/class/facture.class.php', + 'object' => 'Facture'), + 'fournisseur/facture' => array('table' => 'facture_fourn', + 'fields' => array('ref', 'ref_client'), + 'class' => 'fourn/class/fournisseur.facture.class.php', + 'object' => 'FactureFournisseur'), + 'produit' => array('table' => 'product', + 'fields' => array('ref'), + 'class' => 'product/class/product.class.php', + 'object' => 'Product'), + 'productlot' => array('table' => 'product_lot', + 'fields' => array('batch'), + 'class' => 'product/stock/class/productlot.class.php', + 'object' => 'Productlot'), + 'projet' => array('table' => 'projet', + 'fields' => array('ref'), + 'class' => 'projet/class/projet.class.php', + 'object' => 'Project'), + 'projet_task' => array('table' => 'projet_task', + 'fields' => array('ref'), + 'class' => 'projet/class/task.class.php', + 'object' => 'Task'), + 'ressource' => array('table' => 'resource', + 'fields' => array('ref'), + 'class' => 'ressource/class/dolressource.class.php', + 'object' => 'Dolresource'), + 'bom' => array('table' => 'bom_bom', + 'fields' => array('ref'), + 'class' => 'bom/class/bom.class.php', + 'object' => 'BOM'), + 'mrp' => array('table' => 'mrp_mo', + 'fields' => array('ref'), + 'class' => 'mrp/class/mo.class.php', + 'object' => 'Mo'), ); if (!is_object($hookmanager)) { @@ -2997,43 +3035,43 @@ class EmailCollector extends CommonObject // Set candidature ref if not yet defined /*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status - { - // Get next Ref - $defaultref = ''; - $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; + { + // Get next Ref + $defaultref = ''; + $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; - // Search template files - $file = ''; $classname = ''; $filefound = 0; $reldir = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); - if (file_exists($file)) { - $filefound = 1; - $classname = $modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + if (file_exists($file)) { + $filefound = 1; + $classname = $modele; + break; + } + } - if ($filefound) { - if ($savesocid > 0) { - if ($savesocid != $candidaturetocreate->socid) { - $errorforactions++; - setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); - } - } else { - if ($candidaturetocreate->socid > 0) - { - $thirdpartystatic->fetch($candidaturetocreate->socid); - } - } + if ($filefound) { + if ($savesocid > 0) { + if ($savesocid != $candidaturetocreate->socid) { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); + } + } else { + if ($candidaturetocreate->socid > 0) + { + $thirdpartystatic->fetch($candidaturetocreate->socid); + } + } - $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); - $modModuleToUseForNextValue = new $classname; - $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); - } - $candidaturetocreate->ref = $defaultref; - }*/ + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $modModuleToUseForNextValue = new $classname; + $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); + } + $candidaturetocreate->ref = $defaultref; + }*/ if ($errorforthisaction) { $errorforactions++; From 778093f38271d672fa6c8d5235febc3e38649fdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 16:45:32 +0200 Subject: [PATCH 065/159] Log --- htdocs/emailcollector/class/emailcollector.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 0452e74f6d1..3afca8464fa 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1589,6 +1589,8 @@ class EmailCollector extends CommonObject $header = $imapemail->getHeader()->raw; $overview = $imapemail->getAttributes(); } else { + $operationslog .= '
email = '.((string) $imapemail); + //$header = imap_headerinfo($connection, $imapemail); $header = imap_fetchheader($connection, $imapemail, 0); $overview = imap_fetch_overview($connection, $imapemail, 0); @@ -3139,11 +3141,16 @@ class EmailCollector extends CommonObject if (!empty($targetdir) && empty($mode)) { if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); + $operationslog .= '
Move mail '.((string) $imapemail); + $res = imap_mail_move($connection, $imapemail, $targetdir, 0); if ($res == false) { $errorforemail++; $this->error = imap_last_error(); $this->errors[] = $this->error; + + $operationslog .= '
Error in move '.$this->error; + dol_syslog(imap_last_error()); } } else { @@ -3199,6 +3206,7 @@ class EmailCollector extends CommonObject $output = $langs->trans('NoNewEmailToProcess'); } + // Disconnect if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $client->disconnect(); } else { From c510b7d4df482342e6d99eb0e0cd418681732cc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 18:13:51 +0200 Subject: [PATCH 066/159] Add hidden search parameter search_current_entity --- htdocs/admin/defaultvalues.php | 7 ++++++- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/projet/list.php | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 6b0b722b629..81f1da40615 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -383,7 +383,12 @@ if (!is_array($result) && $result < 0) { print ''; } - print ''; + // Multicompany + print ''; + if (isModEnabled('multicompany')) { + print dol_escape_htmltag($defaultvalue->entity); + } + print ''; // Actions print ''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ca0dd2f04bf..f604a9b9185 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -305,7 +305,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // 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).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e7e8cc40b68..65cf2238491 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -117,6 +117,7 @@ $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_import_key = GETPOST('search_import_key', 'alpha'); +$search_current_entity = GETPOST('search_current_entity', 'alpha'); $searchCategoryCustomerOperator = 0; if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int'); @@ -473,7 +474,7 @@ if ($search_project_contact > 0) { $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= " WHERE p.entity IN (".getEntity('project').')'; +$sql .= " WHERE p.entity IN (".getEntity('project', $search_current_entity ? 0 : 1).')'; if (empty($user->rights->projet->all->lire)) { $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } From 9821833d0d9f9c85597a474bd4b85e2f6278a25f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Apr 2023 18:18:55 +0200 Subject: [PATCH 067/159] Clean code --- htdocs/projet/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 65cf2238491..445e370d85d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -117,7 +117,6 @@ $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_import_key = GETPOST('search_import_key', 'alpha'); -$search_current_entity = GETPOST('search_current_entity', 'alpha'); $searchCategoryCustomerOperator = 0; if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int'); @@ -474,7 +473,7 @@ if ($search_project_contact > 0) { $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= " WHERE p.entity IN (".getEntity('project', $search_current_entity ? 0 : 1).')'; +$sql .= " WHERE p.entity IN (".getEntity('project', (GETPOST('search_current_entity', 'int') ? 0 : 1)).')'; if (empty($user->rights->projet->all->lire)) { $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } From a52e7b1a570110a661442cf9209fd0e5c94167ca Mon Sep 17 00:00:00 2001 From: priojk Date: Wed, 12 Apr 2023 21:23:49 +0200 Subject: [PATCH 068/159] rename action from makeorder to createorder --- htdocs/fourn/commande/card.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79c9fe49b4..090a5d666e9 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -8,9 +8,10 @@ * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ion Agorria - * Copyright (C) 2018-2019 Frédéric France - * Copyright (C) 2022 Gauthier VERDOL - * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Joachim Kueter * * 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 @@ -1047,7 +1048,7 @@ if (empty($reshook)) { $action = ''; } elseif ($methodecommande <= 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors'); - $action = 'makeorder'; + $action = 'createorder'; } } @@ -2437,7 +2438,7 @@ if ($action == 'create') { */ if ($user->socid == 0 && $action != 'delete') { - if ($action != 'makeorder' && $action != 'presend' && $action != 'editline') { + if ($action != 'createorder' && $action != 'presend' && $action != 'editline') { print '
'; $parameters = array(); @@ -2568,7 +2569,7 @@ if ($action == 'create') { if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { if ($usercanorder) { - print ''; + print ''; } else { print ''; } @@ -2636,7 +2637,7 @@ if ($action == 'create') { print "
"; } - if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') { + if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'createorder') { // Set status to ordered (action=commande) print ''."\n"; print '
'; @@ -2677,7 +2678,7 @@ if ($action == 'create') { $action = 'presend'; } - if ($action != 'makeorder' && $action != 'presend' ) { + if ($action != 'createorder' && $action != 'presend' ) { print '
'; // Generated documents From a43674477a9e58ff2ea427fd5f2f028a9ed7fa1c Mon Sep 17 00:00:00 2001 From: priojk Date: Wed, 12 Apr 2023 21:51:58 +0200 Subject: [PATCH 069/159] revert preliminary fix from v17 --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c0c22a94ec1..f13e00c3b8d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -20,6 +20,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Joachim Kueter * * 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 @@ -619,7 +620,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } } if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - if (!empty($_GET['action']) && (preg_match('/^create|^add_price|^make/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { + if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Now search in setup to overwrite default values if (!empty($user->default_values)) { // $user->default_values defined from menu 'Setup - Default values' if (isset($user->default_values[$relativepathstring]['createform'])) { From 845f888caac6e298eb965b08c7b53fd271024f7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 10:40:27 +0200 Subject: [PATCH 070/159] Add note --- htdocs/public/eventorganization/attendee_new.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 56af2b78a44..2372428a5ad 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -724,6 +724,9 @@ if ($project->date_start_event || $project->date_end_event) { if ($project->location) { print ''.dol_escape_htmltag($project->location).'
'; } +if ($project->note_public) { + print '
'.dol_escape_htmltag($project->note_public).'
'; +} print '
'; From 4fe73e1fc3bf72c70f8bd56c9ac1c7a260796272 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 10:40:57 +0200 Subject: [PATCH 071/159] Fix duplicate defined --- htdocs/public/eventorganization/attendee_new.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 1b9a555f246..f74c5b8fa24 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -34,9 +34,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -553,8 +551,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen // Add link between invoice and the attendee registration /*if (!$error) { - $facture->add_object_linked($confattendee->element, $confattendee->id); - }*/ + $facture->add_object_linked($confattendee->element, $confattendee->id); + }*/ } if (!$error) { @@ -726,6 +724,9 @@ if ($project->date_start_event || $project->date_end_event) { if ($project->location) { print ''.dol_escape_htmltag($project->location).'
'; } +if ($project->note_public) { + print '
'.dol_escape_htmltag($project->note_public).'
'; +} print '
'; From fbe8e2731d7584fd3fcdb9e3394a857b7c72e656 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 12:58:06 +0200 Subject: [PATCH 072/159] Fix escapment --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/public/eventorganization/attendee_new.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c306005cffe..0f8ee157340 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1488,7 +1488,7 @@ function dol_escape_json($stringtoescape) * @param string $noescapetags '' or 'common' or list of tags to not escape. TODO Does not works yet when there is attributes into tag. * @param int $escapeonlyhtmltags 1=Escape only html tags, not the special chars like accents. * @return string Escaped string - * @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent() + * @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent(), dol_htmlentitiesbr() */ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags = '', $escapeonlyhtmltags = 0) { diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index f74c5b8fa24..043e52f5808 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -725,7 +725,7 @@ if ($project->location) { print ''.dol_escape_htmltag($project->location).'
'; } if ($project->note_public) { - print '
'.dol_escape_htmltag($project->note_public).'
'; + print '
'.dol_htmlentitiesbr($project->note_public).'
'; } print '
'; From 4fc8b40b71619511fba9d1a9b9b486b55dc47d6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 13:06:09 +0200 Subject: [PATCH 073/159] Fix too verbose --- htdocs/emailcollector/class/emailcollector.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7391d6e6acd..ff10cedcb66 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1020,8 +1020,8 @@ class EmailCollector extends CommonObject } } //var_dump($substitutionarray); - dol_syslog('substitutionarray='.var_export($substitutionarray, true)); - //var_dump($substitutionarray); + //dol_syslog('substitutionarray='.var_export($substitutionarray, true)); + $valuetouse = make_substitutions($valuetouse, $substitutionarray); if (preg_match('/^options_/', $tmpproperty)) { $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse; From 2fbfd4fe4c1716a1e5d56a6ff38895ee811cfe38 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 13 Apr 2023 14:27:27 +0200 Subject: [PATCH 074/159] FIX: undefined variable used in order billing mass action --- htdocs/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 49e6b0b3555..7263085337c 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -511,7 +511,7 @@ if (empty($reshook)) { if ($result > 0) { $lineid = $result; if (!empty($createbills_onebythird)) //increment rang to keep order - $TFactThirdNbLines[$rcp->socid]++; + $TFactThirdNbLines[$cmd->socid]++; } else { $lineid = 0; $error++; From 4c51e35adc32f816832a3df16635a82b1c44c0eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 15:00:34 +0200 Subject: [PATCH 075/159] FIX Bad deletion of email when there is several emails processed --- .../class/emailcollector.class.php | 715 ++++++++++-------- 1 file changed, 418 insertions(+), 297 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index ff10cedcb66..4c6c8e214a4 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -127,7 +127,7 @@ class EmailCollector extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax200'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'), - 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'), + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'cssview'=>'small', 'csslist'=>'small tdoverflowmax200'), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflowmax125'), 'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflowmax50', 'default'=>'993'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)', 'default'=>'UTF-8'), @@ -136,13 +136,11 @@ class EmailCollector extends CommonObject 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>"1", 'position'=>103, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'), 'oauth_service' => array('type'=>'varchar(128)', 'label'=>'oauthService', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>104, 'notnull'=>0, 'index'=>1, 'comment'=>"IMAP login oauthService", 'arrayofkeyval'=>array(), 'help'=>'TokenMustHaveBeenCreated'), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>104, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), - //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), - //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'help'=>"EmailCollectorTargetDir"), 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'csslist'=>'small tdoverflowmax200'), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'cssview'=>'small', 'csslist'=>'small tdoverflowmax200'), 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), @@ -381,11 +379,10 @@ class EmailCollector extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->label = $langs->trans("CopyOf")." ".$object->label; if (empty($object->host)) { $object->host = 'imap.example.com'; } - // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); @@ -443,15 +440,15 @@ class EmailCollector extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ /* - public function fetchLines() - { - $this->lines=array(); + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - } - */ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -878,8 +875,24 @@ class EmailCollector extends CommonObject */ private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject, $header, &$operationslog) { + global $conf, $langs; + $errorforthisaction = 0; + // set output lang + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + } + // Overwrite values with values extracted from source email // $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); @@ -1000,7 +1013,8 @@ class EmailCollector extends CommonObject if ($regforregex[1] == 'SET' || empty($valuecurrent)) { $valuetouse = $regforregex[2]; - $substitutionarray = array(); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); @@ -1081,6 +1095,9 @@ class EmailCollector extends CommonObject $searchfilternodoltrackid = 0; $searchfilterisanswer = 0; $searchfilterisnotanswer = 0; + $searchfilterreplyto = 0; + $searchfilterexcludebody = ''; + $searchfilterexcludesubject = ''; $operationslog = ''; $now = dol_now(); @@ -1139,7 +1156,7 @@ class EmailCollector extends CommonObject getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'), getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE') - ); + ); $serviceFactory = new \OAuth\ServiceFactory(); $oauthname = explode('-', $OAUTH_SERVICENAME); // ex service is Google-Emails we need only the first part Google @@ -1230,64 +1247,91 @@ class EmailCollector extends CommonObject } if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + // Use PHPIMAP external library $criteria = array(array('UNDELETED')); // Seems not supported by some servers foreach ($this->filters as $rule) { if (empty($rule['status'])) { continue; } + + $not = ''; + if (strpos($rule['rulevalue'], '!') === 0) { + // The value start with !, so we exclude the criteria + $not = 'NOT '; + } + + if ($rule['type'] == 'from') { + $tmprulevaluearray = explode('*', $rule['rulevalue']); + if (count($tmprulevaluearray) >= 2) { + foreach ($tmprulevaluearray as $tmprulevalue) { + array_push($criteria, array($not."FROM" => $tmprulevalue)); + } + } else { + array_push($criteria, array($not."FROM" => $rule['rulevalue'])); + } + } if ($rule['type'] == 'to') { $tmprulevaluearray = explode('*', $rule['rulevalue']); if (count($tmprulevaluearray) >= 2) { foreach ($tmprulevaluearray as $tmprulevalue) { - array_push($criteria, array("TO" => $tmprulevalue)); + array_push($criteria, array($not."TO" => $tmprulevalue)); } } else { - array_push($criteria, array("TO" => $rule['rulevalue'])); + array_push($criteria, array($not."TO" => $rule['rulevalue'])); } } if ($rule['type'] == 'bcc') { - array_push($criteria, array("BCC" => $rule['rulevalue'])); + array_push($criteria, array($not."BCC" => $rule['rulevalue'])); } if ($rule['type'] == 'cc') { - array_push($criteria, array("CC" => $rule['rulevalue'])); - } - if ($rule['type'] == 'from') { - array_push($criteria, array("FROM" => $rule['rulevalue'])); + array_push($criteria, array($not."CC" => $rule['rulevalue'])); } if ($rule['type'] == 'subject') { - array_push($criteria, array("SUBJECT" => $rule['rulevalue'])); + if (strpos($rule['rulevalue'], '!') === 0) { + //array_push($criteria, array("NOT SUBJECT" => $rule['rulevalue'])); + $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + array_push($criteria, array("SUBJECT" => $rule['rulevalue'])); + } } if ($rule['type'] == 'body') { - array_push($criteria, array("BODY" => $rule['rulevalue'])); + if (strpos($rule['rulevalue'], '!') === 0) { + //array_push($criteria, array("NOT BODY" => $rule['rulevalue'])); + $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + array_push($criteria, array("BODY" => $rule['rulevalue'])); + } } if ($rule['type'] == 'header') { - array_push($criteria, array("HEADER" => $rule['rulevalue'])); + array_push($criteria, array($not."HEADER" => $rule['rulevalue'])); } - if ($rule['type'] == 'notinsubject') { - array_push($criteria, array("SUBJECT NOT" => $rule['rulevalue'])); - } - if ($rule['type'] == 'notinbody') { - array_push($criteria, array("BODY NOT" => $rule['rulevalue'])); - } + /* seems not used */ + /* + if ($rule['type'] == 'notinsubject') { + array_push($criteria, array($not."SUBJECT NOT" => $rule['rulevalue'])); + } + if ($rule['type'] == 'notinbody') { + array_push($criteria, array($not."BODY NOT" => $rule['rulevalue'])); + }*/ if ($rule['type'] == 'seen') { - array_push($criteria, array("SEEN")); + array_push($criteria, array($not."SEEN")); } if ($rule['type'] == 'unseen') { - array_push($criteria, array("UNSEEN")); + array_push($criteria, array($not."UNSEEN")); } if ($rule['type'] == 'unanswered') { - array_push($criteria, array("UNANSWERED")); + array_push($criteria, array($not."UNANSWERED")); } if ($rule['type'] == 'answered') { - array_push($criteria, array("ANSWERED")); + array_push($criteria, array($not."ANSWERED")); } if ($rule['type'] == 'smaller') { - array_push($criteria, array("SMALLER")); + array_push($criteria, array($not."SMALLER")); } if ($rule['type'] == 'larger') { - array_push($criteria, array("LARGER")); + array_push($criteria, array($not."LARGER")); } // Rules to filter after the search imap @@ -1310,6 +1354,10 @@ class EmailCollector extends CommonObject if ($rule['type'] == 'isnotanswer') { $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/'; } + + if ($rule['type'] == 'replyto') { + $searchfilterreplyto++; $searchhead .= '/Reply-To.*'.preg_quote($rule['rulevalue'], '/').'/'; + } } if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined. @@ -1327,65 +1375,94 @@ class EmailCollector extends CommonObject dol_syslog("IMAP search string = ".var_export($criteria, true)); $search = var_export($criteria, true); } else { + // Use native IMAP functions $search = 'UNDELETED'; // Seems not supported by some servers foreach ($this->filters as $rule) { if (empty($rule['status'])) { continue; } - if ($rule['type'] == 'to') { - $tmprulevaluearray = explode('*', $rule['rulevalue']); + // Forge the IMAP search string. + // See https://www.rfc-editor.org/rfc/rfc3501 + + $not = ''; + if (strpos($rule['rulevalue'], '!') === 0) { + // The value start with !, so we exclude the criteria + $not = 'NOT '; + } + + if ($rule['type'] == 'from') { + $tmprulevaluearray = explode('*', $rule['rulevalue']); // Search on abc*def means searching on 'abc' and on 'def' if (count($tmprulevaluearray) >= 2) { foreach ($tmprulevaluearray as $tmprulevalue) { - $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $tmprulevalue).'"'; + $search .= ($search ? ' ' : '').$not.'FROM "'.str_replace('"', '', $tmprulevalue).'"'; } } else { - $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; + $search .= ($search ? ' ' : '').$not.'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + } + } + if ($rule['type'] == 'to') { + $tmprulevaluearray = explode('*', $rule['rulevalue']); // Search on abc*def means searching on 'abc' and on 'def' + if (count($tmprulevaluearray) >= 2) { + foreach ($tmprulevaluearray as $tmprulevalue) { + $search .= ($search ? ' ' : '').$not.'TO "'.str_replace('"', '', $tmprulevalue).'"'; + } + } else { + $search .= ($search ? ' ' : '').$not.'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; } } if ($rule['type'] == 'bcc') { - $search .= ($search ? ' ' : '').'BCC'; + $search .= ($search ? ' ' : '').$not.'BCC'; } if ($rule['type'] == 'cc') { - $search .= ($search ? ' ' : '').'CC'; - } - if ($rule['type'] == 'from') { - $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + $search .= ($search ? ' ' : '').$not.'CC'; } if ($rule['type'] == 'subject') { - $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if (strpos($rule['rulevalue'], '!') === 0) { + //$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + $searchfilterexcludesubject = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + } } if ($rule['type'] == 'body') { - $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if (strpos($rule['rulevalue'], '!') === 0) { + //$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']); + } else { + $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + } } if ($rule['type'] == 'header') { - $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue']; + $search .= ($search ? ' ' : '').$not.'HEADER '.$rule['rulevalue']; } - if ($rule['type'] == 'notinsubject') { - $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - } - if ($rule['type'] == 'notinbody') { - $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - } + /* seems not used */ + /* + if ($rule['type'] == 'notinsubject') { + $search .= ($search ? ' ' : '').'NOT SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + } + if ($rule['type'] == 'notinbody') { + $search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + }*/ if ($rule['type'] == 'seen') { - $search .= ($search ? ' ' : '').'SEEN'; + $search .= ($search ? ' ' : '').$not.'SEEN'; } if ($rule['type'] == 'unseen') { - $search .= ($search ? ' ' : '').'UNSEEN'; + $search .= ($search ? ' ' : '').$not.'UNSEEN'; } if ($rule['type'] == 'unanswered') { - $search .= ($search ? ' ' : '').'UNANSWERED'; + $search .= ($search ? ' ' : '').$not.'UNANSWERED'; } if ($rule['type'] == 'answered') { - $search .= ($search ? ' ' : '').'ANSWERED'; + $search .= ($search ? ' ' : '').$not.'ANSWERED'; } if ($rule['type'] == 'smaller') { - $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; + $search .= ($search ? ' ' : '').$not.'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; } if ($rule['type'] == 'larger') { - $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; + $search .= ($search ? ' ' : '').$not.'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; } // Rules to filter after the search imap @@ -1408,6 +1485,10 @@ class EmailCollector extends CommonObject if ($rule['type'] == 'isnotanswer') { $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/'; } + + if ($rule['type'] == 'replyto') { + $searchfilterreplyto++; $searchhead .= '/Reply-To.*'.preg_quote($rule['rulevalue'], '/').'/'; + } } if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined. @@ -1463,7 +1544,8 @@ class EmailCollector extends CommonObject } } else { // Scan IMAP inbox - $arrayofemail = imap_search($connection, $search, null, $charset); + $arrayofemail = imap_search($connection, $search, SE_UID, $charset); + if ($arrayofemail === false) { // Nothing found or search string not understood $mapoferrrors = imap_errors(); @@ -1475,23 +1557,25 @@ class EmailCollector extends CommonObject } } + $arrayofemailtodelete = array(); // Track email to delete to make the deletion at end. + // Loop on each email found if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) { // Loop to get part html and plain /* - 0 multipart/mixed - 1 multipart/alternative - 1.1 text/plain - 1.2 text/html - 2 message/rfc822 - 2 multipart/mixed - 2.1 multipart/alternative - 2.1.1 text/plain - 2.1.2 text/html - 2.2 message/rfc822 - 2.2 multipart/alternative - 2.2.1 text/plain - 2.2.2 text/html + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html */ dol_syslog("Start of loop on email", LOG_INFO, 1); @@ -1508,9 +1592,8 @@ class EmailCollector extends CommonObject $header = $imapemail->getHeader()->raw; $overview = $imapemail->getAttributes(); } else { - //$header = imap_headerinfo($connection, $imapemail); - $header = imap_fetchheader($connection, $imapemail, 0); - $overview = imap_fetch_overview($connection, $imapemail, 0); + $header = imap_fetchheader($connection, $imapemail, FT_UID); + $overview = imap_fetch_overview($connection, $imapemail, FT_UID); } $header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines @@ -1537,7 +1620,7 @@ class EmailCollector extends CommonObject $emailto = $this->decodeSMTPSubject($overview[0]->to); - $operationslog .= '
** Process email '.dol_escape_htmltag($iforemailloop)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); + $operationslog .= '
** Process email #'.dol_escape_htmltag($iforemailloop)." - ".dol_escape_htmltag((string) $imapemail)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']); @@ -1545,7 +1628,7 @@ class EmailCollector extends CommonObject $trackidfoundintorecipientid = 0; $reg = array(); // See also later list of all supported tags... - if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|job|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { + if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { $trackidfoundintorecipienttype = $reg[1]; $trackidfoundintorecipientid = $reg[2]; } elseif (preg_match('/\+emailing-(\w+)@/', $emailto, $reg)) { // Can be 'emailing-test' or 'emailing-IdMailing-IdRecipient' @@ -1625,8 +1708,6 @@ class EmailCollector extends CommonObject $ticketfoundby = ''; $candidaturefoundby = ''; - $this->db->begin(); - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']); @@ -1660,7 +1741,7 @@ class EmailCollector extends CommonObject $attachments = []; } } else { - $this->getmsg($connection, $imapemail); + $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments } //print $plainmsg; //var_dump($plainmsg); exit; @@ -1670,6 +1751,15 @@ class EmailCollector extends CommonObject // Removed emojis $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + if ($searchfilterexcludebody) { + if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email body contains string '.$searchfilterexcludebody; + dol_syslog(" Discarded - Email body contains string ".$searchfilterexcludebody); + continue; // Exclude email + } + } + //var_dump($plainmsg); //var_dump($htmlmsg); //var_dump($messagetext); @@ -1679,45 +1769,45 @@ class EmailCollector extends CommonObject // Parse IMAP email structure /* - $structure = imap_fetchstructure($connection, $imapemail, 0); + $structure = imap_fetchstructure($connection, $imapemail, FT_UID); - $partplain = $parthtml = -1; - $encodingplain = $encodinghtml = ''; + $partplain = $parthtml = -1; + $encodingplain = $encodinghtml = ''; - $result = createPartArray($structure, ''); + $result = createPartArray($structure, ''); - foreach($result as $part) - { - // $part['part_object']->type seems 0 for content - // $part['part_object']->type seems 5 for attachment - if (empty($part['part_object'])) continue; - if ($part['part_object']->subtype == 'HTML') - { - $parthtml=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodinghtml = 'aaa'; - } - } - if ($part['part_object']->subtype == 'PLAIN') - { - $partplain=$part['part_number']; - if ($part['part_object']->encoding == 4) - { - $encodingplain = 'rr'; - } - } - } - //var_dump($result); - //var_dump($partplain); - //var_dump($parthtml); + foreach($result as $part) + { + // $part['part_object']->type seems 0 for content + // $part['part_object']->type seems 5 for attachment + if (empty($part['part_object'])) continue; + if ($part['part_object']->subtype == 'HTML') + { + $parthtml=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodinghtml = 'aaa'; + } + } + if ($part['part_object']->subtype == 'PLAIN') + { + $partplain=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodingplain = 'rr'; + } + } + } + //var_dump($result); + //var_dump($partplain); + //var_dump($parthtml); - //var_dump($structure); - //var_dump($parthtml); - //var_dump($partplain); + //var_dump($structure); + //var_dump($parthtml); + //var_dump($partplain); - $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); - */ + $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK|FTP_UID); + */ //var_dump($messagetext); //var_dump($structure->parts[0]->parts); @@ -1753,6 +1843,14 @@ class EmailCollector extends CommonObject //var_dump($msgid);exit; } + if ($searchfilterexcludesubject) { + if (preg_match('/'.preg_quote($searchfilterexcludesubject, '/').'/ms', $subject)) { + $nbemailprocessed++; + $operationslog .= '
Discarded - Email subject contains string '.$searchfilterexcludesubject; + dol_syslog(" Discarded - Email subject contains string ".$searchfilterexcludesubject); + continue; // Exclude email + } + } $reg = array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { @@ -1771,6 +1869,7 @@ class EmailCollector extends CommonObject } $fk_element_id = 0; $fk_element_type = ''; + $this->db->begin(); $contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0; @@ -1859,11 +1958,11 @@ class EmailCollector extends CommonObject $objectemail = new Adherent($this->db); } /*if ($reg[1] == 'leav') { // Leave / Holiday - $objectemail = new Holiday($db); - } - if ($reg[1] == 'exp') { // ExpenseReport - $objectemail = new ExpenseReport($db); - }*/ + $objectemail = new Holiday($db); + } + if ($reg[1] == 'exp') { // ExpenseReport + $objectemail = new ExpenseReport($db); + }*/ } elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) { // This is an external reference, we check if we have it in our database if (!is_object($objectemail)) { @@ -2022,34 +2121,34 @@ class EmailCollector extends CommonObject } /* - if ($replyto) { - if (empty($contactid)) { // Try to find contact using email - $result = $contactstatic->fetch(0, null, '', $replyto); + if ($replyto) { + if (empty($contactid)) { // Try to find contact using email + $result = $contactstatic->fetch(0, null, '', $replyto); - if ($result > 0) { - dol_syslog("We found a contact with the email ".$replyto); - $contactid = $contactstatic->id; - $contactfoundby = 'email of contact ('.$replyto.')'; - if (empty($thirdpartyid) && $contactstatic->socid > 0) { - $result = $thirdpartystatic->fetch($contactstatic->socid); - if ($result > 0) { - $thirdpartyid = $thirdpartystatic->id; - $thirdpartyfoundby = 'email of contact ('.$replyto.')'; - } - } - } - } + if ($result > 0) { + dol_syslog("We found a contact with the email ".$replyto); + $contactid = $contactstatic->id; + $contactfoundby = 'email of contact ('.$replyto.')'; + if (empty($thirdpartyid) && $contactstatic->socid > 0) { + $result = $thirdpartystatic->fetch($contactstatic->socid); + if ($result > 0) { + $thirdpartyid = $thirdpartystatic->id; + $thirdpartyfoundby = 'email of contact ('.$replyto.')'; + } + } + } + } - if (empty($thirdpartyid)) { // Try to find thirdparty using email - $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); - if ($result > 0) { - dol_syslog("We found a thirdparty with the email ".$replyto); - $thirdpartyid = $thirdpartystatic->id;; - $thirdpartyfoundby = 'email ('.$replyto.')'; - } - } - } - */ + if (empty($thirdpartyid)) { // Try to find thirdparty using email + $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); + if ($result > 0) { + dol_syslog("We found a thirdparty with the email ".$replyto); + $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyfoundby = 'email ('.$replyto.')'; + } + } + } + */ // Do operations (extract variables and creating data) if ($mode < 2) { // 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates @@ -2378,98 +2477,98 @@ class EmailCollector extends CommonObject $this->errors[] = 'User Not allowed to add documents'; } $arrayobject = array( - 'propale' => array('table' => 'propal', - 'fields' => array('ref'), - 'class' => 'comm/propal/class/propal.class.php', - 'object' => 'Propal'), - 'holiday' => array('table' => 'holiday', - 'fields' => array('ref'), - 'class' => 'holiday/class/holiday.class.php', - 'object' => 'Holiday'), - 'expensereport' => array('table' => 'expensereport', - 'fields' => array('ref'), - 'class' => 'expensereport/class/expensereport.class.php', - 'object' => 'ExpenseReport'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentjobposition.class.php', - 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentcandidature.class.php', - 'object' => ' RecruitmentCandidature'), - 'societe' => array('table' => 'societe', - 'fields' => array('code_client', 'code_fournisseur'), - 'class' => 'societe/class/societe.class.php', - 'object' => 'Societe'), - 'commande' => array('table' => 'commande', - 'fields' => array('ref'), - 'class' => 'commande/class/commande.class.php', - 'object' => 'Commande'), - 'expedition' => array('table' => 'expedition', - 'fields' => array('ref'), - 'class' => 'expedition/class/expedition.class.php', - 'object' => 'Expedition'), - 'contract' => array('table' => 'contrat', - 'fields' => array('ref'), - 'class' => 'contrat/class/contrat.class.php', - 'object' => 'Contrat'), - 'fichinter' => array('table' => 'fichinter', - 'fields' => array('ref'), - 'class' => 'fichinter/class/fichinter.class.php', - 'object' => 'Fichinter'), - 'ticket' => array('table' => 'ticket', - 'fields' => array('ref'), - 'class' => 'ticket/class/ticket.class.php', - 'object' => 'Ticket'), - 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', - 'fields' => array('ref'), - 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', - 'object' => 'KnowledgeRecord'), - 'supplier_proposal' => array('table' => 'supplier_proposal', - 'fields' => array('ref'), - 'class' => 'supplier_proposal/class/supplier_proposal.class.php', - 'object' => 'SupplierProposal'), - 'fournisseur/commande' => array('table' => 'commande_fournisseur', - 'fields' => array('ref', 'ref_supplier'), - 'class' => 'fourn/class/fournisseur.commande.class.php', - 'object' => 'SupplierProposal'), - 'facture' => array('table' => 'facture', - 'fields' => array('ref'), - 'class' => 'compta/facture/class/facture.class.php', - 'object' => 'Facture'), - 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', 'ref_client'), - 'class' => 'fourn/class/fournisseur.facture.class.php', - 'object' => 'FactureFournisseur'), - 'produit' => array('table' => 'product', - 'fields' => array('ref'), - 'class' => 'product/class/product.class.php', - 'object' => 'Product'), - 'productlot' => array('table' => 'product_lot', - 'fields' => array('batch'), - 'class' => 'product/stock/class/productlot.class.php', - 'object' => 'Productlot'), - 'projet' => array('table' => 'projet', - 'fields' => array('ref'), - 'class' => 'projet/class/projet.class.php', - 'object' => 'Project'), - 'projet_task' => array('table' => 'projet_task', - 'fields' => array('ref'), - 'class' => 'projet/class/task.class.php', - 'object' => 'Task'), - 'ressource' => array('table' => 'resource', - 'fields' => array('ref'), - 'class' => 'ressource/class/dolressource.class.php', - 'object' => 'Dolresource'), - 'bom' => array('table' => 'bom_bom', - 'fields' => array('ref'), - 'class' => 'bom/class/bom.class.php', - 'object' => 'BOM'), - 'mrp' => array('table' => 'mrp_mo', - 'fields' => array('ref'), - 'class' => 'mrp/class/mo.class.php', - 'object' => 'Mo'), + 'propale' => array('table' => 'propal', + 'fields' => array('ref'), + 'class' => 'comm/propal/class/propal.class.php', + 'object' => 'Propal'), + 'holiday' => array('table' => 'holiday', + 'fields' => array('ref'), + 'class' => 'holiday/class/holiday.class.php', + 'object' => 'Holiday'), + 'expensereport' => array('table' => 'expensereport', + 'fields' => array('ref'), + 'class' => 'expensereport/class/expensereport.class.php', + 'object' => 'ExpenseReport'), + 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentjobposition.class.php', + 'object' => 'RecruitmentJobPosition'), + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentcandidature.class.php', + 'object' => ' RecruitmentCandidature'), + 'societe' => array('table' => 'societe', + 'fields' => array('code_client', 'code_fournisseur'), + 'class' => 'societe/class/societe.class.php', + 'object' => 'Societe'), + 'commande' => array('table' => 'commande', + 'fields' => array('ref'), + 'class' => 'commande/class/commande.class.php', + 'object' => 'Commande'), + 'expedition' => array('table' => 'expedition', + 'fields' => array('ref'), + 'class' => 'expedition/class/expedition.class.php', + 'object' => 'Expedition'), + 'contract' => array('table' => 'contrat', + 'fields' => array('ref'), + 'class' => 'contrat/class/contrat.class.php', + 'object' => 'Contrat'), + 'fichinter' => array('table' => 'fichinter', + 'fields' => array('ref'), + 'class' => 'fichinter/class/fichinter.class.php', + 'object' => 'Fichinter'), + 'ticket' => array('table' => 'ticket', + 'fields' => array('ref'), + 'class' => 'ticket/class/ticket.class.php', + 'object' => 'Ticket'), + 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', + 'fields' => array('ref'), + 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', + 'object' => 'KnowledgeRecord'), + 'supplier_proposal' => array('table' => 'supplier_proposal', + 'fields' => array('ref'), + 'class' => 'supplier_proposal/class/supplier_proposal.class.php', + 'object' => 'SupplierProposal'), + 'fournisseur/commande' => array('table' => 'commande_fournisseur', + 'fields' => array('ref', 'ref_supplier'), + 'class' => 'fourn/class/fournisseur.commande.class.php', + 'object' => 'SupplierProposal'), + 'facture' => array('table' => 'facture', + 'fields' => array('ref'), + 'class' => 'compta/facture/class/facture.class.php', + 'object' => 'Facture'), + 'fournisseur/facture' => array('table' => 'facture_fourn', + 'fields' => array('ref', 'ref_client'), + 'class' => 'fourn/class/fournisseur.facture.class.php', + 'object' => 'FactureFournisseur'), + 'produit' => array('table' => 'product', + 'fields' => array('ref'), + 'class' => 'product/class/product.class.php', + 'object' => 'Product'), + 'productlot' => array('table' => 'product_lot', + 'fields' => array('batch'), + 'class' => 'product/stock/class/productlot.class.php', + 'object' => 'Productlot'), + 'projet' => array('table' => 'projet', + 'fields' => array('ref'), + 'class' => 'projet/class/projet.class.php', + 'object' => 'Project'), + 'projet_task' => array('table' => 'projet_task', + 'fields' => array('ref'), + 'class' => 'projet/class/task.class.php', + 'object' => 'Task'), + 'ressource' => array('table' => 'resource', + 'fields' => array('ref'), + 'class' => 'ressource/class/dolressource.class.php', + 'object' => 'Dolresource'), + 'bom' => array('table' => 'bom_bom', + 'fields' => array('ref'), + 'class' => 'bom/class/bom.class.php', + 'object' => 'BOM'), + 'mrp' => array('table' => 'mrp_mo', + 'fields' => array('ref'), + 'class' => 'mrp/class/mo.class.php', + 'object' => 'Mo'), ); if (!is_object($hookmanager)) { @@ -2826,43 +2925,43 @@ class EmailCollector extends CommonObject // Set candidature ref if not yet defined /*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status - { - // Get next Ref - $defaultref = ''; - $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; + { + // Get next Ref + $defaultref = ''; + $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; - // Search template files - $file = ''; $classname = ''; $filefound = 0; $reldir = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); - if (file_exists($file)) { - $filefound = 1; - $classname = $modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + if (file_exists($file)) { + $filefound = 1; + $classname = $modele; + break; + } + } - if ($filefound) { - if ($savesocid > 0) { - if ($savesocid != $candidaturetocreate->socid) { - $errorforactions++; - setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); - } - } else { - if ($candidaturetocreate->socid > 0) - { - $thirdpartystatic->fetch($candidaturetocreate->socid); - } - } + if ($filefound) { + if ($savesocid > 0) { + if ($savesocid != $candidaturetocreate->socid) { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$candidaturetocreate->socid.') by setting socid in operation with a different value', null, 'errors'); + } + } else { + if ($candidaturetocreate->socid > 0) + { + $thirdpartystatic->fetch($candidaturetocreate->socid); + } + } - $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); - $modModuleToUseForNextValue = new $classname; - $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); - } - $candidaturetocreate->ref = $defaultref; - }*/ + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $modModuleToUseForNextValue = new $classname; + $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); + } + $candidaturetocreate->ref = $defaultref; + }*/ if ($errorforthisaction) { $errorforactions++; @@ -2871,7 +2970,7 @@ class EmailCollector extends CommonObject $result = $candidaturetocreate->create($user); if ($result <= 0) { $errorforactions++; - $this->error = 'Failed to create ticket: '.join(', ', $candidaturetocreate->errors); + $this->error = 'Failed to create candidature: '.join(', ', $candidaturetocreate->errors); $this->errors = $candidaturetocreate->errors; } @@ -2927,26 +3026,24 @@ class EmailCollector extends CommonObject // Error for email or not ? if (!$errorforactions) { - if (!empty($targetdir) && empty($mode)) { - if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); - $res = imap_mail_move($connection, $imapemail, $targetdir, 0); - if ($res == false) { - $errorforemail++; - $this->error = imap_last_error(); - $this->errors[] = $this->error; - dol_syslog(imap_last_error()); - } - } else { + if (!empty($targetdir)) { + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { // Move mail using PHP-IMAP dol_syslog("EmailCollector::doCollectOneCollector move message ".($imapemail->getHeader()->get('subject'))." to ".$targetdir, LOG_DEBUG); - $imapemail->move($targetdir); + if (empty($mode)) { + $imapemail->move($targetdir); + } + } else { + dol_syslog("EmailCollector::doCollectOneCollector move message ".((string) $imapemail)." to ".$connectstringtarget, LOG_DEBUG); + $operationslog .= '
Move mail '.((string) $imapemail).' - '.$msgid; + + $arrayofemailtodelete[$imapemail] = $msgid; } } else { - if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG); - } else { + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("EmailCollector::doCollectOneCollector message '".($imapemail->getHeader()->get('subject'))."' using this->host=".$this->host.", this->access_type=".$this->acces_type." was set to read", LOG_DEBUG); + } else { + dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG); } } } else { @@ -2990,12 +3087,34 @@ class EmailCollector extends CommonObject $output = $langs->trans('NoNewEmailToProcess'); } + // Disconnect if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $client->disconnect(); } else { + foreach ($arrayofemailtodelete as $imapemail => $msgid) { + dol_syslog("EmailCollect::doCollectOneCollector delete email ".$imapemail." ".$msgid); + + $operationslog .= "
delete email ".$imapemail." ".$msgid; + + if (empty($mode) && empty($error)) { + $res = imap_mail_move($connection, $imapemail, $targetdir, CP_UID); + if ($res == false) { + $errorforemail++; + $this->error = imap_last_error(); + $this->errors[] = $this->error; + + $operationslog .= '
Error in move '.$this->error; + + dol_syslog(imap_last_error()); + } + } + } + if (empty($mode) && empty($error)) { dol_syslog("Expunge", LOG_DEBUG); - imap_expunge($connection); // To validate any move + $operationslog .= "
Expunge"; + + imap_expunge($connection); // To validate all moves } imap_close($connection); } @@ -3036,7 +3155,7 @@ class EmailCollector extends CommonObject * getmsg * * @param Object $mbox Structure - * @param string $mid prefix + * @param string $mid UID email * @param string $destdir Target dir for attachments * @return array Array with number and object */ @@ -3053,7 +3172,8 @@ class EmailCollector extends CommonObject // add code here to get date, from, to, cc, subject... // BODY - $s = imap_fetchstructure($mbox, $mid); + $s = imap_fetchstructure($mbox, $mid, FT_UID); + if (!$s->parts) { // simple @@ -3099,8 +3219,8 @@ class EmailCollector extends CommonObject // DECODE DATA $data = ($partno) ? - imap_fetchbody($mbox, $mid, $partno) : // multipart - imap_body($mbox, $mid); // simple + imap_fetchbody($mbox, $mid, $partno, FT_UID) : // multipart + imap_body($mbox, $mid, FT_UID); // simple // Any part may be encoded, even plain text messages, so check everything. if ($p->encoding == 4) { $data = quoted_printable_decode($data); @@ -3153,13 +3273,14 @@ class EmailCollector extends CommonObject * Check if the same file name already exists in the upload folder, * append increment number to the original filename */ - while (file_exists($destdir."/" . $file_name . "." . $extension)) { - $file_name = (string) $file_name_original . ' (' . $num . ')'; + while (file_exists($destdir."/".$file_name.".".$extension)) { + $file_name = $file_name_original . ' (' . $num . ')'; $file_name_complete = $file_name . "." . $extension; $destination = $destdir.'/'.$file_name_complete; $num++; } + $destination = dol_sanitizePathName($destination); file_put_contents($destination, $data); } From 67e07a4db73ffdf1a79877651c7c41f748100357 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 16:31:06 +0200 Subject: [PATCH 076/159] Consistency of sort field --- 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 167e851a6c2..d0f6b032bc1 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -93,7 +93,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (empty($sortfield)) { - $sortfield = 'type_template, lang, position, label'; + $sortfield = 'type_template,lang,position,label'; } if (empty($sortorder)) { $sortorder = 'ASC'; @@ -1011,7 +1011,7 @@ foreach ($fieldlist as $field => $value) { } $sortfieldtouse = ($sortable ? $fieldlist[$field] : ''); if ($sortfieldtouse == 'type_template') { - $sortfieldtouse.= ',label'; + $sortfieldtouse.= 'type_template,lang,position,label'; } print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $align.' '); } From 5c54d5d279abb46808992bc70adbdf6a29470d17 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 13 Apr 2023 16:55:00 +0200 Subject: [PATCH 077/159] FIX check on wrong variable, some unnecessary code removed --- htdocs/product/class/productcustomerprice.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 6a6fe72a08a..39adc8cd598 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -871,7 +871,7 @@ class Productcustomerprice extends CommonObject $prodsocpriceupd->recuperableonly = $this->recuperableonly; $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate); - if ($result < 0) { + if ($resultupd < 0) { $error++; $this->error = $prodsocpriceupd->error; } @@ -889,7 +889,7 @@ class Productcustomerprice extends CommonObject $prodsocpricenew->recuperableonly = $this->recuperableonly; $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate); - if ($result < 0) { + if ($resultupd < 0) { $error++; $this->error = $prodsocpricenew->error; } @@ -923,7 +923,7 @@ class Productcustomerprice extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) { + if (!$notrigger) { $result = $this->call_trigger('PRODUCT_CUSTOMER_PRICE_DELETE', $user); if ($result < 0) { $error++; From 50346a71197cb0c7ae07a6e236875d4f2925b40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 13 Apr 2023 16:58:16 +0200 Subject: [PATCH 078/159] Doc --- htdocs/product/class/productcustomerprice.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 6a6fe72a08a..2f50528e818 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -66,6 +66,7 @@ class Productcustomerprice extends CommonObject public $price_min; public $price_min_ttc; public $price_base_type; + public $default_vat_code; public $tva_tx; public $recuperableonly; public $localtax1_type; @@ -78,6 +79,9 @@ class Productcustomerprice extends CommonObject */ public $fk_user; + /** + * @var PriceByCustomerLine[] + */ public $lines = array(); From c37ca020645943fa43b29445edb043c2f3fceb4e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 13 Apr 2023 17:13:56 +0200 Subject: [PATCH 079/159] optimize section for add & remove apiFile --- htdocs/core/lib/modulebuilder.lib.php | 105 ++++++++++++++++++++++++++ htdocs/modulebuilder/index.php | 84 ++++----------------- 2 files changed, 120 insertions(+), 69 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index d5f2a6e50c8..83d06c43c55 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -742,3 +742,108 @@ function writePermsInAsciiDoc($file, $destfile) } return 1; } + +/** + * Add Object in ModuleApi File + * @param string $file path of file + * @param array $objects array of objects in the module + * @param string $modulename name of module + * @return int 1 if OK, -1 if KO + */ +function addObjectsToApiFile($file, $objects, $modulename) +{ + if (!file_exists($file)) { + return -1; + } + $content = file($file); + $includeClass = "dol_include_once('/mymodule/class/myobject.class.php');"; + $props = "public \$myobject;"; + $varcomented = "@var MyObject \$myobject {@type MyObject}"; + $constructObj = "\$this->myobject = new MyObject(\$this->db);"; + + // add properties and declare them in consturctor + foreach ($content as $lineNumber => &$lineContent) { + if (strpos($lineContent, $varcomented) !== false) { + $lineContent = ''; + foreach ($objects as $object) { + $lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL; + } + //var_dump($lineContent);exit; + } + if (strpos($lineContent, $props) !== false) { + $lineContent = ''; + foreach ($objects as $object) { + $lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL; + } + } + if (strpos($lineContent, $constructObj) !== false) { + $lineContent = ''; + foreach ($objects as $object) { + $lineContent .= "\t\t\$this->".strtolower($object)." = new ".$object."(\$this->db);". PHP_EOL; + } + } + if (strpos($lineContent, $includeClass) !== false) { + $lineContent = ''; + foreach ($objects as $object) { + $lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($object).".class.php');". PHP_EOL; + } + } + } + $allContent = implode("", $content); + file_put_contents($file, $allContent); + + //add methods for each object + $allContent = getFromFile($file, '/*begin methods CRUD*/', '/*end methods CRUD*/'); + foreach ($objects as $object) { + $contentReplaced =str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent); + dolReplaceInFile($file, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/')); + } + dolReplaceInFile($file, array($allContent => '','MyModule' => ucfirst($modulename))); + return 1; +} + +/** + * Remove Object variables and methods from API_Module File + * @param string $file file api module + * @param string $objectname name of object whant to remove + * @param string $modulename name of module + * @return int 1 if OK, -1 if KO + */ +function removeObjectFromApiFile($file, $objectname, $modulename) +{ + $begin = '/*CRUD FOR '.strtoupper($objectname).'*/'; + $end = '/*END CRUD FOR '.strtoupper($objectname).'*/'; + $includeClass = "dol_include_once('/".strtolower($modulename)."/class/".strtolower($objectname).".class.php');"; + $varcomentedDel = "\t * @var ".$objectname." \$".strtolower($objectname)." {@type ".$objectname."}"; + $propsDel = "\tpublic \$".strtolower($objectname).";"; + $constructObjDel = "\t\t\$this->".strtolower($objectname)." = new ".$objectname."(\$this->db);"; + + if (!file_exists($file)) { + return -1; + } + $content = file($file); + // for delete property and the initialization from the construct + foreach ($content as $lineNumber => &$lineContent) { + if (strpos($lineContent, $includeClass) !== false) { + $lineContent = ''; + } + if (strpos($lineContent, $varcomentedDel) !== false) { + $lineContent = ''; + } + if (strpos($lineContent, $propsDel) !== false) { + $lineContent = ''; + } + if (strpos($lineContent, $constructObjDel) !== false) { + $lineContent = ''; + } + } + $allContent = implode("", $content); + file_put_contents($file, $allContent); + // for delete methods of object + $allContent = getFromFile($file, $begin, $end); + $check = dolReplaceInFile($file, array($allContent => '')); + if ($check) { + dolReplaceInFile($file, array($begin => '', $end => '')); + } + return 1; +} diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 03483212860..ef929f15180 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -471,72 +471,10 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac ); if (count($objects) > 1) { - $file = $destfile; - $content = file($file); - $props = "public \$myobject;"; - $varcomented = "@var MyObject \$myobject {@type MyObject}"; - $constructObj = "\$this->myobject = new MyObject(\$this->db);"; - // add properties and declare them in consturctor - foreach ($content as $lineNumber => &$lineContent) { - if (strpos($lineContent, $varcomented) !== false) { - $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL; - } - //var_dump($lineContent);exit; - } - if (strpos($lineContent, $props) !== false) { - $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL; - } - } - if (strpos($lineContent, $constructObj) !== false) { - $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\t\t\$this->".strtolower($object)."= new ".$object."(\$this->db);". PHP_EOL; - } - } - } - $allContent = implode("", $content); - file_put_contents($destfile, $allContent); - } - if (count($objects) > 1) { - $search = "/*begin methods CRUD*/"; - // Open the file and read line by line - $handle = fopen($destfile, "r"); - $i = 1; - $lines = array(); - $props = " public \$myobject; "; - while (($line = fgets($handle)) !== false) { - //search line begin - if (strpos($line, $search) !== false) { - $start_line = $i; - - // Copy lines until the end on array - while (($line = fgets($handle)) !== false) { - if (strpos($line, "/*end methods CRUD*/") !== false) { - $end_line = $i; - break; - } - $lines[] = $line; - $i++; - } - break; - } - - $i++; - } - $allContent = implode("", $lines); - - foreach ($objects as $object) { - $contentReplaced = str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent); - dolReplaceInFile($destfile, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/')); - } - dolReplaceInFile($destfile, array($allContent => '')); - fclose($handle); + addObjectsToApiFile($destfile, $objects, $modulename); } else { dolReplaceInFile($destfile, $arrayreplacement); + dolReplaceInFile($destfile, array('/*begin methods CRUD*/' => '/*begin methods CRUD*/'."\n\t".'/*CRUD FOR '.strtoupper($objectname).'*/', '/*end methods CRUD*/' => '/*END CRUD FOR '.strtoupper($objectname).'*/'."\n\t".'/*end methods CRUD*/')); } if ($varnametoupdate) { @@ -938,17 +876,25 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml')); - // Get list of existing objects - $objects = dolGetListOfObjectClasses($destdir); - - // Now we delete the file if ($relativefilename) { $dirnametodelete = dirname($relativefilename); $filetodelete = $dirins.'/'.$relativefilename; $dirtodelete = $dirins.'/'.$dirnametodelete; - $result = dol_delete_file($filetodelete); + //check when we want delete api_file + if (strpos($relativefilename, 'api') !== false) { + $removeFile = removeObjectFromApiFile($file_api, $objectname, $module); + $var = getFromFile($file_api, '/*begin methods CRUD*/', '/*end methods CRUD*/'); + if (str_word_count($var) == 0) { + $result = dol_delete_file($filetodelete); + } + if ($removeFile) { + setEventMessages($langs->trans("ApiObjectDeleted"), null); + } + } else { + $result = dol_delete_file($filetodelete); + } if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { From d4af17c1ae315376377cfd6fee37407ca498401a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 17:35:20 +0200 Subject: [PATCH 080/159] Trans --- htdocs/emailcollector/class/emailcollector.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 6e3043e4764..783583122d7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -3196,6 +3196,7 @@ class EmailCollector extends CommonObject dol_syslog("End of loop on emails", LOG_INFO, -1); } else { + $langs->load("admin"); $output = $langs->trans('NoNewEmailToProcess'); } From 09426bd81f13f00cb5b3177d5a1c73398eba5d29 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 18:30:06 +0200 Subject: [PATCH 081/159] Fix test on user->id --- htdocs/user/class/user.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3bc86df0225..aa065dcbceb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -835,6 +835,12 @@ class User extends CommonObject dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity, $notrigger for user id=".$this->id); + if (empty($this->id)) { + $error++; + $this->error = 'Try to call addrights on an object user with an empty id'; + return -1; + } + $error = 0; $whereforadd = ''; From 02624744e7d51079251cb1d7e3848b363aca613a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 20:34:54 +0200 Subject: [PATCH 082/159] NEW Can set flag default value on email templates --- htdocs/admin/mails_templates.php | 147 ++++++++++++++++--------------- htdocs/langs/en_US/admin.lang | 2 + 2 files changed, 78 insertions(+), 71 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d0f6b032bc1..20c88c3479a 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -109,21 +109,21 @@ $tabname[25] = MAIN_DB_PREFIX."c_email_templates"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,content"; +$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,defaultfortype,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfield[25] .= ',content_lines'; } // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue = array(); -$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,defaultfortype,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfieldvalue[25] .= ',content_lines'; } // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert = array(); -$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,defaultfortype,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfieldinsert[25] .= ',content_lines'; } @@ -164,13 +164,14 @@ if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabhelp = array(); $tabhelp[25] = array( 'label'=>$langs->trans('EnterAnyCode'), - 'topic'=>''.$helpsubstit.'', - 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), - 'content'=>''.$helpsubstit.'', - 'content_lines'=>''.$helpsubstitforlines.'', 'type_template'=>$langs->trans("TemplateForElement"), 'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), - 'position'=>$langs->trans("PositionIntoComboList") + 'position'=>$langs->trans("PositionIntoComboList"), + 'topic'=>''.$helpsubstit.'', + 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), + 'defaultfortype'=>$langs->trans("DefaultForTypeDesc"), + 'content'=>''.$helpsubstit.'', + 'content_lines'=>''.$helpsubstitforlines.'' ); @@ -307,7 +308,7 @@ if (empty($reshook)) { $ok = 1; foreach ($listfield as $f => $value) { // Not mandatory fields - if (in_array($value, ['joinfiles', 'content', 'content_lines', 'module'])) { + if (in_array($value, ['joinfiles', 'defaultfortype', 'content', 'content_lines', 'module'])) { continue; } @@ -383,6 +384,9 @@ if (empty($reshook)) { if ($value == 'position' && !is_numeric($_POST[$keycode])) { $_POST[$keycode] = '1'; } + if ($value == 'defaultfortype' && !is_numeric($_POST[$keycode])) { + $_POST[$keycode] = '0'; + } //var_dump($keycode.' '.$value); if ($i) { @@ -400,7 +404,7 @@ if (empty($reshook)) { } } elseif ($keycode == 'content') { $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfiles', 'private', 'position', 'entity'))) { + } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position', 'entity'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; @@ -430,7 +434,7 @@ if (empty($reshook)) { // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs + // Modify value of fields $i = 0; foreach ($listfieldmodify as $field) { if ($field == 'entity') { @@ -449,20 +453,20 @@ if (empty($reshook)) { } // Rename some POST variables into a generic name - if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) { + if ($field == 'fk_user' && !(GETPOST('fk_user', 'int') > 0)) { $_POST['fk_user'] = ''; } if ($field == 'topic') { - $_POST['topic'] = $_POST['topic-'.$rowid]; + $_POST['topic'] = GETPOST('topic-'.$rowid); } if ($field == 'joinfiles') { - $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; + $_POST['joinfiles'] = GETPOST('joinfiles-'.$rowid); } if ($field == 'content') { - $_POST['content'] = $_POST['content-'.$rowid]; + $_POST['content'] = GETPOST('content-'.$rowid); } if ($field == 'content_lines') { - $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; + $_POST['content_lines'] = GETPOST('content_lines-'.$rowid); } if ($i) { @@ -470,7 +474,7 @@ if (empty($reshook)) { } $sql .= $field."="; - if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) { + if (GETPOST($keycode) == '' || (!in_array($keycode, array('langcode', 'position', 'private', 'defaultfortype')) && !GETPOST($keycode))) { $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') { $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work @@ -482,12 +486,11 @@ if (empty($reshook)) { } } elseif ($keycode == 'content') { $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfiles', 'private', 'position'))) { + } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'"; } - $i++; } @@ -572,7 +575,7 @@ if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu $morejs = array(); $morecss = array(); -$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active"; +$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, defaultfortype, content_lines, content, enabled, active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates"; $sql .= " WHERE entity IN (".getEntity('email_template').")"; if (!$user->admin) { @@ -693,6 +696,7 @@ if ($action == 'create') { $obj->position = GETPOST('position'); $obj->topic = GETPOST('topic'); $obj->joinfiles = GETPOST('joinfiles'); + $obj->defaultfortype = GETPOST('defaultfortype') ? 1 : 0; $obj->content = GETPOST('content', 'restricthtml'); // Form to add a new line @@ -711,9 +715,9 @@ if ($action == 'create') { // dans les dictionnaires de donnees $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate - $align = "left"; + $css = "left"; if ($fieldlist[$field] == 'module') { - $valuetoshow = ''; + $valuetoshow = ' '; } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); @@ -724,20 +728,20 @@ if ($action == 'create') { if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'position') { + $css = 'center'; + } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + if ($fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'type_template') { - $valuetoshow = $langs->trans("TypeOfTemplate"); $align = "center"; + $valuetoshow = $langs->trans("TypeOfTemplate"); $css = "center"; } - if ($fieldlist[$field] == 'private') { - $align = 'center'; - } - if ($fieldlist[$field] == 'position') { - $align = 'center'; + if (in_array($fieldlist[$field], array('private', 'private', 'defaultfortype'))) { + $css = 'center'; } if ($fieldlist[$field] == 'topic') { @@ -753,7 +757,7 @@ if ($action == 'create') { $valuetoshow = ''; } if ($valuetoshow != '') { - print ''; + print ''; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; } elseif (!empty($tabhelp[$id][$value])) { @@ -793,18 +797,18 @@ if ($action == 'create') { fieldList($fieldlist, $obj, $tabname[$id], 'add'); } } - + // Action column print ''; print ''; print ""; // Show fields for topic, join files and body - $fieldsforcontent = array('topic', 'joinfiles', 'content'); + $fieldsforcontent = array('topic', 'joinfiles', 'defaultfortype', 'content'); if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); + $fieldsforcontent = array('topic', 'joinfiles', 'defaultfortype', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { - print ''; + print ''; // Topic of email if ($tmpfieldlist == 'topic') { @@ -911,7 +915,6 @@ if ($num > $listlimit) { // Title line with search boxes print ''; - foreach ($fieldlist as $field => $value) { if ($value == 'module') { print ''; @@ -935,13 +938,13 @@ foreach ($fieldlist as $field => $value) { print ''; } } - -if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { +/*if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { print ''; -} - +}*/ +// Status +print ''; // Action column -print ''; +print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; @@ -951,7 +954,7 @@ print ''; print ''; foreach ($fieldlist as $field => $value) { $showfield = 1; // By defaut - $align = "left"; + $css = "left"; $sortable = 1; $valuetoshow = ''; $forcenowrap = 1; @@ -959,13 +962,13 @@ foreach ($fieldlist as $field => $value) { $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; $valuetoshow=$tmp['valuetoshow']; - $align=$tmp['align']; + $css=$tmp['align']; $sortable=$tmp['sortable']; */ $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate if ($fieldlist[$field] == 'module') { - $align = 'tdoverflowmax100'; + $css = 'tdoverflowmax100'; } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); @@ -980,18 +983,20 @@ foreach ($fieldlist as $field => $value) { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'type_template') { - $align = 'center'; + $css = 'center'; $valuetoshow = $langs->trans("TypeOfTemplate"); } if ($fieldlist[$field] == 'private') { - $align = 'center'; + $css = 'center'; } if ($fieldlist[$field] == 'position') { - $align = 'center'; + $css = 'center'; } if ($fieldlist[$field] == 'joinfiles') { - $valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0; + $valuetoshow = $langs->trans("FilesAttachedToEmail"); + $css = 'center'; + $forcenowrap = 0; } if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; @@ -1013,7 +1018,7 @@ foreach ($fieldlist as $field => $value) { if ($sortfieldtouse == 'type_template') { $sortfieldtouse.= 'type_template,lang,position,label'; } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $align.' '); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' '); } } @@ -1042,7 +1047,6 @@ if ($num) { fieldList($fieldlist, $obj, $tabname[$id], 'edit'); } - print ''; print ''; print ''; print ''; @@ -1057,7 +1061,7 @@ if ($num) { } foreach ($fieldsforcontent as $tmpfieldlist) { $showfield = 1; - $align = "left"; + $css = "left"; $valuetoshow = $obj->$tmpfieldlist; $class = 'tddict'; @@ -1065,7 +1069,7 @@ if ($num) { if ($showfield) { // Show line for topic, joinfiles and content print ''; - print ''; + print ''; if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print ''; @@ -1139,7 +1143,7 @@ if ($num) { continue; } $showfield = 1; - $align = ""; + $css = ""; $class = "tddict"; $title = ''; $tmpvar = $fieldlist[$field]; @@ -1158,7 +1162,7 @@ if ($num) { } if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; - $align = "center"; + $css = "center"; } if ($value == 'lang' && $valuetoshow) { $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); @@ -1171,7 +1175,7 @@ if ($num) { } } if ($value == 'private') { - $align = "center"; + $css = "center"; if ($valuetoshow) { $valuetoshow = yn($valuetoshow); } else { @@ -1179,18 +1183,18 @@ if ($num) { } } if ($value == 'position') { - $align = "center"; + $css = "center"; } - if ($value == 'joinfiles') { - $align = "center"; + if (in_array($value, array('joinfiles', 'defaultfortype'))) { + $css = "center"; if ($valuetoshow) { $valuetoshow = yn(1); } else { $valuetoshow = ''; } } - if ($align) { - $class .= ' '.$align; + if ($css) { + $class .= ' '.$css; } // Show value for field @@ -1288,6 +1292,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { + //print $value; if ($value == 'module') { print ''; } elseif ($value == 'fk_user') { @@ -1343,11 +1348,11 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } print ''; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { - continue; + //print ''; } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { - continue; + print ''; } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { - continue; + //print ''; } else { $size = ''; $class = ''; $classtd = ''; if ($value == 'code') { @@ -1357,19 +1362,19 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $class = 'maxwidth200'; } if ($value == 'private') { - $class = 'maxwidth50'; $classtd = 'center'; + $class = 'maxwidth50'; + $classtd = 'center'; } if ($value == 'position') { - $class = 'maxwidth50 center'; $classtd = 'center'; - } - if ($value == 'libelle') { - $class = 'quatrevingtpercent'; + $class = 'maxwidth50 center'; + $classtd = 'center'; } if ($value == 'topic') { $class = 'quatrevingtpercent'; } - if ($value == 'sortorder' || $value == 'sens' || $value == 'category_type') { - $size = 'size="2" '; + if ($value == 'defaultfortype') { + $class = 'width25 center'; + $classtd = 'center'; } print ''; @@ -1377,10 +1382,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if (empty($user->admin)) { print $form->selectyesno($value, '1', 1); } else { - print $form->selectyesno($value, (isset($obj->{$value}) ? $obj->{$value}:''), 1); + print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1); } } else { - print ''; + print ''; } print ''; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a493b104036..36fd9425943 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2381,3 +2381,5 @@ MAIN_IMAP_USE_PHPIMAP=Use the PHP-IMAP library for IMAP instead of native PHP IM MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) NotAvailableByDefaultEnabledOnModuleActivation=Not created by default. Created on module activation only. CSSPage=CSS Style +Defaultfortype=Default +DefaultForTypeDesc=Template used by default when creating a new email for the template type \ No newline at end of file From 59cc3663a79b059f8431b8ac37f9bcfedc98e027 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 21:00:56 +0200 Subject: [PATCH 083/159] NEW Show picto into the combobox of widgets --- htdocs/core/class/html.formother.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 6bcd8ea1e6c..cce5cf7819d 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1207,7 +1207,7 @@ class FormOther if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') { $label = $label.' '; } - $arrayboxtoactivatelabel[$box->id] = $label; // We keep only boxes not shown for user, to show into combo list + $arrayboxtoactivatelabel[$box->id] = array('label'=>$label, 'data-html'=>img_picto('', $box->boximg, 'class="pictofixedwidth"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list } foreach ($boxidactivatedforuser as $boxid) { if (empty($boxorder)) { @@ -1226,7 +1226,7 @@ class FormOther $selectboxlist .= ''; $selectboxlist .= ''; $selectboxlist .= ''; - $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone hideonprint', 0, 'hidden selected', 0, 1); + $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone hideonprint', 0, 'hidden selected', 0, 0); if (empty($conf->use_javascript_ajax)) { $selectboxlist .= ' '; } From 8ab1b5923c9c07b90b3b7f9e24df9ab0fbd69a31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 22:26:55 +0200 Subject: [PATCH 084/159] NEW Use by default the domain $dolibarr_main_url_root for SMTP HELO This solves "Temporary unavailable" error with gmail smtp relay. --- htdocs/core/class/conf.class.php | 4 ++++ htdocs/core/class/smtps.class.php | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index b3991ecfcf2..d70de618be8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -967,6 +967,10 @@ class Conf $this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1; } + if (!isset($this->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { + $this->global->MAIL_SMTP_USE_FROM_FOR_HELO = 2; + } + if (!defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) { if (defined('MAIN_ANTIVIRUS_COMMAND')) { $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND'); diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index e7b0207595a..fe1f90dd735 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -665,13 +665,17 @@ class SMTPs if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; - } else { + } elseif ($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO == 1) { // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. - // If the from to is 'aaa ', we will keep 'ccc.com' + // So if the from to is 'aaa ', we will keep 'ccc.com' $hosth = $this->getFrom('addr'); $hosth = preg_replace('/^.*.*$/', '', $hosth); $hosth = preg_replace('/.*@/', '', $hosth); + } elseif ($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO == 2) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 2, we use the domain in the $dolibarr_main_url_root. + global $dolibarr_main_url_root; + $hosth = getDomainFromURL($dolibarr_main_url_root, 1); } } From 16809e557fb63582ff81e19a87c9842285d121dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 22:31:38 +0200 Subject: [PATCH 085/159] Fix column balance --- htdocs/comm/index.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index bdc865160a5..a7c1f2ee8c8 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -517,7 +517,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO * Draft interventions */ if (isModEnabled('ficheinter')) { - $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut"; + $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut, f.duree as duration"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -572,12 +572,16 @@ if (isModEnabled('ficheinter')) { $companystatic->canvas = $obj->canvas; print ''; - print ''; + print ''; print $fichinterstatic->getNomUrl(1); print ""; - print ''; + print ''; print $companystatic->getNomUrl(1, 'customer'); - print ''; + print ''; + print ''; + print convertSecondToTime($obj->duration); + print ''; + print ''; $i++; } } From 291a7b1d15b4a05c20504dc146c3980281c85fc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 22:59:05 +0200 Subject: [PATCH 086/159] Update functions_openid_connect.php --- htdocs/core/login/functions_openid_connect.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index dcff99adaad..f9a4483205e 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -36,10 +36,16 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit { global $db, $conf, $langs; - dol_syslog("functions_openid_connect::check_user_password_openid_connect"); + // Force master entity in transversal mode + $entity = $entitytotest; + if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $entity = 1; + } $login = ''; + dol_syslog("functions_openid_connect::check_user_password_openid_connect usertotest=".$usertotest." passwordtotest=".preg_replace('/./', '*', $passwordtotest)." entitytotest=".$entitytotest); + // Step 1 is done by user: request an authorization code if (GETPOSTISSET('username')) { @@ -80,7 +86,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit // Success: retrieve claim to return to Dolibarr as login $sql = 'SELECT login, entity, datestartvalidity, dateendvalidity'; $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; - $sql .= " WHERE login = '".$userinfo_content->$login_claim."'"; + $sql .= " WHERE login = '".$db->escape($userinfo_content->$login_claim)."'"; $sql .= ' AND entity IN (0,'.(array_key_exists('dol_entity', $_SESSION) ? ((int) $_SESSION["dol_entity"]) : 1).')'; dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); From 30542b58e1705b7baabef849f77365060ff9f701 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 23:07:41 +0200 Subject: [PATCH 087/159] Doc --- htdocs/core/login/functions_openid.php | 2 +- htdocs/core/login/functions_openid_connect.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index 0591a1baddf..4ff7576e934 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -70,7 +70,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) $sql = "SELECT login, entity, datestartvalidity, dateendvalidity"; $sql .= " FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE openid = '".$db->escape(GETPOST('openid_identity'))."'"; - $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? ((int) $_SESSION["dol_entity"]) : 1).")"; + $sql .= " AND entity IN (0,".(!empty($_SESSION["dol_entity"]) ? ((int) $_SESSION["dol_entity"]) : 1).")"; dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index f9a4483205e..0db79a506ea 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -19,6 +19,8 @@ * \file htdocs/core/login/functions_openid_connect.php * \ingroup core * \brief OpenID Connect: Authorization Code flow authentication + * + * See https://github.com/Dolibarr/dolibarr/issues/22740 for more information about setup openid_connect */ include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; From e99d25cf875876a34fb2de7e9de2d7ab8f80552d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 13 Apr 2023 23:21:05 +0200 Subject: [PATCH 088/159] Comment --- htdocs/core/lib/security.lib.php | 1 + htdocs/core/login/functions_openid.php | 3 +++ htdocs/core/login/functions_openid_connect.php | 1 + 3 files changed, 5 insertions(+) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3c9ca5e34d9..023f8ebafba 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -109,6 +109,7 @@ function dolGetRandomBytes($length) /** * Encode a string with a symetric encryption. Used to encrypt sensitive data into database. * Note: If a backup is restored onto another instance with a different $dolibarr_main_instance_unique_id, then decoded value will differ. + * This function is called for example by dol_set_const() when saving a sensible data into database configuration table llx_const. * * @param string $chain string to encode * @param string $key If '', we use $dolibarr_main_instance_unique_id diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index 4ff7576e934..d45819cf039 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -20,6 +20,9 @@ * \file htdocs/core/login/functions_openid.php * \ingroup core * \brief Authentication functions for OpenId mode + * + * This authentication method is based on "OpenID v2" and is deprecated. + * Use instead the method "OpenID Connect". */ include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php'; diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index 0db79a506ea..b1980b3419f 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -96,6 +96,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { + // TODO I think we can remove this because this is done now natively by core after calling check_user_password_openid_connect() $now = dol_now(); if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) { // Load translation files required by the page From 834cb830475471c4b8b1dcbc4cb2261cefe29622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 14 Apr 2023 10:06:10 +0200 Subject: [PATCH 089/159] NEW repair script skip views --- htdocs/core/db/Database.interface.php | 11 +++++++++ htdocs/core/db/mysqli.class.php | 32 +++++++++++++++++++++++++++ htdocs/core/db/pgsql.class.php | 28 +++++++++++++++++++++++ htdocs/core/db/sqlite3.class.php | 32 +++++++++++++++++++++++++++ htdocs/install/repair.php | 28 ++++++++++++++--------- 5 files changed, 121 insertions(+), 10 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 180f928eac0..ac9d6134f9a 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -129,6 +129,17 @@ interface Database public function DDLListTables($database, $table = ''); // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * List tables into a database with table type + * + * @param string $database Name of database + * @param string $table Name of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTablesFull($database, $table = ''); + // phpcs:enable + /** * Return last request executed with query() * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index e36fc547fa0..091a9bb8cf6 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -716,6 +716,38 @@ class DoliDBMysqli extends DoliDB return $listtables; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * List tables into a database + * + * @param string $database Name of database + * @param string $table Nmae of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTablesFull($database, $table = '') + { + // phpcs:enable + $listtables = array(); + + $like = ''; + if ($table) { + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; + } + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW FULL TABLES FROM `".$tmpdatabase."` ".$like.";"; + + $result = $this->query($sql); + if ($result) { + while ($row = $this->fetch_row($result)) { + $listtables[] = $row; + } + } + return $listtables; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index fb18ed0f161..626a2ef6043 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -977,6 +977,34 @@ class DoliDBPgsql extends DoliDB return $listtables; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * List tables into a database + * + * @param string $database Name of database + * @param string $table Name of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTablesFull($database, $table = '') + { + // phpcs:enable + $listtables = array(); + + $escapedlike = ''; + if ($table) { + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $escapedlike = " AND table_name LIKE '".$this->escape($tmptable)."'"; + } + $result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name"); + if ($result) { + while ($row = $this->fetch_row($result)) { + $listtables[] = $row; + } + } + return $listtables; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 40d0f10baa8..909676439ca 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -896,6 +896,38 @@ class DoliDBSqlite3 extends DoliDB return $listtables; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * List tables into a database with table type + * + * @param string $database Name of database + * @param string $table Name of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTablesFull($database, $table = '') + { + // phpcs:enable + $listtables = array(); + + $like = ''; + if ($table) { + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; + } + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW FULL TABLES FROM ".$tmpdatabase." ".$like.";"; + //print $sql; + $result = $this->query($sql); + if ($result) { + while ($row = $this->fetch_row($result)) { + $listtables[] = $row; + } + } + return $listtables; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 70be057b7b8..b5b408b00ca 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1244,7 +1244,7 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { if ($db->type == "mysql" || $db->type == "mysqli") { $force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha'); - $listoftables = $db->DDLListTables($db->database_name); + $listoftables = $db->DDLListTablesFull($db->database_name); // Disable foreign key checking for avoid errors if ($force_utf8_on_tables == 'confirmed') { @@ -1255,14 +1255,18 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { foreach ($listoftables as $table) { // do not convert llx_const if mysql encrypt/decrypt is used - if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table[0])) { + continue; + } + if ($table[1] == 'VIEW') { + print ''.$table[0].' is a '.$table[1].' (Skipped)'; continue; } print ''; - print $table; - $sql1 = "ALTER TABLE ".$table." ROW_FORMAT=dynamic"; - $sql2 = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + print $table[0]; + $sql1 = "ALTER TABLE ".$table[0]." ROW_FORMAT=dynamic"; + $sql2 = "ALTER TABLE ".$table[0]." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; print ''; print ''; if ($force_utf8_on_tables == 'confirmed') { @@ -1297,7 +1301,7 @@ if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { if ($db->type == "mysql" || $db->type == "mysqli") { $force_utf8mb4_on_tables = GETPOST('force_utf8mb4_on_tables', 'alpha'); - $listoftables = $db->DDLListTables($db->database_name); + $listoftables = $db->DDLListTablesFull($db->database_name); // Disable foreign key checking for avoid errors if ($force_utf8mb4_on_tables == 'confirmed') { @@ -1308,14 +1312,18 @@ if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { foreach ($listoftables as $table) { // do not convert llx_const if mysql encrypt/decrypt is used - if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table[0])) { + continue; + } + if ($table[1] == 'VIEW') { + print ''.$table[0].' is a '.$table[1].' (Skipped)'; continue; } print ''; - print $table; - $sql1 = "ALTER TABLE ".$table." ROW_FORMAT=dynamic"; - $sql2 = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; + print $table[0]; + $sql1 = "ALTER TABLE ".$table[0]." ROW_FORMAT=dynamic"; + $sql2 = "ALTER TABLE ".$table[0]." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; print ''; print ''; if ($force_utf8mb4_on_tables == 'confirmed') { From ccb88a9b76a61b79605f6759b3a447d724336b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 14 Apr 2023 10:10:28 +0200 Subject: [PATCH 090/159] NEW repair script skip views --- htdocs/core/db/pgsql.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 626a2ef6043..2295d659704 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -996,7 +996,7 @@ class DoliDBPgsql extends DoliDB $escapedlike = " AND table_name LIKE '".$this->escape($tmptable)."'"; } - $result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name"); + $result = pg_query($this->db, "SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name"); if ($result) { while ($row = $this->fetch_row($result)) { $listtables[] = $row; From 0c86eebcc7968a55e9b27e164ba9f4cfe4e344b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 14 Apr 2023 10:15:23 +0200 Subject: [PATCH 091/159] fix debug bar --- htdocs/debugbar/class/TraceableDB.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 8e28b0c59bd..3622558731f 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -205,6 +205,18 @@ class TraceableDB extends DoliDB return $this->db->DDLListTables($database, $table); } + /** + * List tables into a database with table info + * + * @param string $database Name of database + * @param string $table Nmae of table filter ('xxx%') + * @return array List of tables in an array + */ + public function DDLListTablesFull($database, $table = '') + { + return $this->db->DDLListTablesFull($database, $table); + } + /** * Return last request executed with query() * From f5ce54728dc375f2a4f93d3207f326783d34312b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Apr 2023 13:18:10 +0200 Subject: [PATCH 092/159] Fix css --- htdocs/user/list.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 1f18cc20da5..368b5d7856f 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -1189,13 +1189,14 @@ while ($i < $imaxinloop) { // Multicompany enabled if (isModEnabled('multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if (!empty($arrayfields['u.entity']['checked'])) { - print ''; if (!$obj->entity) { - print $langs->trans("AllEntities"); + $labeltouse = $langs->trans("AllEntities"); } else { $mc->getInfo($obj->entity); - print $mc->label; + $labeltouse = $mc->label; } + print ''; + print $labeltouse; print ''; if (!$i) { $totalarray['nbfield']++; From 98e389bdcedb1c68115040232549f072919e772d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Apr 2023 13:18:10 +0200 Subject: [PATCH 093/159] Fix css --- htdocs/user/list.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 4bec595bf48..28e84a677b7 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -1164,13 +1164,14 @@ while ($i < $imaxinloop) { // Multicompany enabled if (isModEnabled('multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if (!empty($arrayfields['u.entity']['checked'])) { - print ''; if (!$obj->entity) { - print $langs->trans("AllEntities"); + $labeltouse = $langs->trans("AllEntities"); } else { $mc->getInfo($obj->entity); - print $mc->label; + $labeltouse = $mc->label; } + print ''; + print $labeltouse; print ''; if (!$i) { $totalarray['nbfield']++; From f425bd46540747de95e57119b8b39f095d3c3cff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 01:24:50 +0200 Subject: [PATCH 094/159] Fix sqlforlike when searching with like and _ string --- htdocs/core/db/mysqli.class.php | 2 +- htdocs/core/db/pgsql.class.php | 2 +- htdocs/core/db/sqlite3.class.php | 2 +- test/phpunit/CodingSqlTest.php | 38 ++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 0eef42b7424..a05dbf46e4b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -494,7 +494,7 @@ class DoliDBMysqli extends DoliDB */ public function escapeforlike($stringtoencode) { - return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 28ac15a43ff..f4df72ceb26 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -741,7 +741,7 @@ class DoliDBPgsql extends DoliDB */ public function escapeforlike($stringtoencode) { - return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index e31eeffe457..71872b0898b 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -669,7 +669,7 @@ class DoliDBSqlite3 extends DoliDB */ public function escapeforlike($stringtoencode) { - return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode); } /** diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 00c7a5aebae..504203eeabf 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -157,6 +157,44 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } + /** + * testEscape + * + * @return string + */ + public function testEscape() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $a = 'abc"\'def'; + print $a; + $result = $db->escape($a); // $result must be abc\"\'def + $this->assertEquals('abc\"\\\'def', $result); + } + + /** + * testEscapeForLike + * + * @return string + */ + public function testEscapeForLike() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $a = 'abc"\'def_ghi%klm\\nop'; + //print $a; + $result = $db->escapeforlike($a); // $result must be abc"'def\_ghi\%klm\\nop + $this->assertEquals('abc"\'def\_ghi\%klm\\\\nop', $result); + } + /** * testSql * From 6b7de51d213f1ce016aa13950149b02827c85592 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 01:52:35 +0200 Subject: [PATCH 095/159] Work on PHP 8 compatibility --- htdocs/core/class/conf.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/install/inc.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d70de618be8..01cdfde69fe 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -358,11 +358,12 @@ class Conf if ($modulename == 'supplierproposal') { $modulename = 'supplier_proposal'; } + $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules + // deprecated if (!isset($this->$modulename) || !is_object($this->$modulename)) { $this->$modulename = new stdClass(); } $this->$modulename->enabled = true; - $this->modules[] = $modulename; // Add this module in list of enabled modules } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 82644198aa3..a139a66c286 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -166,7 +166,9 @@ function getDolUserInt($key, $default = 0, $tmpuser = null) function isModEnabled($module) { global $conf; - return !empty($conf->$module->enabled); + + return !empty($conf->modules[$module]); + //return !empty($conf->$module->enabled); } /** diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 636f365683f..c0bded73cd2 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -323,6 +323,7 @@ if (!isset($conf->syslog) || !is_object($conf->syslog)) { $conf->syslog = new stdClass(); } $conf->syslog->enabled = 1; +$conf->modules['syslog'] = 'syslog'; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); @@ -435,6 +436,7 @@ function conf($dolibarr_main_document_root) $conf->syslog = new stdClass(); } $conf->syslog->enabled = 1; + $conf->modules['syslog'] = 'syslog'; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); From b55271dedb0f63fa40262c2f117f8b3820b8e317 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 03:16:53 +0200 Subject: [PATCH 096/159] Fix warning --- htdocs/core/class/conf.class.php | 2 +- htdocs/user/class/user.class.php | 6 ++++++ scripts/cron/cron_run_jobs.php | 8 +------- scripts/emailings/mailing-send.php | 8 ++++---- test/phpunit/ActionCommTest.php | 2 +- test/phpunit/AllTests.php | 4 ++-- test/phpunit/BuildDocTest.php | 14 +++++++------- test/phpunit/CommandeTest.php | 2 +- test/phpunit/EntrepotTest.php | 2 +- test/phpunit/FactureTest.php | 2 +- test/phpunit/FilesLibTest.php | 11 +++++++++-- test/phpunit/FunctionsLibTest.php | 4 ++-- test/phpunit/KnowledgeRecordTest.php | 2 +- test/phpunit/MouvementStockTest.php | 2 +- test/phpunit/PaypalTest.php | 2 +- test/phpunit/PricesTest.php | 5 ----- test/phpunit/ProductTest.php | 2 +- test/phpunit/RestAPIUserTest.php | 2 +- test/phpunit/StripeTest.php | 2 +- test/phpunit/WebservicesProductsTest.php | 2 +- 20 files changed, 43 insertions(+), 41 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 01cdfde69fe..410ecfe7399 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -359,7 +359,7 @@ class Conf $modulename = 'supplier_proposal'; } $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules - // deprecated + // deprecated in php 8.2 if (!isset($this->$modulename) || !is_object($this->$modulename)) { $this->$modulename = new stdClass(); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index aa065dcbceb..e7b9bdbf844 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -257,6 +257,12 @@ class User extends CommonObject */ public $clicktodial_poste; + /** + * @var string 0 by default, 1 if click to dial data were already loaded for this user + */ + public $clicktodial_loaded; + + public $datelastlogin; public $datepreviouslogin; public $flagdelsessionsbefore; diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 29c8025758c..818f2676af6 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -95,13 +95,7 @@ $now = dol_now(); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=".$userlogin." - ".dol_print_date($now, 'dayhourrfc')." - ".gethostname()." *****\n"; // Check module cron is activated -if (empty($conf->cron->enabled)) { - print "Error: module Scheduled jobs (cron) not activated\n"; - exit(-1); -} - -// Check module cron is activated -if (empty($conf->cron->enabled)) { +if (!isModEnabled('cron')) { print "Error: module Scheduled jobs (cron) not activated\n"; exit(-1); } diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 464a127ce15..63f10782978 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -234,13 +234,13 @@ if ($resql) { $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid); $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $onlinepaymentenabled++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $onlinepaymentenabled++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -258,7 +258,7 @@ if ($resql) { } } /* For backward compatibility */ - if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { + if (isModEnabled('paypal') && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index 2499841d671..12be63af3e4 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -83,7 +83,7 @@ class ActionCommTest extends PHPUnit\Framework\TestCase global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - if (empty($conf->agenda->enabled)) { + if (!isModEnabled('agenda')) { print __METHOD__." module agenda must be enabled.\n"; die(1); } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 84ea7a42a6e..9a6934da2f4 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -37,7 +37,7 @@ if ($langs->defaultlang != 'en_US') { print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n"; exit(1); } -if (empty($conf->adherent->enabled)) { +if (!isModEnabled('adherent')) { print "Error: Module member must be enabled to have significant results.\n"; exit(1); } @@ -45,7 +45,7 @@ if (isModEnabled('ldap')) { print "Error: LDAP module should not be enabled.\n"; exit(1); } -if (!empty($conf->google->enabled)) { +if (isModEnabled('google')) { print "Warning: Google module should not be enabled.\n"; } if (empty($user->id)) { diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index bf61ba38fbd..4d12760a1ba 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -112,25 +112,25 @@ class BuildDocTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (! $conf->facture->enabled) { + if (!isModEnabled('facture')) { print __METHOD__." invoice module not enabled\n"; die(1); } - if (! $conf->commande->enabled) { + if (!isModEnabled('commande')) { print __METHOD__." order module not enabled\n"; die(1); } - if (! $conf->propal->enabled) { + if (!isModEnabled('propal')) { print __METHOD__." propal module not enabled\n"; die(1); } - if (! $conf->project->enabled) { + if (!isModEnabled('project')) { print __METHOD__." project module not enabled\n"; die(1); } - if (! $conf->expedition->enabled) { + if (!isModEnabled('expedition')) { print __METHOD__." shipment module not enabled\n"; die(1); } - if (! $conf->ficheinter->enabled) { + if (!isModEnabled('ficheinter')) { print __METHOD__." intervention module not enabled\n"; die(1); } - if (! $conf->expensereport->enabled) { + if (!isModEnabled('expensereport')) { print __METHOD__." expensereport module not enabled\n"; die(1); } diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index cb439fe2c84..196ec351d2f 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -83,7 +83,7 @@ class CommandeTest extends PHPUnit\Framework\TestCase global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - if (empty($conf->commande->enabled)) { + if (!isModEnabled('commande')) { print __METHOD__." module customer order must be enabled.\n"; die(1); } diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 8ee0c537f8a..d3cdd2d52d4 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -82,7 +82,7 @@ class EntrepotTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->stock->enabled)) { + if (!isModEnabled('stock')) { print __METHOD__." Module Stock must be enabled.\n"; die(1); } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 5f12eacdd60..6f1dacf0aab 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -86,7 +86,7 @@ class FactureTest extends PHPUnit\Framework\TestCase if (!isModEnabled('facture')) { print __METHOD__." module customer invoice must be enabled.\n"; die(1); } - if (!empty($conf->ecotaxdeee->enabled)) { + if (isModEnabled('ecotaxdeee')) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(1); } diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 8ba2022c111..3af5c36023a 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -417,7 +417,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $errorstring = ''; dol_mkdir($conf->admin->dir_temp); - $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; + $conf->syslog->enabled=1; + $conf->modules['syslog'] = 'syslog'; + $_REQUEST['logtohtml']=1; $conf->logbuffer=array(); $result=dol_compress_file($filein, $fileout, $format, $errorstring); @@ -427,6 +430,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_uncompress($fileout, $dirout); print __METHOD__." uncompress result=".join(',', $result)."\n"; + print join(', ', $conf->logbuffer); $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); // Format gz @@ -445,7 +449,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $errorstring = ''; dol_mkdir($conf->admin->dir_temp); - $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; + $conf->syslog->enabled=1; + $conf->modules['syslog'] = 'syslog'; + $_REQUEST['logtohtml']=1; $conf->logbuffer=array(); $result=dol_compress_file($filein, $fileout, $format, $errorstring); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index e635e449379..c361698a501 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1141,10 +1141,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $verifcond=verifCond('1==2'); $this->assertFalse($verifcond, 'Test a false comparison'); - $verifcond=verifCond('$conf->facture->enabled'); + $verifcond=verifCond('isModEnabled("facture")'); $this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled'); - $verifcond=verifCond('$conf->moduledummy->enabled'); + $verifcond=verifCond('isModEnabled("moduledummy")'); $this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled'); $verifcond=verifCond(0); diff --git a/test/phpunit/KnowledgeRecordTest.php b/test/phpunit/KnowledgeRecordTest.php index ffa189adc48..d071ea7b024 100644 --- a/test/phpunit/KnowledgeRecordTest.php +++ b/test/phpunit/KnowledgeRecordTest.php @@ -86,7 +86,7 @@ class KnowledgeRecordTest extends PHPUnit\Framework\TestCase global $conf, $user, $langs, $db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - if (empty($conf->knowledgemanagement->enabled)) { + if (!isModEnabled('knowledgemanagement')) { print __METHOD__." module knowledgemanagement must be enabled.\n"; die(1); } } diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index d084f50d6e0..da3afc0d070 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -114,7 +114,7 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - if (empty($conf->productbatch->enabled)) { + if (!isModEnabled('productbatch')) { print "\n".__METHOD__." module Lot/Serial must be enabled.\n"; die(1); } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index 378c703684b..fdcc17fd48d 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -83,7 +83,7 @@ class PaypalTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->paypal->enabled)) { + if (!isModEnabled('paypal')) { print __METHOD__." Module Paypal must be enabled.\n"; die(1); } diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 5378407c2b4..7d88fa69897 100644 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -149,11 +149,6 @@ class PricesTest extends PHPUnit\Framework\TestCase global $mysoc; $mysoc=new Societe($db); - // To force status that say module multicompany is on - //$conf->multicurrency=new stdClass(); - //$conf->multicurrency->enabled = 0; - - /* * Country France */ diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index d23d2562f22..79685e5fab5 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -82,7 +82,7 @@ class ProductTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->produit->enabled)) { + if (!isModEnabled('produit')) { print __METHOD__." Module Product must be enabled.\n"; die(1); } diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index a1214c1a047..4de0557c561 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -73,7 +73,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $this->savlangs=$langs; $this->savdb=$db; - if (empty($conf->api->enabled)) { + if (!isModEnabled('api')) { print __METHOD__." module api must be enabled.\n"; die(1); } diff --git a/test/phpunit/StripeTest.php b/test/phpunit/StripeTest.php index 08eb585b7f7..e26b023a38e 100644 --- a/test/phpunit/StripeTest.php +++ b/test/phpunit/StripeTest.php @@ -83,7 +83,7 @@ class StripeTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->stripe->enabled)) { + if (!isModEnabled('stripe')) { print __METHOD__." Module Stripe must be enabled.\n"; die(1); } diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index f79bdc6313c..021c305f7e2 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -42,7 +42,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; $conf->global->MAIN_UMASK='0666'; -if (empty($conf->service->enabled)) { +if (!isModEnabled('service')) { print "Error: Module service must be enabled.\n"; exit(1); } From 443f5190dbc60c31e4b67c73daddc5911bf862e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 04:19:53 +0200 Subject: [PATCH 097/159] Fix phpunit --- test/phpunit/CodingSqlTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 504203eeabf..d72dc879742 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -170,10 +170,12 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - $a = 'abc"\'def'; - print $a; - $result = $db->escape($a); // $result must be abc\"\'def - $this->assertEquals('abc\"\\\'def', $result); + if ($db->type == 'mysqli') { + $a = 'abc"\'def'; + print $a; + $result = $db->escape($a); // $result must be abc\"\'def with mysql + $this->assertEquals('abc\"\\\'def', $result); + } } /** @@ -191,7 +193,7 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase $a = 'abc"\'def_ghi%klm\\nop'; //print $a; - $result = $db->escapeforlike($a); // $result must be abc"'def\_ghi\%klm\\nop + $result = $db->escapeforlike($a); // $result must be abc"'def\_ghi\%klm\\nop with mysql $this->assertEquals('abc"\'def\_ghi\%klm\\\\nop', $result); } From 4db9830f1cd8a98f3a53dd34c432e2d8323401a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 04:20:53 +0200 Subject: [PATCH 098/159] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee378d191dd..6cb27e2307f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,7 +77,7 @@ jobs: php: '8.1' env: DB=mysql - stage: PHP Dev - if: type = push AND branch = develop + if: type = push AND branch = developdisabled php: '8.2' env: DB=mysql From 4e3dcbab293ecdc129d99cec06d2bc9d76590679 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 12:13:24 +0200 Subject: [PATCH 099/159] Fix phpunit --- htdocs/core/lib/functions.lib.php | 6 ++++++ test/phpunit/BuildDocTest.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a139a66c286..8ddb3843696 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -167,6 +167,12 @@ function isModEnabled($module) { global $conf; + // Fix special cases + $arrayconv = array('project' => 'projet'); + if (!empty($arrayconv[$module])) { + $module = $arrayconv[$module]; + } + return !empty($conf->modules[$module]); //return !empty($conf->$module->enabled); } diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 4d12760a1ba..ff29cea109a 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -121,7 +121,7 @@ class BuildDocTest extends PHPUnit\Framework\TestCase if (!isModEnabled('propal')) { print __METHOD__." propal module not enabled\n"; die(1); } - if (!isModEnabled('project')) { + if (!isModEnabled('projet')) { print __METHOD__." project module not enabled\n"; die(1); } if (!isModEnabled('expedition')) { From 0c251d64bbf3f560581554c52f25a505ea8cffcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 01:35:33 +0300 Subject: [PATCH 100/159] Update llx_10_c_regions.sql Turkey regions added --- htdocs/install/mysql/data/llx_10_c_regions.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index f86fbe069b8..d319396e246 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -547,3 +547,11 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23208, '', 0, 'Nor-Oriental'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23209, '', 0, 'Zuliana'); +-- Turkiye (Turkey) Regions (id country=221) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22101, '', 0, 'Marmara'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22102, '', 0, 'İç Anadolu'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22103, '', 0, 'Ege'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22104, '', 0, 'Akdeniz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22105, '', 0, 'Güneydoğu'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22106, '', 0, 'Karadeniz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 221, 22107, '', 0, 'Doğu Anadolu'); From f0d4dc1caf85efa485347d8c9c148567a5d5c2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 01:41:37 +0300 Subject: [PATCH 101/159] Update llx_c_tva.sql Turkey Vat added --- htdocs/install/mysql/data/llx_c_tva.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 72cff6afde7..74e62e8acdc 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -403,3 +403,9 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2335,61, '0','0','No VAT',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2336,61, '10','0','VAT 10%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2337,61, '18','0','VAT 18%',1); + +-- Turkiye (Turkey) (id country=221) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22101,221, '0','0','No VAT',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22102,221, '1','0','VAT 1%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22103,221, '8','0','VAT 8%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (22104,221, '18','0','VAT 18%',1); From 80a6d08e8438d37f9ce5c744c7029e3d91921bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 02:21:20 +0300 Subject: [PATCH 102/159] Update llx_20_c_departements.sql Turkiye cities added --- .../mysql/data/llx_20_c_departements.sql | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 9e93196c3d7..bff1a15fa93 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -1951,3 +1951,88 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '45', '', 0, '宮崎', '宮崎県', 1); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '46', '', 0, '鹿児島', '鹿児島県', 1); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) values (12301, '47', '', 0, '沖縄', '沖縄県', 1); + + +-- Turkiye (Turkey) (id country=221) + +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-01',22104,'Adana'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-02',22107,'Adıyaman'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-03',22103,'Afyon'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-04',22107,'Ağrı'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-05',22106,'Amasya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-06',22102,'Ankara'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-07',22104,'Antalya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-08',22106,'Artvin'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-09',22103,'Aydın'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-10',22101,'Balıkesir'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-11',22101,'Bilecik'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-12',22107,'Bingöl'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-13',22107,'Bitlis'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-14',22106,'Bolu'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-15',22104,'Burdur'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-16',22101,'Bursa'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-17',22101,'Çanakkale'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-18',22102,'Çankırı'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-19',22106,'Çorum'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-20',22104,'Denizli'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-21',22105,'Diyarbakır'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-22',22101,'Edirne'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-23',22107,'Elazığ'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-24',22107,'Erzincan'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-25',22107,'Erzurum'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-26',22102,'Eskişehir'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-27',22105,'Gaziantep'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-28',22106,'Giresun'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-29',22106,'Gümüşhane'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-30',22107,'Hakkari'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-31',22104,'Hatay'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-32',22104,'Isparta'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-33',22104,'İçel'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-34',22101,'İstanbul'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-35',22103,'İzmir'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-36',22107,'Kars'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-37',22106,'Kastamonu'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-38',22102,'Kayseri'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-39',22101,'Kırklareli'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-40',22102,'Kırşehir'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-41',22101,'Kocaeli'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-42',22102,'Konya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-43',22103,'Kütahya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-44',22107,'Malatya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-45',22103,'Manisa'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-46',22104,'Kahramanmaraş'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-47',22105,'Mardin'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-48',22103,'Muğla'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-49',22107,'Muş'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-50',22102,'Nevşehir'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-51',22102,'Niğde'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-52',22106,'Ordu'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-53',22106,'Rize'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-54',22101,'Sakarya'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-55',22106,'Samsun'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-56',22105,'Siirt'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-57',22106,'Sinop'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-58',22102,'Sivas'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-59',22101,'Tekirdağ'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-60',22106,'Tokat'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-61',22106,'Trabzon'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-62',22107,'Tunceli'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-63',22105,'Şanlıurfa'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-63',22103,'Uşak'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-65',22107,'Van'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-66',22102,'Yozgat'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-67',22106,'Zonguldak'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-68',22102,'Aksaray'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-69',22106,'Bayburt'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-70',22102,'Karaman'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-71',22102,'Kırıkkale'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-72',22105,'Batman'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-73',22105,'Şırnak'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-74',22106,'Bartın'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-75',22107,'Ardahan'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-76',22107,'Iğdır'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-77',22101,'Yalova'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-78',22106,'Karabük'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-79',22105,'Kilis'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-80',22104,'Osmaniye'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce); From ed4331ee1601d4007d1cc857c445591b6c21835f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 02:27:44 +0300 Subject: [PATCH 103/159] Update llx_c_currencies.sql Turkey Lira currency sign fixed --- htdocs/install/mysql/data/llx_c_currencies.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index 04d17e98b6a..0c02c303c78 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -154,7 +154,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TWD' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'THB', '[3647]', 1, 'Thailand Baht'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TTD', '[84,84,36]', 1, 'Trinidad and Tobago Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TND', NULL, 1, 'Tunisia Dinar'); -INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TRY', '[8356]', 1, 'Turkey Lira'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TRY', '[8378]', 1, 'Turkey Lira'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'TVD', '[36]', 1, 'Tuvalu Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'UAH', '[8372]', 1, 'Ukraine Hryvna'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'AED', NULL, 1, 'United Arab Emirates Dirham'); From c58840d32bfdaef53c733869f7276764b1fa231a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 02:34:12 +0300 Subject: [PATCH 104/159] Update llx_20_c_departements.sql typo fixed --- htdocs/install/mysql/data/llx_20_c_departements.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index bff1a15fa93..ad647028c9a 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -2035,4 +2035,4 @@ INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-77 INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-78',22106,'Karabük'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-79',22105,'Kilis'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-80',22104,'Osmaniye'); -INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce'); From f376fce8b58da19372f8ca32e5b1e1c2a05b9661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:02:42 +0300 Subject: [PATCH 105/159] Update llx_c_revenuestamp.sql Turkey Revenue stamp tax added --- htdocs/install/mysql/data/llx_c_revenuestamp.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_revenuestamp.sql b/htdocs/install/mysql/data/llx_c_revenuestamp.sql index 8f8eaca93ca..f19f40abe30 100644 --- a/htdocs/install/mysql/data/llx_c_revenuestamp.sql +++ b/htdocs/install/mysql/data/llx_c_revenuestamp.sql @@ -31,6 +31,10 @@ insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) -- MEXICO (id country=154) -- -insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1); +insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1); insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1542, 154, 3, 'percent', 'Revenue stamp mexico', 1); +-- Turkiye (Turkey) (id country=221) -- +insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (22101,221,0.00948,'percent','Mukavelenameler Damga Vergisi',1); +insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (22102,221,0.00189,'percent','Kira mukavelenameleri Damga Vergisi',1); + From 69bca5da4b4b3a3c3e09eb89a09d9405f93b26d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bayram=20G=C3=BCrb=C3=BCz?= <68557038+BayramGrbz45@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:13:20 +0300 Subject: [PATCH 106/159] Update llx_c_revenuestamp.sql fix tipo --- htdocs/install/mysql/data/llx_c_revenuestamp.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_revenuestamp.sql b/htdocs/install/mysql/data/llx_c_revenuestamp.sql index f19f40abe30..ba4e316e2d0 100644 --- a/htdocs/install/mysql/data/llx_c_revenuestamp.sql +++ b/htdocs/install/mysql/data/llx_c_revenuestamp.sql @@ -31,7 +31,7 @@ insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) -- MEXICO (id country=154) -- -insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1); +insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1); insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1542, 154, 3, 'percent', 'Revenue stamp mexico', 1); -- Turkiye (Turkey) (id country=221) -- From df909b515faec901b0e5be76e53eab1109b49d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 17 Apr 2023 13:42:05 +0200 Subject: [PATCH 107/159] Fix phpunit --- test/phpunit/ProductTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 79685e5fab5..93a5e4787ba 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -82,7 +82,7 @@ class ProductTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (!isModEnabled('produit')) { + if (!isModEnabled('product')) { print __METHOD__." Module Product must be enabled.\n"; die(1); } From 939d5cc3225c9f516bf9c5ae9281ba9052ec18bc Mon Sep 17 00:00:00 2001 From: x Date: Tue, 18 Apr 2023 10:26:51 +0200 Subject: [PATCH 108/159] Add fk_default_workstation on bom line and mrp production --- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_bom_bomline.sql | 3 ++- htdocs/install/mysql/tables/llx_mrp_production.sql | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) 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 c4735898126..cf71f0a02e4 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 @@ -394,3 +394,6 @@ ALTER TABLE llx_c_email_templates add COLUMN defaultfortype smallint DEFAULT 0; ALTER TABLE llx_mailing ADD COLUMN fk_user_modif integer AFTER fk_user_creat; ALTER TABLE llx_mailing ADD COLUMN evenunsubscribe smallint DEFAULT 0; ALTER TABLE llx_mailing ADD COLUMN name_from varchar(128) AFTER email_from; + +ALTER TABLE llx_bom_bomline ADD COLUMN fk_default_workstation integer DEFAULT NULL; +ALTER TABLE llx_mrp_production ADD COLUMN fk_default_workstation integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index eae1f6c6662..27f22e5c07e 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -26,6 +26,7 @@ CREATE TABLE llx_bom_bomline( disable_stock_change smallint DEFAULT 0, efficiency double(24,8) NOT NULL DEFAULT 1, fk_unit integer NULL, - position integer NOT NULL DEFAULT 0 + position integer NOT NULL DEFAULT 0, + fk_default_workstation integer DEFAULT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_mrp_production.sql b/htdocs/install/mysql/tables/llx_mrp_production.sql index a76e1f655ae..eac6bb1969b 100644 --- a/htdocs/install/mysql/tables/llx_mrp_production.sql +++ b/htdocs/install/mysql/tables/llx_mrp_production.sql @@ -33,6 +33,7 @@ CREATE TABLE llx_mrp_production( tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_user_creat integer NOT NULL, fk_user_modif integer, - import_key varchar(14) + import_key varchar(14), + fk_default_workstation integer DEFAULT NULL ) ENGINE=innodb; From ce227bd78ef1e7f23cd89ad197051b0c672de795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 10:46:24 +0200 Subject: [PATCH 109/159] use isModEnabled --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index e7b9bdbf844..8767c70f2b1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke * Copyright (C) 2018-2021 Nicolas ZABOURI - * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * Copyright (C) 2019 Abbes Bahfir * * This program is free software; you can redistribute it and/or modify @@ -2453,7 +2453,7 @@ class User extends CommonObject //print $password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id; $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword'; $url .= '&username='.urlencode($this->login)."&passworduidhash=".urlencode(dol_hash($password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id)); - if (!empty($conf->multicompany->enabled)) { + if (isModEnabled('multicompany')) { $url .= '&entity='.(!empty($this->entity) ? $this->entity : 1); } From e3d6933cf085283e0796e0d23c6b0f522d2af085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 10:53:00 +0200 Subject: [PATCH 110/159] Update translate.class.php --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 7379877753b..19cb66ad68d 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -459,7 +459,7 @@ class Translate // Enable caching of lang file in memory (not by default) $usecachekey = ''; // Using a memcached server - if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { + if (isModEnabled('memcached') && !empty($conf->global->MEMCACHED_SERVER)) { $usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) From 5ce5559ee53641d2d7f5cf66c953be78a43e20d7 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 18 Apr 2023 11:01:57 +0200 Subject: [PATCH 111/159] Add field on class "fk_default_workstation" --- htdocs/bom/class/bom.class.php | 6 ++++++ htdocs/mrp/class/mo.class.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 43a40705660..e10139f3711 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1732,6 +1732,12 @@ class BOMLine extends CommonObjectLine */ public $childBom = array(); + /* + * Service Workstation + */ + public $fk_default_workstation; + + /** * Constructor diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 100043ef055..d170230e0f7 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1744,6 +1744,11 @@ class MoLine extends CommonObjectLine public $import_key; public $fk_parent_line; + /* + * Service Workstation + */ + public $fk_default_workstation; + /** * Constructor * From c2fe891ed6a4f6a530aa49dde7b1ac6e98cb8a3c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 18 Apr 2023 09:06:26 +0000 Subject: [PATCH 112/159] Fixing style errors. --- htdocs/mrp/class/mo.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d170230e0f7..f7587daf331 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1744,10 +1744,10 @@ class MoLine extends CommonObjectLine public $import_key; public $fk_parent_line; - /* + /* * Service Workstation */ - public $fk_default_workstation; + public $fk_default_workstation; /** * Constructor From 8e51bf2c55d00d330ac60a8997ffe313e23d7a50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 14:04:27 +0200 Subject: [PATCH 113/159] Debug 18 --- htdocs/admin/agenda.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/conf.class.php | 7 ------- htdocs/core/lib/expedition.lib.php | 4 ++-- htdocs/core/lib/order.lib.php | 14 +++++++------- htdocs/core/lib/propal.lib.php | 13 ++++++++----- htdocs/core/lib/sendings.lib.php | 12 ++++++------ htdocs/delivery/card.php | 16 +++++++++------- htdocs/delivery/class/delivery.class.php | 5 ++--- htdocs/expedition/card.php | 8 ++++---- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/expedition/list.php | 4 ++-- htdocs/product/index.php | 6 +++--- htdocs/reception/card.php | 4 ++-- 15 files changed, 49 insertions(+), 52 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 7c7eecc84f0..b6e30f65454 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -161,7 +161,7 @@ if (!empty($triggers)) { $module = 'fournisseur'; } if ($module == 'shipping') { - $module = 'expedition_bon'; + $module = 'expedition'; } if ($module == 'member') { $module = 'adherent'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 318ce32f115..1f34fbd18a9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2888,7 +2888,7 @@ if ($action == 'create' && $usercancreate) { $numshipping = $object->countNbOfShipments(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { + if ((getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'creer')) || (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'creer'))) { if ($user->hasRight('expedition', 'creer')) { print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d411321386b..1c3481fb1f6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4142,7 +4142,7 @@ abstract class CommonObject } elseif ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; - $module = 'expedition_bon'; + $module = 'expedition'; } elseif ($objecttype == 'delivery') { $classpath = 'delivery/class'; $subelement = 'delivery'; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 410ecfe7399..855b8aae2a9 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -522,13 +522,6 @@ class Conf // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. - // Sous module bons d'expedition - $this->expedition_bon = new stdClass(); - $this->expedition_bon->enabled = (empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? 0 : $this->global->MAIN_SUBMODULE_EXPEDITION); - // Sub module delivery note Sous module bons de livraison - $this->delivery_note = new stdClass(); - $this->delivery_note->enabled = (empty($this->global->MAIN_SUBMODULE_DELIVERY) ? 0 : $this->global->MAIN_SUBMODULE_DELIVERY); - // Module fournisseur if (!empty($this->fournisseur)) { $this->fournisseur->commande = new stdClass(); diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php index 21076122903..ea692fc2ab7 100644 --- a/htdocs/core/lib/expedition.lib.php +++ b/htdocs/core/lib/expedition.lib.php @@ -53,7 +53,7 @@ function expedition_prepare_head(Expedition $object) $hselected = $h; $h++; - if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { $head[$h][0] = DOL_URL_ROOT."/admin/delivery.php"; $head[$h][1] = $langs->trans("Receivings"); $h++; @@ -121,7 +121,7 @@ function expedition_admin_prepare_head() $head[$h][2] = 'receivings'; $h++; - if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { $extrafields->fetch_name_optionals_label('delivery'); $extrafields->fetch_name_optionals_label('deliverydet'); diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index cb5a2247953..8368df4496e 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -60,28 +60,28 @@ function commande_prepare_head(Commande $object) $h++; } - if ((isModEnabled('expedition_bon') && $user->hasRight('expedition', 'lire')) - || (isModEnabled('delivery_note') && $user->hasRight('expedition', 'delivery', 'lire'))) { + if ((getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'lire')) + || (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'lire'))) { $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; $text = ''; - if (isModEnabled('expedition_bon')) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { $text .= $langs->trans("Shipments"); } - if (isModEnabled('expedition_bon') && isModEnabled('delivery_note')) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { $text .= ' - '; } - if (isModEnabled('delivery_note')) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { $text .= $langs->trans("Receivings"); } if ($nbShipments > 0 || $nbReceiption > 0) { $text .= ''.($nbShipments ? $nbShipments : 0); } - if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && ($nbShipments > 0 || $nbReceiption > 0)) { $text .= ' - '; } - if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && ($nbShipments > 0 || $nbReceiption > 0)) { $text .= ($nbReceiption ? $nbReceiption : 0); } if ($nbShipments > 0 || $nbReceiption > 0) { diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 588418c7449..b24fec85a9c 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -42,16 +42,19 @@ function propal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && isModEnabled('expedition_bon') && $user->rights->expedition->lire) - || (isModEnabled("expedition") && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) { + if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->rights->expedition->lire) + || (isModEnabled("expedition") && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->lire)))) { $langs->load("sendings"); $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; - if (isModEnabled('expedition_bon')) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { $text = $langs->trans("Shipment"); } - if (isModEnabled('delivery_note')) { - $text .= '/'.$langs->trans("Receivings"); + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + $text .= '/'; + } + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + $text .= $langs->trans("Receivings"); } $head[$h][1] = $text; $head[$h][2] = 'shipping'; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 4013c6d41e9..cfbed82f9d3 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,7 +47,7 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; - if ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->lire) { // delivery link $object->fetchObjectLinked($object->id, $object->element); if (isset($object->linkedObjectsIds['delivery']) && is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) { // If there is a delivery @@ -133,7 +133,7 @@ function delivery_prepare_head($object) $h = 0; $head = array(); - if (isModEnabled('expedition_bon') && $user->rights->expedition->lire) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->rights->expedition->lire) { $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; $head[$h][1] = $langs->trans("SendingCard"); $head[$h][2] = 'shipping'; @@ -236,13 +236,13 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; - //if ($conf->delivery_note->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; $sql .= ' p.description as product_desc'; $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; //TODO Add link to expeditiondet_batch $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; @@ -285,7 +285,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; print ''; }*/ - if (!empty($conf->delivery_note->enabled)) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { print ''.$langs->trans("DeliveryOrder").''; //print ''.$langs->trans("QtyReceived").''; print ''.$langs->trans("DeliveryDate").''; @@ -427,7 +427,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') }*/ // Informations on receipt - if (!empty($conf->delivery_note->enabled)) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { include_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php'; $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index ea345efadcb..abed76cff93 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (isModEnabled("product") || isModEnabled("service")) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } -if (isModEnabled('expedition_bon')) { +if (isModEnabled('expedition')) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; } if (isModEnabled('stock')) { @@ -104,9 +104,10 @@ if ($action == 'add') { $object->commande_id = GETPOST("commande_id", 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - if (!isModEnabled('expedition_bon') && isModEnabled('stock')) { - $expedition->entrepot_id = GETPOST('entrepot_id', 'int'); - } + /* ->entrepot_id seems to not exists + if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) { + $object->entrepot_id = GETPOST('entrepot_id', 'int'); + }*/ // We loop on each line of order to complete object delivery with qty to delivery $commande = new Commande($db); @@ -479,10 +480,11 @@ if ($action == 'create') { print ''.$object->getLibStatut(4)."\n"; print '';*/ - if (!isModEnabled('expedition_bon') && isModEnabled('stock')) { + + if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) { // Entrepot $entrepot = new Entrepot($db); - $entrepot->fetch($object->entrepot_id); + $entrepot->fetch($expedition->entrepot_id); print ''.$langs->trans("Warehouse").''; print ''.$entrepot->label.''; print ''; @@ -647,7 +649,7 @@ if ($action == 'create') { } if ($user->rights->expedition->delivery->supprimer) { - if (isModEnabled('expedition_bon')) { + if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&expid='.$object->origin_id.'&action=delete&token='.newToken().'&backtopage='.urlencode(DOL_URL_ROOT.'/expedition/card.php?id='.$object->origin_id), ''); } else { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 472db131563..5adb955e0d3 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -205,7 +205,7 @@ class Delivery extends CommonObject dol_syslog("Delivery::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (!isModEnabled('expedition_bon')) { + if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { $commande = new Commande($this->db); $commande->id = $this->commande_id; $commande->fetch_lines(); @@ -233,8 +233,7 @@ class Delivery extends CommonObject $error++; } - if (!isModEnabled('expedition_bon')) { - // TODO standardize status uniformiser les statuts + if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { $ret = $this->setStatut(2, $this->origin_id, $this->origin); if (!$ret) { $error++; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f2947e9b09f..fb4285f369d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -436,7 +436,7 @@ if (empty($reshook)) { $_GET["commande_id"] = GETPOST('commande_id', 'int'); $action = 'create'; } - } elseif ($action == 'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer) { + } elseif ($action == 'create_delivery' && getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->creer) { // Build a receiving receipt $db->begin(); @@ -2157,13 +2157,13 @@ if ($action == 'create') { $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; $sql .= ', p.description as product_desc'; $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); @@ -2592,7 +2592,7 @@ if ($action == 'create') { // This is just to generate a delivery receipt //var_dump($object->linkedObjectsIds['delivery']); - if ($conf->delivery_note->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->delivery->creer && empty($object->linkedObjectsIds['delivery'])) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->delivery->creer && empty($object->linkedObjectsIds['delivery'])) { print dolGetButtonAction('', $langs->trans('CreateDeliveryOrder'), 'default', $_SERVER["PHP_SELF"].'?action=create_delivery&token='.newToken().'&id='.$object->id, ''); } // Close diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c3ddf973049..f145c82c9ea 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -840,7 +840,7 @@ class Expedition extends CommonObject // phpcs:enable global $conf; - if ($conf->delivery_note->enabled) { + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) { // Expedition validee include_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php'; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 2b8a54e999f..ac17743092e 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -142,8 +142,8 @@ $arrayfields = array( 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)), - 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->delivery_note->enabled) ? 0 : 1)), + 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)), + 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) ); diff --git a/htdocs/product/index.php b/htdocs/product/index.php index a25737d5583..32a07ae40d4 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -36,10 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $type = GETPOST("type", 'int'); -if ($type == '' && empty($user->rights->produit->lire)) { +if ($type == '' && !$user->hasRight('produit', 'lire') && $user->hasRight('service', 'lire')) { $type = '1'; // Force global page on service page only } -if ($type == '' && empty($user->rights->service->lire)) { +if ($type == '' && !$user->hasRight('service', 'lire') && $user->hasRight('produit', 'lire')) { $type = '0'; // Force global page on product page only } @@ -58,7 +58,7 @@ if ($type == '0') { } elseif ($type == '1') { $result = restrictedArea($user, 'service'); } else { - $result = restrictedArea($user, 'produit|service|expedition'); + $result = restrictedArea($user, 'produit|service|expedition|reception'); } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 7db91569a8d..c0871f5fae0 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1787,13 +1787,13 @@ if ($action == 'create') { $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; $sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot"; $sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; $sql .= ', p.description as product_desc'; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; $sql .= ", ".MAIN_DB_PREFIX."reception as e"; $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('reception').")"; $sql .= " AND obj.fk_commande = ".((int) $origin_id); From 7cf21e6ee6c4ee24caff6cd1e75040eab956b6ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 14:47:02 +0200 Subject: [PATCH 114/159] Debug v18 --- htdocs/core/lib/functions.lib.php | 6 +++++- htdocs/fourn/commande/card.php | 1 + htdocs/reception/card.php | 13 +++++++++---- htdocs/reception/class/reception.class.php | 10 ++++++---- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8ddb3843696..4cce4716c37 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -168,7 +168,11 @@ function isModEnabled($module) global $conf; // Fix special cases - $arrayconv = array('project' => 'projet'); + $arrayconv = array( + 'project' => 'projet', + 'supplier_order'=>'fournisseur', + 'supplier_invoice'=>'fournisseur' + ); if (!empty($arrayconv[$module])) { $module = $arrayconv[$module]; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79c9fe49b4..a5d97b9440d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1873,6 +1873,7 @@ if ($action == 'create') { } print "\n"; } elseif (!empty($object->id)) { + // view $result = $object->fetch($id, $ref); $object->fetch_thirdparty(); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index c0871f5fae0..3e2210b69c7 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1895,6 +1895,8 @@ if ($action == 'create') { // Qty in other receptions (with reception and warehouse used) if ($origin && $origin_id > 0) { print ''; + $htmltooltip = ''; + $qtyalreadyreceived = 0; if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { foreach ($alreadysent as $key => $val) { if ($lines[$i]->fk_commandefourndet == $key) { @@ -1906,22 +1908,25 @@ if ($action == 'create') { $j++; if ($j > 1) { - print '
'; + $htmltooltip .= '
'; } $reception_static->fetch($receptionline_var['reception_id']); - print $reception_static->getNomUrl(1); - print ' - '.$receptionline_var['qty']; + $htmltooltip .= $reception_static->getNomUrl(1, 0, 0, 0, 1); + $htmltooltip .= ' - '.$receptionline_var['qty']; $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); if (isModEnabled('stock') && $receptionline_var['warehouse'] > 0) { $warehousestatic->fetch($receptionline_var['warehouse']); $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } - print ' '.$form->textwithpicto('', $htmltext, 1); + $htmltooltip .= ' '.$form->textwithpicto('', $htmltext, 1); + + $qtyalreadyreceived += $receptionline_var['qty']; } } } } + print $form->textwithpicto($qtyalreadyreceived, $htmltooltip, 1, 'info', '', 0, 3, 'tooltip'.$lines[$i]->id); print ''; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index f2da87feab5..d60c286ecf6 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1257,13 +1257,15 @@ class Reception extends CommonObject $linkstart .= $linkclose.'>'; $linkend = ''; + $result .= $linkstart; if ($withpicto) { - $result .= ($linkstart.img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); + $result .= img_object(($notooltip ? '' : $label), $this->picto, '', 0, 0, $notooltip ? 0 : 1); } - if ($withpicto && $withpicto != 2) { - $result .= ' '; + if ($withpicto != 2) { + $result .= $this->ref; } - $result .= $linkstart.$this->ref.$linkend; + + $result .= $linkend; global $action; $hookmanager->initHooks(array($this->element . 'dao')); From 2ac7ef7ef51b1791eac665218d0d45aa793357a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 16:15:13 +0200 Subject: [PATCH 115/159] Clean code --- htdocs/admin/dict.php | 6 +- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/stock.php | 6 +- htdocs/admin/workflow.php | 10 +-- htdocs/comm/index.php | 8 +-- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/list.php | 4 +- htdocs/commande/list_det.php | 4 +- .../stats/supplier_turnover_by_thirdparty.php | 4 +- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/lib/company.lib.php | 4 +- htdocs/core/lib/contact.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 8 ++- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/project.lib.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 18 ++--- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 18 ++--- htdocs/core/modules/modBanque.class.php | 2 +- htdocs/core/modules/modCategorie.class.php | 6 +- htdocs/core/modules/modProduct.class.php | 18 ++--- htdocs/core/modules/modService.class.php | 18 ++--- htdocs/core/modules/modSociete.class.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 4 +- .../task/doc/doc_generic_task_odt.modules.php | 4 +- .../reception/doc/pdf_squille.modules.php | 2 +- ...e_20_modWorkflow_WorkflowManager.class.php | 2 +- ..._50_modNotification_Notification.class.php | 4 +- htdocs/ecm/index_auto.php | 8 +-- htdocs/ecm/search.php | 8 +-- htdocs/fourn/card.php | 6 +- .../class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 4 +- htdocs/fourn/commande/index.php | 2 +- htdocs/fourn/facture/list.php | 3 +- htdocs/fourn/index.php | 4 +- htdocs/fourn/paiement/list.php | 3 +- htdocs/hrm/core/tpl/skilldet.fiche.tpl.php | 71 ------------------- htdocs/product/admin/product.php | 2 +- htdocs/product/class/product.class.php | 6 +- htdocs/product/stock/product.php | 4 +- htdocs/product/stock/replenish.php | 2 +- htdocs/projet/element.php | 4 +- htdocs/reception/card.php | 10 +-- htdocs/reception/contact.php | 4 +- htdocs/reception/document.php | 2 +- htdocs/reception/note.php | 2 +- .../canvas/actions_card_common.class.php | 2 +- htdocs/societe/card.php | 4 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/list.php | 4 +- htdocs/societe/notify/card.php | 2 +- 54 files changed, 130 insertions(+), 201 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 33833162b11..25fb809b9b1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -495,15 +495,15 @@ $tabcond[8] = isModEnabled("societe"); $tabcond[9] = true; $tabcond[10] = true; $tabcond[11] = (isModEnabled("societe")); -$tabcond[12] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); -$tabcond[13] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); +$tabcond[12] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); +$tabcond[13] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); $tabcond[14] = (isModEnabled("product") && (isModEnabled('ecotax') || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); $tabcond[15] = true; $tabcond[16] = (isModEnabled("societe") && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); $tabcond[17] = (isModEnabled('deplacement') || isModEnabled('expensereport')); $tabcond[18] = isModEnabled("expedition") || isModEnabled("reception"); $tabcond[19] = isModEnabled("societe"); -$tabcond[20] = (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"); +$tabcond[20] = isModEnabled("supplier_order"); $tabcond[21] = isModEnabled("propal"); $tabcond[22] = (isModEnabled('commande') || isModEnabled("propal")); $tabcond[23] = true; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 5a5c2f25c0e..ff7178a9ed3 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -64,7 +64,7 @@ $conditions = array( 'NOTE_PRIVATE' => 1, 'SOCIETE' => 1, 'PRODUCTDESC' => (isModEnabled("product") || isModEnabled("service")), - 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('supplier_proposal') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), + 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), 'USERSIGN' => 1, 'MAILING' => isModEnabled('mailing'), 'MAIL' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande')), diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 9c8473f5f7f..211996712a9 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -310,7 +310,7 @@ $found = 0; print ''; print ''.$langs->trans("ReStockOnBill").''; print ''; -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); @@ -332,7 +332,7 @@ $found++; print ''; print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); @@ -381,7 +381,7 @@ if (isModEnabled("reception")) { print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; print ''; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index cf55c7b9127..28d347bcabe 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -122,7 +122,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( 'family'=>'classify_supplier_proposal', 'position'=>60, - 'enabled'=>(isModEnabled('supplier_proposal') && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 'enabled'=>(isModEnabled('supplier_proposal') && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 'picto'=>'supplier_proposal', 'warning'=>'' ), @@ -131,7 +131,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION'=>array( 'family'=>'classify_supplier_order', 'position'=>63, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && isModEnabled("reception") && isModEnabled('supplier_order')), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -139,7 +139,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED'=>array( 'family'=>'classify_supplier_order', 'position'=>64, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && isModEnabled("reception") && isModEnabled('supplier_order')), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -147,7 +147,7 @@ $workflowcodes = array( 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( 'family'=>'classify_supplier_order', 'position'=>65, - 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), + 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -164,7 +164,7 @@ $workflowcodes = array( 'WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE'=>array( 'family'=>'classify_reception', 'position'=>95, - 'enabled'=>(isModEnabled("reception") && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 'enabled'=>(isModEnabled("reception") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 'picto'=>'reception' ), diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index a7c1f2ee8c8..4be7cd47f4c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -97,7 +97,7 @@ if (isModEnabled('supplier_proposal')) { if (isModEnabled('commande')) { $orderstatic = new Commande($db); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $supplierorderstatic = new CommandeFournisseur($db); } @@ -673,7 +673,7 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; } /* - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; }*/ @@ -704,7 +704,7 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { /* * Last suppliers */ -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { +if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -769,7 +769,7 @@ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERM { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; }*/ - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index abf68f1d30e..356e28ccc31 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2935,7 +2935,7 @@ if ($action == 'create') { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) { - if ($object->statut == Propal::STATUS_SIGNED && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($object->statut == Propal::STATUS_SIGNED && isModEnabled("supplier_order")) { if ($usercancreatepurchaseorder) { print ''.$langs->trans("AddPurchaseOrder").''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1f34fbd18a9..a005a0fb642 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2853,7 +2853,7 @@ if ($action == 'create' && $usercancreate) { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 49e6b0b3555..032fd3393e2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2567,7 +2567,7 @@ if ($resql) { } $stock_order = $generic_product->stats_commande['qty']; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; @@ -2588,7 +2588,7 @@ if ($resql) { } else { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 3faa292b78d..78f7c687175 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -2045,7 +2045,7 @@ if ($resql) { } $stock_order = $generic_product->stats_commande['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (isModEnabled('supplier_order')) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; @@ -2066,7 +2066,7 @@ if ($resql) { } else { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (isModEnabled('supplier_order')) { $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 515a004a3cd..dee0a0f2217 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -607,10 +607,10 @@ if (count($amount)) { if (isModEnabled('supplier_proposal') && $key > 0) { print ' '.img_picto($langs->trans("ProposalStats"), "stats").' '; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $key > 0) { + if (isModEnabled("supplier_order") && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && $key > 0) { + if (isModEnabled("supplier_invoice") && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print ''; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 615872eb101..05f8c8d215e 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -73,7 +73,7 @@ if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DI $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) { +if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal')) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) { $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e2e10a8de48..60537abd797 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -128,7 +128,7 @@ function societe_prepare_head(Societe $object) } } $supplier_module_enabled = 0; - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $supplier_module_enabled = 1; } if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { @@ -179,7 +179,7 @@ function societe_prepare_head(Societe $object) } // Related items - if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) + if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][1] = $langs->trans("Referers"); diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 2dbf97d4785..e864060bc25 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -93,7 +93,7 @@ function contact_prepare_head(Contact $object) } // Related items - if (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled('ficheinter') || isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id; $head[$tab][1] = $langs->trans("Referers"); $head[$tab][2] = 'consumption'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4cce4716c37..d0043916ea4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -169,10 +169,12 @@ function isModEnabled($module) // Fix special cases $arrayconv = array( - 'project' => 'projet', - 'supplier_order'=>'fournisseur', - 'supplier_invoice'=>'fournisseur' + 'project' => 'projet' ); + if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { + $arrayconv['supplier_order'] = 'fournisseur'; + $arrayconv['supplier_invoice'] = 'fournisseur'; + } if (!empty($arrayconv[$module])) { $module = $arrayconv[$module]; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 9c49035a757..8933ac848cf 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1142,7 +1142,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')) { $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index ed3f8d7a4a3..408f661e2b9 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -70,7 +70,7 @@ function product_prepare_head($object) } if (!empty($object->status_buy) || (isModEnabled('margin') && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase - if ((((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->lire) + if ((isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'read') || $user->hasRight('supplier_invoice', 'read')) || (isModEnabled('margin') && $user->hasRight("margin", "liretous")) ) { if ($usercancreadprice) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 47e45225205..dd7026a0d60 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -126,7 +126,7 @@ function project_prepare_head(Project $project, $moreparam = '') $h++; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) + if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('contrat') || isModEnabled('ficheinter') || isModEnabled('agenda') || isModEnabled('deplacement') || isModEnabled('stock')) { diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 8be5531965c..d77ed72c8db 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -12,7 +12,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- Top-Menu -- old: (module, enabled, rowid, ...) insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled || $conf->supplier_invoice->enabled))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModeEnabled('supplier_order') || isModEnabled('supplier_invoice')))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', '$conf->product->enabled || $conf->service->enabled', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', '$conf->bom->enabled || $conf->mrp->enabled', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->rights->bom->read||$user->rights->mrp->read', '', 0, 31, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', '$conf->project->enabled', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 32, __ENTITY__); @@ -86,8 +86,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&leftmenu=thirdparties', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 506__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=p&leftmenu=prospects', 'ListProspectsShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 507__+MAX_llx_menu__, 'companies', '', 506__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=prospects&action=create&type=p', 'MenuNewProspect', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 509__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=c&leftmenu=customers', 'ListCustomersShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 4, __ENTITY__); @@ -99,7 +99,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=p', 'ThirdPartyProspects', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 605__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=c', 'ThirdPartyCustomers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 607__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=o', 'Others', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 4, __ENTITY__); -- Third parties - Category customer @@ -107,8 +107,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 651__+MAX_llx_menu__, 'companies', '', 650__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=1', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Third parties - Category supplier -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Third parties - Category contact insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 670__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=4', 'ContactCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); @@ -314,9 +314,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 037d1fee8c2..ea05679b2d7 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -400,7 +400,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $nature = "sells"; } if ($objp->nature == 3 - && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice')) + && isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $nature = "purchases"; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7c51180fe68..1b86dbfe84d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -123,7 +123,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled'=> ((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) ) - || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) + || (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) ), 'perms'=> ($user->hasRight('societe', 'lire') || $user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), 'module'=>'societe|fournisseur' @@ -1238,7 +1238,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le } // Suppliers - if (isModEnabled('societe') && (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) || isModEnabled('supplier_proposal'))) { + if (isModEnabled('societe') && (isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal'))) { $langs->load("suppliers"); $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 2, ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), '', $mainmenu, 'suppliers'); $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 3, $user->hasRight('societe', 'creer') && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire'))); @@ -1259,7 +1259,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le $newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } // Categories suppliers - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/categories/index.php?leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->hasRight('categorie', 'lire')); } } @@ -1275,7 +1275,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->hasRight('societe', 'contact', 'lire')); } - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->hasRight('fournisseur', 'lire')); } $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->hasRight('societe', 'contact', 'lire')); @@ -1632,7 +1632,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if (isModEnabled('banque')) { $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_bank', 70); } - if (isModEnabled('facture') || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) { + if (isModEnabled('facture') || isModEnabled('supplier_invoice')) { $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 80); } if (isModEnabled('tax')) { @@ -1703,7 +1703,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef $nature = "sells"; } if ($objp->nature == 3 - && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice')) + && isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $nature = "purchases"; } @@ -1815,7 +1815,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { $modecompta = 'BOOKKEEPING'; // Not yet implemented. } - if ($modecompta && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) { + if ($modecompta && isModEnabled('supplier_invoice')) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire')); $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire')); @@ -2031,7 +2031,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme if (isModEnabled('variants')) { $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('product', 'read')); } - if (isModEnabled('propal') || (isModEnabled('commande') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('facture') || isModEnabled('fournisseur') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->hasRight('product', 'read')); } @@ -2048,7 +2048,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->hasRight('service', 'read'), '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="pictofixedwidth"')); $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer')); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read')); - if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read')); } // Categories diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 0cf58098967..78f0385fcdc 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -162,7 +162,7 @@ class modBanque extends DolibarrModules "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company" ); $this->export_special_array[$r] = array('-b.amount'=>'NULLIFNEG', 'b.amount'=>'NULLIFNEG'); - if ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order') || !isModEnabled('supplier_invoice')) { + if (!isModEnabled('supplier_order') && !isModEnabled('supplier_invoice')) { unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index d4900e18540..a0f1eea90bd 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -130,7 +130,7 @@ class modCategorie extends DolibarrModules if (isModEnabled("product") || isModEnabled("service")) { $typeexample .= ($typeexample ? " / " : "")."0=Product-Service"; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } if (isModEnabled("societe")) { @@ -205,7 +205,7 @@ class modCategorie extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; $this->export_label[$r] = 'CatSupList'; $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = 'isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")'; + $this->export_enabled[$r] = 'isModEnabled("supplier_order") || isModEnabled("supplier_invoice")'; $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); $this->export_fields_array[$r] = array( 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", @@ -493,7 +493,7 @@ class modCategorie extends DolibarrModules } // 1 Suppliers - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $r++; $this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; $this->import_label[$r] = "CatSupLinks"; // Translation key diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index a6fc98ffc08..247069f8401 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -211,7 +211,7 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $usenpr) { $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (isModEnabled('stock')) { @@ -224,7 +224,7 @@ class modProduct extends DolibarrModules $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { @@ -258,7 +258,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -277,7 +277,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -292,7 +292,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -313,7 +313,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; } if (isModEnabled('stock')) { @@ -625,7 +625,7 @@ class modProduct extends DolibarrModules )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (is_object($mysoc) && $usenpr) { @@ -709,7 +709,7 @@ class modProduct extends DolibarrModules 'p.desiredstock' => '' )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); } if (is_object($mysoc) && $usenpr) { @@ -775,7 +775,7 @@ class modProduct extends DolibarrModules $this->import_updatekeys_array[$r] = array('pwp.fk_product'=>'Product', 'pwp.fk_entrepot'=>'Warehouse'); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r] = $this->rights_class.'_supplierprices'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index b4a6d2f6025..d323bf382ef 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -176,7 +176,7 @@ class modService extends DolibarrModules if (is_object($mysoc) && $usenpr) { $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (isModEnabled('stock')) { @@ -189,7 +189,7 @@ class modService extends DolibarrModules $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { @@ -221,7 +221,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -240,7 +240,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -255,7 +255,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -276,7 +276,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; } $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; @@ -572,7 +572,7 @@ class modService extends DolibarrModules )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (is_object($mysoc) && $usenpr) { @@ -663,7 +663,7 @@ class modService extends DolibarrModules 'p.desiredstock' => '' )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); } if (is_object($mysoc) && $usenpr) { @@ -706,7 +706,7 @@ class modService extends DolibarrModules } if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r] = $this->rights_class.'_supplierprices'; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index d63084ac5b5..2904f5afd66 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -413,7 +413,7 @@ class modSociete extends DolibarrModules 't.libelle'=>"company", 's.entity'=>'company', ); // We define here only fields that use another picto - if (!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (!isModEnabled("supplier_order") && !isModEnabled("supplier_invoice")) { unset($this->export_fields_array[$r]['s.code_fournisseur']); unset($this->export_entities_array[$r]['s.code_fournisseur']); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 16a197f42b9..653d40e9ef6 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -50,10 +50,10 @@ if (isModEnabled('facture')) { if (isModEnabled('commande')) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 983d6f9b97a..96a5b75c626 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -51,10 +51,10 @@ if (isModEnabled('facture')) { if (isModEnabled('commande')) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index b605ac68631..f950bac3e1d 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -935,7 +935,7 @@ class pdf_squille extends ModelePdfReception $origin_id = $object->origin_id; // TODO move to external function - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { // commonly $origin='commande' + if (isModEnabled("supplier_order")) { // commonly $origin='commande' $outputlangs->load('orders'); $classname = 'CommandeFournisseur'; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index f85a26697b7..ab4371f3075 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -219,7 +219,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers // Firstly, we set to purchase order to "Billed" if WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER is set. // After we will set proposals - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { $object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element); if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 39f0e37c206..54073df0b09 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -135,9 +135,9 @@ class InterfaceNotification extends DolibarrTriggers $element = $obj->elementtype; // Exclude events if related module is disabled - if ($element == 'order_supplier' && ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))) { + if ($element == 'order_supplier' && !isModEnabled('supplier_order')) { $qualified = 0; - } elseif ($element == 'invoice_supplier' && ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_invoice'))) { + } elseif ($element == 'invoice_supplier' && !isModEnabled('supplier_invoice')) { $qualified = 0; } elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) { $qualified = 0; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index ae641047b30..26bb0f481c8 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -333,11 +333,11 @@ if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } - if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")) { - $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); + if (isModEnabled("supplier_order")) { + $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } - if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) { - $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); + if (isModEnabled("supplier_invoice")) { + $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { $langs->load("compta"); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index c43428fae8e..eeaf0c3e457 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -135,11 +135,11 @@ if (isModEnabled('facture')) { if (isModEnabled('supplier_proposal')) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); +if (isModEnabled("supplier_order")) { + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); +if (isModEnabled("supplier_invoice")) { + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index c321f42d997..5c9dccc3118 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -384,7 +384,7 @@ if ($object->id > 0) { print ''; print ''; - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { + if (isModEnabled("supplier_order") && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''; print ''; print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer); @@ -464,7 +464,7 @@ if ($object->id > 0) { } } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { // Box proposals $tmp = $object->getOutstandingOrders('supplier'); $outstandingOpened = $tmp['opened']; @@ -485,7 +485,7 @@ if ($object->id > 0) { } } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_invoice")) { $warn = ''; $tmp = $object->getOutstandingBills('supplier'); $outstandingOpened = $tmp['opened']; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e3f8e3c5f81..22acc6258cc 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3464,7 +3464,7 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; $qtydelivered = array(); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a5d97b9440d..1e5aa64b602 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2559,7 +2559,7 @@ if ($action == 'create') { } if (in_array($object->statut, array(3, 4, 5))) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $usercanreceive) { + if (isModEnabled("supplier_order") && $usercanreceive) { print ''; } else { print ''; @@ -2585,7 +2585,7 @@ if ($action == 'create') { // Create bill //if (isModEnabled('facture')) //{ - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled + if (isModEnabled("supplier_invoice") && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { print ''.$langs->trans("CreateBill").''; } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index dc30d1296f9..3ecf97813e7 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -177,7 +177,7 @@ if ($resql) { * Draft orders */ -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 878cca686e8..25045b154e0 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -205,8 +205,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if ((!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) - || (!isModEnabled('supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) { +if (!isModEnabled('supplier_invoice')) { accessforbidden(); } if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 18d86da67e7..5f37e08ed4b 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -100,7 +100,7 @@ if ($resql) { // Draft orders -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; @@ -158,7 +158,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO } // Draft invoices -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->facture->lire) { +if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; $sql .= ", s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index e4db29cb962..1b7db48a063 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -124,8 +124,7 @@ if ($user->socid) { // require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; // $object = new PaiementFourn($db); // restrictedArea($user, $object->element); -if ((!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) - || (!isModEnabled('supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) { +if (!isModEnabled('supplier_invoice')) { accessforbidden(); } if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) diff --git a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php index 42a4506ae96..0d5cef8139c 100644 --- a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php +++ b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php @@ -5,77 +5,6 @@ if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } -/* -// $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create -// $cssclass must be defined by caller. For example $cssclass='fieldtitle' -$module = $object->element; -$note_public = 'note_public'; -$note_private = 'note_private'; - -$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); -// Set $permission from the $permissionnote var defined on calling page -$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); -$moreparam = (isset($moreparam) ? $moreparam : ''); -$value_public = $object->note_public; -$value_private = $object->note_private; -if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) { -$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; -if (GETPOST('action', 'aZ09') == 'edit'.$note_public) { -$value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd); -if (dol_textishtml($value_public)) { -$value_public .= "
\n"; -} else { -$value_public .= "\n"; -} -} -} -if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) { -$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; -if (GETPOST('action', 'aZ09') == 'edit'.$note_private) { -$value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd); -if (dol_textishtml($value_private)) { -$value_private .= "
\n"; -} else { -$value_private .= "\n"; -} -} -}*/ -/* -// Special cases -if ($module == 'propal') { -$permission = $user->rights->propal->creer; -} elseif ($module == 'supplier_proposal') { -$permission = $user->rights->supplier_proposal->creer; -} elseif ($module == 'fichinter') { -$permission = $user->rights->ficheinter->creer; -} elseif ($module == 'project') { -$permission = $user->rights->projet->creer; -} elseif ($module == 'project_task') { -$permission = $user->rights->projet->creer; -} elseif ($module == 'invoice_supplier') { -if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { -$permission = $user->rights->fournisseur->facture->creer; -} else { -$permission = $user->rights->supplier_invoice->creer; -} -} elseif ($module == 'order_supplier') { -if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { -$permission = $user->rights->fournisseur->commande->creer; -} else { -$permission = $user->rights->supplier_order->creer; -} -} elseif ($module == 'societe') { -$permission = $user->hasRight('societe', 'creer'); -} elseif ($module == 'contact') { -$permission = $user->hasRight('societe', 'creer'); -} elseif ($module == 'shipping') { -$permission = $user->rights->expedition->creer; -} elseif ($module == 'product') { -$permission = $user->rights->produit->creer; -} elseif ($module == 'ecmfiles') { -$permission = $user->rights->ecm->setup; -}*/ -//else dol_print_error('','Bad value '.$module.' for param module'); if (!empty($object->table_element_line)) { // Show object lines diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 92897c45aa5..f6e0d42bfe4 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -601,7 +601,7 @@ print ''; print ''; // Use conditionnement in buying -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { print ''; print ''.$form->textwithpicto($langs->trans("UseProductSupplierPackaging"), $langs->trans("PackagingForThisProductDesc")).''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index db5ebf7bf4c..243d31e2c1d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5636,7 +5636,7 @@ class Product extends CommonObject } $stock_sending_client = $this->stats_expedition['qty']; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $filterStatus = empty($conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK) ? '3,4' : $conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK; if (isset($includedraftpoforvirtual)) { $filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them @@ -5647,7 +5647,7 @@ class Product extends CommonObject } $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->reception->enabled)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->reception->enabled)) { // Case module reception is not used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { @@ -5659,7 +5659,7 @@ class Product extends CommonObject } $stock_reception_fournisseur = $this->stats_reception['qty']; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && isModEnabled("reception")) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && isModEnabled("reception")) { // Case module reception is used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 80a5f969a84..7befa095142 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -813,7 +813,7 @@ if ($id > 0 || $ref) { } // Number of supplier order running - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($found) { $helpondiff .= '
'; } else { @@ -829,7 +829,7 @@ if ($id > 0 || $ref) { } // Number of product from supplier order already received (partial receipt) - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($found) { $helpondiff .= '
'; } else { diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ed014731b52..c5f35eb7864 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -440,7 +440,7 @@ if ($usevirtualstock) { $sqlExpeditionsCli = '0'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index a737ffce640..1d264548b11 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -54,10 +54,10 @@ if (isModEnabled('commande')) { if (isModEnabled('supplier_proposal')) { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3e2210b69c7..757f52b9d49 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $origin_id = $object->$typeobject->id; $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); @@ -800,7 +800,7 @@ if ($action == 'create') { // Ref print ''; - if ($origin == 'supplierorder' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($origin == 'supplierorder' && isModEnabled("supplier_order")) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$objectsrc->ref; } if ($origin == 'propal' && isModEnabled("propal")) { @@ -1405,7 +1405,7 @@ if ($action == 'create') { $objectsrc = new Propal($db); $objectsrc->fetch($object->$typeobject->id); } - if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } @@ -2139,7 +2139,7 @@ if ($action == 'create') { } // Create bill - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) { + if (isModEnabled("supplier_invoice") && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) { if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { // TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // If we do that, we must also make this option official. @@ -2153,7 +2153,7 @@ if ($action == 'create') { if ($user->rights->reception->creer && $object->statut > 0 && !$object->billed) { $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on receptions instead of orders - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + if (isModEnabled("supplier_order")) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? $label = "ClassifyBilled"; $paramaction = 'classifybilled'; } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 92b0dd2f1e8..57bfa8bbf4d 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -57,7 +57,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } @@ -195,7 +195,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { print ''; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 615872eb101..05f8c8d215e 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -73,7 +73,7 @@ if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DI $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) { +if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal')) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) { $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e2e10a8de48..60537abd797 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -128,7 +128,7 @@ function societe_prepare_head(Societe $object) } } $supplier_module_enabled = 0; - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $supplier_module_enabled = 1; } if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { @@ -179,7 +179,7 @@ function societe_prepare_head(Societe $object) } // Related items - if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) + if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][1] = $langs->trans("Referers"); diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 2dbf97d4785..e864060bc25 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -93,7 +93,7 @@ function contact_prepare_head(Contact $object) } // Related items - if (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled('ficheinter') || isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id; $head[$tab][1] = $langs->trans("Referers"); $head[$tab][2] = 'consumption'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4cce4716c37..d0043916ea4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -169,10 +169,12 @@ function isModEnabled($module) // Fix special cases $arrayconv = array( - 'project' => 'projet', - 'supplier_order'=>'fournisseur', - 'supplier_invoice'=>'fournisseur' + 'project' => 'projet' ); + if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { + $arrayconv['supplier_order'] = 'fournisseur'; + $arrayconv['supplier_invoice'] = 'fournisseur'; + } if (!empty($arrayconv[$module])) { $module = $arrayconv[$module]; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 9c49035a757..8933ac848cf 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1142,7 +1142,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')) { $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index ed3f8d7a4a3..408f661e2b9 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -70,7 +70,7 @@ function product_prepare_head($object) } if (!empty($object->status_buy) || (isModEnabled('margin') && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase - if ((((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->lire) + if ((isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'read') || $user->hasRight('supplier_invoice', 'read')) || (isModEnabled('margin') && $user->hasRight("margin", "liretous")) ) { if ($usercancreadprice) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 47e45225205..dd7026a0d60 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -126,7 +126,7 @@ function project_prepare_head(Project $project, $moreparam = '') $h++; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) + if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('contrat') || isModEnabled('ficheinter') || isModEnabled('agenda') || isModEnabled('deplacement') || isModEnabled('stock')) { diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 8be5531965c..d77ed72c8db 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -12,7 +12,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- Top-Menu -- old: (module, enabled, rowid, ...) insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled || $conf->supplier_invoice->enabled))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModeEnabled('supplier_order') || isModEnabled('supplier_invoice')))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', '$conf->product->enabled || $conf->service->enabled', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', '$conf->bom->enabled || $conf->mrp->enabled', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->rights->bom->read||$user->rights->mrp->read', '', 0, 31, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', '$conf->project->enabled', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 32, __ENTITY__); @@ -86,8 +86,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&leftmenu=thirdparties', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 506__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=p&leftmenu=prospects', 'ListProspectsShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 507__+MAX_llx_menu__, 'companies', '', 506__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=prospects&action=create&type=p', 'MenuNewProspect', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 509__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=c&leftmenu=customers', 'ListCustomersShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 4, __ENTITY__); @@ -99,7 +99,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=p', 'ThirdPartyProspects', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 605__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=c', 'ThirdPartyCustomers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe")', __HANDLER__, 'left', 607__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=o', 'Others', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 4, __ENTITY__); -- Third parties - Category customer @@ -107,8 +107,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 651__+MAX_llx_menu__, 'companies', '', 650__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=1', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Third parties - Category supplier -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Third parties - Category contact insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 670__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=4', 'ContactCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); @@ -314,9 +314,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 037d1fee8c2..ea05679b2d7 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -400,7 +400,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $nature = "sells"; } if ($objp->nature == 3 - && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice')) + && isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $nature = "purchases"; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7c51180fe68..1b86dbfe84d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -123,7 +123,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled'=> ((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) ) - || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) + || (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) ), 'perms'=> ($user->hasRight('societe', 'lire') || $user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), 'module'=>'societe|fournisseur' @@ -1238,7 +1238,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le } // Suppliers - if (isModEnabled('societe') && (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) || isModEnabled('supplier_proposal'))) { + if (isModEnabled('societe') && (isModEnabled('supplier_order') || isModEnabled('supplier_invoice') || isModEnabled('supplier_proposal'))) { $langs->load("suppliers"); $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 2, ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire')), '', $mainmenu, 'suppliers'); $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 3, $user->hasRight('societe', 'creer') && ($user->hasRight('fournisseur', 'lire') || $user->hasRight('supplier_order', 'lire') || $user->hasRight('supplier_invoice', 'lire') || $user->hasRight('supplier_proposal', 'lire'))); @@ -1259,7 +1259,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le $newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } // Categories suppliers - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/categories/index.php?leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->hasRight('categorie', 'lire')); } } @@ -1275,7 +1275,7 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->hasRight('societe', 'contact', 'lire')); } - if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->hasRight('fournisseur', 'lire')); } $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->hasRight('societe', 'contact', 'lire')); @@ -1632,7 +1632,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if (isModEnabled('banque')) { $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_bank', 70); } - if (isModEnabled('facture') || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) { + if (isModEnabled('facture') || isModEnabled('supplier_invoice')) { $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->hasRight('accounting', 'chartofaccount'), '', $mainmenu, 'accountancy_admin_default', 80); } if (isModEnabled('tax')) { @@ -1703,7 +1703,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef $nature = "sells"; } if ($objp->nature == 3 - && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice')) + && isModEnabled('supplier_invoice') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $nature = "purchases"; } @@ -1815,7 +1815,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { $modecompta = 'BOOKKEEPING'; // Not yet implemented. } - if ($modecompta && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))) { + if ($modecompta && isModEnabled('supplier_invoice')) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->hasRight('accounting', 'comptarapport', 'lire')); $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->hasRight('accounting', 'comptarapport', 'lire')); @@ -2031,7 +2031,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme if (isModEnabled('variants')) { $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->hasRight('product', 'read')); } - if (isModEnabled('propal') || (isModEnabled('commande') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('facture') || isModEnabled('fournisseur') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->hasRight('product', 'read')); } @@ -2048,7 +2048,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->hasRight('service', 'read'), '', $mainmenu, 'service', 0, '', '', '', img_picto('', 'service', 'class="pictofixedwidth"')); $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->hasRight('service', 'creer')); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->hasRight('service', 'read')); - if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { + if (isModEnabled('propal') || isModEnabled('commande') || isModEnabled('facture') || isModEnabled('supplier_proposal') || isModEnabled('supplier_order') || isModEnabled('supplier_invoice')) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->hasRight('service', 'read')); } // Categories diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 0cf58098967..78f0385fcdc 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -162,7 +162,7 @@ class modBanque extends DolibarrModules "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company" ); $this->export_special_array[$r] = array('-b.amount'=>'NULLIFNEG', 'b.amount'=>'NULLIFNEG'); - if ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order') || !isModEnabled('supplier_invoice')) { + if (!isModEnabled('supplier_order') && !isModEnabled('supplier_invoice')) { unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index d4900e18540..a0f1eea90bd 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -130,7 +130,7 @@ class modCategorie extends DolibarrModules if (isModEnabled("product") || isModEnabled("service")) { $typeexample .= ($typeexample ? " / " : "")."0=Product-Service"; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } if (isModEnabled("societe")) { @@ -205,7 +205,7 @@ class modCategorie extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; $this->export_label[$r] = 'CatSupList'; $this->export_icon[$r] = $this->picto; - $this->export_enabled[$r] = 'isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")'; + $this->export_enabled[$r] = 'isModEnabled("supplier_order") || isModEnabled("supplier_invoice")'; $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); $this->export_fields_array[$r] = array( 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", @@ -493,7 +493,7 @@ class modCategorie extends DolibarrModules } // 1 Suppliers - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $r++; $this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; $this->import_label[$r] = "CatSupLinks"; // Translation key diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index a6fc98ffc08..247069f8401 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -211,7 +211,7 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $usenpr) { $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (isModEnabled('stock')) { @@ -224,7 +224,7 @@ class modProduct extends DolibarrModules $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { @@ -258,7 +258,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -277,7 +277,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -292,7 +292,7 @@ class modProduct extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -313,7 +313,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; } if (isModEnabled('stock')) { @@ -625,7 +625,7 @@ class modProduct extends DolibarrModules )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (is_object($mysoc) && $usenpr) { @@ -709,7 +709,7 @@ class modProduct extends DolibarrModules 'p.desiredstock' => '' )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); } if (is_object($mysoc) && $usenpr) { @@ -775,7 +775,7 @@ class modProduct extends DolibarrModules $this->import_updatekeys_array[$r] = array('pwp.fk_product'=>'Product', 'pwp.fk_entrepot'=>'Warehouse'); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r] = $this->rights_class.'_supplierprices'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index b4a6d2f6025..d323bf382ef 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -176,7 +176,7 @@ class modService extends DolibarrModules if (is_object($mysoc) && $usenpr) { $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (isModEnabled('stock')) { @@ -189,7 +189,7 @@ class modService extends DolibarrModules $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { @@ -221,7 +221,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -240,7 +240,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -255,7 +255,7 @@ class modService extends DolibarrModules if (isModEnabled('barcode')) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product')); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref')); } if (getDolGlobalInt('MAIN_MULTILANGS')) { @@ -276,7 +276,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object'; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; } $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')'; @@ -572,7 +572,7 @@ class modService extends DolibarrModules )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } if (is_object($mysoc) && $usenpr) { @@ -663,7 +663,7 @@ class modService extends DolibarrModules 'p.desiredstock' => '' )); } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) { $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); } if (is_object($mysoc) && $usenpr) { @@ -706,7 +706,7 @@ class modService extends DolibarrModules } if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; $this->import_code[$r] = $this->rights_class.'_supplierprices'; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index d63084ac5b5..2904f5afd66 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -413,7 +413,7 @@ class modSociete extends DolibarrModules 't.libelle'=>"company", 's.entity'=>'company', ); // We define here only fields that use another picto - if (!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (!isModEnabled("supplier_order") && !isModEnabled("supplier_invoice")) { unset($this->export_fields_array[$r]['s.code_fournisseur']); unset($this->export_entities_array[$r]['s.code_fournisseur']); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 16a197f42b9..653d40e9ef6 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -50,10 +50,10 @@ if (isModEnabled('facture')) { if (isModEnabled('commande')) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 983d6f9b97a..96a5b75c626 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -51,10 +51,10 @@ if (isModEnabled('facture')) { if (isModEnabled('commande')) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index b605ac68631..f950bac3e1d 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -935,7 +935,7 @@ class pdf_squille extends ModelePdfReception $origin_id = $object->origin_id; // TODO move to external function - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { // commonly $origin='commande' + if (isModEnabled("supplier_order")) { // commonly $origin='commande' $outputlangs->load('orders'); $classname = 'CommandeFournisseur'; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index f85a26697b7..ab4371f3075 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -219,7 +219,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers // Firstly, we set to purchase order to "Billed" if WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER is set. // After we will set proposals - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { $object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element); if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 39f0e37c206..54073df0b09 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -135,9 +135,9 @@ class InterfaceNotification extends DolibarrTriggers $element = $obj->elementtype; // Exclude events if related module is disabled - if ($element == 'order_supplier' && ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))) { + if ($element == 'order_supplier' && !isModEnabled('supplier_order')) { $qualified = 0; - } elseif ($element == 'invoice_supplier' && ((!isModEnabled('fournisseur') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_invoice'))) { + } elseif ($element == 'invoice_supplier' && !isModEnabled('supplier_invoice')) { $qualified = 0; } elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) { $qualified = 0; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index ae641047b30..26bb0f481c8 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -333,11 +333,11 @@ if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } - if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")) { - $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); + if (isModEnabled("supplier_order")) { + $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } - if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) { - $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); + if (isModEnabled("supplier_invoice")) { + $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { $langs->load("compta"); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index c43428fae8e..eeaf0c3e457 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -135,11 +135,11 @@ if (isModEnabled('facture')) { if (isModEnabled('supplier_proposal')) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); +if (isModEnabled("supplier_order")) { + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); +if (isModEnabled("supplier_invoice")) { + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index c321f42d997..5c9dccc3118 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -384,7 +384,7 @@ if ($object->id > 0) { print ''; print ''; - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { + if (isModEnabled("supplier_order") && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''; print ''; print ''; // Use conditionnement in buying -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { print ''; print ''; print ''; print ''; - if ($conf->service->enabled) { + if (isModEnabled("service")) { print ''; print ''; - if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { print ''; } } @@ -1829,7 +1829,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; - if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + if (isModEnabled("service") && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { print ''; } -//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); +//if (isModEnabled('agenda') && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); if ($object->client) { print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -2350,7 +2352,7 @@ if ($resql) { // Author if (!empty($arrayfields['u.login']['checked'])) { - print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); $totalarray['nbfield']++; } if (!empty($arrayfields['s.rowid']['checked'])) { - print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, 'actioncolumn '); + print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, ''); $totalarray['nbfield']++; } if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, 'actioncolumn '); + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' '); $totalarray['nbfield']++; } if (!empty($arrayfields['s.name_alias']['checked'])) { @@ -1510,7 +1510,7 @@ if (!empty($arrayfields['s.import_key']['checked'])) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); $totalarray['nbfield']++; // For the column action } print ''."\n"; From 77441f2dd2d72e9ef669f9a802a613b8ca049d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 23:39:02 +0200 Subject: [PATCH 130/159] use isModEnabled --- htdocs/core/lib/functions.lib.php | 14 +++++++------- htdocs/core/tpl/login.tpl.php | 4 ++-- htdocs/core/tpl/passwordforgotten.tpl.php | 4 ++-- htdocs/core/tpl/passwordreset.tpl.php | 4 ++-- htdocs/public/demo/index.php | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d927c4588b2..8b722efd411 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3801,22 +3801,22 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char // TODO Remove this block, we can add this using the hook now $showgmap = $showomap = 0; - if (($element == 'thirdparty' || $element == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { + if (($element == 'thirdparty' || $element == 'societe') && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { $showgmap = 1; } - if ($element == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { + if ($element == 'contact' && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { $showgmap = 1; } - if ($element == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { + if ($element == 'member' && isModEnabled('google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { $showgmap = 1; } - if (($element == 'thirdparty' || $element == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { + if (($element == 'thirdparty' || $element == 'societe') && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { $showomap = 1; } - if ($element == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { + if ($element == 'contact' && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { $showomap = 1; } - if ($element == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { + if ($element == 'member' && isModEnabled('openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { $showomap = 1; } if ($showgmap) { @@ -9779,7 +9779,7 @@ function printCommonFooter($zone = 'private') // Google Analytics // TODO Add a hook here - if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { + if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index a1045beedb9..71c8b33c5a3 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -447,7 +447,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getLoginPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -468,7 +468,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index deec94ee004..f43a2c63d9e 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -287,7 +287,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getPasswordForgottenPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -308,7 +308,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php index e3202ff511f..3b1bed10338 100644 --- a/htdocs/core/tpl/passwordreset.tpl.php +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -328,7 +328,7 @@ if (!empty($morelogincontent) && is_array($morelogincontent)) { // Google Analytics // TODO Remove this, and add content into hook getPasswordForgottenPageExtraOptions() instead -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) { $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID); foreach ($tmptagarray as $tmptag) { print "\n"; @@ -349,7 +349,7 @@ if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { ?>

diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index f7274d5b06b..c71f1d86dc7 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -434,7 +434,7 @@ print '
'; // TODO Replace this with a hook // Google Adsense (need Google module) -if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { +if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { print '
'."\n"; print '
'; $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index 56854244f7b..6641cfaecf6 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -79,7 +79,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index 6edb752ead8..1d8688a35e6 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -54,7 +54,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index a2b320e50db..0ed8d07fe51 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -188,7 +188,7 @@ abstract class ActionsCardCommon $s = $modCodeClient->getToolTip($langs, $this->object, 0); $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1); - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->tpl['supplier_enabled'] = 1; // Load object modCodeFournisseur diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5e2af49e4d4..6cc50d51399 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1091,7 +1091,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->client = 1; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur = 1; } @@ -1836,7 +1836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Supplier - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { print '
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9415901152e..4ab00102105 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2970,7 +2970,7 @@ class Societe extends CommonObject } } if (empty($option) || preg_match('/supplier/', $option)) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $this->fournisseur) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $this->fournisseur) { $s .= '<'.$tag.' class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).''; } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3362755d962..5129e1ddb55 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -231,9 +231,9 @@ $arrayfields = array( 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>3, 'checked'=>1), 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(isModEnabled('barcode'))), 's.code_client'=>array('label'=>"CustomerCodeShort", 'position'=>10, 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), 's.zip'=>array('label'=>"Zip", 'position'=>20, 'checked'=>1), 's.town'=>array('label'=>"Town", 'position'=>21, 'checked'=>0), diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index f299ef2ee82..e4ce8015381 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -184,7 +184,7 @@ if ($result > 0) { print '
'; print $langs->trans('SupplierCode').''; print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); From 9a420b8f41fd5fac57463331bbda2c1f9592c736 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 16:15:13 +0200 Subject: [PATCH 116/159] Clean code --- htdocs/admin/dict.php | 6 +- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/stock.php | 6 +- htdocs/admin/workflow.php | 10 +-- htdocs/comm/index.php | 8 +-- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/list.php | 4 +- htdocs/commande/list_det.php | 4 +- .../stats/supplier_turnover_by_thirdparty.php | 4 +- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/lib/company.lib.php | 4 +- htdocs/core/lib/contact.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 8 ++- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/project.lib.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 18 ++--- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 18 ++--- htdocs/core/modules/modBanque.class.php | 2 +- htdocs/core/modules/modCategorie.class.php | 6 +- htdocs/core/modules/modProduct.class.php | 18 ++--- htdocs/core/modules/modService.class.php | 18 ++--- htdocs/core/modules/modSociete.class.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 4 +- .../task/doc/doc_generic_task_odt.modules.php | 4 +- .../reception/doc/pdf_squille.modules.php | 2 +- ...e_20_modWorkflow_WorkflowManager.class.php | 2 +- ..._50_modNotification_Notification.class.php | 4 +- htdocs/ecm/index_auto.php | 8 +-- htdocs/ecm/search.php | 8 +-- htdocs/fourn/card.php | 6 +- .../class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 4 +- htdocs/fourn/commande/index.php | 2 +- htdocs/fourn/facture/list.php | 3 +- htdocs/fourn/index.php | 4 +- htdocs/fourn/paiement/list.php | 3 +- htdocs/hrm/core/tpl/skilldet.fiche.tpl.php | 71 ------------------- htdocs/product/admin/product.php | 2 +- htdocs/product/class/product.class.php | 6 +- htdocs/product/stock/product.php | 4 +- htdocs/product/stock/replenish.php | 2 +- htdocs/projet/element.php | 4 +- htdocs/reception/card.php | 10 +-- htdocs/reception/contact.php | 4 +- htdocs/reception/document.php | 2 +- htdocs/reception/note.php | 2 +- .../canvas/actions_card_common.class.php | 2 +- htdocs/societe/card.php | 4 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/list.php | 4 +- htdocs/societe/notify/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- 55 files changed, 131 insertions(+), 202 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 33833162b11..25fb809b9b1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -495,15 +495,15 @@ $tabcond[8] = isModEnabled("societe"); $tabcond[9] = true; $tabcond[10] = true; $tabcond[11] = (isModEnabled("societe")); -$tabcond[12] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); -$tabcond[13] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); +$tabcond[12] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); +$tabcond[13] = (isModEnabled('commande') || isModEnabled("propal") || isModEnabled('facture') || isModEnabled("supplier_invoice") || isModEnabled("supplier_order")); $tabcond[14] = (isModEnabled("product") && (isModEnabled('ecotax') || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); $tabcond[15] = true; $tabcond[16] = (isModEnabled("societe") && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); $tabcond[17] = (isModEnabled('deplacement') || isModEnabled('expensereport')); $tabcond[18] = isModEnabled("expedition") || isModEnabled("reception"); $tabcond[19] = isModEnabled("societe"); -$tabcond[20] = (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"); +$tabcond[20] = isModEnabled("supplier_order"); $tabcond[21] = isModEnabled("propal"); $tabcond[22] = (isModEnabled('commande') || isModEnabled("propal")); $tabcond[23] = true; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 5a5c2f25c0e..ff7178a9ed3 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -64,7 +64,7 @@ $conditions = array( 'NOTE_PRIVATE' => 1, 'SOCIETE' => 1, 'PRODUCTDESC' => (isModEnabled("product") || isModEnabled("service")), - 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('supplier_proposal') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), + 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('supplier_proposal') || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), 'USERSIGN' => 1, 'MAILING' => isModEnabled('mailing'), 'MAIL' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande')), diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 9c8473f5f7f..211996712a9 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -310,7 +310,7 @@ $found = 0; print '
'.$langs->trans("ReStockOnBill").''; -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); @@ -332,7 +332,7 @@ $found++; print '
'.$langs->trans("ReStockOnValidateOrder").''; -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($conf->use_javascript_ajax) { if ($disabled) { print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"'); @@ -381,7 +381,7 @@ if (isModEnabled("reception")) { print '
'.$langs->trans("ReStockOnDispatchOrder").''; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition'); } else { diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index cf55c7b9127..28d347bcabe 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -122,7 +122,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( 'family'=>'classify_supplier_proposal', 'position'=>60, - 'enabled'=>(isModEnabled('supplier_proposal') && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 'enabled'=>(isModEnabled('supplier_proposal') && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 'picto'=>'supplier_proposal', 'warning'=>'' ), @@ -131,7 +131,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION'=>array( 'family'=>'classify_supplier_order', 'position'=>63, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && isModEnabled("reception") && isModEnabled('supplier_order')), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -139,7 +139,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED'=>array( 'family'=>'classify_supplier_order', 'position'=>64, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && isModEnabled("reception") && isModEnabled('supplier_order')), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -147,7 +147,7 @@ $workflowcodes = array( 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( 'family'=>'classify_supplier_order', 'position'=>65, - 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), + 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -164,7 +164,7 @@ $workflowcodes = array( 'WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE'=>array( 'family'=>'classify_reception', 'position'=>95, - 'enabled'=>(isModEnabled("reception") && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 'enabled'=>(isModEnabled("reception") && (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 'picto'=>'reception' ), diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index a7c1f2ee8c8..4be7cd47f4c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -97,7 +97,7 @@ if (isModEnabled('supplier_proposal')) { if (isModEnabled('commande')) { $orderstatic = new Commande($db); } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $supplierorderstatic = new CommandeFournisseur($db); } @@ -673,7 +673,7 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; } /* - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; }*/ @@ -704,7 +704,7 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { /* * Last suppliers */ -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { +if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -769,7 +769,7 @@ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERM { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; }*/ - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index abf68f1d30e..356e28ccc31 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2935,7 +2935,7 @@ if ($action == 'create') { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) { - if ($object->statut == Propal::STATUS_SIGNED && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($object->statut == Propal::STATUS_SIGNED && isModEnabled("supplier_order")) { if ($usercancreatepurchaseorder) { print ''.$langs->trans("AddPurchaseOrder").''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1f34fbd18a9..a005a0fb642 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2853,7 +2853,7 @@ if ($action == 'create' && $usercancreate) { // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 49e6b0b3555..032fd3393e2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2567,7 +2567,7 @@ if ($resql) { } $stock_order = $generic_product->stats_commande['qty']; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; @@ -2588,7 +2588,7 @@ if ($resql) { } else { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 3faa292b78d..78f7c687175 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -2045,7 +2045,7 @@ if ($resql) { } $stock_order = $generic_product->stats_commande['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (isModEnabled('supplier_order')) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; @@ -2066,7 +2066,7 @@ if ($resql) { } else { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (isModEnabled('supplier_order')) { $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 515a004a3cd..dee0a0f2217 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -607,10 +607,10 @@ if (count($amount)) { if (isModEnabled('supplier_proposal') && $key > 0) { print ' '.img_picto($langs->trans("ProposalStats"), "stats").' '; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $key > 0) { + if (isModEnabled("supplier_order") && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && $key > 0) { + if (isModEnabled("supplier_invoice") && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print '
'; print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer); @@ -464,7 +464,7 @@ if ($object->id > 0) { } } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { // Box proposals $tmp = $object->getOutstandingOrders('supplier'); $outstandingOpened = $tmp['opened']; @@ -485,7 +485,7 @@ if ($object->id > 0) { } } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_invoice")) { $warn = ''; $tmp = $object->getOutstandingBills('supplier'); $outstandingOpened = $tmp['opened']; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e3f8e3c5f81..22acc6258cc 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3464,7 +3464,7 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; $qtydelivered = array(); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a5d97b9440d..1e5aa64b602 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2559,7 +2559,7 @@ if ($action == 'create') { } if (in_array($object->statut, array(3, 4, 5))) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $usercanreceive) { + if (isModEnabled("supplier_order") && $usercanreceive) { print ''; } else { print ''; @@ -2585,7 +2585,7 @@ if ($action == 'create') { // Create bill //if (isModEnabled('facture')) //{ - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled + if (isModEnabled("supplier_invoice") && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { print ''.$langs->trans("CreateBill").''; } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index dc30d1296f9..3ecf97813e7 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -177,7 +177,7 @@ if ($resql) { * Draft orders */ -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 878cca686e8..25045b154e0 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -205,8 +205,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if ((!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) - || (!isModEnabled('supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) { +if (!isModEnabled('supplier_invoice')) { accessforbidden(); } if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 18d86da67e7..5f37e08ed4b 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -100,7 +100,7 @@ if ($resql) { // Draft orders -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; @@ -158,7 +158,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO } // Draft invoices -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->facture->lire) { +if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; $sql .= ", s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index e4db29cb962..1b7db48a063 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -124,8 +124,7 @@ if ($user->socid) { // require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; // $object = new PaiementFourn($db); // restrictedArea($user, $object->element); -if ((!isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) - || (!isModEnabled('supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) { +if (!isModEnabled('supplier_invoice')) { accessforbidden(); } if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) diff --git a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php index 42a4506ae96..0d5cef8139c 100644 --- a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php +++ b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php @@ -5,77 +5,6 @@ if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } -/* -// $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create -// $cssclass must be defined by caller. For example $cssclass='fieldtitle' -$module = $object->element; -$note_public = 'note_public'; -$note_private = 'note_private'; - -$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); -// Set $permission from the $permissionnote var defined on calling page -$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); -$moreparam = (isset($moreparam) ? $moreparam : ''); -$value_public = $object->note_public; -$value_private = $object->note_private; -if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) { -$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; -if (GETPOST('action', 'aZ09') == 'edit'.$note_public) { -$value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd); -if (dol_textishtml($value_public)) { -$value_public .= "
\n"; -} else { -$value_public .= "\n"; -} -} -} -if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) { -$stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; -if (GETPOST('action', 'aZ09') == 'edit'.$note_private) { -$value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd); -if (dol_textishtml($value_private)) { -$value_private .= "
\n"; -} else { -$value_private .= "\n"; -} -} -}*/ -/* -// Special cases -if ($module == 'propal') { -$permission = $user->rights->propal->creer; -} elseif ($module == 'supplier_proposal') { -$permission = $user->rights->supplier_proposal->creer; -} elseif ($module == 'fichinter') { -$permission = $user->rights->ficheinter->creer; -} elseif ($module == 'project') { -$permission = $user->rights->projet->creer; -} elseif ($module == 'project_task') { -$permission = $user->rights->projet->creer; -} elseif ($module == 'invoice_supplier') { -if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { -$permission = $user->rights->fournisseur->facture->creer; -} else { -$permission = $user->rights->supplier_invoice->creer; -} -} elseif ($module == 'order_supplier') { -if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { -$permission = $user->rights->fournisseur->commande->creer; -} else { -$permission = $user->rights->supplier_order->creer; -} -} elseif ($module == 'societe') { -$permission = $user->hasRight('societe', 'creer'); -} elseif ($module == 'contact') { -$permission = $user->hasRight('societe', 'creer'); -} elseif ($module == 'shipping') { -$permission = $user->rights->expedition->creer; -} elseif ($module == 'product') { -$permission = $user->rights->produit->creer; -} elseif ($module == 'ecmfiles') { -$permission = $user->rights->ecm->setup; -}*/ -//else dol_print_error('','Bad value '.$module.' for param module'); if (!empty($object->table_element_line)) { // Show object lines diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 92897c45aa5..f6e0d42bfe4 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -601,7 +601,7 @@ print '
'.$form->textwithpicto($langs->trans("UseProductSupplierPackaging"), $langs->trans("PackagingForThisProductDesc")).''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index db5ebf7bf4c..243d31e2c1d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5636,7 +5636,7 @@ class Product extends CommonObject } $stock_sending_client = $this->stats_expedition['qty']; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $filterStatus = empty($conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK) ? '3,4' : $conf->global->SUPPLIER_ORDER_STATUS_FOR_VIRTUAL_STOCK; if (isset($includedraftpoforvirtual)) { $filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them @@ -5647,7 +5647,7 @@ class Product extends CommonObject } $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->reception->enabled)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && empty($conf->reception->enabled)) { // Case module reception is not used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { @@ -5659,7 +5659,7 @@ class Product extends CommonObject } $stock_reception_fournisseur = $this->stats_reception['qty']; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && isModEnabled("reception")) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && isModEnabled("reception")) { // Case module reception is used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 80a5f969a84..7befa095142 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -813,7 +813,7 @@ if ($id > 0 || $ref) { } // Number of supplier order running - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($found) { $helpondiff .= '
'; } else { @@ -829,7 +829,7 @@ if ($id > 0 || $ref) { } // Number of product from supplier order already received (partial receipt) - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { if ($found) { $helpondiff .= '
'; } else { diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ed014731b52..c5f35eb7864 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -440,7 +440,7 @@ if ($usevirtualstock) { $sqlExpeditionsCli = '0'; } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (isModEnabled("supplier_order")) { $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index a737ffce640..1d264548b11 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -54,10 +54,10 @@ if (isModEnabled('commande')) { if (isModEnabled('supplier_proposal')) { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) { +if (isModEnabled("supplier_invoice")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } -if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { +if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; } if (isModEnabled('contrat')) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3e2210b69c7..757f52b9d49 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $origin_id = $object->$typeobject->id; $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); @@ -800,7 +800,7 @@ if ($action == 'create') { // Ref print '
'; - if ($origin == 'supplierorder' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($origin == 'supplierorder' && isModEnabled("supplier_order")) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$objectsrc->ref; } if ($origin == 'propal' && isModEnabled("propal")) { @@ -1405,7 +1405,7 @@ if ($action == 'create') { $objectsrc = new Propal($db); $objectsrc->fetch($object->$typeobject->id); } - if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) { + if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } @@ -2139,7 +2139,7 @@ if ($action == 'create') { } // Create bill - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) { + if (isModEnabled("supplier_invoice") && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) { if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { // TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // If we do that, we must also make this option official. @@ -2153,7 +2153,7 @@ if ($action == 'create') { if ($user->rights->reception->creer && $object->statut > 0 && !$object->billed) { $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on receptions instead of orders - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + if (isModEnabled("supplier_order")) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? $label = "ClassifyBilled"; $paramaction = 'classifybilled'; } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 92b0dd2f1e8..57bfa8bbf4d 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -57,7 +57,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } @@ -195,7 +195,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { print ''; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; @@ -1347,17 +1347,18 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl // Job position if (!empty($arrayfields['t.poste']['checked'])) { - print ''; } // Address - Phone - Email if (!empty($arrayfields['t.address']['checked'])) { - print ''; } @@ -1379,7 +1380,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl // Birthday if (!empty($arrayfields['t.birthday']['checked'])) { - print ''; } @@ -1390,7 +1391,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl } if ($showuserlogin) { - print ''; + print ''; } } else { $colspan = 1 + ($showuserlogin ? 1 : 0); @@ -1442,7 +1443,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $colspan++; } } - print ''; + print ''; } print "\n
'; $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index 56854244f7b..6641cfaecf6 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -79,7 +79,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index 6edb752ead8..1d8688a35e6 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -54,7 +54,7 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($origin == 'order_supplier' && $object->$typeobject->id && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order"))) { + if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) { $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index a2b320e50db..0ed8d07fe51 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -188,7 +188,7 @@ abstract class ActionsCardCommon $s = $modCodeClient->getToolTip($langs, $this->object, 0); $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1); - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { $this->tpl['supplier_enabled'] = 1; // Load object modCodeFournisseur diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5e2af49e4d4..6cc50d51399 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1091,7 +1091,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->client = 1; } - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur = 1; } @@ -1836,7 +1836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Supplier - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { + if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { print '
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9415901152e..4ab00102105 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2970,7 +2970,7 @@ class Societe extends CommonObject } } if (empty($option) || preg_match('/supplier/', $option)) { - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $this->fournisseur) { + if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $this->fournisseur) { $s .= '<'.$tag.' class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).''; } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3362755d962..5129e1ddb55 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -231,9 +231,9 @@ $arrayfields = array( 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>3, 'checked'=>1), 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(isModEnabled('barcode'))), 's.code_client'=>array('label'=>"CustomerCodeShort", 'position'=>10, 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), 's.zip'=>array('label'=>"Zip", 'position'=>20, 'checked'=>1), 's.town'=>array('label'=>"Town", 'position'=>21, 'checked'=>0), diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index f299ef2ee82..e4ce8015381 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -184,7 +184,7 @@ if ($result > 0) { print '
'; print $langs->trans('SupplierCode').''; print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 79520727955..a11a10e6bcf 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -2005,7 +2005,7 @@ if ($action == 'create') { } // Create an order - if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut == SupplierProposal::STATUS_SIGNED) { + if (isModEnabled("supplier_order") && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($usercancreateorder) { print ''; } From 224c7b18475b23b400d85237bbbd69709cc62e48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 16:40:38 +0200 Subject: [PATCH 117/159] Debug v18 --- htdocs/admin/mails_templates.php | 4 ++-- htdocs/core/lib/company.lib.php | 19 ++++++++++--------- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/reception/card.php | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 20c88c3479a..c71afe928ae 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -215,10 +215,10 @@ if (isModEnabled('ficheinter')) { if (isModEnabled('supplier_proposal')) { $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation')); } -if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire))) { +if (isModEnabled("supplier_order") && ($user->hasRight('fournisseur', 'commande', 'lire') || $user->hasRight('supplier_order', 'read'))) { $elementList['order_supplier_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder')); } -if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { +if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice')); } if (isModEnabled('contrat') && !empty($user->rights->contrat->lire)) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 60537abd797..7f051a1672e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1339,7 +1339,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl // Photo - Name if (!empty($arrayfields['t.name']['checked'])) { - print ''; + print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage)); print ''; + print ''; if ($obj->poste) { - print $obj->poste; + print dol_escape_htmltag($obj->poste); } print ''; - print $contactstatic->getBannerAddress('contact', $object); + $addresstoshow = $contactstatic->getBannerAddress('contact', $object); + print ''; + print $addresstoshow; print ''; + print ''; print dol_print_date($db->jdate($obj->birthday)); print ''; + print ''; $tmpuser= new User($db); $resfetch = $tmpuser->fetch(0, '', '', 0, -1, '', $contactstatic->id); if ($resfetch > 0) { @@ -1433,7 +1434,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $colspan++; } } - print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'.$langs->trans("None").'
'.$langs->trans("None").'
\n"; print ''; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 8933ac848cf..17752f9081b 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1142,7 +1142,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) $result = ''; - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')) { + if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 757f52b9d49..4280dabfc9d 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -2140,7 +2140,7 @@ if ($action == 'create') { // Create bill if (isModEnabled("supplier_invoice") && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) { - if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { + if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) { // TODO show button only if (!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // If we do that, we must also make this option official. print '
'.$langs->trans("CreateBill").''; @@ -2153,7 +2153,7 @@ if ($action == 'create') { if ($user->rights->reception->creer && $object->statut > 0 && !$object->billed) { $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on receptions instead of orders - if (isModEnabled("supplier_order")) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + if (isModEnabled("supplier_order") && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? $label = "ClassifyBilled"; $paramaction = 'classifybilled'; } From 2742da237964d19626b83f6f7fc27ad791476f7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 16:56:17 +0200 Subject: [PATCH 118/159] Prepare charset --- htdocs/core/modules/import/import_csv.modules.php | 2 ++ htdocs/core/modules/import/modules_import.php | 3 +++ htdocs/imports/import.php | 2 ++ 3 files changed, 7 insertions(+) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 8ad5ef94b2f..1c62db7db57 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -86,6 +86,8 @@ class ImportCsv extends ModeleImports public $nbupdate = 0; // # of update done during the import + public $charset = ''; + /** * Constructor diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 4ead826d27f..c57d42c8094 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -75,6 +75,9 @@ class ModeleImports public $libversion = array(); + public $charset; + + /** * @var array Element mapping from table name */ diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 963581e1350..9422172a4f9 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -142,6 +142,7 @@ $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); $separator = (GETPOST('separator', 'alphanohtml') ? GETPOST('separator', 'alphanohtml', 3) : ''); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); // We must use 'nohtml' and not 'alphanohtml' because we must accept " +$charset = GETPOST('charset', 'aZ09'); $separator_used = str_replace('\t', "\t", $separator); $objimport = new Import($db); @@ -802,6 +803,7 @@ if ($step == 4 && $datatoimport) { if ($model == 'csv') { $obj->separator = $separator_used; $obj->enclosure = $enclosure; + $obj->charset = ''; } if ($model == 'xlsx') { if (!preg_match('/\.xlsx$/i', $filetoimport)) { From 54c70d3742776a980eb7ac185caee8db07e11113 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 17:03:24 +0200 Subject: [PATCH 119/159] Rename files --- htdocs/core/modules/export/export_csviso.modules.php | 2 +- htdocs/core/modules/export/export_csvutf8.modules.php | 2 +- .../export/{exports_csv.modules.php => exportcsv.modules.php} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename htdocs/core/modules/export/{exports_csv.modules.php => exportcsv.modules.php} (99%) diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index 29a9e24e76a..6fd66aec769 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exports_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index f517dd00839..fc79bc79825 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exports_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/exports_csv.modules.php b/htdocs/core/modules/export/exportcsv.modules.php similarity index 99% rename from htdocs/core/modules/export/exports_csv.modules.php rename to htdocs/core/modules/export/exportcsv.modules.php index 442c7cb628f..fd96bf468f3 100644 --- a/htdocs/core/modules/export/exports_csv.modules.php +++ b/htdocs/core/modules/export/exportcsv.modules.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/core/modules/export/export_csv.modules.php + * \file htdocs/core/modules/export/exportcsv.modules.php * \ingroup export * \brief File of class to build exports with CSV format */ From fa849696fb4cc76df97953c1f31db50e024b5f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:16:02 +0200 Subject: [PATCH 120/159] use isModEnabled --- htdocs/comm/propal/card.php | 2 +- htdocs/core/boxes/box_actions.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 16 +++++++------- htdocs/core/modules/modAgenda.class.php | 22 +++++++++---------- htdocs/core/modules/modECM.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 6 ++--- .../doc/doc_generic_project_odt.modules.php | 2 +- .../project/doc/pdf_beluga.modules.php | 2 +- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/fichinter/card-rec.php | 8 +++---- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card-rec.php | 4 ++-- htdocs/fourn/facture/card.php | 2 +- htdocs/mrp/class/mo.class.php | 2 +- htdocs/product/admin/price_rules.php | 6 ++--- htdocs/product/admin/product.php | 6 ++--- htdocs/product/admin/product_extrafields.php | 4 ++-- .../admin/product_supplier_extrafields.php | 4 ++-- htdocs/product/index.php | 4 ++-- htdocs/projet/element.php | 2 +- htdocs/projet/tasks/time.php | 6 ++--- htdocs/public/agenda/agendaexport.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/workstation/workstation_agenda.php | 4 ++-- 28 files changed, 61 insertions(+), 61 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 356e28ccc31..3a3fdfe50a0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2904,7 +2904,7 @@ if ($action == 'create') { } } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print '' . $langs->trans("AddAction") . ''; }*/ diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index a47f5d4f744..7b149ba4085 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -60,7 +60,7 @@ class box_actions extends ModeleBoxes $this->db = $db; - $this->enabled = $conf->agenda->enabled; + $this->enabled = isModEnabled('agenda'); $this->hidden = !($user->hasRight('agenda', 'myactions', 'read')); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d2294f781ab..d927c4588b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3584,7 +3584,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } - //if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + //if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create) if (isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) { $type = 'AC_TEL'; $link = ''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index d77ed72c8db..9c2a54ff2a5 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -13,7 +13,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- old: (module, enabled, rowid, ...) insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '(isModEnabled("societe") && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModeEnabled('supplier_order') || isModEnabled('supplier_invoice')))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', '$conf->product->enabled || $conf->service->enabled', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', 'isModEnabled("product") || isModEnabled("service")', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', '$conf->bom->enabled || $conf->mrp->enabled', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->rights->bom->read||$user->rights->mrp->read', '', 0, 31, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', '$conf->project->enabled', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 32, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 5__+MAX_llx_menu__, 'propal|commande|fournisseur|supplier_order|supplier_invoice|contrat|ficheinter', '$conf->propal->enabled || $conf->commande->enabled || $conf->supplier_order->enabled || $conf->contrat->enabled || $conf->ficheinter->enabled', __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); @@ -115,10 +115,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("societe") && $conf->categorie->enabled', __HANDLER__, 'left', 671__+MAX_llx_menu__, 'companies', '', 670__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=4', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Product - Product -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'products', 'product', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=product&type=0', 'Products', 0, 'products', '$user->rights->produit->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=product&action=create&type=0', 'NewProduct', 1, 'products', '$user->rights->produit->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?mainmenu=products&type=0', 'MenuStocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'products', 'product', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=product&type=0', 'Products', 0, 'products', '$user->rights->produit->lire', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=product&action=create&type=0', 'NewProduct', 1, 'products', '$user->rights->produit->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("product")', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?mainmenu=products&type=0', 'MenuStocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?mainmenu=products&type=0&search_subjecttolotserial=1', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2806__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php?mainmenu=products', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__); @@ -127,9 +127,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?mainmenu=products&id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 8, __ENTITY__); -- Product - Services -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?mainmenu=products&leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?mainmenu=products&leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("service")', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?mainmenu=products&leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?mainmenu=products&id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__); -- Product - Stocks diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 38debb8633a..4c2b86e59b7 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -113,7 +113,7 @@ class modAgenda extends DolibarrModules //------------ $datestart = dol_now(); $this->cronjobs = array( - 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart), + 0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'isModEnabled("agenda")', 'datestart'=>$datestart), ); // Permissions @@ -212,7 +212,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>86, 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read', - 'enabled'=>'$conf->agenda->enabled || $conf->resource->enabled', + 'enabled'=>'isModEnabled("agenda") || $conf->resource->enabled', 'target'=>'', 'user'=>2, ); @@ -228,7 +228,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>100, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2, ); @@ -242,7 +242,7 @@ class modAgenda extends DolibarrModules 'langs'=>'commercial', 'position'=>101, 'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -257,7 +257,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>140, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -271,7 +271,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>141, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -285,7 +285,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>142, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -329,7 +329,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>110, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -343,7 +343,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>111, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -357,7 +357,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>112, 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); @@ -400,7 +400,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>160, 'perms'=>'$user->rights->agenda->allactions->read', - 'enabled'=>'$conf->agenda->enabled', + 'enabled'=>'isModEnabled("agenda")', 'target'=>'', 'user'=>2 ); diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 09556b43cd8..3dbd624bb51 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -127,7 +127,7 @@ class modECM extends DolibarrModules 'langs'=>'ecm', 'position'=>82, 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup', - 'enabled'=>'$conf->ecm->enabled', + 'enabled'=>'isModEnabled("ecm")', 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 247069f8401..d8192a37df4 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -168,7 +168,7 @@ class modProduct extends DolibarrModules 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>300, - 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index d323bf382ef..4828513a8ff 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -135,7 +135,7 @@ class modService extends DolibarrModules 'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>300, - 'enabled'=>'$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'enabled'=>'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both @@ -284,7 +284,7 @@ class modService extends DolibarrModules $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" } - if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) + if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice $r++; @@ -705,7 +705,7 @@ class modService extends DolibarrModules $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled } - if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) + if (!isModEnabled("product")) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries) if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 653d40e9ef6..af807516c30 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1048,7 +1048,7 @@ class doc_generic_project_odt extends ModelePDFProjects 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, - 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire + 'test' => isModEnabled('agenda') && $user->rights->agenda->allactions->lire ), ); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index ba175dc7c52..525c3bd2ece 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -462,7 +462,7 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, + 'test'=> isModEnabled('agenda') && $user->rights->agenda->allactions->read, 'lang'=>'agenda') ); diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 71e0d18fc99..f0e019a82e1 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -76,7 +76,7 @@ class InterfaceActionsAuto extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->agenda) || empty($conf->agenda->enabled)) { + if (!isModEnabled('agenda')) { return 0; // Module not active, we do nothing } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index de6d5f97c24..75b1c944192 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -398,9 +398,9 @@ if ($action == 'create') { print '
'; $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } @@ -709,9 +709,9 @@ if ($action == 'create') { */ $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a4244195bfa..64c6d399966 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1643,7 +1643,7 @@ if ($action == 'create') { } // Proposal - if ($conf->service->enabled && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { + if (isModEnabled("service") && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) { if ($user->rights->propal->creer) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2aeb13d762c..dff3ed98858 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2462,7 +2462,7 @@ if ($action == 'create') { } } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; }*/ diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index fb8179f2042..1e08deb7fd0 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -1059,9 +1059,9 @@ if ($action == 'create') { print dol_get_fiche_end(); $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) { + if (!isModEnabled("service")) { $title = $langs->trans("Products"); - } elseif (empty($conf->product->enabled)) { + } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 393c32e500a..bfd0f1a184a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3946,7 +3946,7 @@ if ($action == 'create') { } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; }*/ diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 100043ef055..0c93e2dd835 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -100,7 +100,7 @@ class Mo extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:(t.status:=:1)', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>'$conf->bom->enabled', 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall', 'picto'=>'bom'), 'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'$conf->product->enabled', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'isModEnabled("product")', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200', 'alwayseditable'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'css'=>'maxwidth400', 'csslist'=>'tdoverflowmax150'), diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index 4fa0c293b2d..561c8d48e90 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -30,7 +30,7 @@ $langs->loadLangs(array('admin', 'products')); $action = GETPOST('action', 'aZ09'); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { +if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) { accessforbidden(); } @@ -119,10 +119,10 @@ while ($result = $db->fetch_object($query)) { $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index f6e0d42bfe4..f79b8ab982e 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -41,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $langs->loadLangs(array("admin", "products")); // Security check -if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) { +if (!$user->admin || (!isModEnabled("product") && !isModEnabled("service"))) { accessforbidden(); } @@ -271,10 +271,10 @@ $formbarcode = new FormBarCode($db); $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index 4885c595097..d5b97555ba4 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -66,10 +66,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } diff --git a/htdocs/product/admin/product_supplier_extrafields.php b/htdocs/product/admin/product_supplier_extrafields.php index afd46f104ae..6469c3d9b42 100644 --- a/htdocs/product/admin/product_supplier_extrafields.php +++ b/htdocs/product/admin/product_supplier_extrafields.php @@ -67,10 +67,10 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $title = $langs->trans('ProductServiceSetup'); $textobject = $langs->trans("ProductsAndServices"); -if (empty($conf->product->enabled)) { +if (!isModEnabled("product")) { $title = $langs->trans('ServiceSetup'); $textobject = $langs->trans('Services'); -} elseif (empty($conf->service->enabled)) { +} elseif (!isModEnabled("service")) { $title = $langs->trans('ProductSetup'); $textobject = $langs->trans('Products'); } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 32a07ae40d4..d31e365295f 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -73,11 +73,11 @@ if (!isset($_GET["type"])) { $transAreaType = $langs->trans("ProductsAndServicesArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled)) { +if ((isset($_GET["type"]) && $_GET["type"] == 0) || !isModEnabled("service")) { $transAreaType = $langs->trans("ProductsArea"); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled)) { +if ((isset($_GET["type"]) && $_GET["type"] == 1) || !isModEnabled("product")) { $transAreaType = $langs->trans("ServicesArea"); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1d264548b11..98f841013ba 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -629,7 +629,7 @@ $listofreferent = array( 'lang'=>'agenda', 'buttonnew'=>'AddEvent', 'testnew'=>$user->rights->agenda->myactions->create, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read), + 'test'=> isModEnabled('agenda') && $user->rights->agenda->myactions->read), */ ); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index fbec220b671..0da51607eb8 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1458,7 +1458,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print '
'; print $langs->trans('ServiceToUseOnLines'); @@ -1750,7 +1750,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''.$langs->trans("Product").''; print ''; print img_picto('', 'product'); print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1); diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index e8d9f986f91..e9bca76cdbc 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -84,7 +84,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Security check -if (empty($conf->agenda->enabled)) { +if (!isModEnabled('agenda')) { httponly_accessforbidden('Module Agenda not enabled'); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 8552f257fcc..e0386ddd1c6 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -577,7 +577,7 @@ class Thirdparties extends DolibarrApi throw new RestException(501, 'Module "Thirdparties" needed for this request'); } - if (empty($conf->product->enabled)) { + if (!isModEnabled("product")) { throw new RestException(501, 'Module "Products" needed for this request'); } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 07436ae6140..5b993769449 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -147,7 +147,7 @@ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index a3036ad19c7..d665f1efcc4 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -222,7 +222,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled)) { + if (isModEnabled('agenda')) { if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { @@ -232,7 +232,7 @@ if ($object->id > 0) { print '
'; - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); From 15c60e29f41ed996ba7cecf5a40ed5be068084be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:18:47 +0200 Subject: [PATCH 121/159] use isModEnabled --- htdocs/core/modules/modAgenda.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 4c2b86e59b7..20a2016939f 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -212,7 +212,7 @@ class modAgenda extends DolibarrModules 'langs'=>'agenda', 'position'=>86, 'perms'=>'$user->rights->agenda->myactions->read || $user->rights->resource->read', - 'enabled'=>'isModEnabled("agenda") || $conf->resource->enabled', + 'enabled'=>'isModEnabled("agenda") || isModEnabled("resource")', 'target'=>'', 'user'=>2, ); From a38a303e1ce34f3b1b23b3ce064716814fb83c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:23:34 +0200 Subject: [PATCH 122/159] use isModEnabled --- htdocs/commande/list_det.php | 4 ++-- htdocs/contrat/list.php | 4 ++-- .../modules/mailings/advthirdparties.modules.php | 2 +- .../core/modules/mailings/thirdparties.modules.php | 2 +- htdocs/core/modules/modTicket.class.php | 14 +++++++------- htdocs/projet/activity/perday.php | 3 +-- htdocs/projet/activity/permonth.php | 3 +-- htdocs/projet/activity/perweek.php | 3 +-- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/user/card.php | 2 +- 11 files changed, 19 insertions(+), 22 deletions(-) diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 78f7c687175..c0855371f6d 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -875,7 +875,7 @@ if ($resql) { $moreforfilter .= ''; } // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled("categorie") && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -883,7 +883,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); $moreforfilter .= '
'; } - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + if (isModEnabled("categorie") && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a671297b0de..c51a4398cf1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.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'; -if (!empty($conf->categorie->enabled)) { +if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -701,7 +701,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->right $moreforfilter .= '
'; } // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 6137bcca2ff..ced14b802a0 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -253,7 +253,7 @@ class mailing_advthirdparties extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - if (empty($conf->categorie->enabled)) { + if (!isModEnabled("categorie")) { $num = 0; // Force empty list if category module is not enabled } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index f34eb600228..53cba7c915f 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -295,7 +295,7 @@ class mailing_thirdparties extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - if (empty($conf->categorie->enabled)) { + if (!isModEnabled("categorie")) { $num = 0; // Force empty list if category module is not enabled } diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 67c27178987..01ae671bad7 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -157,7 +157,7 @@ class modTicket extends DolibarrModules 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public,fk_parent", "code,label,pos,use_default"), 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), - 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled && getDolGlobalString('TICKET_ENABLE_RESOLUTION')), + 'tabcond' => array(isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket"), isModEnabled("ticket") && getDolGlobalString('TICKET_ENABLE_RESOLUTION')), 'tabhelp' => array( array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), @@ -238,7 +238,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/index.php', 'langs' => 'ticket', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 88, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules 'target' => '', 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both @@ -253,7 +253,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/index.php', 'langs' => 'ticket', 'position' => 101, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 2); @@ -266,7 +266,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/card.php?action=create', 'langs' => 'ticket', 'position' => 102, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->write', 'target' => '', 'user' => 2); @@ -280,7 +280,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/list.php?search_fk_status=non_closed', 'langs' => 'ticket', 'position' => 103, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 2); @@ -294,7 +294,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed', 'langs' => 'ticket', 'position' => 105, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 0); @@ -307,7 +307,7 @@ class modTicket extends DolibarrModules 'url' => '/ticket/stats/index.php', 'langs' => 'ticket', 'position' => 107, - 'enabled' => '$conf->ticket->enabled', + 'enabled' => 'isModEnabled("ticket")', 'perms' => '$user->rights->ticket->read', 'target' => '', 'user' => 0); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 5438ea6e47f..9c4e47037c2 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -495,8 +495,7 @@ print '
'; $moreforfilter = ''; // Filter on categories -/*if (!empty($conf->categorie->enabled)) -{ +/*if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index e6226ca677c..bff135b713f 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -410,8 +410,7 @@ $moreforfilter = ''; // Filter on categories /* -if (!empty($conf->categorie->enabled)) -{ +if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b3aa85e6226..1d3a6ef3c2c 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -546,8 +546,7 @@ $moreforfilter = ''; // Filter on categories /* - if (!empty($conf->categorie->enabled)) - { + if (isModEnabled("categorie")) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 17f4d66168b..92cbda347ae 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1006,7 +1006,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire) { $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx'); } // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index adf86b7ac49..b922b1cbed6 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -806,7 +806,7 @@ $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form- $moreforfilter .= '
'; // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index cafb1ae847b..570b78f7604 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -353,7 +353,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; // Go back to create page } else { - if (!empty($conf->categorie->enabled)) { + if (isModEnabled("categorie")) { // Categories association $usercats = GETPOST('usercats', 'array'); $object->setCategories($usercats); From 7760ba86dabee47c985bbd1019f56991acc5164c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:33:36 +0200 Subject: [PATCH 123/159] use isModEnabled --- .../template/class/myobject.class.php | 2 +- .../core/modules/modMyModule.class.php | 18 +++++++++--------- ...e_99_modMyModule_MyModuleTriggers.class.php | 2 +- .../modulebuilder/template/mymoduleindex.php | 4 ++-- .../template/myobject_contact.php | 3 +-- .../template/myobject_document.php | 3 +-- .../modulebuilder/template/myobject_note.php | 3 +-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d57a1fca39f..dac32970ae6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -121,7 +121,7 @@ class MyObject extends CommonObject 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1), 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'isModEnabled("project")', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1, 'cssview'=>'wordbreak'), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1, 'cssview'=>'wordbreak'), diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 2788c78fc37..e8f3f26772b 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -221,7 +221,7 @@ class modMyModule extends DolibarrModules // Name of columns with primary key (try to always name it 'rowid') 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary - 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled), + 'tabcond'=>array(isModEnabled('mymodule'), isModEnabled('mymodule'), isModEnabled('mymodule')), // Tooltip for every fields of dictionaries: DO NOT PUT AN EMPTY ARRAY 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), ...), ); @@ -252,13 +252,13 @@ class modMyModule extends DolibarrModules // 'frequency' => 2, // 'unitfrequency' => 3600, // 'status' => 0, - // 'test' => '$conf->mymodule->enabled', + // 'test' => 'isModEnabled("mymodule")', // 'priority' => 50, // ), ); // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'isModEnabled("mymodule")', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'isModEnabled("mymodule")', 'priority'=>50) // ); // Permissions provided by this module @@ -437,11 +437,11 @@ class modMyModule extends DolibarrModules // Create extrafields during init //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); + //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', 'isModEnabled("mymodule")'); // Permissions $this->remove($options); diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index c51bc01376c..9420c83b8c0 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -90,7 +90,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->mymodule) || empty($conf->mymodule->enabled)) { + if (!isModEnabled('mymodule')) { return 0; // If module is not enabled, we do nothing } diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 3b7b1b13009..3c7cc5f9ec5 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -186,8 +186,8 @@ END MODULEBUILDER DRAFT MYOBJECT */ print '
'; -$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; +$NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); +$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT // Last modified myobject diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 9568201238c..4f384a006e5 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -175,8 +175,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index ff1756e2b15..7ffa467cdc0 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -193,8 +193,7 @@ $morehtmlref = '
'; // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 1f3bf7c9fd4..584a7ccd9e3 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -168,8 +168,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) - { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) From 40c5be6f7fb01e57bef049e1ccfa7ce7ef49b92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:37:07 +0200 Subject: [PATCH 124/159] use isModEnabled --- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index c752dd41632..81d8c93f240 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -211,7 +211,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { From f8d3c28e687aa9dbbb2d95cb4e80c19e10bc82d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 20:37:42 +0200 Subject: [PATCH 125/159] Look and feel v18 --- htdocs/commande/list.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 032fd3393e2..be01453d941 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -2045,7 +2045,9 @@ if ($resql) { // Ref customer if (!empty($arrayfields['c.ref_client']['checked'])) { - print '
'.$obj->ref_client.''; + print dol_escape_htmltag($obj->ref_client); + print ''; + print ''; if ($userstatic->id) { print $userstatic->getNomUrl(-1); } else { From cfa10bb8ba27e31f33dbdfac43a1fbab4ee965ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:40:07 +0200 Subject: [PATCH 126/159] use isModEnabled --- .../modulebuilder/template/core/boxes/mymodulewidget1.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 7ea4b553e71..ace98374461 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -101,8 +101,10 @@ class mymodulewidget1 extends ModeleBoxes $this->param = $param; - //$this->enabled = $conf->global->FEATURES_LEVEL > 0; // Condition when module is enabled or not - //$this->hidden = ! ($user->rights->mymodule->myobject->read); // Condition when module is visible by user (test on permission) + // Condition when module is enabled or not + // $this->enabled = getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0; + // Condition when module is visible by user (test on permission) + // $this->hidden = !$user->hasRight('mymodule', 'myobject', 'read'); } /** From 1cb2a9afd1dca313a6ce7958d12623620ea1ea68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:49:27 +0200 Subject: [PATCH 127/159] fix doc --- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/mrp/class/mo.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e10139f3711..f3975e58125 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1732,8 +1732,8 @@ class BOMLine extends CommonObjectLine */ public $childBom = array(); - /* - * Service Workstation + /** + * @var int Service Workstation */ public $fk_default_workstation; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 44775b996b6..46b33051fd9 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1744,8 +1744,8 @@ class MoLine extends CommonObjectLine public $import_key; public $fk_parent_line; - /* - * Service Workstation + /** + * @var int Service Workstation */ public $fk_default_workstation; From 25850a7e0a06b0124672ce89e3932d17039d92aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 20:59:43 +0200 Subject: [PATCH 128/159] typo --- htdocs/mrp/class/api_mos.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 2312f4bd636..594cd0e1ac4 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -345,10 +345,10 @@ class Mos extends DolibarrApi } if (empty($labelmovement)) { - throw new RestException(500, "Field inventorylabel not prodivded"); + throw new RestException(500, "Field inventorylabel not provided"); } if (empty($codemovement)) { - throw new RestException(500, "Field inventorycode not prodivded"); + throw new RestException(500, "Field inventorycode not provided"); } // Code for consume and produce... From 296ab378b18773f080720020e931e126799792c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Apr 2023 21:54:52 +0200 Subject: [PATCH 129/159] Fix css --- htdocs/societe/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5129e1ddb55..2f6159633fb 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1355,15 +1355,15 @@ $totalarray['nbfield'] = 0; // -------------------------------------------------------------------- print '