From 39ce121dd2a6b7e2f240e18cb7d94fd0fd328960 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:50:12 +0200 Subject: [PATCH 01/33] Update card.php --- htdocs/contact/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index d486432f142..d7eb7f53d82 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -32,6 +32,8 @@ * \brief Card of a contact */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -52,14 +54,15 @@ $langs->loadLangs(array('companies', 'users', 'other', 'commercial')); $mesg = ''; $error = 0; $errors = array(); +// Get parameters $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); - $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); +// Initialize technical object $object = new Contact($db); $extrafields = new ExtraFields($db); From 38dc398bda54bbc713a69c51d1087c333c06144a Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:51:26 +0200 Subject: [PATCH 02/33] Update consumption.php --- htdocs/contact/consumption.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index c3cd54d890e..fff1ba17644 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -22,9 +22,11 @@ /** * \file htdocs/contact/consumption.php * \ingroup societe - * \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty + * \brief Add a tab on thirdparty view to list all products/services bought or sells by thirdparty */ + +// Load Dolibarr environment require "../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; From 0af3a3cf8ebe41f680b6652e651e21317e763f43 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:52:29 +0200 Subject: [PATCH 03/33] Update document.php --- htdocs/contact/document.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 3fac8adea15..f62e82ee5a1 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -23,6 +23,8 @@ * \brief Page with attached files on contact */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -33,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page $langs->loadLangs(array('other', 'companies', 'contact')); +// Get parameters $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); From 4cb4f5d411ed798c81cb2bd9b9b4b28ccc3635ce Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:56:31 +0200 Subject: [PATCH 04/33] Update list.php --- htdocs/contact/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index f5810db2b13..d5c0d333d03 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -33,6 +33,8 @@ * \brief Page to list all contacts */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -44,6 +46,7 @@ $langs->loadLangs(array("companies", "suppliers", "categories")); $socialnetworks = getArrayOfSocialNetworks(); +// Get parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); From f4ad2d9aa5f7abb8eaebe0512824b352053877bd Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 30 Aug 2022 11:12:07 +0200 Subject: [PATCH 05/33] Fix : SQL error on 16-17 migration --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 1b0d8a33231..5db36ee955b 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -71,8 +71,8 @@ ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER a ALTER TABLE llx_holiday CHANGE COLUMN date_approve date_approval datetime; -UPDATE llx_holiday SET date_approval = date_valid WHEN statut = 3 AND date_approval IS NULL; -UPDATE llx_holiday SET fk_user_approve = fk_user_valid WHEN statut = 3 AND fk_user_approve IS NULL; +UPDATE llx_holiday SET date_approval = date_valid WHERE statut = 3 AND date_approval IS NULL; +UPDATE llx_holiday SET fk_user_approve = fk_user_valid WHERE statut = 3 AND fk_user_approve IS NULL; ALTER TABLE llx_inventory ADD COLUMN categories_product VARCHAR(255) DEFAULT NULL AFTER fk_product; From 6e31609b14ec77cb98757bb3831c469bc3d5276c Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 30 Aug 2022 11:31:20 +0200 Subject: [PATCH 06/33] Fix #21810 : Broken statistics in project module --- htdocs/projet/class/projectstats.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 9b2314deacc..f1295c10424 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -528,4 +528,22 @@ class ProjectStats extends Stats // var_dump($res);print '
'; return $res; } + + /** + * Return average of entity by month + * @param int $year year number + * @return int value + */ + protected function getAverageByMonth($year) + { + $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; + $sql .= " FROM ".$this->from; + $sql .= $this->join; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } } From 2a8474003d23943da9cabc59816e5e7d0c3178dc Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:34:28 +0200 Subject: [PATCH 07/33] update code --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 05f692be526..e2b8ace4783 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -526,7 +526,7 @@ $tabcond[40] = (isModEnabled("societe") && !empty($conf->global->THIRDPARTY_ENAB $tabcond[41] = !empty($conf->intracommreport->enabled); $tabcond[42] = isModEnabled("product"); $tabcond[43] = isModEnabled("product") && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2; -$tabcond[44] = !empty($conf->asset->enabled); +$tabcond[44] = isModEnabled('asset'); // List of help for fields (no more used, help is defined into tabcomplete) $tabhelp = array(); From c0e27f252c40229ec55321bb574a0cbf7bf6733e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:35:37 +0200 Subject: [PATCH 08/33] update code --- htdocs/asset/accountancy_codes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/accountancy_codes.php b/htdocs/asset/accountancy_codes.php index 431b4ba7c68..824f1a75bbb 100644 --- a/htdocs/asset/accountancy_codes.php +++ b/htdocs/asset/accountancy_codes.php @@ -58,7 +58,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); $result = $assetaccountancycodes->fetchAccountancyCodes($object->id); if ($result < 0) { From 8d08f302615afcc0e85849d30dc6e6843cca35da Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:36:05 +0200 Subject: [PATCH 09/33] update code --- htdocs/asset/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index 3d40cf62328..437e51cf0b1 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -86,7 +86,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); /* From 7563ba8d6edc534c52f26ac8353fc5f485f3097c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:36:43 +0200 Subject: [PATCH 10/33] update code --- htdocs/asset/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index d94ba613d91..c2d768b5405 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -80,7 +80,7 @@ if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) $socid = $user->socid; $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); From f201e5994e289f3cb2e284bf425a0914d35ecc65 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:37:09 +0200 Subject: [PATCH 11/33] update code --- htdocs/asset/depreciation_options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/depreciation_options.php b/htdocs/asset/depreciation_options.php index ba5719705dc..23c66d8961b 100644 --- a/htdocs/asset/depreciation_options.php +++ b/htdocs/asset/depreciation_options.php @@ -58,7 +58,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!empty($object->not_depreciated)) accessforbidden(); $object->asset_depreciation_options = &$assetdepreciationoptions; From e6e6a7000b1713cebccb4009c3f848d6ec269353 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:37:39 +0200 Subject: [PATCH 12/33] update code --- htdocs/asset/depreciation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index 8f3547d81fb..679d750c668 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -56,7 +56,7 @@ if ($id > 0 || !empty($ref)) { if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!empty($object->not_depreciated)) accessforbidden(); $object->asset_depreciation_options = &$assetdepreciationoptions; From 9414d5cfd5ba1b5ade4ee1f9664e1ce80fa767fb Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:38:21 +0200 Subject: [PATCH 13/33] update code --- htdocs/asset/disposal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/disposal.php b/htdocs/asset/disposal.php index 7fddb92b05f..e06e86c78ac 100644 --- a/htdocs/asset/disposal.php +++ b/htdocs/asset/disposal.php @@ -57,7 +57,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbidden(); From 5811fc0cc52a4c04957b450b3cbe8e5574be198a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:38:48 +0200 Subject: [PATCH 14/33] update code --- htdocs/asset/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 96b222b26c1..9f4439f94d6 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -78,7 +78,7 @@ $permissiontoadd = $user->rights->asset->asset->write; // Used by the include of if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); /* From 34a2ffe33423044575aefa7239b7f02e6d16c232 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:39:24 +0200 Subject: [PATCH 15/33] update code --- htdocs/asset/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index c475e22fc83..45f90101adc 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -125,7 +125,7 @@ $permissiontoadd = $user->rights->asset->write; $permissiontodelete = $user->rights->asset->delete; // Security check -if (empty($conf->asset->enabled)) { +if (!isModEnabled('asset')) { accessforbidden('Module not enabled'); } @@ -134,7 +134,7 @@ if ($user->socid > 0) accessforbidden(); $socid = 0; if ($user->socid > 0) $socid = $user->socid; $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); From 94a31d6d634262764e0d1371be2550acd70fcc0e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:39:52 +0200 Subject: [PATCH 16/33] update code --- htdocs/asset/note.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index 8de86d49bb7..810ab7f4462 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -57,7 +57,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); /* From 67929038a9c6a2a6b3fe0e948e7a48773c58034a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:40:26 +0200 Subject: [PATCH 17/33] update code --- htdocs/asset/model/accountancy_codes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php index 7582b61177e..6eb6d70abaf 100644 --- a/htdocs/asset/model/accountancy_codes.php +++ b/htdocs/asset/model/accountancy_codes.php @@ -59,7 +59,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); $result = $assetaccountancycodes->fetchAccountancyCodes(0, $object->id); From 6fd3a0d4cd5e2c0260cf63bc5db69fd553c7bfee Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:40:53 +0200 Subject: [PATCH 18/33] update code --- htdocs/asset/model/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index f1db3030dc2..51a7fb515bf 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -88,7 +88,7 @@ if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) $socid = $user->socid; $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); From 52fad955c4faf5159a914ece8868514d2fc69474 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:41:23 +0200 Subject: [PATCH 19/33] update code --- htdocs/asset/model/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 3d3ec2f67d2..756ac32e31f 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -80,7 +80,7 @@ if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) $socid = $user->socid; $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); From e4ff238afa983e952fa0c117083a279a5b90be58 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:41:54 +0200 Subject: [PATCH 20/33] update code --- htdocs/asset/model/depreciation_options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php index c34bd38dc46..f3f585f5397 100644 --- a/htdocs/asset/model/depreciation_options.php +++ b/htdocs/asset/model/depreciation_options.php @@ -59,7 +59,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig if ($user->socid > 0) accessforbidden(); $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); $object->asset_depreciation_options = &$assetdepreciationoptions; From b082443ad042c4be0cbfa654c48e66cc0ccd79f1 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:42:36 +0200 Subject: [PATCH 21/33] update code --- htdocs/asset/model/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index a55d5f49f9a..1d85a982e5d 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -126,7 +126,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig $permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))); // Security check -if (empty($conf->asset->enabled)) { +if (!isModEnabled('asset')) { accessforbidden('Module not enabled'); } @@ -140,7 +140,7 @@ if ($user->socid > 0) { } $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->asset->enabled)) accessforbidden(); +if (!isModEnabled('asset')) accessforbidden(); if (!$permissiontoread) accessforbidden(); /* From 6812d5d890816afd8ab117502f3594bd808c89ac Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:43:58 +0200 Subject: [PATCH 22/33] update code --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index cb38d7a3546..54e64ccc769 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -71,7 +71,7 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf- if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier', 'invoice_supplier_rec'))) { $colspan++; // With this, there is a column move button } -if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') { +if (isModEnabled('asset') && $object->element == 'invoice_supplier') { $colspan++; } From 16788846b93bdadd4b1c81e1d4bfaa9549561e4e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:44:26 +0200 Subject: [PATCH 23/33] update code --- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 761be27b512..b2974ffbbfc 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -73,7 +73,7 @@ if (in_array($object->element, array('propal', 'supplier_proposal', 'facture', ' if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan += 2; } -if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') { +if (isModEnabled('asset') && $object->element == 'invoice_supplier') { $colspan++; } From 151ed11388e376a8b7d6535aef9308eebab8beed Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:44:50 +0200 Subject: [PATCH 24/33] update code --- htdocs/core/tpl/objectline_title.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 762e9b4eefa..79d4ebeae11 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -160,7 +160,7 @@ if ($outputalsopricetotalwithtax) { print ''.$langs->trans('TotalTTCShort').''; } -if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') { +if (isModEnabled('asset') && $object->element == 'invoice_supplier') { print ''; } From 6116478cca2c9e7316f92b24d4538edc83302edd Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 30 Aug 2022 11:45:15 +0200 Subject: [PATCH 25/33] update code --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index c93e0d5c4cd..b660bd89d93 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -397,7 +397,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } } - if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') { + if (isModEnabled('asset') && $object->element == 'invoice_supplier') { print ''; $coldisplay++; if (!empty($product_static->accountancy_code_buy) || From c666c2cb89d3ae77f335e9be999a3510840c99fb Mon Sep 17 00:00:00 2001 From: Julien Nicolas Date: Tue, 30 Aug 2022 12:02:53 +0200 Subject: [PATCH 26/33] Bugfix project stats when user has no project In case of no project assigned to user, stats were using all projects --- htdocs/projet/class/project.class.php | 42 ++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f395173b327..04e32a80c5d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2040,7 +2040,6 @@ class Project extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) @@ -2056,10 +2055,14 @@ class Project extends CommonObject // For external user, no check is done on company because readability is managed by public status of project and assignement. //$socid=$user->socid; - $projectsListId = null; - if (empty($user->rights->projet->all->lire)) { - $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); - } + $response = new WorkboardResponse(); + $response->warning_delay = $conf->project->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("OpenedProjects"); + $response->labelShort = $langs->trans("Opened"); + $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; + $response->img = img_object('', "projectpub"); + $response->nbtodo = 0; + $response->nbtodolate = 0; $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql .= " FROM (".MAIN_DB_PREFIX."projet as p"; @@ -2069,9 +2072,19 @@ class Project extends CommonObject //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql .= " WHERE p.fk_statut = 1"; $sql .= " AND p.entity IN (".getEntity('project').')'; - if (!empty($projectsListId)) { + + + $projectsListId = null; + if (!$user->rights->projet->all->lire) { + $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; + $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); + if (empty($projectsListId)) { + return $response; + } + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; } + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; // For external user, no check is done on company permission because readability is managed by public status of project and assignement. @@ -2082,16 +2095,6 @@ class Project extends CommonObject if ($resql) { $project_static = new Project($this->db); - $response = new WorkboardResponse(); - $response->warning_delay = $conf->project->warning_delay / 60 / 60 / 24; - $response->label = $langs->trans("OpenedProjects"); - $response->labelShort = $langs->trans("Opened"); - if ($user->rights->projet->all->lire) { - $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; - } else { - $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; - } - $response->img = img_object('', "projectpub"); // This assignment in condition is not a bug. It allows walking the results. while ($obj = $this->db->fetch_object($resql)) { @@ -2107,12 +2110,11 @@ class Project extends CommonObject } return $response; - } else { - $this->error = $this->db->error(); - return -1; } - } + $this->error = $this->db->error(); + return -1; + } /** * Function used to replace a thirdparty id with another one. From 27ce241074d08986c552436fc369f9df15b04bbc Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 22:33:54 +0200 Subject: [PATCH 27/33] Update modules_takepos.php --- htdocs/core/modules/takepos/modules_takepos.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php index 24fa70b7f28..89b3dbde5bc 100644 --- a/htdocs/core/modules/takepos/modules_takepos.php +++ b/htdocs/core/modules/takepos/modules_takepos.php @@ -16,14 +16,14 @@ * 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 . - * or see http://www.gnu.org/ + * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** * \file htdocs/core/modules/takepos/modules_takepos.php * \ingroup takepos - * \brief Fichier contenant la classe mere de numerotation des tickets de caisse + * \brief File containing the parent class for the numbering of cash register receipts */ From ed4ed8705d742053575cd47783db5561a77d1cc5 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 22:43:19 +0200 Subject: [PATCH 28/33] Update mod_takepos_ref_simple.php --- .../core/modules/takepos/mod_takepos_ref_simple.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 41b7bb8c90e..31eb9345110 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -15,8 +15,8 @@ * 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 . - * or see http://www.gnu.org/ + * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** @@ -24,6 +24,7 @@ * \ingroup takepos * \brief File with Simple ref numbering module for takepos */ + dol_include_once('/core/modules/takepos/modules_takepos.php'); /** @@ -80,10 +81,10 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos } /** - * Test si les numeros deja en vigueur dans la base ne provoquent pas de - * de conflits qui empechera cette numerotation de fonctionner. + * Test if the numbers already in the database do not cause any conflicts that will prevent this + * of conflicts that will prevent this numbering from working. * - * @return boolean false si conflit, true si ok + * @return boolean false if KO (there is a conflict), true if OK */ public function canBeActivated() { From a97f606cd9baf1fa25f2dfbada2b3edc24ddd33d Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 22:47:44 +0200 Subject: [PATCH 29/33] Update mod_takepos_ref_universal.php --- .../modules/takepos/mod_takepos_ref_universal.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index 7e46c10a341..9a6e632b92c 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -17,8 +17,8 @@ * 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 . - * or see http://www.gnu.org/ + * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** @@ -26,6 +26,7 @@ * \ingroup takepos * \brief File with Universal ref numbering module for takepos */ + dol_include_once('/core/modules/takepos/modules_takepos.php'); /** @@ -51,7 +52,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos public $nom = 'Universal'; /** - * Renvoi la description du modele de numerotation + * return description of the numbering model * * @return string Texte descripif */ @@ -77,7 +78,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos $tooltip .= $langs->trans('GenericMaskCodes5'); $tooltip .= $langs->trans('CashDeskGenericMaskCodes6'); - // Parametrage du prefix + // Setting up the prefix $texte .= ''.$langs->trans("Mask").':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; @@ -92,7 +93,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos } /** - * Renvoi un exemple de numerotation + * Return an example of numbering * * @return string Example */ @@ -125,7 +126,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - // On defini critere recherche compteur + // We define search criteria counter $mask = $conf->global->TAKEPOS_REF_UNIVERSAL_MASK; if (!$mask) { From 60bfd55db1a4256c5785471902004b7cfc136566 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Aug 2022 22:51:30 +0200 Subject: [PATCH 30/33] Update ecm.php --- htdocs/admin/ecm.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 44df7f74189..3e0c2378742 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -22,6 +22,8 @@ * \brief Page to setup ECM (GED) module */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -37,6 +39,8 @@ if (!$user->admin) { /* * Action */ + +// set if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -47,6 +51,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { } } +// delete if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { From f6c6797dc4d077a3b721089ebf91913b7be978a7 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:38:18 +0200 Subject: [PATCH 31/33] Update compare.php --- htdocs/hrm/compare.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index c8bb01d85e5..686d5820695 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -1,9 +1,9 @@ - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2021 Greg Rastklan - * Copyright (C) 2021 Jean-Pascal BOUDET - * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Greg Rastklan + * Copyright (C) 2021 Jean-Pascal BOUDET + * Copyright (C) 2021 Grégory BLEMAND * * 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 @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * \file class/compare.php + * \file htdocs/hrm/compare.php * \ingroup hrm * \brief This file compares skills of user groups * @@ -33,23 +33,29 @@ * */ + +// Load Dolibarr environment require_once '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/evaluation.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/position.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm.lib.php'; -$permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read; -$permissiontoadd = 0; -if (empty($conf->hrm->enabled)) accessforbidden(); -if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); +// Load translation files required by the page $langs->load('hrm'); +// Permissions +$permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read; +$permissiontoadd = 0; + +if (empty($conf->hrm->enabled)) accessforbidden(); +if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); + /* * View From 66cb51708cd1f2ef7ae08f5f7e1202c3bd6dfe76 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:49:27 +0200 Subject: [PATCH 32/33] Update index.php --- htdocs/hrm/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 1160ee0fc14..861bde0fb51 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -26,6 +26,8 @@ * \brief Home page for HRM area. */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -34,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; + if (!empty($conf->deplacement->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; } @@ -48,12 +51,15 @@ if (!empty($conf->holiday->enabled)) { require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; } + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager = new HookManager($db); $hookmanager->initHooks('hrmindex'); // Load translation files required by the page $langs->loadLangs(array('users', 'holiday', 'trips', 'boxes')); +// Get Parameters $socid = GETPOST("socid", "int"); // Protection if external user From e390e6273b7e399a3ffb2b52a554bf38dc9a6257 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:56:16 +0200 Subject: [PATCH 33/33] Update position.php --- htdocs/hrm/position.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 78838136a1e..2659321e5fc 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -20,9 +20,9 @@ */ /** - * \file position.php - * \ingroup hrm - * \brief Page to create/edit/view position + * \file htdocs/hrm/position.php + * \ingroup hrm + * \brief Page to create/edit/view position */ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db @@ -88,10 +88,6 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_position.lib.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php'; -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$fk_job = GETPOST('fk_job', 'int'); // Get parameters $id = GETPOST('fk_job', 'int'); @@ -105,12 +101,18 @@ $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'positioncard'; // To manage different context of search +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +$fk_job = GETPOST('fk_job', 'int'); + // Initialize technical objects $object = new Job($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id; + $hookmanager->initHooks(array('positiontab', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -130,6 +132,7 @@ foreach ($object->fields as $key => $val) { // Load object include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +// Permissions $permissiontoread = $user->rights->hrm->all->read; $permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->hrm->all->delete;