From 42a79c3dc002ded87f0b7110efe0ddb6cad19c25 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 20 Aug 2024 09:44:07 +0200 Subject: [PATCH 01/21] Update api_recruitments.class.php with pagination (#30677) * Update api_recruitments.class.php with pagination * Update api_recruitments.class.php --------- Co-authored-by: Laurent Destailleur --- .../class/api_recruitments.class.php | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php index 4d509928372..bfa82e27155 100644 --- a/htdocs/recruitment/class/api_recruitments.class.php +++ b/htdocs/recruitment/class/api_recruitments.class.php @@ -123,7 +123,6 @@ class Recruitments extends DolibarrApi return $this->_cleanObjectDatas($this->candidature); } - /** * List jobpositions * @@ -135,13 +134,14 @@ class Recruitments extends DolibarrApi * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of order objects * * @throws RestException * * @url GET /jobposition/ */ - public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') + public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false) { $obj_ret = array(); $tmpobject = new RecruitmentJobPosition($this->db); @@ -186,6 +186,9 @@ class Recruitments extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -212,6 +215,23 @@ class Recruitments extends DolibarrApi throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } @@ -225,13 +245,15 @@ class Recruitments extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of order objects * * @throws RestException * * @url GET /candidature/ */ - public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false) { global $db, $conf; @@ -278,6 +300,9 @@ class Recruitments extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -296,7 +321,7 @@ class Recruitments extends DolibarrApi $obj = $this->db->fetch_object($result); $tmp_object = new RecruitmentCandidature($this->db); if ($tmp_object->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($tmp_object), $properties); } $i++; } @@ -304,6 +329,23 @@ class Recruitments extends DolibarrApi throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } From 3b2207ca2f3552bede6581022fdcb5153b849c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 20 Aug 2024 09:46:42 +0200 Subject: [PATCH 02/21] Add docker installation instructions (#30684) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2152d970a62..b81d632a728 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ You can use any web server supporting PHP (Apache, Nginx, ...) and a supported d - Follow the installer instructions;;; +### Using Docker images + +Dolibarr is also available as a [Docker image](https://hub.docker.com/r/dolibarr/dolibarr). Installation instructions are available [here](https://github.com/Dolibarr/dolibarr-docker). + ### Using ready to use SaaS/Cloud offers If you lack the time to install it yourself, consider exploring commercial 'ready-to-use' Cloud offerings (refer to https://saas.dolibarr.org). Keep in mind that this third option comes with associated costs. From 5ed0d017e03211c5e0c629218564ca278d203c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Aug 2024 09:46:59 +0200 Subject: [PATCH 03/21] fix phpdoc (#30685) --- htdocs/core/lib/project.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 8c5ceb8656b..dd5d927662b 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1157,7 +1157,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t * Output a task line into a pertime input mode * * @param string $inc Line number (start to 0, then increased by recursive call) - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param User|null $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) @@ -1378,7 +1378,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec * Output a task line into a pertime input mode * * @param string $inc Line number (start to 0, then increased by recursive call) - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param User|null $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) @@ -1777,7 +1777,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr * @param string $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $projectsrole Array of roles user has on project @@ -2177,7 +2177,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param string $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $projectsrole Array of roles user has on project From 0166b6c0e9bd79b5e21b130adc07c24720f0ae71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bagnol?= Date: Tue, 20 Aug 2024 09:51:27 +0200 Subject: [PATCH 04/21] # FIX truncate mail server error message to fit to database (mailling module) (#30534) * truncate mail server error message to fit to database * fix typo * substr under DB->escape --------- Co-authored-by: Laurent Destailleur --- htdocs/comm/mailing/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 8971aaa6ec8..30a33c53654 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -427,7 +427,7 @@ if (empty($reshook)) { dol_syslog("comm/mailing/card.php: error for #".$iforemailloop.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid); + $sql .= " SET statut=-1, error_text='".$db->escape(substr($mail->error, 0, 255))."', date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid); $resql2 = $db->query($sql); if (!$resql2) { dol_print_error($db); From a90b6d877939192765c9144c2466c435f03b47da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 10:10:13 +0200 Subject: [PATCH 05/21] Fix warning and option MAIN_AUTOFILL_DATE --- htdocs/compta/facture/card.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 43758c04eab..8d82368b230 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1035,7 +1035,7 @@ if (empty($reshook)) { $object->socid = GETPOSTINT('socid'); } - if (GETPOSTINT('type') === '') { + if (GETPOST('type') === '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } @@ -3209,6 +3209,9 @@ if ($action == 'create') { $subelement = $regs[2]; } + $dateinvoice = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server + $date_pointoftax = dol_mktime(0, 0, 0, GETPOSTINT('date_pointoftaxmonth'), GETPOSTINT('date_pointoftaxday'), GETPOSTINT('date_pointoftaxyear'), 'tzserver'); + if ($element == 'project') { $projectid = $originid; @@ -3221,12 +3224,9 @@ if ($action == 'create') { if (empty($fk_account)) { $fk_account = $soc->fk_account; } - if (!$remise_percent) { - $remise_percent = $soc->remise_percent; - } - if (!$dateinvoice) { + if (empty($dateinvoice)) { // Do not set 0 here (0 for a date is 1970) - $dateinvoice = (empty($dateinvoice) ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $dateinvoice); + $dateinvoice = getDolGlobalString('MAIN_AUTOFILL_DATE') ? '' : -1; } } else { // For compatibility @@ -3278,8 +3278,6 @@ if ($action == 'create') { $cond_reglement_id = (!empty($expesrc->cond_reglement_id) ? $expesrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); $mode_reglement_id = (!empty($expesrc->mode_reglement_id) ? $expesrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - //$remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); - //$remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (isModEnabled('multicurrency')) { $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); @@ -3293,8 +3291,6 @@ if ($action == 'create') { $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); - //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (isModEnabled('multicurrency')) { if (!empty($objectsrc->multicurrency_code)) { @@ -3314,8 +3310,7 @@ if ($action == 'create') { $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id; $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id; $fk_account = empty($soc->fk_account) ? $fk_account : $soc->fk_account; - //$remise_percent = $soc->remise_percent; - //$remise_absolue = 0; + $dateinvoice = (empty($dateinvoice) ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $dateinvoice); // Do not set 0 here (0 for a date is 1970) if (isModEnabled('multicurrency') && !empty($soc->multicurrency_code)) { @@ -4121,8 +4116,6 @@ if ($action == 'create') { // TODO for compatibility if ($origin == 'contrat') { // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva - //$objectsrc->remise_absolue = $remise_absolue; - //$objectsrc->remise_percent = $remise_percent; $objectsrc->update_price(1, 'auto', 1); } From 465b7dc2c661250919f2e3009f7b19f312f6b429 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 20 Aug 2024 10:18:06 +0200 Subject: [PATCH 06/21] Update api_contacts.class.php with pagination (#30679) Co-authored-by: Laurent Destailleur --- htdocs/societe/class/api_contacts.class.php | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 95e7de8d649..f345a21abc2 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -168,11 +168,12 @@ class Contacts extends DolibarrApi * @param int $includecount Count and return also number of elements the contact is used as a link for * @param int $includeroles Includes roles of the contact * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return Contact[] Array of contact objects * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includecount = 0, $includeroles = 0, $properties = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includecount = 0, $includeroles = 0, $properties = '', $pagination_data = false) { global $db, $conf; @@ -225,6 +226,9 @@ class Contacts extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { @@ -263,9 +267,24 @@ class Contacts extends DolibarrApi } else { throw new RestException(503, 'Error when retrieve contacts : '.$sql); } - if (!count($obj_ret)) { - throw new RestException(404, 'Contacts not found'); + + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; } + return $obj_ret; } From f613752bd3ac0e043d004461d94e9c13c66a9752 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 20 Aug 2024 10:18:15 +0200 Subject: [PATCH 07/21] Update api_contracts.class.php with pagination (#30681) Co-authored-by: Laurent Destailleur --- htdocs/contrat/class/api_contracts.class.php | 27 +++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 1503a214162..eaaeb04daa0 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -82,8 +82,6 @@ class Contracts extends DolibarrApi return $this->_cleanObjectDatas($this->contract); } - - /** * List contracts * @@ -96,12 +94,13 @@ class Contracts extends DolibarrApi * @param string $thirdparty_ids Thirdparty ids to filter contracts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names - * @return array Array of contract objects + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* + * @return array Array of order objects * * @throws RestException 404 Not found * @throws RestException 503 Error */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '', $pagination_data = false) { global $db, $conf; @@ -143,6 +142,9 @@ class Contracts extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -172,6 +174,23 @@ class Contracts extends DolibarrApi throw new RestException(503, 'Error when retrieve contrat list : '.$this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } From 23c91578f06c6cba39934ab53b462e795f1cfefa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 11:02:47 +0200 Subject: [PATCH 08/21] =?UTF-8?q?NEW=20Add=20p=C3=AEcto=20on=20list=20of?= =?UTF-8?q?=20notification=20email=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/notification.php | 8 +++++--- htdocs/core/lib/admin.lib.php | 21 ++++++++++++++------- htdocs/core/lib/functions.lib.php | 6 ++++++ htdocs/langs/en_US/admin.lang | 9 +++++---- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index d6b2b267c3c..bc1c95aa688 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -259,11 +259,12 @@ print ''; print '

'; +// Emails templates for notification + print '
'; print ''; print ''; -// Notification per contacts $title = $langs->trans("TemplatesForNotifications"); print load_fiche_titre($title, '', 'email'); @@ -310,7 +311,8 @@ foreach ($listofnotifiedevents as $notifiedevent) { $model = 'expensereport_send'; } elseif ($notifiedevent['elementtype'] == 'order_supplier') { $model = 'order_supplier_send'; - // } elseif ($notifiedevent['elementtype'] == 'invoice_supplier') $model = 'invoice_supplier_send'; + } elseif ($notifiedevent['elementtype'] == 'invoice_supplier') { + $model = 'invoice_supplier_send'; } elseif ($notifiedevent['elementtype'] == 'member') { $model = 'member'; } @@ -318,7 +320,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { $constantes[$notifiedevent['code'].'_TEMPLATE'] = array('type'=>'emailtemplate:'.$model, 'label'=>$label); } -$helptext = ''; +$helptext = $langs->trans("EmailTemplateHelp", $langs->transnoentitiesnoconv("Tools"), $langs->transnoentitiesnoconv("EMailTemplates")); form_constantes($constantes, 3, $helptext, 'EmailTemplate'); print $form->buttonsSaveCancel("Save", ''); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index becaa9b03e4..39851e8c16b 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1728,7 +1728,7 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu $form = new Form($db); if (empty($strictw3c)) { - dol_syslog("Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_DEBUG); + dol_syslog("Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_WARNING); } if (!empty($strictw3c) && $strictw3c == 1) { print "\n".''; @@ -1779,6 +1779,7 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu $result = $db->query($sql); dol_syslog("List params", LOG_DEBUG); + if ($result) { $obj = $db->fetch_object($result); // Take first result of select @@ -1786,23 +1787,29 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu $obj = (object) array('rowid' => '', 'name' => $const, 'value' => '', 'type' => $type, 'note' => ''); } - if (empty($strictw3c)) { + if (empty($strictw3c)) { // deprecated. must be always true. print "\n".''; print ''; print ''; + print ''; } print ''; // Show label of parameter print ''; - if (empty($strictw3c)) { - print ''; - } print ''; print ''; print ''; print ''; + + $picto = 'generic'; + $tmparray = explode(':', $obj->type); + if (!empty($tmparray[1])) { + $picto = preg_replace('/_send$/', '', $tmparray[1]); + } + print img_picto('', $picto, 'class="pictofixedwidth"'); + if (!empty($tableau[$key]['tooltip'])) { print $form->textwithpicto($label ? $label : $langs->trans('Desc'.$const), $tableau[$key]['tooltip']); } else { @@ -1896,8 +1903,8 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu print ''; } - // Submit - if (empty($strictw3c)) { + // Submit button + if (empty($strictw3c)) { // deprecated. must be always true. print ''; print ''; print ""; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 28f2ad34333..5a6dada732a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4931,6 +4931,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco $pictowithouttext = str_replace('object_', '', $pictowithouttext); $pictowithouttext = str_replace('_nocolor', '', $pictowithouttext); + // Fix some values of $pictowithouttext + $pictoconvertkey = array('facture' => 'bill', 'shipping' => 'shipment', 'fichinter' => 'intervention', 'agenda' => 'calendar', 'invoice_supplier' => 'supplier_invoice', 'order_supplier' => 'supplier_order'); + if (in_array($pictowithouttext, array_keys($pictoconvertkey))) { + $pictowithouttext = $pictoconvertkey[$pictowithouttext]; + } + if (strpos($pictowithouttext, 'fontawesome_') === 0 || strpos($pictowithouttext, 'fa-') === 0) { // This is a font awesome image 'fontawesome_xxx' or 'fa-xxx' $pictowithouttext = str_replace('fontawesome_', '', $pictowithouttext); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 242fc0d79a4..1ed5ba5161e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1993,10 +1993,10 @@ ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules ExpenseReportNumberingModules=Expense reports numbering module NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only. YouMayFindNotificationsFeaturesIntoModuleNotification=You may find options for email notifications by enabling and configuring the module "Notification". -TemplatesForNotifications=Templates for notifications +TemplatesForNotifications=Emails templates for notifications ListOfNotificationsPerUser=List of automatic notifications per user* ListOfNotificationsPerUserOrContact=List of possible automatic notifications (on business event) available per user* or per contact** -ListOfFixedNotifications=List of automatic fixed notifications +ListOfFixedNotifications=Global recipients emails for automatic email notifications GoOntoUserCardToAddMore=Go to the tab "Notifications" of a user to add or remove notifications for users GoOntoContactCardToAddMore=Go to the tab "Notifications" of a third party to add or remove notifications for contacts/addresses Threshold=Threshold @@ -2279,6 +2279,7 @@ NotAPublicIp=Not a public IP MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation. FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled EmailTemplate=Template for email +EmailTemplateHelp=You can create emails templates from menu %s - %s EMailsWillHaveMessageID=Emails will have a 'Message-ID' header matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label @@ -2549,6 +2550,6 @@ ConfirmDeleteSocialNetwork= Are you sure want to delete this record ? AnOwnerMustBeSetIfEmailTemplateIsPrivate=An owner must be set if the email template is set as private ContactsDefaultRoles=For third parties of the "individual" type, a contact can be created simultaneously. Define here the roles that will be systematically assigned to this contact. MenuDict=Dictionary -AddMoreParams=Add more parameters for connection (cookies, tokens, ...)
Exemple: token : value token +AddMoreParams=Add more parameters for connection (cookies, tokens, ...)
Example: token : value token ParamName=Name of parameter -ParamValue=Value of parameter \ No newline at end of file +ParamValue=Value of parameter From 99924d4432fce44ad5cee7752f30d05bcb0f89f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 11:05:32 +0200 Subject: [PATCH 09/21] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1ed5ba5161e..737b283f08e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1457,7 +1457,7 @@ HRMSetup=HRM module setup CompanySetup=Companies module setup CompanyCodeChecker=Options for automatic generation of customer/vendor codes AccountCodeManager=Options for automatic generation of customer/vendor accounting codes -NotificationsDesc=Email notifications can be sent automatically for some Dolibarr events.
Recipients of notifications can be defined: +NotificationsDesc=Email notifications can be sent automatically on certain events.
Recipients of notifications can be defined: NotificationsDescUser=* per user (on the tab "Notifications" of a user) NotificationsDescContact=* per third-party contacts (on the tab "Notifications" of a third party) NotificationsDescGlobal=* or by setting global email addresses (on the setup page of the module). From 0830af9f1104e90526afdcd98b1ba7344fff40c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 11:45:15 +0200 Subject: [PATCH 10/21] Fix label-picto of extrafields --- htdocs/core/class/extrafields.class.php | 19 ++++++++++--------- htdocs/core/lib/functions.lib.php | 4 ++-- .../core/tpl/admin_extrafields_edit.tpl.php | 3 ++- htdocs/langs/en_US/admin.lang | 12 ++++++------ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 71f6df7c1cb..f3d61f71fdc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -90,9 +90,9 @@ class ExtraFields 'ip' => 'ExtrafieldIP', 'icon' => 'Icon', 'password' => 'ExtrafieldPassword', + 'radio' => 'ExtrafieldRadio', 'select' => 'ExtrafieldSelect', 'sellist' => 'ExtrafieldSelectList', - 'radio' => 'ExtrafieldRadio', 'checkbox' => 'ExtrafieldCheckBox', 'chkbxlst' => 'ExtrafieldCheckBoxFromList', 'link' => 'ExtrafieldLink', @@ -2585,23 +2585,24 @@ class ExtraFields { global $langs; + $arraytype2label = array(''); + $tmptype2label = ExtraFields::$type2label; - $type2label = array(''); foreach ($tmptype2label as $key => $val) { - $type2label[$key] = $langs->transnoentitiesnoconv($val); + $arraytype2label[$key] = $langs->transnoentitiesnoconv($val); } if (!getDolGlobalString('MAIN_USE_EXTRAFIELDS_ICON')) { - unset($type2label['icon']); + unset($arraytype2label['icon']); } if (!getDolGlobalString('MAIN_USE_GEOPHP')) { - unset($type2label['point']); - unset($type2label['multipts']); - unset($type2label['linestrg']); - unset($type2label['polygon']); + unset($arraytype2label['point']); + unset($arraytype2label['multipts']); + unset($arraytype2label['linestrg']); + unset($arraytype2label['polygon']); } - return $type2label; + return $arraytype2label; } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5a6dada732a..14b4f94b15e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4860,8 +4860,8 @@ function getPictoForType($key, $morecss = '') 'select' => 'list', 'sellist' => 'list', 'radio' => 'check-circle', - 'checkbox' => 'check-square', - 'chkbxlst' => 'check-square', + 'checkbox' => 'list', + 'chkbxlst' => 'list', 'link' => 'link', 'icon' => "question", 'point' => "country", diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 94a7f990810..254442a8df4 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -223,7 +223,8 @@ if (in_array($type, array_keys($typewecanchangeinto))) { } print $formadmin->selectTypeOfFields('type', GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : $type, $typewecanchangeinto); } else { - print getPictoForType($type).$type2label[$type]; + print getPictoForType($type); + print $type2label[$type]; print ''; } ?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 737b283f08e..bd7939331c9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -454,13 +454,13 @@ ExtrafieldPriceWithCurrency=Price with currency ExtrafieldMail = Email ExtrafieldUrl = Url ExtrafieldIP = IP -ExtrafieldSelect = Select list -ExtrafieldSelectList = Select from table +ExtrafieldSelect=Select list +ExtrafieldSelectList=Select from table ExtrafieldSeparator=Separator (not a field) ExtrafieldPassword=Password -ExtrafieldRadio=Radio buttons (one choice only) -ExtrafieldCheckBox=Checkboxes -ExtrafieldCheckBoxFromList=Checkboxes from table +ExtrafieldRadio=Radio buttons (1 choice only) +ExtrafieldCheckBox=Select list (n choices) +ExtrafieldCheckBoxFromList=Select from table (n choices) ExtrafieldLink=Link to an object ExtrafieldPointGeo=Geometric Point ExtrafieldMultiPointGeo=Geometric Multi Point @@ -475,7 +475,7 @@ ExtrafieldParamHelpselect=List of values must be lines with format key,value (wh ExtrafieldParamHelpcheckbox=List of values must be lines with format key,value (where key can't be '0')

for example:
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=List of values must be lines with format key,value (where key can't be '0')

for example:
1,value1
2,value2
3,value3
... ExtrafieldParamHelpsellist=List of values comes from a table
Syntax: table_name:label_field:id_field::filtersql
Example: c_typent:libelle:id::filtersql

- id_field is necessarily a primary int key
- filtersql is a condition. It must use the USF syntax. Example: (active:=:1) to display only active value
You can also use $ID$ in filter which is the current id of current object
If you want to filter on extrafields use syntax extra.fieldcode=... (where fieldcode is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter -ExtrafieldParamHelpchkbxlst=List of values comes from a table
Syntax: table_name:label_field:id_field::filtersql
Example: c_typent:libelle:id::filtersql

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpchkbxlst=List of values comes from a table
Syntax: table_name:label_field:id_field::filtersql
Example: c_typent:libelle:id::filtersql

filter can be a simple test (eg active=1 to display only active value)
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax: ObjectName:Classpath ExtrafieldParamHelpSeparator=Keep empty for a simple separator
Set this to 1 for a collapsing separator (open by default for new session, then status is kept for each user session)
Set this to 2 for a collapsing separator (collapsed by default for new session, then status is kept fore each user session) LibraryToBuildPDF=Library used for PDF generation From 5b8a3a10a4159fc5b5493f7e22851e30cf60addc Mon Sep 17 00:00:00 2001 From: kkhelifa-opendsi Date: Tue, 20 Aug 2024 12:08:58 +0200 Subject: [PATCH 11/21] NEW: Add auto generate document when reception is created (#30688) * NEW: Add auto generate document when reception is created * Corrections * Corrections * Corrections --- htdocs/reception/card.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 457b21e046c..a6e19e93dba 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -308,6 +308,7 @@ if (empty($reshook)) { // avec info diverses + qte a livrer if ($object->origin == "supplierorder") { + $object->origin = 'order_supplier'; $classname = 'CommandeFournisseur'; } else { $classname = ucfirst($object->origin); @@ -438,6 +439,30 @@ if (empty($reshook)) { if ($ret <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; + } else { + // Define output language + if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + $object->fetch_thirdparty(); + $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); + } + $model = $object->model_pdf; + $ret = $object->fetch($object->id); // Reload to get new records + + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) { + dol_print_error($db, $result); + } + } } } } else { From eee66bff8b743930b48b03a6757d7618292fc59f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 12:28:41 +0200 Subject: [PATCH 12/21] Doc --- htdocs/install/mysql/tables/llx_contrat.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_contrat.sql b/htdocs/install/mysql/tables/llx_contrat.sql index 6269cdbc8d0..15837f25125 100644 --- a/htdocs/install/mysql/tables/llx_contrat.sql +++ b/htdocs/install/mysql/tables/llx_contrat.sql @@ -30,12 +30,14 @@ create table llx_contrat datec datetime, -- creation date date_contrat datetime, statut smallint DEFAULT 0, -- not used. deprecated - fin_validite datetime, - date_cloture datetime, + + fin_validite datetime, -- not used + date_cloture datetime, -- not used + fk_soc integer NOT NULL, fk_projet integer, - fk_commercial_signature integer, -- obsolete - fk_commercial_suivi integer, -- obsolete + fk_commercial_signature integer, -- obsolete + fk_commercial_suivi integer, -- obsolete fk_user_author integer NOT NULL default 0, fk_user_modif integer, fk_user_cloture integer, From 16e72b46027a21ff28e4a1b96eb3dcd67fd11aa6 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 20 Aug 2024 12:29:16 +0200 Subject: [PATCH 13/21] Qual: Fix phan notices for fournisseur.facture.class.php (#30680) # Qual: Fix phan notices for fournisseur.facture.class.php Fix phan notices in one of the popular classes to improve future detection. --- dev/tools/phan/baseline.txt | 1 - .../fourn/class/fournisseur.facture.class.php | 97 +++++++++++-------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 77a3ee0d4b6..7ef70c15293 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -809,7 +809,6 @@ return [ 'htdocs/fourn/class/fournisseur.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], - 'htdocs/fourn/class/fournisseur.facture.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/fourn/class/paiementfourn.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/commande/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e403acb9cca..c0fe3d11dc8 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -176,12 +176,12 @@ class FactureFournisseur extends CommonInvoice public $date_echeance; /** - * @var double $amount + * @var float * @deprecated See $total_ttc, $total_ht, $total_tva */ public $amount = 0; /** - * @var double $remise + * @var float * @deprecated */ public $remise = 0; @@ -315,6 +315,11 @@ class FactureFournisseur extends CommonInvoice ); + /** + * @var int Id User modifying + */ + public $fk_user_valid; + /** * Standard invoice */ @@ -418,6 +423,12 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); + // Defaults + $originaldatewhen = 0; + $nextdatewhen = 0; + $previousdaynextdatewhen = 0; + $_facrec = null; + // Create invoice from a template recurring invoice if ($this->fac_rec > 0) { $this->fk_fac_rec_source = $this->fac_rec; @@ -433,10 +444,6 @@ class FactureFournisseur extends CommonInvoice $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); $this->socid = $_facrec->socid; - } else { - $originaldatewhen = 0; - $nextdatewhen = 0; - $previousdaynextdatewhen = 0; } $this->entity = $_facrec->entity; // Invoice created in same entity than template @@ -506,8 +513,8 @@ class FactureFournisseur extends CommonInvoice if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->thirdparty->default_lang)) { $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->default_lang)) { - $newlang = $this->default_lang; // for thirdparty + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && property_exists($this, 'default_lang') && isset($this->default_lang)) { // @phan-suppress-current-line PhanUndeclaredProperty + $newlang = $this->default_lang; // for thirdparty @phan-suppress-current-line PhanUndeclaredProperty } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); @@ -747,7 +754,8 @@ class FactureFournisseur extends CommonInvoice $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ? null : $_facrec->lines[$i]->fk_product_fournisseur_price; + // $fk_product_fournisseur_price not used and does not exist on line + // $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ? null : $_facrec->lines[$i]->fk_product_fournisseur_price; $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; // If buyprice not defined from template invoice, we try to guess the best value @@ -1204,7 +1212,7 @@ class FactureFournisseur extends CommonInvoice $this->author = (int) $this->author; } if (isset($this->fk_user_valid)) { - $this->fk_user_valid = trim($this->fk_user_valid); + $this->fk_user_valid = (int) $this->fk_user_valid; } if (isset($this->fk_facture_source)) { $this->fk_facture_source = (int) $this->fk_facture_source; @@ -2056,13 +2064,13 @@ class FactureFournisseur extends CommonInvoice * already have the right value (the caller has to manage the multilanguage). * * @param string $desc Description of the line - * @param double $pu Unit price (HT or TTC according to price_base_type, > 0 even for credit note) - * @param double $txtva Force Vat rate to use, -1 for auto. - * @param double $txlocaltax1 LocalTax1 Rate - * @param double $txlocaltax2 LocalTax2 Rate - * @param double $qty Quantity + * @param float $pu Unit price (HT or TTC according to price_base_type, > 0 even for credit note) + * @param float $txtva Force Vat rate to use, -1 for auto. + * @param float $txlocaltax1 LocalTax1 Rate + * @param float $txlocaltax2 LocalTax2 Rate + * @param float $qty Quantity * @param int $fk_product Product/Service ID predefined - * @param double $remise_percent Percentage discount of the line + * @param float $remise_percent Percentage discount of the line * @param int $date_start Service start date * @param int $date_end Service expiry date * @param int $fk_code_ventilation Accounting breakdown code @@ -2071,10 +2079,10 @@ class FactureFournisseur extends CommonInvoice * @param int $type Type of line (0=product, 1=service) * @param int $rang Position of line * @param int $notrigger Disable triggers - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one * @param int $origin_id id origin document - * @param double $pu_devise Amount in currency + * @param float $pu_devise Amount in currency * @param string $ref_supplier Supplier ref * @param int $special_code Special code * @param int $fk_parent_line Parent line id @@ -2320,29 +2328,29 @@ class FactureFournisseur extends CommonInvoice } /** - * Update a line detail into database + * Update a line detail in the database * - * @param int $id Id of line invoice - * @param string $desc Description of line - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) - * @param double $vatrate VAT Rate (Can be '8.5', '8.5 (ABC)') - * @param double $txlocaltax1 LocalTax1 Rate - * @param double $txlocaltax2 LocalTax2 Rate - * @param double $qty Quantity - * @param int $idproduct Id produit - * @param string $price_base_type HT or TTC - * @param int $info_bits Miscellaneous information of line - * @param int $type Type of line (0=product, 1=service) - * @param double $remise_percent Percentage discount of the line - * @param int $notrigger Disable triggers - * @param int|string $date_start Date start of service - * @param int|string $date_end Date end of service - * @param array $array_options extrafields array - * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_devise Amount in currency - * @param string $ref_supplier Supplier ref - * @param int $rang Line rank - * @return int<-1,1> Return integer <0 if KO, >0 if OK + * @param int $id Id of line invoice + * @param string $desc Description of line + * @param float $pu Prix unitaire (HT ou TTC selon price_base_type) + * @param float $vatrate VAT Rate (Can be '8.5', '8.5 (ABC)') + * @param float $txlocaltax1 LocalTax1 Rate + * @param float $txlocaltax2 LocalTax2 Rate + * @param float $qty Quantity + * @param int $idproduct Id produit + * @param string $price_base_type HT or TTC + * @param int $info_bits Miscellaneous information of line + * @param int $type Type of line (0=product, 1=service) + * @param float $remise_percent Percentage discount of the line + * @param int $notrigger Disable triggers + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service + * @param array $array_options extrafields array + * @param ?int $fk_unit Code of the unit to use. Null to use the default one + * @param float $pu_devise Amount in currency + * @param string $ref_supplier Supplier ref + * @param int $rang Line rank + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = [], $fk_unit = null, $pu_devise = 0, $ref_supplier = '', $rang = 0) { @@ -3765,7 +3773,8 @@ class SupplierInvoiceLine extends CommonObjectLine public $oldline; /** - * @deprecated + * @var string + * @deprecated See $product_ref * @see $product_ref */ public $ref; @@ -3830,7 +3839,13 @@ class SupplierInvoiceLine extends CommonObjectLine */ public $description; + /** + * @var int|string + */ public $date_start; + /** + * @var int|string + */ public $date_end; /** From 69bc79b9a937431799fd876979a2d96d9cbdd5b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 15:02:33 +0200 Subject: [PATCH 14/21] Fix test on securiy page --- htdocs/admin/system/security.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 38e9416a3da..7a13d06a420 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -710,10 +710,19 @@ print '
'; print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') ? '1' : ''.$langs->trans("Undefined").''); print '   ('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)"; + +// Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML +$savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES'); +$savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML'); +$savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY'); $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; $result=dol_htmlwithnojs(' src=>0xbeefed'); +$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES; +$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML; +$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY; + if ($result == 'InvalidHTMLStringCantBeCleaned') { print '   -   '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !'; } else { @@ -726,10 +735,18 @@ print '
'; print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') ? '1' : ''.$langs->trans("Undefined").''); print '   ('.$langs->trans("Recommended").': 1)   -   Module "php-tidy" must be enabled (currently: '.((extension_loaded('tidy') && class_exists("tidy")) ? 'Enabled' : img_picto('', 'warning').' Not available').")"; if (extension_loaded('tidy') && class_exists("tidy")) { + // Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY + $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES'); + $savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML'); + $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY'); $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; $result=dol_htmlwithnojs(' src=>0xbeefed'); + $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES; + $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML; + $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY; + if ($result == 'InvalidHTMLStringCantBeCleaned') { print '   -   '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !'; } else { From 07c9dea71eb3bb51bf2b4cf4014c09e7014b0ea2 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Tue, 20 Aug 2024 23:23:30 +0200 Subject: [PATCH 15/21] Qual: add fields array property into categorie class (#30450) * new: add fields array into categorie class * reveiw php stan --------- Co-authored-by: Laurent Destailleur --- htdocs/categories/class/categorie.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b8f8cfede1c..fdac24d6760 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -285,6 +285,24 @@ class Categorie extends CommonObject */ public $imgHeight; + public $fields=array( + "rowid" => array("type"=>"integer", "label"=>"TechnicalID", "enabled"=>"1", 'position'=>10, 'notnull'=>1, "visible"=>"-1",), + "fk_parent" => array("type"=>"integer", "label"=>"Fkparent", "enabled"=>"1", 'position'=>20, 'notnull'=>1, "visible"=>"-1", "css"=>"maxwidth500 widthcentpercentminusxx",), + "label" => array("type"=>"varchar(180)", "label"=>"Label", "enabled"=>"1", 'position'=>25, 'notnull'=>1, "visible"=>"-1", "alwayseditable"=>"1", "css"=>"minwidth300", "cssview"=>"wordbreak", "csslist"=>"tdoverflowmax150",), + "ref_ext" => array("type"=>"varchar(255)", "label"=>"Refext", "enabled"=>"1", 'position'=>30, 'notnull'=>0, "visible"=>"0", "alwayseditable"=>"1",), + "type" => array("type"=>"integer", "label"=>"Type", "enabled"=>"1", 'position'=>35, 'notnull'=>1, "visible"=>"-1", "alwayseditable"=>"1",), + "description" => array("type"=>"text", "label"=>"Description", "enabled"=>"1", 'position'=>40, 'notnull'=>0, "visible"=>"-1", "alwayseditable"=>"1",), + "color" => array("type"=>"varchar(8)", "label"=>"Color", "enabled"=>"1", 'position'=>45, 'notnull'=>0, "visible"=>"-1", "alwayseditable"=>"1",), + "position" => array("type"=>"integer", "label"=>"Position", "enabled"=>"1", 'position'=>50, 'notnull'=>0, "visible"=>"-1", "alwayseditable"=>"1",), + "fk_soc" => array("type"=>"integer:Societe:societe/class/societe.class.php", "label"=>"ThirdParty", "picto"=>"company", "enabled"=>"1", 'position'=>55, 'notnull'=>0, "visible"=>"-1", "alwayseditable"=>"1", "css"=>"maxwidth500 widthcentpercentminusxx", "csslist"=>"tdoverflowmax150",), + "visible" => array("type"=>"integer", "label"=>"Visible", "enabled"=>"1", 'position'=>60, 'notnull'=>1, "visible"=>"-1", "alwayseditable"=>"1",), + "import_key" => array("type"=>"varchar(14)", "label"=>"ImportId", "enabled"=>"1", 'position'=>900, 'notnull'=>0, "visible"=>"-2", "alwayseditable"=>"1",), + "date_creation" => array("type"=>"datetime", "label"=>"Datecreation", "enabled"=>"1", 'position'=>70, 'notnull'=>0, "visible"=>"-1", "alwayseditable"=>"1",), + "tms" => array("type"=>"timestamp", "label"=>"DateModification", "enabled"=>"1", 'position'=>75, 'notnull'=>1, "visible"=>"-1", "alwayseditable"=>"1",), + "fk_user_creat" => array("type"=>"integer:User:user/class/user.class.php", "label"=>"UserAuthor", "enabled"=>"1", 'position'=>80, 'notnull'=>0, "visible"=>"-2", "alwayseditable"=>"1", "css"=>"maxwidth500 widthcentpercentminusxx", "csslist"=>"tdoverflowmax150",), + "fk_user_modif" => array("type"=>"integer:User:user/class/user.class.php", "label"=>"UserModif", "enabled"=>"1", 'position'=>85, 'notnull'=>-1, "visible"=>"-2", "alwayseditable"=>"1", "css"=>"maxwidth500 widthcentpercentminusxx", "csslist"=>"tdoverflowmax150",), + ); + /** * Constructor * From 0dc5f67d64f740b82318036b72faea47ec21eaa6 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Tue, 20 Aug 2024 23:29:35 +0200 Subject: [PATCH 16/21] NEW: add warehouseId parameters in select_produit to limit result to existing product in select (#30477) * ongoing * new: add warehouseId parameters inselect_produit to limit result to existing product in select * new: add warehouseId parameters inselect_produit to limit result to existing product in select * new: add warehouseId parameters inselect_produit to limit result to existing product in select * try reveiw * fix from review * fix from reiview * review php stan --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/html.form.class.php | 17 ++++++++++++++--- htdocs/product/ajax/products.php | 3 ++- htdocs/product/stock/massstockmove.php | 7 +++---- htdocs/projet/card.php | 6 ++++-- htdocs/public/project/new.php | 6 ++++-- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f7cdbd1e1e5..b7e6afcb68e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2621,9 +2621,11 @@ class Form * @param ?mixed[] $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @param int<0,1> $nooutput No print if 1, return the output into a string * @param int<-1,1> $status_purchase Purchase status: -1=No filter on purchase status, 0=Products not on purchase, 1=Products on purchase + * @param int $warehouseId Filter by Warehouses Id where there is real stock + * * @return void|string */ - public function select_produits($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1) + public function select_produits($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1, $warehouseId = 0) { // phpcs:enable global $langs, $conf; @@ -2664,6 +2666,9 @@ class Form } // mode=1 means customers products $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&status_purchase=' . $status_purchase . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus; + if ((int) $warehouseId>0) { + $urloption .= '&warehouseid=' . (int) $warehouseId; + } $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); if (isModEnabled('variants') && is_array($selected_combinations)) { @@ -2755,7 +2760,7 @@ class Form $out .= img_picto($langs->trans("Search"), 'search'); } } else { - $out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase); + $out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId); } if (empty($nooutput)) { @@ -2870,9 +2875,10 @@ class Form * 'warehouseclosed' = count products from closed warehouses, * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase + * @param int $warehouseId Filter by Warehouses Id where there is real stock * @return array|string Array of keys for json */ - public function select_produits_list($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = 'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1) + public function select_produits_list($selected = 0, $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = 'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1, $warehouseId = 0) { // phpcs:enable global $langs; @@ -3039,6 +3045,11 @@ class Form } elseif (!isModEnabled('service')) { // when service module is disabled, show products only $sql .= " AND p.fk_product_type = 0"; } + + if ((int) $warehouseId > 0) { + $sql .= " AND EXISTS (SELECT psw.fk_product FROM " . $this->db->prefix() . "product_stock as psw WHERE psw.reel>0 AND psw.fk_entrepot=".(int) $warehouseId." AND psw.fk_product = p.rowid)"; + } + // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('selectProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 40e30036df0..82adfeae524 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -59,6 +59,7 @@ $finished = GETPOSTINT('finished'); $alsoproductwithnosupplierprice = GETPOSTINT('alsoproductwithnosupplierprice'); $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOSTINT('hidepriceinlabel'); +$warehouseId = GETPOST('warehouseid', 'int'); // Security check restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&product'); @@ -308,7 +309,7 @@ if ($action == 'fetch' && !empty($id)) { } if (empty($mode) || $mode == 1) { // mode=1: customer - $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase); + $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId); } elseif ($mode == 2) { // mode=2: supplier $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, 0, $alsoproductwithnosupplierprice); } diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index a72e8ed14e4..7833d7b42bd 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -691,19 +691,18 @@ if (getDolGlobalInt('PRODUIT_LIMIT_SIZE') <= 0) { } else { $limit = getDolGlobalString('PRODUIT_LIMIT_SIZE'); } - print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); -print $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); +print $form->select_produits((isset($id_product)?$id_product:0), 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); print ''; // Batch number if (isModEnabled('productbatch')) { print ''; print img_picto($langs->trans("LotSerial"), 'lot', 'class="paddingright"'); - print ''; + print ''; print ''; } // Qty -print ''; +print ''; // Button to add line print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 365a01d97fc..04267bb5d14 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -635,9 +635,11 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { if ($filefound && !empty($classname)) { $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); - $modProject = new $classname(); + if (class_exists($classname)) { + $modProject = new $classname(); - $defaultref = $modProject->getNextValue($thirdparty, $object); + $defaultref = $modProject->getNextValue($thirdparty, $object); + } } if (is_numeric($defaultref) && $defaultref <= 0) { diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 8cd5ba18d6a..e95341d683b 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -276,9 +276,11 @@ if (empty($reshook) && $action == 'add') { if ($filefound && !empty($classname)) { $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); - $modProject = new $classname(); + if (class_exists($classname)) { + $modProject = new $classname(); - $defaultref = $modProject->getNextValue($thirdparty, $object); + $defaultref = $modProject->getNextValue($thirdparty, $object); + } } if (is_numeric($defaultref) && $defaultref <= 0) { From 4db05d65a5bfe00d198386329dbc905198793d26 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Tue, 20 Aug 2024 23:32:09 +0200 Subject: [PATCH 17/21] New display for list event of contactAddress (#30702) * New display for list event of contactAddress * remove var_dump --- htdocs/contact/agenda.php | 5 + htdocs/contact/messaging.php | 319 ++++++++++++++++++++++++++++++ htdocs/core/lib/functions.lib.php | 7 +- 3 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 htdocs/contact/messaging.php diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 5a4ac3ad1c1..29764e77757 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -259,6 +259,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $out = ''; $newcardbutton = ''; + $messagingUrl = DOL_URL_ROOT.'/contact/messaging.php?id='.$object->id; + $newcardbutton .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + $messagingUrl = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; + $newcardbutton .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + if (isModEnabled('agenda')) { $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { diff --git a/htdocs/contact/messaging.php b/htdocs/contact/messaging.php new file mode 100644 index 00000000000..a2f4f0f0c01 --- /dev/null +++ b/htdocs/contact/messaging.php @@ -0,0 +1,319 @@ + + * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * + * 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/contact/agenda.php + * \ingroup societe + * \brief Card agenda 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'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +// Load translation files required by the page +$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'); +$id = GETPOSTINT('id'); +$socid = GETPOSTINT('socid'); + +// Initialize objects +$object = new Contact($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($id); +$objcanvas = null; +$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); +if (!empty($canvas)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); +} + +if (GETPOST('actioncode', 'array')) { + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) { + $actioncode = '0'; + } +} else { + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); +} +$search_rowid = GETPOST('search_rowid'); +$search_agenda_label = GETPOST('search_agenda_label'); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission + +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'a.datep, a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('contactagenda', 'globalcard')); + + +/* + * Actions + */ + +$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + $actioncode = ''; + $search_agenda_label = ''; + } +} + + +/* + * View + */ + +$form = new Form($db); + +$title = $langs->trans("ContactEvents"); +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { + $title = $object->lastname; +} +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Partner'; + +llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-societe page-contact-card_agenda'); + + +if ($socid > 0) { + $objsoc = new Societe($db); + $objsoc->fetch($socid); +} + +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { + $object = new Contact($db); + $result = $object->fetch($id); + if ($result <= 0) { + dol_print_error(null, $object->error); + } + } + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template +} else { + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- + + // Confirm deleting contact + if ($user->hasRight('societe', 'contact', 'supprimer')) { + if ($action == 'delete') { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } + + /* + * Onglets + */ + $head = array(); + if ($id > 0) { + // Si edition contact deja existent + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { + dol_print_error($db, $object->error); + exit; + } + $res = $object->fetch_optionals(); + if ($res < 0) { + dol_print_error($db, $object->error); + exit; + } + + // Show tabs + $head = contact_prepare_head($object); + + $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + } + + if (!empty($id) && $action != 'edit' && $action != 'create') { + $objsoc = new Societe($db); + + /* + * Card in view mode + */ + + dol_htmloutput_errors($error, $errors); + + print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; + if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + if ($objsoc->id > 0) { + $morehtmlref .= $objsoc->getNomUrl(1); + } else { + $morehtmlref .= ''.$langs->trans("ContactNotLinkedToCompany").''; + } + } + $morehtmlref .= '
'; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + + print '
'; + + print '
'; + + $object->info($socid); + dol_print_object_info($object, 1); + + print '
'; + + print dol_get_fiche_end(); + + + // Actions buttons + + $objthirdparty = $object; + $objcon = new stdClass(); + + $out = ''; + $permok = $user->hasRight('agenda', 'myactions', 'create'); + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { + $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); + } + + $morehtmlright = ''; + + $messagingUrl = DOL_URL_ROOT.'/contact/messaging.php?id='.$object->id; + $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 2); + $messagingUrl = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; + $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1); + + + if (isModEnabled('agenda')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } + } + + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { + print '
'; + + $param = '&socid='.urlencode((string) ($socid)); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); + } + + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_thirdparty_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + if (!empty($conf->dol_optimize_smallscreen)) { + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + } + + print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + + // TODO Replace this with same code than into list.php + show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 14b4f94b15e..332f12551cd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13847,7 +13847,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".((int) $objcon->id); } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') { + if ((is_object($filterobj) && get_class($filterobj) == 'Societe') || (is_object($filterobj) && get_class($filterobj) == 'Contact')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; } elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; @@ -13904,6 +13904,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, if ($filterobj->id) { $sql .= " AND a.fk_element = ".((int) $filterobj->id); } + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contact' && $filterobj->id) { + $sql .= " AND a.fk_contact = sp.rowid"; + if ($filterobj->id) { + $sql .= " AND a.fk_contact = ".((int) $filterobj->id); + } } } else { $sql .= " AND u.rowid = ". ((int) $filterobj->id); From d551f200f29fe59811e560142122a09c1d3f1d64 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Tue, 20 Aug 2024 23:32:43 +0200 Subject: [PATCH 18/21] new: when initHook() and restrictedArea() exists always execute first initHook() (#30703) --- htdocs/adherents/type_ldap.php | 6 +++--- htdocs/barcode/printsheet.php | 4 ++-- htdocs/categories/edit.php | 6 +++--- htdocs/categories/photos.php | 5 +++-- htdocs/categories/viewcat.php | 6 +++--- htdocs/comm/contact.php | 2 ++ htdocs/comm/multiprix.php | 1 + htdocs/comm/propal/contact.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/commande/contact.php | 1 - htdocs/compta/bank/line.php | 4 +++- htdocs/compta/bank/treso.php | 9 ++++----- htdocs/compta/bank/various_payment/card.php | 7 ++++--- htdocs/compta/deplacement/card.php | 7 ++++--- htdocs/compta/facture/contact.php | 3 ++- htdocs/compta/journal/purchasesjournal.php | 5 ++++- htdocs/compta/journal/sellsjournal.php | 5 ++++- htdocs/compta/localtax/card.php | 7 +++---- htdocs/compta/localtax/clients.php | 5 ++++- htdocs/compta/prelevement/rejets.php | 7 ++++--- htdocs/compta/recap-compta.php | 5 +++-- htdocs/compta/resultat/clientfourn.php | 6 ++++-- htdocs/compta/resultat/result.php | 2 +- htdocs/compta/stats/cabyprodserv.php | 7 ++++--- htdocs/compta/stats/cabyuser.php | 2 +- htdocs/compta/stats/casoc.php | 7 ++++--- htdocs/contact/agenda.php | 7 ++++--- htdocs/contact/list.php | 9 +++++---- htdocs/contact/note.php | 8 +++----- htdocs/contact/project.php | 3 ++- htdocs/contrat/agenda.php | 7 ++++--- htdocs/contrat/list.php | 4 +++- htdocs/delivery/card.php | 7 ++++--- htdocs/ecm/index.php | 6 +++--- htdocs/ecm/index_auto.php | 8 ++++---- htdocs/ecm/index_medias.php | 7 ++++--- htdocs/expedition/contact.php | 2 +- htdocs/expensereport/list.php | 15 ++++++++------- htdocs/fourn/card.php | 7 +++++-- htdocs/fourn/commande/contact.php | 2 +- htdocs/fourn/commande/info.php | 6 +++--- htdocs/fourn/facture/contact.php | 2 +- htdocs/fourn/facture/document.php | 2 +- htdocs/fourn/facture/info.php | 2 +- htdocs/imports/import.php | 8 +++----- htdocs/loan/card.php | 3 +-- htdocs/margin/agentMargins.php | 3 ++- htdocs/margin/tabs/productMargins.php | 4 ++-- htdocs/modulebuilder/template/mymoduleindex.php | 3 +++ htdocs/product/card.php | 6 +++--- htdocs/product/inventory/card.php | 3 ++- htdocs/product/inventory/inventory.php | 3 ++- htdocs/product/note.php | 6 ++---- htdocs/product/stats/propal.php | 4 +++- htdocs/product/stock/card.php | 6 +++--- htdocs/product/stock/movement_card.php | 9 +++++---- htdocs/product/stock/productlot_document.php | 3 ++- htdocs/product/stock/replenish.php | 3 ++- htdocs/product/traduction.php | 7 +++---- htdocs/projet/contact.php | 5 +++-- htdocs/projet/element.php | 5 +++-- htdocs/projet/tasks.php | 7 ++++--- htdocs/resource/card.php | 2 +- htdocs/societe/consumption.php | 9 ++++----- htdocs/societe/notify/card.php | 9 ++++----- htdocs/societe/price.php | 7 ++++--- htdocs/societe/project.php | 3 ++- htdocs/societe/societecontact.php | 8 ++++---- htdocs/supplier_proposal/contact.php | 5 +++-- htdocs/user/agenda_extsites.php | 6 +++--- htdocs/user/clicktodial.php | 3 +-- htdocs/user/document.php | 8 +++----- htdocs/user/ldap.php | 6 +++--- htdocs/user/note.php | 4 ++-- htdocs/user/param_ihm.php | 7 +++---- htdocs/user/perms.php | 7 +++---- htdocs/variants/card.php | 7 ++++--- 77 files changed, 221 insertions(+), 185 deletions(-) diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index e85d39c1d36..e7bb1edb40d 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -36,15 +36,15 @@ $langs->loadLangs(array("admin", "members", "ldap")); $id = GETPOSTINT('rowid'); $action = GETPOST('action', 'aZ09'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); + // Security check $result = restrictedArea($user, 'adherent', $id, 'adherent_type'); $object = new AdherentType($db); $object->fetch($id); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 82ea04051c5..a59a19155fd 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -68,11 +68,11 @@ if (!isModEnabled('barcode')) { if (!$user->hasRight('barcode', 'read')) { accessforbidden(); } -restrictedArea($user, 'barcode'); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('printsheettools')); +restrictedArea($user, 'barcode'); + $parameters = array(); // Note that $action and $object may have been modified by some diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index f93254da64b..b199380b9be 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -54,6 +54,9 @@ if ($id == "") { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -72,9 +75,6 @@ if (is_numeric($type)) { $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categorycard')); - $error = 0; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 8b47e14e4bc..b3680e517a5 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -48,6 +48,9 @@ if ($id == '' && $label == '') { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -65,8 +68,6 @@ if (is_numeric($type)) { $upload_dir = $conf->categorie->multidir_output[$object->entity]; -$hookmanager->initHooks(array('categorycard')); - /* * Actions */ diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 545bd9b3306..e4b081e7e47 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -73,6 +73,9 @@ if ($id == "" && $label == "") { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard', 'globalcard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -91,9 +94,6 @@ if (is_numeric($type)) { $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categorycard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 7d6e5e7a4ab..d8e70c31c9e 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,6 +59,8 @@ if ($user->socid) { $action = ''; $socid = $user->socid; } + +$hookmanager->initHooks(array('contactlist')); $result = restrictedArea($user, 'societe', $socid, ''); diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index c9a4dd839ed..1e54374a795 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -47,6 +47,7 @@ if ($user->socid > 0) { $action = ''; $id = $user->socid; } +$hookmanager->initHooks(array('thirdpartyprice', 'globalcard')); $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 3e47a6921e3..abfcd72a41d 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -68,8 +68,8 @@ $socid = ''; if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'propal', $object->id); $hookmanager->initHooks(array('proposalcontactcard', 'globalcard')); +$result = restrictedArea($user, 'propal', $object->id); $usercancreate = $user->hasRight("propal", "creer"); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 2dccb456e9e..9e50a579a13 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -177,13 +177,13 @@ if (!empty($socid)) { $module = 'societe'; $dbtable = '&societe'; } +$hookmanager->initHooks(array('propallist')); $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new Propal($db); -$hookmanager->initHooks(array('propallist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 3b20df2931e..0c0e1d7c346 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -49,7 +49,6 @@ if ($user->socid) { $hookmanager->initHooks(array('ordercontact', 'globalcard')); $result = restrictedArea($user, 'commande', $id, ''); -$hookmanager->initHooks(array('ordercontactcard', 'globalcard')); $usercancreate = $user->hasRight("commande", "creer"); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 278f5cf5b55..90fcdd02f30 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -74,12 +74,14 @@ if ($user->socid) { $socid = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('bankline')); + $result = restrictedArea($user, 'banque', $accountoldid, 'bank_account'); if (!$user->hasRight('banque', 'lire') && !$user->hasRight('banque', 'consolidate')) { accessforbidden(); } -$hookmanager->initHooks(array('bankline')); $object = new AccountLine($db); $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->element); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index e9add12186e..f9710114614 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -49,15 +49,14 @@ $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); - - -$vline = GETPOST('vline'); -$page = GETPOSTISSET("page") ? GETPOST("page") : 0; // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('banktreso', 'globalcard')); +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); + +$vline = GETPOST('vline'); +$page = GETPOSTISSET("page") ? GETPOST("page") : 0; /* * View diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 3cd1e1f3477..0cc15df0101 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -67,13 +67,14 @@ $socid = GETPOSTINT("socid"); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', '', '', ''); - -$object = new PaymentVarious($db); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('variouscard', 'globalcard')); +$result = restrictedArea($user, 'banque', '', '', ''); + +$object = new PaymentVarious($db); + $permissiontoadd = $user->hasRight('banque', 'modifier'); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index b4aed3ce32e..cfe75817e68 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -43,6 +43,10 @@ $id = GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); + $result = restrictedArea($user, 'deplacement', $id, ''); $action = GETPOST('action', 'aZ09'); @@ -50,9 +54,6 @@ $confirm = GETPOST('confirm', 'alpha'); $object = new Deplacement($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); - $permissionnote = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 2eeadafc1fc..01a73a53990 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -56,9 +56,10 @@ $object = new Facture($db); if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0)); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('invoicecontactcard', 'globalcard')); $result = restrictedArea($user, 'facture', $object->id); -$hookmanager->initHooks(array('invoicecontactcard', 'globalcard')); $usercancreate = $user->hasRight("facture", "creer"); diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 1e9aff0869d..653a007a74e 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -50,13 +50,16 @@ $date_endyear = GETPOST('date_endyear'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['purchasejournallist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['purchasejournallist']); /* * Actions diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 64d06b3ed09..3292a395ee8 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -52,13 +52,16 @@ $date_endyear = GETPOST('date_endyear'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['selljournallist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['selljournallist']); /* * Actions diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 3e939d40f1b..0b6453cc81a 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -48,13 +48,12 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - -$object = new Localtax($db); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('localtaxvatcard', 'globalcard')); +$result = restrictedArea($user, 'tax', '', '', 'charges'); + +$object = new Localtax($db); /** * Actions diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 7a493817ce7..f69a32bdd3c 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -105,13 +105,16 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['customerlocaltaxlist']); + $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); exit; } -$hookmanager->initHooks(['customerlocaltaxlist']); $calc = 0; /* diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 88d1f736422..1b6d440c62d 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -56,6 +56,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); + if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { @@ -88,9 +92,6 @@ $line = new LignePrelevement($db); $thirdpartystatic = new Societe($db); $userstatic = new User($db); -$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); - - // List of invoices $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,"; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index f916930e148..2c3ff9d23c3 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -42,6 +42,9 @@ if ($user->socid > 0) { $id = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('recapcomptacard', 'globalcard')); + $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); @@ -49,8 +52,6 @@ if ($id > 0) { $object->fetch($id); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('recapcomptacard', 'globalcard')); // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f1e5e79d063..6adb5762ad9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -151,14 +151,16 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['customersupplierreportlist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['customersupplierreportlist']); - /* * View diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 306a32157f8..a5d4ef0ddec 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -159,13 +159,13 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } +$hookmanager->initHooks(['resultreportlist']); if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['resultreportlist']); /* * View diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 133f83ece71..4401b262a9f 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -44,6 +44,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } + +// Hook +$hookmanager->initHooks(array('cabyprodservlist')); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } @@ -83,9 +87,6 @@ if ($selected_type == '') { $selected_type = -1; } -// Hook -$hookmanager->initHooks(array('cabyprodservlist')); - // Date range $year = GETPOST("year"); $month = GETPOST("month"); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 38619a7eacf..ab2220a8e77 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -40,13 +40,13 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } +$hookmanager->initHooks(['cabyuserreportlist']); if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['cabyuserreportlist']); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = getDolGlobalString('ACCOUNTING_MODE'); if (GETPOST("modecompta")) { diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 75f8e8ec709..0b935ba2664 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -72,6 +72,10 @@ if (GETPOST('subcat', 'alpha') === 'yes') { if ($user->socid > 0) { $socid = $user->socid; } + +// Hook +$hookmanager->initHooks(array('casoclist')); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } @@ -79,9 +83,6 @@ if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -// Hook -$hookmanager->initHooks(array('casoclist')); - // Date range $year = GETPOSTINT("year"); $month = GETPOSTINT("month"); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 29764e77757..1950d33111c 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -90,6 +90,10 @@ $search_agenda_label = GETPOST('search_agenda_label'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('contactagenda', 'globalcard')); + $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -109,9 +113,6 @@ if (!$sortorder) { $sortorder = 'DESC'; } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('contactagenda', 'globalcard')); - /* * Actions diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 94b296c79b7..e35a62608b0 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -65,10 +65,6 @@ if ($contextpage == 'poslist') { $id = GETPOSTINT('id'); $contactid = GETPOSTINT('id'); $ref = ''; // There is no ref for contacts -if ($user->socid > 0) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'contact', $contactid, ''); $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars @@ -189,6 +185,11 @@ $object = new Contact($db); $extrafields = new ExtraFields($db); $hookmanager->initHooks(array($contextpage)); +if ($user->socid > 0) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'contact', $contactid, ''); + // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 70fa0def19e..0ee8f0afeb4 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -49,15 +49,13 @@ if ($user->socid > 0) { accessforbidden(); } } -$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); - - -$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -// $hookmanager->initHooks(array('contactcard')); -> Name conflict with product/card.php $hookmanager->initHooks(array('contactnote')); +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); + +$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php /* * Actions diff --git a/htdocs/contact/project.php b/htdocs/contact/project.php index d4b56b31d06..c60b90b198f 100644 --- a/htdocs/contact/project.php +++ b/htdocs/contact/project.php @@ -30,11 +30,12 @@ $langs->loadLangs(array("contacts", "companies", "projects")); // Security check $id = GETPOSTINT('id'); -$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('projectcontact')); +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); + /* * Actions */ diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 1e3f4e86d52..5387ccd0a6b 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -64,6 +64,10 @@ if ($user->socid) { // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($id) ? 'rowid' : 'ref'); + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('agendacontract', 'globalcard')); + $result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype); $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -89,9 +93,6 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('agendacontract', 'globalcard')); - $permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $result = restrictedArea($user, 'contrat', $object->id); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 60722a34607..0d935b95721 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -135,6 +135,9 @@ $id = GETPOSTINT('id'); if ($user->socid > 0) { $socid = $user->socid; } + +$hookmanager->initHooks(array('contractlist')); + $result = restrictedArea($user, 'contrat', $id); $diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id; @@ -148,7 +151,6 @@ if ($search_status == '') { // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new Contrat($db); -$hookmanager->initHooks(array('contractlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 24c47fd1f51..9f989484963 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -65,6 +65,10 @@ $id = GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('deliverycard', 'globalcard')); + $result = restrictedArea($user, 'expedition', $id, 'delivery', 'delivery'); $object = new Delivery($db); @@ -79,9 +83,6 @@ $extrafields->fetch_name_optionals_label($object->table_element_line); // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once' -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('deliverycard', 'globalcard')); - $error = 0; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 4e25d22675b..40e88635b75 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -82,6 +82,9 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmindexcard', 'globalcard')); + $result = restrictedArea($user, 'ecm', 0); $permissiontoread = $user->hasRight('ecm', 'read'); @@ -90,9 +93,6 @@ $permissiontocreatedir = $user->hasRight('ecm', 'setup'); $permissiontodelete = $user->hasRight('ecm', 'upload'); $permissiontodeletedir = $user->hasRight('ecm', 'setup'); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmindexcard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7a33cd6de59..881fe61dae4 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -87,16 +87,16 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'ecm', 0); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmautocard', 'globalcard')); + +$result = restrictedArea($user, 'ecm', 0); /* * Actions */ -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmautocard', 'globalcard')); - // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_doc_ref = ''; diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 250837be6ad..bf5ca78cd16 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -92,6 +92,10 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmmediascard', 'globalcard')); + $result = restrictedArea($user, 'ecm', 0); $permissiontouploadfile = ($user->hasRight('ecm', 'setup') || $user->hasRight('mailing', 'creer') || $user->hasRight('website', 'write')); @@ -104,9 +108,6 @@ $websitekey = ''; $permissiontoadd = $permissiontouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmmediascard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 85640453e84..9575a417508 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -69,8 +69,8 @@ if ($id > 0 || !empty($ref)) { if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'expedition', $object->id, ''); $hookmanager->initHooks(array('shipmentcontactcard', 'globalcard')); +$result = restrictedArea($user, 'expedition', $object->id, ''); /* * Actions diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 1c4d6a56d48..eee296c0f35 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -55,12 +55,6 @@ $mode = GETPOST('mode', 'alpha'); $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOSTINT('socid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOSTINT('id'); // If we are on the view of a specific user if ($id > 0) { @@ -137,9 +131,16 @@ if ($search_user == '') { $search_user = -1; } +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +$hookmanager->initHooks(array('expensereportlist')); +$result = restrictedArea($user, 'expensereport', '', ''); + // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new ExpenseReport($db); -$hookmanager->initHooks(array('expensereportlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 7bf13bee5dc..c86f2735a66 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -66,6 +66,10 @@ $id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id')); if ($user->socid) { $id = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); + $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid'); $object = new Fournisseur($db); @@ -74,8 +78,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); + // Security check $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 2821e48f771..1491fb1269f 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $hookmanager->initHooks(array('ordersuppliercardcontact', 'ordersuppliercontactcard', 'globalcard')); +$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 57ca5558c7f..bb5126b63af 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -76,15 +76,15 @@ $socid = 0; if ($user->socid) { $socid = $user->socid; } +// Init Hooks +$hookmanager->initHooks(array('ordersuppliercardinfo')); + $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); if (!$user->hasRight("fournisseur", "commande", "lire")) { accessforbidden(); } -// Init Hooks -$hookmanager->initHooks(array('ordersuppliercardinfo')); - $usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index c896656c791..8abbf086867 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -47,8 +47,8 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercardcontact','invoicesuppliercontactcard', 'globalcard')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 5f31ab179cd..843c9f41211 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -51,8 +51,8 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercarddocument')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Get parameters $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 46671b03d4c..afade92390a 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -44,8 +44,8 @@ $ref = GETPOST("ref", 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercardinfo')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 1ce43edf5ac..0e7bbc1bfee 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -38,6 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; // Load translation files required by the page $langs->loadLangs(array('exports', 'compta', 'errors', 'projects', 'admin')); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('imports')); + // Security check $result = restrictedArea($user, 'import'); @@ -147,11 +150,6 @@ $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') $charset = GETPOST('charset', 'aZ09'); $separator_used = str_replace('\t', "\t", $separator); - -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('imports')); - - $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index ef4457e9177..fc5c392d5a7 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -58,12 +58,11 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } +$hookmanager->initHooks(array('loancard', 'globalcard')); $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); -$hookmanager->initHooks(array('loancard', 'globalcard')); - $error = 0; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index c484f01495e..cc1e061623f 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -78,12 +78,13 @@ if (!empty($enddatemonth)) { $enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear); } +$hookmanager->initHooks(array('marginagentlist')); + // Security check $result = restrictedArea($user, 'margins'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new User($db); -$hookmanager->initHooks(array('marginagentlist')); /* * Actions diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 8d5cdd75ab6..95694b1b193 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -61,14 +61,14 @@ if (!$sortfield) { $sortfield = "f.datef"; } +$hookmanager->initHooks(array('tabproductmarginlist')); + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (!$user->hasRight('margins', 'liretous')) { accessforbidden(); } -$hookmanager->initHooks(array('tabproductmarginlist')); - $search_invoice_date_start = ''; $search_invoice_date_end = ''; if (GETPOSTINT('search_invoice_date_start_month')) { diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 91781a7d148..c6ebcdbb8e3 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -76,6 +76,9 @@ if (isset($user->socid) && $user->socid > 0) { $socid = $user->socid; } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array +//$hookmanager->initHooks(array($object->element.'index')); + // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ac95b0a8e33..458bda8d606 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -187,6 +187,9 @@ if (!empty($canvas)) { $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($id) ? 'rowid' : 'ref'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('productcard', 'globalcard')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -198,9 +201,6 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', 0, 'product&product', '', '', $fieldtype); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('productcard', 'globalcard')); - // Permissions $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'read')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 2fc3e789ac5..a56f734d006 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -42,6 +42,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'in $backtopage = GETPOST('backtopage', 'alpha'); $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; +$hookmanager->initHooks(array('inventorycard', 'globalcard')); // Note that conf->hooks_modules contains array + if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $result = restrictedArea($user, 'stock', $id); } else { @@ -55,7 +57,6 @@ $extrafields = new ExtraFields($db); $includedocgeneration = false; $diroutputmassaction = null; // $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9f4660815fb..af420a87464 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -59,6 +59,7 @@ $lineid = GETPOSTINT('lineid'); $batch = GETPOST('batch', 'alphanohtml'); $totalExpectedValuation = 0; $totalRealValuation = 0; +$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $result = restrictedArea($user, 'stock', $id); } else { @@ -69,7 +70,7 @@ if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $object = new Inventory($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/product/note.php b/htdocs/product/note.php index b718f9894ec..f5e431fc313 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -52,6 +52,8 @@ if ($id > 0 || !empty($ref)) { $permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php +$hookmanager->initHooks(array('productnote')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'product', $object->id, 'product&product', '', ''); @@ -63,10 +65,6 @@ if ($object->id > 0) { restrictedArea($user, 'product|service', $fieldvalue, 'product&product', '', '', $fieldtype); } - -$hookmanager->initHooks(array('productnote')); - - /* * Actions */ diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index ba148724206..62af7f3dd3b 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -42,14 +42,16 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; + if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('productstatspropal')); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index b89e5f16929..c69ed74ff58 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -72,13 +72,13 @@ if (!$sortorder) { $sortorder = "DESC"; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard')); + // Security check //$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); $result = restrictedArea($user, 'stock'); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard')); - $object = new Entrepot($db); $extrafields = new ExtraFields($db); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index df89401e1c8..a1c8906f6aa 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -50,9 +50,6 @@ if (isModEnabled('productbatch')) { $langs->load("productbatch"); } -// Security check -$result = restrictedArea($user, 'stock'); - $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $msid = GETPOSTINT('msid'); @@ -92,9 +89,13 @@ if (!$sortorder) { $pdluoid = GETPOSTINT('pdluoid'); +$hookmanager->initHooks(array('movementlist')); + +// Security check +$result = restrictedArea($user, 'stock'); + // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new MouvementStock($db); -$hookmanager->initHooks(array('movementlist')); $extrafields = new ExtraFields($db); $formfile = new FormFile($db); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index e594d612f73..30924bcde8f 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -54,11 +54,12 @@ $fieldtype = 'rowid'; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('productlotdocuments')); +$result = restrictedArea($user, 'produit|service'); + // Get parameters $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index cf358161eb4..e895b6d792b 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -45,11 +45,12 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('stockreplenishlist')); +$result = restrictedArea($user, 'produit|service'); + //checks if a product has been ordered $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index ca9529267b4..0eb8369a4ef 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -53,6 +53,9 @@ if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('producttranslationcard', 'globalcard')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -64,10 +67,6 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('producttranslationcard', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 1a1c14ac052..773e7fad1a1 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -61,11 +61,12 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($obj // Security check $socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. -$result = restrictedArea($user, 'projet', $id, 'projet&project'); $hookmanager->initHooks(array('projectcontactcard', 'globalcard')); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. +$result = restrictedArea($user, 'projet', $id, 'projet&project'); + /* * Actions diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2b983efa0aa..24459f7dcbd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -187,11 +187,12 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($obj // Security check $socid = $object->socid; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. -$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); $hookmanager->initHooks(array('projectOverview')); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. +$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); + /* * View diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 86e7771c855..fc11ddad28e 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -139,14 +139,15 @@ if (!$sortorder) { // Security check $socid = 0; + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $diroutputmassaction = $conf->project->dir_output.'/tasks/temp/massgeneration/'.$user->id; -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); - $progress = GETPOSTINT('progress'); $budget_amount = GETPOSTFLOAT('budget_amount'); $billable = (GETPOST('billable', 'aZ') == 'yes'? 1 : 0); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index eb692907114..d4591534da6 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -69,6 +69,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. +$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); $result = restrictedArea($user, 'resource', $object->id, 'resource'); @@ -80,7 +81,6 @@ $permissiontodelete = $user->hasRight('resource', 'delete'); * Actions */ -$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); $parameters = array('resource_id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 22cb2326c1a..253b273d774 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -46,6 +46,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); + $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); if ($socid > 0) { @@ -90,11 +94,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $thirdTypeSelect = GETPOST("third_select_id", 'aZ09'); $type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; - -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 720b03549f6..19fe3cda5fd 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -44,6 +44,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartynotification', 'globalcard')); + $result = restrictedArea($user, 'societe', '', ''); $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -67,11 +71,6 @@ $now = dol_now(); $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartynotification', 'globalcard')); - - - /* * Actions */ diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index d67568189a6..b5f35699e90 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -59,14 +59,15 @@ $socid = GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard')); + $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize objects $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard')); - $error = 0; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 2e3c84654bc..a12272c94ab 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -53,11 +53,12 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('projectthirdparty')); +$result = restrictedArea($user, 'societe', $socid, '&societe'); + $object = new Societe($db); $permissiontodelete = $user->hasRight('societe', 'supprimer'); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 227de670c38..3c6b3ce3850 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -65,16 +65,16 @@ $pagenext = $page + 1; if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('contactthirdparty', 'globalcard')); + $result = restrictedArea($user, 'societe', $id, ''); // Initialize objects $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('contactthirdparty', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index adb7956d743..cd82efbe336 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -47,14 +47,15 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } + +$hookmanager->initHooks(array('supplier_proposalcontactcard', 'globalcard')); + $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', ''); $object = new SupplierProposal($db); $permissiontoedit = $user->hasRight('supplier_proposal', 'creer'); -$hookmanager->initHooks(array('supplier_proposalcontactcard', 'globalcard')); - /* * Actions diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 9c435ca8485..ec8ba488e95 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -68,6 +68,9 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop @@ -75,9 +78,6 @@ if (($object->id != $user->id) && (!$user->hasRight('user', 'user', 'lire'))) { accessforbidden(); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); - /* * Actions */ diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 6b540e1f407..647853897e2 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -39,11 +39,10 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('usercard', 'globalcard')); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); /* * Actions diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 06b51074c95..e0a08cd272f 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -75,6 +75,9 @@ if ($user->socid > 0) { } $feature2 = 'user'; +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { @@ -108,11 +111,6 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->user->dir_output."/".$object->id; } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard')); - - - /* * Actions */ diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index a40826c632f..b79f33a0655 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -43,15 +43,15 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userldap', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); $object->fetch($id, '', '', 1); $object->loadRights(); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userldap', 'globalcard')); - /* * Actions diff --git a/htdocs/user/note.php b/htdocs/user/note.php index c6db1416a7b..b90b2bba740 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -59,11 +59,11 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user'); -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard')); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); + /* * Actions diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index e51f7469f5d..0f45e53cb49 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -58,6 +58,9 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userihm', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { accessforbidden(); @@ -81,10 +84,6 @@ $searchformtitle=array($langs->trans("Companies"),$langs->trans("Contacts"),$lan $form = new Form($db); $formadmin = new FormAdmin($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userihm', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 6d93054cee1..1ab6fa0f09e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -74,6 +74,9 @@ if ($user->id == $id && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user accessforbidden(); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userperms', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { accessforbidden(); @@ -85,10 +88,6 @@ $object->loadRights(); $entity = $conf->entity; -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userperms', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 67afacc7de6..5cf4220d79a 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -49,6 +49,10 @@ if (!isModEnabled('variants')) { if ($user->socid > 0) { // Protection if external user accessforbidden(); } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('productattributecard', 'globalcard')); + $result = restrictedArea($user, 'variants'); $object = new ProductAttribute($db); @@ -56,9 +60,6 @@ $object = new ProductAttribute($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once' -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('productattributecard', 'globalcard')); - $permissiontoread = $user->hasRight('variants', 'read'); $permissiontoadd = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoedit = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php From b16e70438b754a378feced1dbe1e3c02898851b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Aug 2024 23:56:24 +0200 Subject: [PATCH 19/21] fix phpdoc (#30698) --- htdocs/delivery/class/delivery.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 8de7839fabd..e2ce2b4bfc1 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -267,9 +267,9 @@ class Delivery extends CommonObject /** * Create a line * - * @param string $origin_id Id of order + * @param int $origin_id Id of order * @param string $qty Quantity - * @param string $fk_product Id of predefined product + * @param int $fk_product Id of predefined product * @param string $description Description * @param array $array_options Array options * @return int Return integer <0 if KO, >0 if OK @@ -278,12 +278,11 @@ class Delivery extends CommonObject { // phpcs:enable $error = 0; - $idprod = $fk_product; $sql = "INSERT INTO ".MAIN_DB_PREFIX."deliverydet (fk_delivery, fk_origin_line,"; $sql .= " fk_product, description, qty)"; $sql .= " VALUES (".$this->id.",".((int) $origin_id).","; - $sql .= " ".($idprod > 0 ? ((int) $idprod) : "null").","; + $sql .= " ".($fk_product > 0 ? ((int) $fk_product) : "null").","; $sql .= " ".($description ? "'".$this->db->escape($description)."'" : "null").","; $sql .= (price2num($qty, 'MS')).")"; From de420b30ef7b715e621729cfe11bfd787be20f66 Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Wed, 21 Aug 2024 00:24:07 +0200 Subject: [PATCH 20/21] fix contacts default roles (#30700) --- htdocs/societe/class/societe.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0bf35006754..677878ad9b8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1169,7 +1169,9 @@ class Societe extends CommonObject $contact->town = $this->town; $this->setUpperOrLowerCase(); $contact->phone_pro = $this->phone; - $contact->roles = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES')); + if (getDolGlobalString('CONTACTS_DEFAULT_ROLES')) { + $contact->roles = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES')); + } $contactId = $contact->create($user, $notrigger); if ($contactId < 0) { From 16681ce7b00fd322a10f556bbce188dcdab69b10 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 21 Aug 2024 00:25:00 +0200 Subject: [PATCH 21/21] qual: Parameter #6 $year of function dol_mktime expects int, string given. (#30693) * Update balance.php * Update export.php * Update list.php * Update listbyaccount.php * Update productMargins.php * Update thirdpartyMargins.php * Update productMargins.php --- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/bookkeeping/export.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/margin/tabs/productMargins.php | 4 ++-- htdocs/margin/tabs/thirdpartyMargins.php | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index fc21dd6945e..92945c6c3a6 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -102,7 +102,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $search_date_end = strtotime($fiscalYear->date_end); } else { $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 4294363e751..fa9c68fa598 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -172,7 +172,7 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE $search_date_end = strtotime($fiscalYear->date_end); } else { $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b0710e6e109..88b34e5cba1 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -177,7 +177,7 @@ if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('beg $search_date_end = strtotime($fiscalYear->date_end); } else { $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 1fff4a6a802..4c2fad27f0d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -153,7 +153,7 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc $search_date_end = strtotime($fiscalYear->date_end); } else { $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 95694b1b193..4c8062adbbb 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -96,8 +96,8 @@ if (empty($search_invoice_date_start) && empty($search_invoice_date_end) && !GET $search_invoice_date_start = strtotime($fiscalYear->date_start); $search_invoice_date_end = strtotime($fiscalYear->date_end); } else { - $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year } diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 5efcde97c71..f0fb30079af 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -105,8 +105,8 @@ if (empty($search_invoice_date_start) && empty($search_invoice_date_end) && !GET $search_invoice_date_start = strtotime($fiscalYear->date_start); $search_invoice_date_end = strtotime($fiscalYear->date_end); } else { - $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); - $year_start = dol_print_date(dol_now(), '%Y'); + $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); + $year_start = (int) dol_print_date(dol_now(), '%Y'); if (dol_print_date(dol_now(), '%m') < $month_start) { $year_start--; // If current month is lower that starting fiscal month, we start last year }