From c5c0628ee86e12f8a7371c33720bf2c698c8c7a2 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 11 Oct 2022 10:05:56 +0200 Subject: [PATCH 01/66] add short cicility --- htdocs/langs/en_US/dict.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index 0524cf1ca18..9eaeb52f8f2 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -250,7 +250,9 @@ CountryMF=Saint Martin ##### Civilities ##### CivilityMME=Mrs. +CivilityMMEShort=CivilityMMEShort CivilityMR=Mr. +CivilityMRShort=CivilityMRShort CivilityMLE=Ms. CivilityMTRE=Master CivilityDR=Doctor From 82ca472245b551df5d05f35813cf8d78b7d9a494 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 18 Oct 2022 10:50:21 +0200 Subject: [PATCH 02/66] FIX: only modify hidden checkbox/multislected extrafields on update if they are provided in request --- htdocs/core/class/extrafields.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 384d4f1fba4..1fbadc2ee81 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2084,13 +2084,21 @@ class ExtraFields $enabled = 1; if (isset($this->attributes[$object->table_element]['list'][$key])) { - $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); + $enabled = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1)); } $perms = 1; if (isset($this->attributes[$object->table_element]['perms'][$key])) { $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); } - if (empty($enabled)) { + if ( + empty($enabled) + || ( + $onlykey === '@GETPOSTISSET' + && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')) + && in_array(abs($enabled), array(2, 5)) + && ! GETPOSTISSET('options_' . $key) // Update hidden checkboxes and multiselect only if they are provided + ) + ) { continue; } if (empty($perms)) { From 6050f607043d9b83462e4a5eea0f620c393879b7 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 18 Oct 2022 11:36:17 +0200 Subject: [PATCH 03/66] add loadRoleMode on getlinearray --- htdocs/projet/class/project.class.php | 11 ++++++----- htdocs/projet/class/task.class.php | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b127d3aa686..63b8d0077ee 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -838,7 +838,7 @@ class Project extends CommonObject } // Fetch tasks - $this->getLinesArray($user); + $this->getLinesArray($user, 0); // Delete tasks $ret = $this->deleteTasks($user); @@ -2204,14 +2204,15 @@ class Project extends CommonObject /** * Create an array of tasks of current project * - * @param User $user Object user we want project allowed to - * @return int >0 if OK, <0 if KO + * @param User $user Object user we want project allowed to + * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action + * @return int >0 if OK, <0 if KO */ - public function getLinesArray($user) + public function getLinesArray($user, $loadRoleMode = 1) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); - $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); + $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index cda8494682b..2663053b549 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -772,9 +772,10 @@ class Task extends CommonObject * @param array $extrafields Show additional column from project or task * @param int $includebilltime Calculate also the time to bill and billed * @param array $search_array_options Array of search + * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action * @return array Array of tasks */ - public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array()) + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadRoleMode = 1) { global $conf, $hookmanager; @@ -925,18 +926,18 @@ class Task extends CommonObject $error = 0; $obj = $this->db->fetch_object($resql); - - if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user - if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { - $error++; + if ($loadRoleMode) { + if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user + if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { + $error++; + } + } + if (is_object($usert)) { // If we ask a filter on a user affected to a task + if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { + $error++; + } } } - if (is_object($usert)) { // If we ask a filter on a user affected to a task - if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { - $error++; - } - } - if (!$error) { $tasks[$i] = new Task($this->db); $tasks[$i]->id = $obj->taskid; From 71bae4f94b42d6099d50ceafd4e837e7c583d7f9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 18 Oct 2022 09:43:55 +0000 Subject: [PATCH 04/66] Fixing style errors. --- htdocs/projet/class/project.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 63b8d0077ee..2e6bdd8cec0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2208,7 +2208,7 @@ class Project extends CommonObject * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action * @return int >0 if OK, <0 if KO */ - public function getLinesArray($user, $loadRoleMode = 1) + public function getLinesArray($user, $loadRoleMode = 1) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); From 87339de68da4232024d8cc090b75cf6597be8468 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 19 Oct 2022 09:29:11 +0200 Subject: [PATCH 05/66] add human readeable trad --- htdocs/langs/en_US/dict.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index 9eaeb52f8f2..00ab5a05f24 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -250,9 +250,9 @@ CountryMF=Saint Martin ##### Civilities ##### CivilityMME=Mrs. -CivilityMMEShort=CivilityMMEShort +CivilityMMEShort=Mrs. CivilityMR=Mr. -CivilityMRShort=CivilityMRShort +CivilityMRShort=Mr. CivilityMLE=Ms. CivilityMTRE=Master CivilityDR=Doctor From 765e619cee2fa6d246aab8eec825879d93c83fc9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 20 Oct 2022 14:47:55 +0200 Subject: [PATCH 06/66] FIX avoid unnecessary multiple calculation (#22637) --- htdocs/core/lib/project.lib.php | 10 ++++++---- htdocs/projet/activity/perday.php | 9 ++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 776d0f0776f..e32eb092a46 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1226,13 +1226,14 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); - $modeinput = 'hours'; + // Comment for avoid unnecessary multiple calculation + /*$modeinput = 'hours'; print ''; + print '';*/ print ''; @@ -1613,13 +1614,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //$tableCell.=' '; print $tableCell; - $modeinput = 'hours'; + // Comment for avoid unnecessary multiple calculation + /*$modeinput = 'hours'; print ''; + print '';*/ print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c191b3baeaa..86df142d40c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -795,12 +795,12 @@ print ''; print ''; -$modeinput = 'hours'; - -if ($conf->use_javascript_ajax) { +if (!empty($conf->use_javascript_ajax)) { + $modeinput = 'hours'; print "\n\n"; print ''; } From c3fb0fde85e8f787da18f6b0f56aeb45973ee4fe Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 20 Oct 2022 15:53:03 +0200 Subject: [PATCH 07/66] FIX : we must be able to select only bom of a specific product + several fixes on select_bom() function --- htdocs/core/class/html.form.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5869a85f3cf..7388da7596e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2428,7 +2428,7 @@ class Form * @param int $forcecombo Force to use combo box * @return void|string */ - public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0) + public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) { // phpcs:enable global $conf, $user, $langs, $db; @@ -2450,8 +2450,9 @@ class Form $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; if (!empty($status)) $sql.= ' AND status = '. (int) $status; - if (!empty($type)) $sql.= ' AND status = '. (int) $type; - if (!empty($limit)) $sql.= 'LIMIT '. (int) $limit; + if (!empty($type)) $sql.= ' AND bomtype = '. (int) $type; + if(! empty($TProducts)) $sql .= ' AND fk_product IN ('.implode(',', $TProducts).')'; + if (!empty($limit)) $sql.= ' LIMIT '. (int) $limit; $resql = $db->query($sql); if ($resql) { if ($showempty) { From 06646d45409002f31e8bfda104693d3ebf71812e Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 20 Oct 2022 15:56:32 +0200 Subject: [PATCH 08/66] FIX : php doc --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7388da7596e..5dd4db65bab 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2426,6 +2426,7 @@ class Form * @param string $morecss Add more css on select * @param string $nooutput No print, return the output into a string * @param int $forcecombo Force to use combo box + * @param array $TProducts Add filter on a defined product * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) From 02d9c9897a19573cc5043ca16090e9baac3a1509 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 20 Oct 2022 16:27:20 +0200 Subject: [PATCH 09/66] FIX : bug on selected value for select_bom() function --- htdocs/core/class/html.form.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5dd4db65bab..564c917ef1a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2464,8 +2464,9 @@ class Form while ($obj = $db->fetch_object($resql)) { $product = new Product($db); $res = $product->fetch($obj->fk_product); - if ($obj->rowid == $selected) $out .= ''; - $out .= ''; + $out .= ''; } } else { $error++; From 2bf2faef723198b26bf492e2bc3e45048d8824d1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 22 Oct 2022 09:22:12 +0200 Subject: [PATCH 10/66] FIX avoid access forbidden with numeric ref --- htdocs/core/lib/security.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 1d3f013e9f3..798ba265643 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -289,6 +289,11 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f return 1; } + // To avoid access forbidden with numeric ref + if ($dbt_select != 'rowid' && $dbt_select != 'id') { + $objectid = "'".$objectid."'"; + } + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) { From 2fa0e34b097492e2abc3d854f4dc75f95774035b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 22 Oct 2022 15:32:54 +0200 Subject: [PATCH 11/66] Fix api product : rang is now position --- htdocs/product/class/api_products.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2566ca24919..484a09947a5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1014,7 +1014,7 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT t.rowid, t.ref, t.ref_ext, t.label, t.rang, t.entity"; + $sql = "SELECT t.rowid, t.ref, t.ref_ext, t.label, t.position, t.entity"; $sql .= " FROM ".$this->db->prefix()."product_attribute as t"; $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; @@ -1051,7 +1051,7 @@ class Products extends DolibarrApi $tmp->ref = $result->ref; $tmp->ref_ext = $result->ref_ext; $tmp->label = $result->label; - $tmp->rang = $result->rang; + $tmp->position = $result->position; $tmp->entity = $result->entity; $return[] = $this->_cleanObjectDatas($tmp); @@ -1088,7 +1088,7 @@ class Products extends DolibarrApi throw new RestException(404, "Product attribute not found"); } - $fields = ["id", "ref", "ref_ext", "label", "rang", "entity"]; + $fields = ["id", "ref", "ref_ext", "label", "position", "entity"]; foreach ($prodattr as $field => $value) { if (!in_array($field, $fields)) { From 6c87982838d8010af3b7368dca24b67d1fe55246 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 22 Oct 2022 19:42:44 +0200 Subject: [PATCH 12/66] Fix newpayment.php with stripeconnect --- htdocs/public/payment/newpayment.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 14d455b5496..c0cfc869e9b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2390,7 +2390,17 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Code for payment with option STRIPE_USE_NEW_CHECKOUT set // Create a Stripe client. + var stripe = Stripe(''); + + var stripe = Stripe('', { stripeAccount: '' }); + // Create an instance of Elements var elements = stripe.elements(); @@ -2433,9 +2443,19 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } elseif (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { ?> // Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set to 1 or 2 - + // Create a Stripe client. + var stripe = Stripe(''); + + var stripe = Stripe('', { stripeAccount: '' }); + Date: Sat, 22 Oct 2022 17:43:17 +0000 Subject: [PATCH 13/66] Fixing style errors. --- htdocs/public/payment/newpayment.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c0cfc869e9b..e9b402b08dd 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2392,13 +2392,13 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Create a Stripe client. + ?> var stripe = Stripe(''); - + ?> var stripe = Stripe('', { stripeAccount: '' }); - @@ -2447,13 +2447,13 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Create a Stripe client. + ?> var stripe = Stripe(''); - + ?> var stripe = Stripe('', { stripeAccount: '' }); - From 57927cac06cafb27996bd16d481fd752059643d2 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 23 Oct 2022 03:00:09 +0200 Subject: [PATCH 14/66] Send expensereports-related e-mails from MAIN_MAIL_EMAIL_FROM address --- htdocs/expensereport/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 1da36a72e32..beb9c501b3e 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -414,7 +414,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailTo && $emailFrom) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -521,7 +521,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -637,7 +637,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -745,7 +745,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_refuse); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -859,7 +859,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -1039,7 +1039,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($user->id); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); From 7ff84f4e42bc4bcb86d3ad424a081c6fcd87ed98 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 23 Oct 2022 03:25:55 +0200 Subject: [PATCH 15/66] Add help picto to remind users to respect SPF/DKIM in FROM e-mails --- htdocs/admin/mailing.php | 3 ++- htdocs/admin/mails.php | 6 ++++-- htdocs/core/lib/admin.lib.php | 7 +++++-- htdocs/langs/en_US/admin.lang | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 37735a43ed3..4d12a87f7bd 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -136,7 +136,8 @@ print ''.$langs->trans("Example").''; print "\n"; print ''; -print $langs->trans("MailingEMailFrom").''; +$help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); +print $langs->trans("MailingEMailFrom").' '.$help.''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) { print ' '.img_warning($langs->trans("BadEMail")); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 67bf775bdd9..5b470eafdc0 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -505,7 +505,8 @@ if ($action == 'edit') { print ''.$langs->trans("OtherOptions").''; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.''; print ''; @@ -702,7 +703,8 @@ if ($action == 'edit') { print ''.$langs->trans("OtherOptions").''; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.''; print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) { print img_warning($langs->trans("Mandatory")); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index fdecb7a73fb..a07f16c06cb 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1709,14 +1709,14 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0'; print ''; } - if ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { + elseif ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; } - if ($const == 'ADHERENT_MAILMAN_LISTS') { + elseif ($const == 'ADHERENT_MAILMAN_LISTS') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; } + elseif ($const == 'ADHERENT_MAIL_FROM') { + print ' '.img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); + } print "\n"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d0c73a562f5..7dd27ff29ab 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -294,6 +294,7 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (default value in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix-like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix-like systems) MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (default value in php.ini: %s) +EMailHelpMsgSPFDKIM=To prevent Dolibarr emails to be classified as spam, make sure that the server is authorized to send e-mails from this address by SPF and DKIM configuration MAIN_MAIL_ERRORS_TO=Email used for error returns emails (fields 'Errors-To' in emails sent) MAIN_MAIL_AUTOCOPY_TO= Copy (Bcc) all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) From 39934a9a81607dd8d0760cdf40f544167fc41537 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 23 Oct 2022 11:19:23 +0200 Subject: [PATCH 16/66] Fix scrutinizer api_thirdparties.class.php 5 issues --- htdocs/societe/class/api_thirdparties.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 962bbf021b8..b5d9f7bfc48 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1082,7 +1082,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_replacable_invoices($id); if ($result < 0) { - throw new RestException(405, $this->thirdparty->error); + throw new RestException(405, $invoice->error); } return $result; @@ -1125,7 +1125,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_qualified_avoir_invoices($id); if ($result < 0) { - throw new RestException(405, $this->thirdparty->error); + throw new RestException(405, $invoice->error); } return $result; @@ -1164,10 +1164,9 @@ class Thirdparties extends DolibarrApi $sql .= " WHERE fk_soc = ".((int) $id); } - $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($this->db->num_rows($result) == 0) { throw new RestException(404, 'Account not found'); } @@ -1409,7 +1408,7 @@ class Thirdparties extends DolibarrApi if ($result > 0) { return array("success" => $result); } else { - throw new RestException(500, 'Error generating the document '.$this->error); + throw new RestException(500, 'Error generating the document '.$this->company->error); } } From 7e1a37c1387107ef2958d24e57bf78cb4bef37ea Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 23 Oct 2022 11:35:58 +0200 Subject: [PATCH 17/66] Fix : remove duplicate code and fix #22176 --- htdocs/core/modules/modProduct.class.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b18d10a29b1..dc0cff86353 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -650,16 +650,7 @@ class modProduct extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r] = array( - 'p.ref'=>'[^ ]', - 'p.price_base_type' => 'HT|TTC', - 'p.tosell'=>'^[0|1]$', - 'p.tobuy'=>'^[0|1]$', - 'p.fk_product_type'=>'^[0|1]$', - 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly' => '^[0|1]$', - 'p.finished' => '^[0|1]$' - ); + // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "ref:PREF123456", From 7bf0287c65862c7ed8ee29de67d1374ccfc4abf1 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 23 Oct 2022 11:46:15 +0200 Subject: [PATCH 18/66] Fix : remove nonsense code --- htdocs/compta/tva/card.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 3a34d71c11d..3d6f4f4d329 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -74,17 +74,6 @@ $hookmanager->initHooks(array('taxvatcard', 'globalcard')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } From 92ad656bf02faa5b9ffb9c5d89598f7f36397998 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 23 Oct 2022 12:06:13 +0200 Subject: [PATCH 19/66] Fix : dict data too long error --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ab7eaf73653..85455dd4be9 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -842,7 +842,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); } else { - dol_print_error($db); + setEventMessages($db->error(), null, 'errors'); } } } From 83afee60470382c3b82597bb76ed7362f09253b5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 24 Oct 2022 07:47:43 +0200 Subject: [PATCH 20/66] FIX can not set prospect status "Do not contact" --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 624dcda170a..8961d70a4cc 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1479,7 +1479,7 @@ class Societe extends CommonObject $sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? ((int) $this->stcomm_id) : "0"); + $sql .= ",fk_stcomm=".($this->stcomm_id >= -1 ? ((int) $this->stcomm_id) : "0"); } if (isset($this->typent_id)) { $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); From d9f067eabb17ba32f54c2293a65adb59404672da Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 24 Oct 2022 09:46:41 +0200 Subject: [PATCH 21/66] FIX : travis & stickler feedbacks --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 564c917ef1a..5efbdeae8e1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2452,7 +2452,7 @@ class Form $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; if (!empty($status)) $sql.= ' AND status = '. (int) $status; if (!empty($type)) $sql.= ' AND bomtype = '. (int) $type; - if(! empty($TProducts)) $sql .= ' AND fk_product IN ('.implode(',', $TProducts).')'; + if (!empty($TProducts)) $sql .= ' AND fk_product IN ('.$this->db->sanitize(implode(',', $TProducts)).')'; if (!empty($limit)) $sql.= ' LIMIT '. (int) $limit; $resql = $db->query($sql); if ($resql) { From baccf336f20bea38699db1a803d1a7116e823c55 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 24 Oct 2022 16:41:31 +0200 Subject: [PATCH 22/66] FIX remove > 0 and -1 --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8961d70a4cc..83de127f254 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1479,7 +1479,7 @@ class Societe extends CommonObject $sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".($this->stcomm_id >= -1 ? ((int) $this->stcomm_id) : "0"); + $sql .= ",fk_stcomm=".(($this->stcomm_id > 0 || $this->stcomm_id = -1) ? ((int) $this->stcomm_id) : "0"); } if (isset($this->typent_id)) { $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); From e9b80fa65605931717219824f977873b992b4ea8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Oct 2022 19:40:51 +0200 Subject: [PATCH 23/66] Fix phpcs --- htdocs/core/lib/admin.lib.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index a07f16c06cb..03bb5d6ba69 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1708,15 +1708,13 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu print ''; - } - elseif ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { + } elseif ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; - } - elseif ($const == 'ADHERENT_MAILMAN_LISTS') { + } elseif ($const == 'ADHERENT_MAILMAN_LISTS') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; - } - elseif ($const == 'ADHERENT_MAIL_FROM') { + } elseif ($const == 'ADHERENT_MAIL_FROM') { print ' '.img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); } From 791927723aaa2aaccb4d49f6dae5b606092ca9b6 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 26 Oct 2022 11:38:07 +0200 Subject: [PATCH 24/66] Fix #22671 : fix permissions notes.tpl.php --- htdocs/core/tpl/notes.tpl.php | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index e0f0c5d9142..0430ec16e0e 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -29,6 +29,9 @@ $module = $object->element; $note_public = 'note_public'; $note_private = 'note_private'; +if ($module == "product") { + $module = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); +} $colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); // Set $permission from the $permissionnote var defined on calling page $permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); @@ -60,37 +63,39 @@ if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) { // Special cases if ($module == 'propal') { - $permission = $user->rights->propale->creer; + $permission = $user->hasRight("propale", "creer"); } elseif ($module == 'supplier_proposal') { - $permission = $user->rights->supplier_proposal->creer; + $permission = $user->hasRight("supplier_proposal", "creer"); } elseif ($module == 'fichinter') { - $permission = $user->rights->ficheinter->creer; + $permission = $user->hasRight("ficheinter", "creer"); } elseif ($module == 'project') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight("projet", "creer"); } elseif ($module == 'project_task') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight("projet", "creer"); } elseif ($module == 'invoice_supplier') { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->facture->creer; + $permission = $user->hasRight("fournisseur", "facture", "creer"); } else { - $permission = $user->rights->supplier_invoice->creer; + $permission = $user->hasRight("supplier_invoice", "creer"); } } elseif ($module == 'order_supplier') { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->commande->creer; + $permission = $user->hasRight("fournisseur", "commande", "creer"); } else { - $permission = $user->rights->supplier_order->creer; + $permission = $user->hasRight("supplier_order", "creer"); } } elseif ($module == 'societe') { - $permission = $user->rights->societe->creer; + $permission = $user->hasRight("societe", "creer"); } elseif ($module == 'contact') { - $permission = $user->rights->societe->creer; + $permission = $user->hasRight("societe", "creer"); } elseif ($module == 'shipping') { - $permission = $user->rights->expedition->creer; + $permission = $user->hasRight("expedition", "creer"); } elseif ($module == 'product') { - $permission = $user->rights->produit->creer; + $permission = $user->hasRight("produit", "creer"); +} elseif ($module == 'service') { + $permission = $user->hasRight("service", "creer"); } elseif ($module == 'ecmfiles') { - $permission = $user->rights->ecm->setup; + $permission = $user->hasRight("ecm", "setup"); } //else dol_print_error('','Bad value '.$module.' for param module'); From 2281b187b7a1ed714aa62f2c078457cefda2f739 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 26 Oct 2022 12:15:30 +0200 Subject: [PATCH 25/66] FIX just add integer --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 83de127f254..7a8e1004468 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1479,7 +1479,7 @@ class Societe extends CommonObject $sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".(($this->stcomm_id > 0 || $this->stcomm_id = -1) ? ((int) $this->stcomm_id) : "0"); + $sql .= ",fk_stcomm=".(int) $this->stcomm_id; } if (isset($this->typent_id)) { $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); From d8c74eff5ff49cc6698e31c9e27c4aef8740903c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Oct 2022 12:39:37 +0200 Subject: [PATCH 26/66] css --- htdocs/admin/system/dolibarr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 144580b83af..4a55c1a1160 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -168,7 +168,7 @@ print ''."\n"; print ''.$langs->trans("Screen").''; print $_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; print ''."\n"; -print ''.$langs->trans("Session").''; +print ''.$langs->trans("Session").''; $i = 0; foreach ($_SESSION as $key => $val) { if ($i > 0) { From bbebdbb840ff74e775f78639831d4bbbc759301d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 28 Oct 2022 15:48:46 +0200 Subject: [PATCH 27/66] Fix php 8.1 warnings --- htdocs/bom/bom_card.php | 2 +- htdocs/core/actions_addupdatedelete.inc.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/project.lib.php | 12 +++++++----- htdocs/mrp/mo_card.php | 7 ++++--- htdocs/mrp/mo_movements.php | 3 ++- htdocs/product/class/html.formproduct.class.php | 1 + htdocs/product/index.php | 4 ++-- htdocs/product/list.php | 4 ++-- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/permonth.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- htdocs/projet/class/project.class.php | 2 +- .../class/recruitmentjobposition.class.php | 2 +- htdocs/recruitment/recruitmentcandidature_agenda.php | 3 ++- htdocs/recruitment/recruitmentcandidature_card.php | 4 ++-- htdocs/recruitment/recruitmentcandidature_list.php | 3 ++- htdocs/recruitment/recruitmentcandidature_note.php | 2 +- htdocs/recruitment/recruitmentjobposition_card.php | 7 ++++--- .../recruitment/recruitmentjobposition_document.php | 2 +- htdocs/recruitment/recruitmentjobposition_note.php | 4 ++-- 21 files changed, 40 insertions(+), 32 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 926797d1f07..89705c25ec5 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -704,7 +704,7 @@ if (empty($reshook)) { // Clone if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=bom', 'clone', $permissiontoadd); + print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=bom', 'clone', $permissiontoadd); } // Close / Cancel diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 6401437ac15..49f3b2fa302 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -435,7 +435,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; + $newlang = !empty($object->thirdparty->default_lang) ? $object->thirdparty->default_lang : ""; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0a1f5f16d6d..67cae4a652e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5060,7 +5060,7 @@ class Form $more .= $input['label'].'
'; } if ($input['type'] == 'select') { - $more .= $this->selectarray($input['name'], $input['values'], $input['default'], $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss); + $more .= $this->selectarray($input['name'], $input['values'], !empty($input['default']) ? $input['default'] : '-1', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss); } else { $more .= $this->multiselectarray($input['name'], $input['values'], is_array($input['default']) ? $input['default'] : [$input['default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr); } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d427f87189a..6028a8d4bea 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1610,7 +1610,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Duration print ''; - $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; + $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0; + if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0; $totalforeachday[$preselectedday] += $dayWorkLoad; $alreadyspent = ''; @@ -1990,7 +1991,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $modeinput = 'hours'; for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - + if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0; $cssonholiday = ''; if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { $cssonholiday .= 'onholidayallday '; @@ -2001,14 +2002,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } $tmparray = dol_getdate($tmpday); - $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; + $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0); $totalforeachday[$tmpday] += $dayWorkLoad; $alreadyspent = ''; if ($dayWorkLoad > 0) { $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); } - $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']); + $alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']); global $numstartworkingday, $numendworkingday; $cssweekend = ''; @@ -2288,7 +2289,8 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $year = $firstdaytoshowarray['year']; $month = $firstdaytoshowarray['mon']; foreach ($TWeek as $weekIndex => $weekNb) { - $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; + $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ; + if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0; $totalforeachweek[$weekNb] += $weekWorkLoad; $alreadyspent = ''; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 4142693b172..32571252ebf 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -49,7 +49,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moc $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $TBomLineId = GETPOST('bomlineid', 'array'); -//$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); +$socid = GETPOST("socid", 'int'); // Initialize technical objects $object = new Mo($db); @@ -678,7 +679,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=mo', 'clone', $permissiontoadd); + print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=mo', 'clone', $permissiontoadd); } // Cancel - Reopen @@ -725,7 +726,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $filedir = $conf->mrp->dir_output.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card + $delallowed = $user->hasRight("mrp", "creer"); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); // Show links to link elements diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 761a17f016d..2f3ed1f2d2b 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -47,7 +47,8 @@ $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mostockmovement'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$massaction = GETPOST('massaction', 'aZ09'); +$lineid = GETPOST('lineid', 'int'); $msid = GETPOST('msid', 'int'); $year = GETPOST("year", 'int'); diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index a21ff6348e6..75a929f53e5 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -403,6 +403,7 @@ class FormProduct dol_syslog(get_class($this)."::selectWorkstations $selected, $htmlname, $empty, $disabled, $fk_product, $empty_label, $forcecombo, $morecss", LOG_DEBUG); + $filterstatus=''; $out = ''; if (!empty($fk_product) && $fk_product > 0) { $this->cache_workstations = array(); diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 845c2e1012d..c2704111094 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -126,7 +126,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This may be /* * Number of products and/or services */ -if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) { +if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) { $prodser = array(); $prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0; $prodser[0]['sell'] = 0; @@ -284,7 +284,7 @@ print '
'; /* * Latest modified products */ -if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) { +if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) { $max = 15; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; $sql .= " p.entity,"; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 26f6a3a410c..50aa776eceb 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1909,7 +1909,7 @@ if ($resql) { // Status (to sell) if (!empty($arrayfields['p.tosell']['checked'])) { print ''; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($obj->tosell, 5, 0); @@ -1922,7 +1922,7 @@ if ($resql) { // Status (to buy) if (!empty($arrayfields['p.tobuy']['checked'])) { print ''; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { print $product_static->LibStatut($obj->tobuy, 5, 1); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 0854dceee67..018aeb85965 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -709,7 +709,7 @@ if (count($tasksarray) > 0) { // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 380b4891376..273affc3563 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -524,7 +524,7 @@ if (count($tasksarray) > 0) { // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index e7bc897db5a..7177f35e71c 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -747,7 +747,7 @@ if (count($tasksarray) > 0) { // Calculate total for all tasks $listofdistinctprojectid = array(); // List of all distinct projects - if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { + if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { foreach ($tasksarraywithoutfilter as $tmptask) { $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c5dcf0d4bb4..81f767d2d7d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2046,7 +2046,7 @@ class Project extends CommonObject $sql .= " AND pt.fk_projet = ".((int) $this->id); $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; - if ($task_id) { + if ($taskid) { $sql .= " AND ptt.fk_task=".((int) $taskid); } if (is_numeric($userid)) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index d5c109a5516..dda796c243e 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -254,7 +254,7 @@ class RecruitmentJobPosition extends CommonObject // Reset some properties unset($object->id); unset($object->fk_user_creat); - unset($object->import_key); + $object->import_key = null; // Clear fields if (property_exists($object, 'ref')) { diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 9988140393d..01d3e8a27c2 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$socid = GETPOST('socid', 'int'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -79,7 +80,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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 4226e016e73..2452c9e530b 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -43,7 +43,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new RecruitmentCandidature($db); @@ -565,7 +565,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd); + print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd); } // Button to convert into a user diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 0489d68bffb..9b860ac54d5 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -47,6 +47,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((e $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $mode = GETPOST('mode', 'aZ'); +$lineid = GETPOST('lineid', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -437,7 +438,7 @@ if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action != $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 543d7a66c10..1649ab5ee5e 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -48,7 +48,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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index 88424f1b06d..be1b9eec084 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -42,7 +42,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new RecruitmentJobPosition($db); @@ -279,6 +279,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if ($action == 'closeas') { + $text = ""; //Form to close proposal (signed or not) $formquestion = array( array('type' => 'select', 'name' => 'status', 'label' => ''.$langs->trans("CloseAs").'', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))), @@ -340,7 +341,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { @@ -435,7 +436,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone if ($permissiontoadd) { - print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd); + print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd); } /* diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index ca9907976be..a162f4c3af7 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -148,7 +148,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index dcda5b53109..5dc4004a361 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -53,7 +53,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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php @@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { From b0c6b59eb2cad3b1b31aecefb6de278fa40a0ae1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Oct 2022 15:56:15 +0200 Subject: [PATCH 28/66] NEW translate setup/ticket API link to https://github.com/Dolibarr/dolibarr/pull/22699 & fix for multicompany --- htdocs/api/class/api_setup.class.php | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 406172590d7..7c43b751082 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1496,6 +1496,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the severity must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of ticket categories * @@ -1503,13 +1504,14 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; - $sql .= " WHERE t.active = ".((int) $active); + $sql .= " WHERE t.entity IN (".getEntity('c_ticket_category').")"; + $sql .= " AND t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { $errormessage = ''; @@ -1538,7 +1540,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $category = $this->db->fetch_object($result); + $this->translateLabel($category, $lang, 'TicketCategoryShort', 'ticket'); + $list[] = $category; } } else { throw new RestException(503, 'Error when retrieving list of ticket categories : '.$this->db->lasterror()); @@ -1555,6 +1559,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the severity must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of ticket severities * @@ -1562,13 +1567,14 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql .= " WHERE t.active = ".((int) $active); + $sql .= " WHERE t.entity IN (".getEntity('c_ticket_severity').")"; + $sql .= " AND t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { $errormessage = ''; @@ -1597,7 +1603,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $severity = $this->db->fetch_object($result); + $this->translateLabel($severity, $lang, 'TicketSeverityShort', 'ticket'); + $list[] = $severity; } } else { throw new RestException(503, 'Error when retrieving list of ticket severities : '.$this->db->lasterror()); @@ -1614,6 +1622,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the severity must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of ticket types * @@ -1621,15 +1630,15 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; - $sql .= " WHERE t.active = ".(int) $active; - // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; - // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + $sql .= " WHERE t.entity IN (".getEntity('c_ticket_type').")"; + $sql .= " AND t.active = ".((int) $active); + // Add sql filters if ($sqlfilters) { $errormessage = ''; @@ -1658,7 +1667,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $type =$this->db->fetch_object($result); + $this->translateLabel($type, $lang, 'TicketTypeShort', 'ticket'); + $list[] = $type; } } else { throw new RestException(503, 'Error when retrieving list of ticket types : '.$this->db->lasterror()); From 8d604e3b2d4fe8416b761d7ed63c0c473a17b29f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Oct 2022 16:16:11 +0200 Subject: [PATCH 29/66] NEW support lang in Civilities API --- htdocs/api/class/api_setup.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 406172590d7..342eedf483d 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -845,6 +845,7 @@ class Setup extends DolibarrApi * @param int $page Page number (starting from zero) * @param string $module To filter on module events * @param int $active Civility is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the civility must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of civility types * @@ -852,7 +853,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') + public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $lang = '', $sqlfilters = '') { $list = array(); @@ -890,7 +891,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $civility = $this->db->fetch_object($result); + $this->translateLabel($civility, $lang, 'Civility', 'dict'); + $list[] = $civility; } } else { throw new RestException(503, 'Error when retrieving list of civility : '.$this->db->lasterror()); From 81bec045865eeac4f549298e581e6f31f970d0f1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Oct 2022 16:17:14 +0200 Subject: [PATCH 30/66] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 7c43b751082..28c693ed87c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1496,7 +1496,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} - * @param string $lang Code of the language the label of the severity must be translated to + * @param string $lang Code of the language the label of the category must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of ticket categories * @@ -1622,7 +1622,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number (starting from zero) * @param int $active Payment term is active or not {@min 0} {@max 1} - * @param string $lang Code of the language the label of the severity must be translated to + * @param string $lang Code of the language the label of the type must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of ticket types * From 72870ec95c224f27ffce9bddc60750ef69502fb8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 28 Oct 2022 16:35:11 +0200 Subject: [PATCH 31/66] Fix : wrong backtopage in recruitmentcandidature_agenda.php --- htdocs/recruitment/recruitmentcandidature_agenda.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 9988140393d..56cc1abb24c 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -209,7 +209,8 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.$objthirdparty->id; } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; + $backtopageurl = urlencode($_SERVER['PHP_SELF'].'?id='.$objthirdparty->id); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl.'&percentage=-1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; From 18c9685051f637de78fe6576214ac76769bdbd41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Oct 2022 17:51:25 +0200 Subject: [PATCH 32/66] Rename table to prepare need of direct debit for non invoices --- htdocs/compta/facture/list.php | 2 +- htdocs/compta/facture/prelevement.php | 8 +++--- htdocs/compta/paiement.php | 2 +- htdocs/compta/paymentbybanktransfer/index.php | 2 +- .../class/bonprelevement.class.php | 26 +++++++++---------- .../class/rejetprelevement.class.php | 4 +-- htdocs/compta/prelevement/create.php | 2 +- htdocs/compta/prelevement/demandes.php | 2 +- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/line.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/core/class/commoninvoice.class.php | 10 +++---- htdocs/core/lib/fourn.lib.php | 2 +- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/fourn/facture/paiement.php | 2 +- .../install/mysql/migration/16.0.0-17.0.0.sql | 5 ++++ ...acture.key.sql => llx_prelevement.key.sql} | 4 +-- ...vement_facture.sql => llx_prelevement.sql} | 2 +- ...ey.sql => llx_prelevement_demande.key.sql} | 4 +-- ...emande.sql => llx_prelevement_demande.sql} | 2 +- htdocs/stripe/class/stripe.class.php | 14 +++++----- 23 files changed, 55 insertions(+), 50 deletions(-) rename htdocs/install/mysql/tables/{llx_prelevement_facture.key.sql => llx_prelevement.key.sql} (76%) rename htdocs/install/mysql/tables/{llx_prelevement_facture.sql => llx_prelevement.sql} (96%) rename htdocs/install/mysql/tables/{llx_prelevement_facture_demande.key.sql => llx_prelevement_demande.key.sql} (78%) rename htdocs/install/mysql/tables/{llx_prelevement_facture_demande.sql => llx_prelevement_demande.sql} (97%) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b5b9687686b..11fdb6ac982 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -493,7 +493,7 @@ if ($action == 'makepayment_confirm' && !empty($user->rights->facture->paiement) $rsql .= " , pfd.date_traite as date_traite"; $rsql .= " , pfd.amount"; $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login"; - $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $rsql .= " , ".MAIN_DB_PREFIX."user as u"; $rsql .= " WHERE fk_facture = ".((int) $objecttmp->id); $rsql .= " AND pfd.fk_user_demande = u.rowid"; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index d475e83c55b..9809554c37f 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -311,7 +311,7 @@ if ($object->id > 0) { $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; $sql .= " , pfd.date_traite as date_traite"; $sql .= " , pfd.amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; if ($type == 'bank-transfer') { $sql .= " WHERE fk_facture_fourn = ".((int) $object->id); } else { @@ -686,7 +686,7 @@ if ($object->id > 0) { // For which amount ? $sql = "SELECT SUM(pfd.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; if ($type == 'bank-transfer') { $sql .= " WHERE fk_facture_fourn = ".((int) $object->id); } else { @@ -812,7 +812,7 @@ if ($object->id > 0) { $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; $sql .= " pfd.date_traite as date_traite, pfd.amount,"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; if ($type == 'bank-transfer') { @@ -889,7 +889,7 @@ if ($object->id > 0) { $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; $sql .= " pb.ref,"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; if ($type == 'bank-transfer') { diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index c51cb19ef1a..f2cd1fe18f9 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -750,7 +750,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $numdirectdebitopen = 0; $totaldirectdebit = 0; $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE fk_facture = ".((int) $objp->facid); $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 9e79cd98939..ba37fde1ba5 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -109,7 +109,7 @@ $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " AND f.total_ttc > 0"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 8aaf8010dd2..344229dc0a8 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -151,7 +151,7 @@ class BonPrelevement extends CommonObject if ($result == 0) { if ($line_id > 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement ("; if ($type != 'bank-transfer') { $sql .= "fk_facture"; } else { @@ -577,7 +577,7 @@ class BonPrelevement extends CommonObject } $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " , ".MAIN_DB_PREFIX."prelevement as pf"; $sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND p.rowid = ".((int) $this->id); @@ -635,7 +635,7 @@ class BonPrelevement extends CommonObject } else { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; } - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; @@ -695,7 +695,7 @@ class BonPrelevement extends CommonObject } else { $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; } - $sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; @@ -788,7 +788,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; } $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; if ($type != 'bank-transfer') { $sql .= " AND f.rowid = pfd.fk_facture"; @@ -1014,7 +1014,7 @@ class BonPrelevement extends CommonObject } // Update invoice requests as done - $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande"; + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande"; $sql .= " SET traite = 1"; $sql .= ", date_traite = '".$this->db->idate($now)."'"; $sql .= ", fk_prelevement_bons = ".((int) $this->id); @@ -1147,7 +1147,7 @@ class BonPrelevement extends CommonObject } if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->id).")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->id).")"; $resql1 = $this->db->query($sql); if (!$resql1) { dol_print_error($this->db); @@ -1171,7 +1171,7 @@ class BonPrelevement extends CommonObject } if (!$error) { - $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".((int) $this->id); + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".((int) $this->id); $resql4 = $this->db->query($sql); if (!$resql4) { dol_print_error($this->db); @@ -1425,7 +1425,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM"; $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."facture as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement as pf,"; $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; @@ -1541,7 +1541,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM"; $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement as pf,"; $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; @@ -1634,7 +1634,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM"; $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."facture as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " ".MAIN_DB_PREFIX."prelevement as pf"; $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id); $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; $sql .= " AND pf.fk_facture = f.rowid"; @@ -1660,7 +1660,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM"; $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " ".MAIN_DB_PREFIX."prelevement as pf"; $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id); $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; $sql .= " AND pf.fk_facture_fourn = f.rowid"; @@ -1691,7 +1691,7 @@ class BonPrelevement extends CommonObject fclose($this->file); if (!empty($conf->global->MAIN_UMASK)) { - @chmod($this->file, octdec($conf->global->MAIN_UMASK)); + @chmod($this->filename, octdec($conf->global->MAIN_UMASK)); } return $result; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index f88ff5201f3..27e27fe60bd 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -221,7 +221,7 @@ class RejetPrelevement $userid = 0; $sql = "SELECT fk_user_demande"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE pfd.fk_prelevement_bons = ".((int) $this->bon_id); $sql .= " AND pfd.fk_facture".($this->type == 'bank-transfer' ? '_fourn' : '').' = '.((int) $fac->id); @@ -289,7 +289,7 @@ class RejetPrelevement //Returns all invoices of a withdrawal $sql = "SELECT f.rowid as facid, pl.amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement as pf"; if ($this->type == 'bank-transfer') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)"; } else { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 5d6a58b9215..c5b0dda6cf2 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -348,7 +348,7 @@ if ($type == 'bank-transfer') { $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; } $sql .= " ".MAIN_DB_PREFIX."societe as s,"; -$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 585c601da56..905c8f36415 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -137,7 +137,7 @@ if ($type != 'bank-transfer') { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; } $sql .= " ".MAIN_DB_PREFIX."societe as s,"; -$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index d6009631ac2..dcb91710bd6 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -177,7 +177,7 @@ $sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,"; $sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl"; -$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture as pf"; +$sql .= ", ".MAIN_DB_PREFIX."prelevement as pf"; if ($object->type != 'bank-transfer') { $sql .= ", ".MAIN_DB_PREFIX."facture as f"; } else { diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 830bd101d0a..d71314a08e2 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -109,7 +109,7 @@ $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.total_ttc > 0"; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 1fccef050d1..186546b74a9 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -262,7 +262,7 @@ if ($id) { $sql .= " , s.rowid as socid, s.nom as name"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " , ".MAIN_DB_PREFIX."prelevement as pf"; if ($type == 'bank-transfer') { $sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f"; } else { diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index b84bc7f3d2d..571c78358e0 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -114,7 +114,7 @@ $sql .= " , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, $sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; -$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement as pf"; if ($type == 'bank-transfer') { $sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f"; } else { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2d63347c029..2a185b362be 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -756,7 +756,7 @@ abstract class CommonInvoice extends CommonObject $bac->fetch(0, $this->socid); $sql = "SELECT count(*)"; - $sql .= " FROM ".$this->db->prefix()."prelevement_facture_demande"; + $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; if ($type == 'bank-transfer') { $sql .= " WHERE fk_facture_fourn = ".((int) $this->id); } else { @@ -786,7 +786,7 @@ abstract class CommonInvoice extends CommonObject } if (is_numeric($amount) && $amount != 0) { - $sql = 'INSERT INTO '.$this->db->prefix().'prelevement_facture_demande('; + $sql = 'INSERT INTO '.$this->db->prefix().'prelevement_demande('; if ($type == 'bank-transfer') { $sql .= 'fk_facture_fourn, '; } else { @@ -883,7 +883,7 @@ abstract class CommonInvoice extends CommonObject } $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn"; - $sql .= " FROM ".$this->db->prefix()."prelevement_facture_demande"; + $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; $sql .= " WHERE rowid = ".((int) $did); dol_syslog(get_class($this)."::makeStripeSepaRequest 1", LOG_DEBUG); @@ -1572,7 +1572,7 @@ abstract class CommonInvoice extends CommonObject $this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?"; } - $sql = "INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande("; + $sql = "INSERT INTO '.MAIN_DB_PREFIX.'prelevement_demande("; $sql .= "fk_facture, "; $sql .= " amount, date_demande, fk_user_demande, ext_payment_id, ext_payment_site, sourcetype, entity)"; $sql .= " VALUES (".$this->id; @@ -1633,7 +1633,7 @@ abstract class CommonInvoice extends CommonObject public function demande_prelevement_delete($fuser, $did) { // phpcs:enable - $sql = 'DELETE FROM '.$this->db->prefix().'prelevement_facture_demande'; + $sql = 'DELETE FROM '.$this->db->prefix().'prelevement_demande'; $sql .= ' WHERE rowid = '.((int) $did); $sql .= ' AND traite = 0'; if ($this->db->query($sql)) { diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index c65013722d4..8ba05557220 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -58,7 +58,7 @@ function facturefourn_prepare_head($object) if (!empty($conf->paymentbybanktransfer->enabled)) { $nbStandingOrders = 0; $sql = "SELECT COUNT(pfd.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE pfd.fk_facture_fourn = ".((int) $object->id); $sql .= " AND pfd.ext_payment_id IS NULL"; $resql = $db->query($sql); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index bd02d7cca53..0d14b322953 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -59,7 +59,7 @@ function facture_prepare_head($object) if (!empty($conf->prelevement->enabled)) { $nbStandingOrders = 0; $sql = "SELECT COUNT(pfd.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE pfd.fk_facture = ".((int) $object->id); $sql .= " AND pfd.ext_payment_id IS NULL"; $resql = $db->query($sql); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 1d7149cdb10..ddc4036e91b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -345,7 +345,7 @@ if (empty($reshook)) { $rsql .= " , pfd.date_traite as date_traite"; $rsql .= " , pfd.amount"; $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login"; - $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $rsql .= " , ".MAIN_DB_PREFIX."user as u"; $rsql .= " WHERE fk_facture_fourn = ".((int) $objecttmp->id); $rsql .= " AND pfd.fk_user_demande = u.rowid"; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index b421496153d..bad8d19bd28 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -718,7 +718,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $numdirectdebitopen = 0; $totaldirectdebit = 0; $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid); $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 24ac0e37ff5..ce81740b50d 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -361,3 +361,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_MODIFY','Template invoices update','Executed when a Template invoices is updated','facturerec',901); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_DELETE','Template invoices deleted','Executed when a Template invoices is deleted','facturerec',902); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_AUTOCREATEBILL','Template invoices use to create invoices with auto batch','Executed when a Template invoices is use to create invoice with auto batch','facturerec',903); + + +ALTER TABLE llx_prelevement_facture RENAME TO llx_prelevement; +ALTER TABLE llx_prelevement_facture_demande RENAME TO llx_prelevement_demande; + diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture.key.sql b/htdocs/install/mysql/tables/llx_prelevement.key.sql similarity index 76% rename from htdocs/install/mysql/tables/llx_prelevement_facture.key.sql rename to htdocs/install/mysql/tables/llx_prelevement.key.sql index bc8b1bd8386..c3234b7756a 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture.key.sql +++ b/htdocs/install/mysql/tables/llx_prelevement.key.sql @@ -18,8 +18,8 @@ -- ============================================================================ -ALTER TABLE llx_prelevement_facture ADD INDEX idx_prelevement_facture_fk_prelevement_lignes (fk_prelevement_lignes); +ALTER TABLE llx_prelevement ADD INDEX idx_prelevement_fk_prelevement_lignes (fk_prelevement_lignes); -ALTER TABLE llx_prelevement_facture ADD CONSTRAINT fk_prelevement_facture_fk_prelevement_lignes FOREIGN KEY (fk_prelevement_lignes) REFERENCES llx_prelevement_lignes (rowid); +ALTER TABLE llx_prelevement ADD CONSTRAINT fk_prelevement_facture_fk_prelevement_lignes FOREIGN KEY (fk_prelevement_lignes) REFERENCES llx_prelevement_lignes (rowid); diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture.sql b/htdocs/install/mysql/tables/llx_prelevement.sql similarity index 96% rename from htdocs/install/mysql/tables/llx_prelevement_facture.sql rename to htdocs/install/mysql/tables/llx_prelevement.sql index 53a329f4376..b1fd80ef78b 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture.sql +++ b/htdocs/install/mysql/tables/llx_prelevement.sql @@ -16,7 +16,7 @@ -- -- =================================================================== -create table llx_prelevement_facture +create table llx_prelevement ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NULL, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.key.sql b/htdocs/install/mysql/tables/llx_prelevement_demande.key.sql similarity index 78% rename from htdocs/install/mysql/tables/llx_prelevement_facture_demande.key.sql rename to htdocs/install/mysql/tables/llx_prelevement_demande.key.sql index 4f9aedb9cdf..cd4ed476635 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.key.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_demande.key.sql @@ -17,6 +17,6 @@ -- =================================================================== -ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture); -ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn); +ALTER TABLE llx_prelevement_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture); +ALTER TABLE llx_prelevement_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn); diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_demande.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql rename to htdocs/install/mysql/tables/llx_prelevement_demande.sql index 9837f709777..bfad4d7fa6a 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_demande.sql @@ -17,7 +17,7 @@ -- =================================================================== -create table llx_prelevement_facture_demande +create table llx_prelevement_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 25a4edb6123..43f940acdee 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -386,7 +386,7 @@ class Stripe extends CommonObject // That's why we can comment the part of code to retrieve a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pi"; $sql .= " WHERE pi.fk_facture = ".((int) $object->id); $sql .= " AND pi.sourcetype = '".$this->db->escape($object->element)."'"; $sql .= " AND pi.entity IN (".getEntity('societe').")"; @@ -530,12 +530,12 @@ class Stripe extends CommonObject $paymentintentalreadyexists = 0; // Check that payment intent $paymentintent->id is not already recorded. $sql = "SELECT pi.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pi"; $sql .= " WHERE pi.entity IN (".getEntity('societe').")"; $sql .= " AND pi.ext_payment_site = '".$this->db->escape($service)."'"; $sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'"; - dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); + dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_demande", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -552,7 +552,7 @@ class Stripe extends CommonObject // If not, we create it. if (!$paymentintentalreadyexists) { $now = dol_now(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", '".$this->db->escape($paymentintent->id)."', ".((int) $object->id).", '".$this->db->escape($object->element)."', ".((int) $conf->entity).", '".$this->db->escape($service)."', ".((float) $amount).")"; $resql = $this->db->query($sql); if (!$resql) { @@ -696,12 +696,12 @@ class Stripe extends CommonObject $setupintentalreadyexists = 0; // Check that payment intent $setupintent->id is not already recorded. $sql = "SELECT pi.rowid"; - $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; + $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_demande as pi"; $sql.= " WHERE pi.entity IN (".getEntity('societe').")"; $sql.= " AND pi.ext_payment_site = '" . $this->db->escape($service) . "'"; $sql.= " AND pi.ext_payment_id = '".$this->db->escape($setupintent->id)."'"; - dol_syslog(get_class($this) . "::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); + dol_syslog(get_class($this) . "::getPaymentIntent search if payment intent already in prelevement_demande", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -717,7 +717,7 @@ class Stripe extends CommonObject if (! $setupintentalreadyexists) { $now=dol_now(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site)"; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site)"; $sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", '".$this->db->escape($setupintent->id)."', ".((int) $object->id).", '".$this->db->escape($object->element)."', " . ((int) $conf->entity) . ", '" . $this->db->escape($service) . "', ".((float) $amount).")"; $resql = $this->db->query($sql); if (! $resql) From 4596a16cdb3c4fc4b02e52d8da59f1cb3d06350b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Oct 2022 18:02:40 +0200 Subject: [PATCH 33/66] css --- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/prelevement/fiche-rejet.php | 2 +- htdocs/compta/prelevement/fiche-stat.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index dcb91710bd6..0ed75b5c3b8 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -111,7 +111,7 @@ if ($id > 0 || $ref) { print ''.$langs->trans("TransData").''; print dol_print_date($object->date_trans, 'day'); - print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; + print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; print ''.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print ''; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 0e59adfc166..de9eb46631c 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -106,7 +106,7 @@ if ($id > 0 || $ref) { print ''.$langs->trans("TransData").''; print dol_print_date($object->date_trans, 'day'); - print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; + print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; print ''.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print ''; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 8d88d761956..3b15676792e 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -100,7 +100,7 @@ if ($id > 0 || $ref) { print ''.$langs->trans("TransData").''; print dol_print_date($object->date_trans, 'day'); - print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; + print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).''; print ''.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print ''; @@ -135,7 +135,7 @@ if ($id > 0 || $ref) { print ''; print ''; - print ''; + print ''; $labelfororderfield = 'WithdrawalFile'; if ($object->type == 'bank-transfer') { $labelfororderfield = 'CreditTransferFile'; From 29d819be5eeb281f9358f1eedbb53d4517d5b076 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Oct 2022 18:11:54 +0200 Subject: [PATCH 34/66] Rename cid so we can retreive it easily on file --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index e21a288e53e..2651df8b2e5 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1783,7 +1783,7 @@ class CMailFile foreach ($matches[1] as $key => $ext) { // We save the image to send in disk $filecontent = $matches[2][$key]; - $cid = dol_hash($this->html, 'md5'); + $cid = 'cid000'.dol_hash($this->html, 'md5'); $destfiletmp = $images_dir.'/'.$cid.'.'.$ext; $fhandle = @fopen($destfiletmp, 'w'); From 0277c07c31fc9d44d634d9ac1025b4f1571f099d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Oct 2022 21:25:42 +0200 Subject: [PATCH 35/66] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 342eedf483d..a604aa46432 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -892,7 +892,7 @@ class Setup extends DolibarrApi $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { $civility = $this->db->fetch_object($result); - $this->translateLabel($civility, $lang, 'Civility', 'dict'); + $this->translateLabel($civility, $lang, 'Civility', array('dict')); $list[] = $civility; } } else { From 6dd07121937293c8d362ad20a164a588ec691ab0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Oct 2022 21:26:45 +0200 Subject: [PATCH 36/66] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 28c693ed87c..ef1d7e4c512 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1541,7 +1541,7 @@ class Setup extends DolibarrApi $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { $category = $this->db->fetch_object($result); - $this->translateLabel($category, $lang, 'TicketCategoryShort', 'ticket'); + $this->translateLabel($category, $lang, 'TicketCategoryShort', array('ticket')); $list[] = $category; } } else { @@ -1604,7 +1604,7 @@ class Setup extends DolibarrApi $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { $severity = $this->db->fetch_object($result); - $this->translateLabel($severity, $lang, 'TicketSeverityShort', 'ticket'); + $this->translateLabel($severity, $lang, 'TicketSeverityShort', array('ticket')); $list[] = $severity; } } else { @@ -1668,7 +1668,7 @@ class Setup extends DolibarrApi $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { $type =$this->db->fetch_object($result); - $this->translateLabel($type, $lang, 'TicketTypeShort', 'ticket'); + $this->translateLabel($type, $lang, 'TicketTypeShort', array('ticket')); $list[] = $type; } } else { From 27ee846562edb0a3c029257e34db8ae2993efde3 Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:14:50 -0500 Subject: [PATCH 37/66] New constant warhouse internal not sell To no show stock of products in internal warehouse --- htdocs/core/tpl/objectline_create.tpl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 381683cf62c..1bfc9587b89 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -258,9 +258,11 @@ if ($nolinesbefore) { } if (empty($senderissupplier)) { $statustoshow = 1; + $statuswarehouse = 'warehouseopen,warehouseinternal'; + if (!empty($conf->global->ENTREPOT_WAREHOUSEINTERNAL_NOT_SELL)) $statuswarehouse = 'warehouseopen'; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, $statuswarehouse, GETPOST('combinations', 'array')); } else { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } From bc4b9c4b18ab9eddc5b365e3a102f818035e0ca5 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 29 Oct 2022 09:39:12 +0200 Subject: [PATCH 38/66] NEW #22622: all partneships displayed on tab partnership of thirdparty and member --- htdocs/core/lib/company.lib.php | 20 +- htdocs/core/lib/member.lib.php | 20 +- htdocs/langs/en_US/partnership.lang | 5 +- htdocs/langs/fr_FR/partnership.lang | 1 + htdocs/partnership/partnership_list.php | 149 ++++++++++++- htdocs/societe/partnership.php | 274 ------------------------ 6 files changed, 180 insertions(+), 289 deletions(-) delete mode 100644 htdocs/societe/partnership.php diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 70589dfb120..43264ac3d98 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -267,9 +267,23 @@ function societe_prepare_head(Societe $object) if (!empty($user->rights->partnership->read)) { $langs->load("partnership"); $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; - $head[$h][0] = DOL_URL_ROOT.'/societe/partnership.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Partnership"); - $head[$h][2] = 'partnership'; + $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Partnerships"); + $nbNote = 0; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n"; + $sql .= " WHERE fk_soc = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbNote = $obj->nb; + } else { + dol_print_error($db); + } + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } + $head[$h][2] = 'partnerships'; if ($nbPartnership > 0) { $head[$h][1] .= ''.$nbPartnership.''; } diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 6e0dcb3b83a..71a9849dc16 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -66,9 +66,23 @@ function member_prepare_head(Adherent $object) if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { if (!empty($user->rights->partnership->read)) { $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; - $head[$h][0] = DOL_URL_ROOT.'/adherents/partnership.php?rowid='.$object->id; - $head[$h][1] = $langs->trans("Partnership"); - $head[$h][2] = 'partnership'; + $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id; + $head[$h][1] = $langs->trans("Partnerships"); + $nbNote = 0; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n"; + $sql .= " WHERE fk_member = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbNote = $obj->nb; + } else { + dol_print_error($db); + } + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } + $head[$h][2] = 'partnerships'; if ($nbPartnership > 0) { $head[$h][1] .= ''.$nbPartnership.''; } diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 6490bf23d8b..89a1bfa742d 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -20,6 +20,7 @@ ModulePartnershipName=Partnership management PartnershipDescription=Module Partnership management PartnershipDescriptionLong= Module Partnership management Partnership=Partnership +Partnerships=Partnerships AddPartnership=Add partnership CancelPartnershipForExpiredMembers=Partnership: Cancel partnership of members with expired subscriptions PartnershipCheckBacklink=Partnership: Check referring backlink @@ -49,8 +50,8 @@ PublicFormRegistrationPartnerDesc=Dolibarr can provide you a public URL/website # Object # DeletePartnership=Delete a partnership -PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party -PartnershipDedicatedToThisMember=Partnership dedicated to this member +PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party +PartnershipDedicatedToThisMember=Partnership dedicated to this member DatePartnershipStart=Start date DatePartnershipEnd=End date ReasonDecline=Decline reason diff --git a/htdocs/langs/fr_FR/partnership.lang b/htdocs/langs/fr_FR/partnership.lang index 41849e2812e..20c3fc0d801 100644 --- a/htdocs/langs/fr_FR/partnership.lang +++ b/htdocs/langs/fr_FR/partnership.lang @@ -20,6 +20,7 @@ ModulePartnershipName=Gestion des partenariats PartnershipDescription=Module de gestion des partenariats PartnershipDescriptionLong= Module de gestion des partenariats Partnership=Partenariat +Partnerships=Partenariats AddPartnership=Ajouter un partenariat CancelPartnershipForExpiredMembers=Partenariat : annuler le partenariat des adhérents dont les cotisations ont expirés PartnershipCheckBacklink=Partenariat : Vérifiez le backlink référent diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 838969e745e..0aba38fd7e3 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -28,7 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; // for other modules @@ -49,7 +51,8 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always ' $mode = GETPOST('mode', 'aZ'); $id = GETPOST('id', 'int'); - +$socid = GETPOST('socid', 'int'); +$memberid = GETPOST('rowid', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -68,7 +71,13 @@ $object = new Partnership($db); $extrafields = new ExtraFields($db); $adherent = new Adherent($db); $diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array +if ($socid > 0) { + $hookmanager->initHooks(array('thirdpartypartnership')); +} elseif ($memberid > 0) { + $hookmanager->initHooks(array('memberpartnership')); +} else { + $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array +} // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -144,7 +153,6 @@ $permissiontodelete = $user->rights->partnership->delete; if (empty($conf->partnership->enabled)) { accessforbidden('Module not enabled'); } -$socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); @@ -325,9 +333,19 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } -if ($managedfor == 'member') - $sql .= " AND fk_member > 0"; -else $sql .= " AND fk_soc > 0"; +if ($managedfor == 'member') { + if ($memberid > 0) { + $sql .= " AND t.fk_member = ".$memberid; + } else { + $sql .= " AND fk_member > 0"; + } +} else { + if ($socid > 0) { + $sql .= " AND t.fk_soc = ".((int) $socid); + } else { + $sql .= " AND fk_soc > 0"; + } +} foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -449,6 +467,113 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); +if ($managedfor == "member") { + if ($memberid > 0 && $user->hasRight('adherent', 'lire')) { + $langs->load("members"); + + $adhstat = new Adherent($db); + $adht = new AdherentType($db); + $result = $adhstat->fetch($memberid); + + if (isModEnabled('notification')) { + $langs->load("mails"); + } + + $adht->fetch($adhstat->typeid); + + $head = member_prepare_head($adhstat); + + print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'user'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'rowid', $linkback); + + print '
'; + + print '
'; + print ''; + + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } + + // Type + print '\n"; + + // Morphy + print ''; + print ''; + + // Company + print ''; + + // Civility + print ''; + print ''; + + print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$adhstat->getmorphylib().'
'.$langs->trans("Company").''.$adhstat->company.'
'.$langs->trans("UserTitle").''.$adhstat->getCivilityLabel().' 
'; + + print '
'; + + print dol_get_fiche_end(); + } +} elseif ($managedfor == "thirdparty") { + if ($socid && $user->hasRight('societe', 'lire')) { + $socstat = new Societe($db); + $res = $socstat->fetch($socid); + if ($res > 0) { + $tmpobject = $object; + $object = $socstat; // $object must be of type Societe when calling societe_prepare_head + $head = societe_prepare_head($socstat); + $object = $tmpobject; + + print dol_get_fiche_head($head, 'partnerships', $langs->trans("ThirdParty"), -1, 'company'); + + dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print ''; + + // Type Prospect/Customer/Supplier + print ''; + + // Customer code + if ($socstat->client && !empty($socstat->code_client)) { + print ''; + print ''; + } + // Supplier code + if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { + print ''; + print ''; + } + + print '
'.$langs->trans('NatureOfThirdParty').''; + print $socstat->getTypeUrl(1); + print '
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client)); + $tmpcheck = $socstat->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; + print $langs->trans('SupplierCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur)); + $tmpcheck = $socstat->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } + print '
'; + print '
'; + print dol_get_fiche_end(); + } + } +} $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -459,6 +584,12 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } +if ($socid) { + $param .= '&socid='.urlencode($socid); +} +if ($memberid) { + $param .= '&rowid='.urlencode($memberid); +} foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { @@ -512,7 +643,11 @@ print ''; print ''; print ''; print ''; - +if ($socid) { + print ''; +} elseif ($memberid) { + print ''; +} $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php deleted file mode 100644 index b7bcd153092..00000000000 --- a/htdocs/societe/partnership.php +++ /dev/null @@ -1,274 +0,0 @@ - - * Copyright (C) 2021 NextGestion - * Copyright (C) 2022 Charlene Benke - * - * 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 partnership_card.php - * \ingroup partnership - * \brief Page to create/edit/view partnership - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; -require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("companies", "partnership", "other")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); - -// Security check -$socid = GETPOST('socid', 'int'); -if (!empty($user->socid)) { - $socid = $user->socid; -} - -if (empty($id) && $socid && (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty')) { - $id = $socid; -} - -$object = new Societe($db); -if ($id > 0) { - $object->fetch($id); -} - -// Initialize technical objects -$object = new Partnership($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('thirdpartypartnership', 'globalcard')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); - -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php -$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; - - -if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') != 'thirdparty') { - accessforbidden('Partnership is not activated for thirdparties'); -} -if (empty($conf->partnership->enabled)) { - accessforbidden(); -} -if (empty($permissiontoread)) { - accessforbidden(); -} -if ($action == 'edit' && empty($permissiontoadd)) { - accessforbidden(); -} - -if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) { - accessforbidden(); -} - - -// Security check -$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); - - -/* - * Actions - */ - -$parameters = array('socid' => $id); -$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'); -} - -$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); -$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); - -if (empty($reshook)) { - $error = 0; - - $backtopage = DOL_URL_ROOT.'/partnership/partnership.php?id='.($id > 0 ? $id : '__ID__'); - - // Actions when linking object each other - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; -} - -$object->fields['fk_soc']['visible'] = 0; -if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) { - $object->fields['reason_decline_or_cancel']['visible'] = 1; -} -$object->fields['note_public']['visible'] = 1; - - -/* - * View - */ - -$form = new Form($db); -$formfile = new FormFile($db); - -$title = $langs->trans("Partnership"); -llxHeader('', $title); - -$form = new Form($db); - -if ($id > 0) { - $langs->load("companies"); - - $object = new Societe($db); - $result = $object->fetch($id); - - if (isModEnabled('notification')) { - $langs->load("mails"); - } - $head = societe_prepare_head($object); - - print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'company'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print '
'; - - print '
'; - print ''; - - if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field - print ''; - } - - if ($object->client) { - print ''; - } - - if ($object->fournisseur) { - print ''; - print ''; - } - - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; - print $langs->trans('CustomerCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print '
'; - print $langs->trans('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
'; - - print '
'; - - print dol_get_fiche_end(); -} else { - dol_print_error('', 'Parameter id not defined'); -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - // Buttons for actions - - if ($action != 'presend') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - // Show - if ($permissiontoadd) { - print dolGetButtonAction($langs->trans('AddPartnership'), '', 'default', DOL_URL_ROOT.'/partnership/partnership_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode(DOL_URL_ROOT.'/societe/partnership.php?id='.$object->id), '', $permissiontoadd); - } - } - print '
'."\n"; - } - - - //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php'; - $morehtmlright = ''; - - print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, ''); - - $socid = $object->id; - - - // TODO Replace this card with a table of list of all partnerships. - - $object = new Partnership($db); - $partnershipid = $object->fetch(0, '', 0, $socid); - - if ($partnershipid > 0) { - print '
'; - print '
'; - print '
'; - print ''."\n"; - - // Common attributes - unset($object->fields['fk_soc']); // Hide field already shown in banner - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - $forcefieldid = 'socid'; - $forceobjectid = $object->fk_soc; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print '
'; - } -} - -// End of page -llxFooter(); -$db->close(); From 3a78777c9fb529181c6877dd9f7e902e34ab65de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Oct 2022 12:07:26 +0200 Subject: [PATCH 39/66] Fix separation of date validation and approval as 2 different dates --- htdocs/holiday/list.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 8f16676f9ce..ddbafbcbd3c 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -126,7 +126,7 @@ $arrayfields = array( 'cp.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>40), 'cp.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>42), 'cp.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1, 'position'=>60), - 'cp.date_approve'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1, 'position'=>70), + 'cp.date_approval'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1, 'position'=>70), 'cp.date_create'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'cp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>501), 'cp.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -271,6 +271,8 @@ $sql .= " cp.statut as status,"; $sql .= " cp.fk_validator,"; $sql .= " cp.date_valid,"; $sql .= " cp.fk_user_valid,"; +$sql .= " cp.date_approval,"; +$sql .= " cp.fk_user_approve,"; $sql .= " cp.date_refuse,"; $sql .= " cp.fk_user_refuse,"; $sql .= " cp.date_cancel,"; @@ -636,12 +638,18 @@ if ($resql) { print ''; } - // End date + // Date validation if (!empty($arrayfields['cp.date_valid']['checked'])) { print ''; print ''; } + // Date appoval + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; + print ''; + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -705,6 +713,9 @@ if ($resql) { if (!empty($arrayfields['cp.date_valid']['checked'])) { print_liste_field_titre($arrayfields['cp.date_valid']['label'], $_SERVER["PHP_SELF"], "cp.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); } + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_approval']['label'], $_SERVER["PHP_SELF"], "cp.date_approval", "", $param, '', $sortfield, $sortorder, 'center '); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -839,18 +850,20 @@ if ($resql) { $totalarray['nbfield']++; } } + // Date validation if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval - print ''; + print ''; print dol_print_date($db->jdate($obj->date_valid), 'day'); print ''; if (!$i) $totalarray['nbfield']++; } - /*if (!empty($arrayfields['cp.date_approve']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_approve), 'day'); - print ''; - if (!$i) $totalarray['nbfield']++; - }*/ + // Date approval + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_approval), 'day'); + print ''; + if (!$i) $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; From 40d18331542e8bfab73006cf5ae3ef6be49cc90e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Oct 2022 12:19:41 +0200 Subject: [PATCH 40/66] Prepare support of --force option on crons --- scripts/cron/cron_run_jobs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index ee866203665..1d95a745e1c 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -164,6 +164,10 @@ $user->getrights(); if (isset($argv[3]) && $argv[3]) { $id = $argv[3]; } +$forcequalified = 0; +if (isset($argv[4]) && $argv[4] == '--force') { + $forcequalified = 1; +} // create a jobs object $object = new Cronjob($db); @@ -313,7 +317,7 @@ exit(0); */ function usage($path, $script_file) { - print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid]\n"; + print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid] [--force]\n"; print "The script return 0 when everything worked successfully.\n"; print "\n"; print "On Linux system, you can have cron jobs ran automatically by adding an entry into cron.\n"; From 41175b73ee05c9c49b27132b02dafa866d483382 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Oct 2022 12:57:14 +0200 Subject: [PATCH 41/66] NEW add option --force on CLI cron_run_jobs.php This allow to execute cron even if date is not yeat reached --- scripts/cron/cron_run_jobs.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 1d95a745e1c..630ae8c9948 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -92,7 +92,7 @@ $hookmanager->initHooks(array('cli')); $now = dol_now(); @set_time_limit(0); -print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=".$userlogin." ***** ".dol_print_date($now, 'dayhourrfc')." *****\n"; +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=".$userlogin." - ".dol_print_date($now, 'dayhourrfc')." *****\n"; // Check module cron is activated if (empty($conf->cron->enabled)) { @@ -250,7 +250,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { } //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database - if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { + if ($forcequalified || (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now))) { echo " - qualified"; dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc')); @@ -325,4 +325,6 @@ function usage($path, $script_file) print "30 3 * * * ".$path.$script_file." securitykey userlogin > ".DOL_DATA_ROOT."/".$script_file.".log\n"; print "For example, to run pending tasks every 5mn, you can add this line:\n"; print "*/5 * * * * ".$path.$script_file." securitykey userlogin > ".DOL_DATA_ROOT."/".$script_file.".log\n"; + print "\n"; + print "The option --force allow to bypass the check on date of execution so job will be executed even if date is not yet reached.\n"; } From d5ad0090a0bb5a204078948e6d11350401d6ddd9 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 29 Oct 2022 17:56:03 +0200 Subject: [PATCH 42/66] sql var not quoted --- htdocs/partnership/partnership_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 0aba38fd7e3..36a0fd39218 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -335,7 +335,7 @@ if ($object->ismultientitymanaged == 1) { } if ($managedfor == 'member') { if ($memberid > 0) { - $sql .= " AND t.fk_member = ".$memberid; + $sql .= " AND t.fk_member = ".((int) $memberid); } else { $sql .= " AND fk_member > 0"; } From 8efaf03ec9526bf3eb84ab1dd6d742e7752fef12 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 29 Oct 2022 21:49:03 +0200 Subject: [PATCH 43/66] FIX - php 8 totalarray --- htdocs/commande/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 455420ce90a..4114f5f4129 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1887,6 +1887,8 @@ if ($resql) { $savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; + $totalarray['val']['c.total_tva'] = 0; + $totalarray['val']['c.total_ttc'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); From 1d08d2c8ab3a32f557a40fd540d6e9762143d18e Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 29 Oct 2022 21:50:06 +0200 Subject: [PATCH 44/66] erreur --- htdocs/commande/list.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4114f5f4129..455420ce90a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1887,8 +1887,6 @@ if ($resql) { $savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; - $totalarray['val']['c.total_tva'] = 0; - $totalarray['val']['c.total_ttc'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); From df2f3b046928de3db14eecbf5d4754146fe59a6e Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 29 Oct 2022 21:50:23 +0200 Subject: [PATCH 45/66] FIX - php 8 totalarray --- htdocs/commande/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 455420ce90a..4114f5f4129 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1887,6 +1887,8 @@ if ($resql) { $savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; + $totalarray['val']['c.total_tva'] = 0; + $totalarray['val']['c.total_ttc'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); From 1c0dd84d6f11de6d9195f9d389e54244bfdda46f Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 29 Oct 2022 21:57:58 +0200 Subject: [PATCH 46/66] OK --- htdocs/commande/list.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4114f5f4129..53e95ff649f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1887,8 +1887,6 @@ if ($resql) { $savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; - $totalarray['val']['c.total_tva'] = 0; - $totalarray['val']['c.total_ttc'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); @@ -2194,7 +2192,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; } - $totalarray['val']['c.total_tva'] += $obj->total_tva; + if (isset($totalarray['val']['c.total_tva'])) { + $totalarray['val']['c.total_tva'] += $obj->total_tva; + } else { + $totalarray['val']['c.total_tva'] = $obj->total_tva; + } } // Amount TTC / gross @@ -2206,7 +2208,11 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; } - $totalarray['val']['c.total_ttc'] += $obj->total_ttc; + if (isset($totalarray['val']['c.total_ttc'])) { + $totalarray['val']['c.total_ttc'] += $obj->total_ttc; + } else { + $totalarray['val']['c.total_ttc'] = $obj->total_ttc; + } } // Currency From d15493e50dbfc8040a6f6cd18aa9413176ced637 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 30 Oct 2022 02:59:11 +0200 Subject: [PATCH 47/66] massacrtion for updating product prices --- htdocs/core/actions_massactions.inc.php | 44 +++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 18 ++++++++++ htdocs/langs/en_US/main.lang | 3 ++ htdocs/langs/en_US/products.lang | 1 + htdocs/langs/fr_FR/main.lang | 5 ++- htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/list.php | 4 +-- 7 files changed, 73 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 49cc6fa873c..7539bb028a4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1240,6 +1240,50 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } } +if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) { + $db->begin(); + if (GETPOSTISSET('pricevariation')) { + $pricepercentage=GETPOST('pricevariation', 'int'); + if ($pricepercentage == 0) { + setEventMessages($langs->trans("RecordsModified", 0), null); + } else { + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + //var_dump($contcats);exit; + if ($result > 0) { + if ($obj->price_base_type == 'TTC') { + $newprice = $object->price_ttc * (100 + $pricepercentage) / 100; + $minprice = $object->price_min_ttc; + } else { + $newprice = $object->price * (100 + $pricepercentage) / 100; + $minprice = $object->price_min; + } + $res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code); + if ($res > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + } + } + + if (!$error) { + if ($nbok > 0) { + setEventMessages($langs->trans("RecordsModified", $nbok), null); + } + $db->commit(); + $toselect=array(); + } else { + $db->rollback(); + } +} + if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) { $db->begin(); $supervisortoset=GETPOST('supervisortoset'); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index f09d7defeb1..74ae317d938 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -78,6 +78,23 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { } } +if ($massaction == 'preupdateprice' && isModEnabled('category')) { + $formquestion = array(); + + $valuefield = '
'; + $valuefield .= '%'; + $valuefield .= '
'; + + $formquestion[] = array( + 'type' => 'other', + 'name' => 'pricevariation', + 'label' => $langs->trans("PriceVariation"), + 'value' => $valuefield + ); + + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUpdatePrice"), $langs->trans("ConfirmUpdatePriceQuestion", count($toselect)), "updateprice", $formquestion, 1, 0, 200, 500, 1); +} + if ($massaction == 'presetsupervisor') { $formquestion = array(); @@ -96,6 +113,7 @@ if ($massaction == 'presetsupervisor') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmSetSupervisor"), $langs->trans("ConfirmSetSupervisorQuestion", count($toselect)), "setsupervisor", $formquestion, 1, 0, 200, 500, 1); } + if ($massaction == 'presend') { $langs->load("mails"); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 325e27b6606..a21d6633718 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1150,9 +1150,12 @@ SetSupervisor=Set Supervisor CreateExternalUser=Create external user ConfirmAffectTag=Bulk Tag Affect ConfirmSetSupervisor=Bulk Supervisor Set +ConfirmUpdatePrice=Choose a price update percentage ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)? +ConfirmUpdatePriceQuestion=Are you sure you want to update the price of the %s selected record(s)? CategTypeNotFound=No tag type found for type of records +PriceVariation=Price variation SupervisorNotFound=Supervisor not found CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index fa2ed9669d9..39f09917d99 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -416,6 +416,7 @@ ProductsMergeSuccess=Products have been merged ErrorsProductsMerge=Errors in products merge SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status +UpdatePrice=Update price StockMouvementExtraFields= Extra Fields (stock mouvement) InventoryExtraFields= Extra Fields (inventory) ScanOrTypeOrCopyPasteYourBarCodes=Scan or type or copy/paste your barcodes diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 2c376c887bf..c51ee2b09fa 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -566,7 +566,7 @@ None=Aucun NoneF=Aucune NoneOrSeveral=Aucun ou plusieurs Late=Retard -LateDesc=Le délai qui définit si un enregistrement est en retard ou non dépend de votre configuration. Demandez à votre administrateur pour changer ce délai depuis Accueil - Configuration - Alertes +LateDesc=Le délai qui définit si un enregistrement est en retard ou non dépend de votre configuration. Demandez à votre administrateur pour changer ce délai depuis Accueil - Configuration - Alertes NoItemLate=Aucun élément en retard Photo=Photo Photos=Photos @@ -1150,9 +1150,12 @@ SetSupervisor=Choisir un superviseur CreateExternalUser=Créer utilisateur externe ConfirmAffectTag=Affecter les tags en masse ConfirmSetSupervisor=Choisir un superviseur en masse +ConfirmUpdatePrice=Choisir un pourcentage de hausse/baisse des prix ConfirmAffectTagQuestion=Êtes-vous sur de vouloir affecter ces catégories aux %s lignes sélectionnées ? ConfirmSetSupervisorQuestion=Êtes-vous sur de vouloir affecter ce superviseur aux %s lignes sélectionnées ? +ConfirmUpdatePriceQuestion=Êtes-vous sur de vouloir mettre à jour les prix des %s lignes sélectionnées ? CategTypeNotFound=Aucun type de tag trouvé pour ce type d'enregistrements +PriceVariation=Variation de prix SupervisorNotFound=Supervisuer non trouvé CopiedToClipboard=Copié dans le presse-papier InformationOnLinkToContract=Ce montant n’est que le total de toutes les lignes du contrat. Aucune notion de temps n’est prise en considération. diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 9061f0498fc..4a679dc4bd6 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -416,6 +416,7 @@ ProductsMergeSuccess=Produits fusionnés ErrorsProductsMerge=Erreur lors de la fusion des produits SwitchOnSaleStatus=Basculer le statut En vente SwitchOnPurchaseStatus=Basculer le statut En achat +UpdatePrice=Mettre à jour le prix StockMouvementExtraFields= Champs supplémentaires (mouvement de stock) InventoryExtraFields= Attributs supplémentaires (inventaire) ScanOrTypeOrCopyPasteYourBarCodes=Scannez ou tapez ou copiez/collez vos codes-barres diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 26f6a3a410c..76fba05b5a7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -310,7 +310,6 @@ if (GETPOST('cancel', 'alpha')) { if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } - $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -737,11 +736,12 @@ if ($resql) { if ($user->rights->{$rightskey}->creer) { $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus"); $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); + $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); } if (isModEnabled('category') && $user->rights->{$rightskey}->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } - if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) { + if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 71e55ab7097dcc3df3ab4f5a1724a3497b02442d Mon Sep 17 00:00:00 2001 From: Faustin Date: Sun, 30 Oct 2022 02:37:56 +0100 Subject: [PATCH 48/66] Translation update --- htdocs/core/actions_massactions.inc.php | 4 ++-- htdocs/core/tpl/massactions_pre.tpl.php | 6 +++--- htdocs/langs/en_US/main.lang | 4 ++-- htdocs/langs/en_US/products.lang | 2 +- htdocs/langs/fr_FR/main.lang | 2 +- htdocs/langs/fr_FR/products.lang | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7539bb028a4..02d4215b963 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1242,8 +1242,8 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) { $db->begin(); - if (GETPOSTISSET('pricevariation')) { - $pricepercentage=GETPOST('pricevariation', 'int'); + if (GETPOSTISSET('pricerate')) { + $pricepercentage=GETPOST('pricerate', 'int'); if ($pricepercentage == 0) { setEventMessages($langs->trans("RecordsModified", 0), null); } else { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 74ae317d938..1e48fc4d5a0 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -82,13 +82,13 @@ if ($massaction == 'preupdateprice' && isModEnabled('category')) { $formquestion = array(); $valuefield = '
'; - $valuefield .= '%'; + $valuefield .= '%'; $valuefield .= '
'; $formquestion[] = array( 'type' => 'other', - 'name' => 'pricevariation', - 'label' => $langs->trans("PriceVariation"), + 'name' => 'pricerate', + 'label' => $langs->trans("Rate"), 'value' => $valuefield ); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a21d6633718..6f849e39be1 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1150,12 +1150,12 @@ SetSupervisor=Set Supervisor CreateExternalUser=Create external user ConfirmAffectTag=Bulk Tag Affect ConfirmSetSupervisor=Bulk Supervisor Set -ConfirmUpdatePrice=Choose a price update percentage +ConfirmUpdatePrice=Choose a increase/decrease price rate ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)? ConfirmUpdatePriceQuestion=Are you sure you want to update the price of the %s selected record(s)? CategTypeNotFound=No tag type found for type of records -PriceVariation=Price variation +Rate=Rate SupervisorNotFound=Supervisor not found CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 39f09917d99..3d5048d99a9 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -416,7 +416,7 @@ ProductsMergeSuccess=Products have been merged ErrorsProductsMerge=Errors in products merge SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status -UpdatePrice=Update price +UpdatePrice=Increase/decrease customer price StockMouvementExtraFields= Extra Fields (stock mouvement) InventoryExtraFields= Extra Fields (inventory) ScanOrTypeOrCopyPasteYourBarCodes=Scan or type or copy/paste your barcodes diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index c51ee2b09fa..39d857ae0e8 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -1155,7 +1155,7 @@ ConfirmAffectTagQuestion=Êtes-vous sur de vouloir affecter ces catégories aux ConfirmSetSupervisorQuestion=Êtes-vous sur de vouloir affecter ce superviseur aux %s lignes sélectionnées ? ConfirmUpdatePriceQuestion=Êtes-vous sur de vouloir mettre à jour les prix des %s lignes sélectionnées ? CategTypeNotFound=Aucun type de tag trouvé pour ce type d'enregistrements -PriceVariation=Variation de prix +Rate=Taux SupervisorNotFound=Supervisuer non trouvé CopiedToClipboard=Copié dans le presse-papier InformationOnLinkToContract=Ce montant n’est que le total de toutes les lignes du contrat. Aucune notion de temps n’est prise en considération. diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 4a679dc4bd6..2592548059c 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -416,7 +416,7 @@ ProductsMergeSuccess=Produits fusionnés ErrorsProductsMerge=Erreur lors de la fusion des produits SwitchOnSaleStatus=Basculer le statut En vente SwitchOnPurchaseStatus=Basculer le statut En achat -UpdatePrice=Mettre à jour le prix +UpdatePrice=Augmenter/baisser le prix de vente StockMouvementExtraFields= Champs supplémentaires (mouvement de stock) InventoryExtraFields= Attributs supplémentaires (inventaire) ScanOrTypeOrCopyPasteYourBarCodes=Scannez ou tapez ou copiez/collez vos codes-barres From ebcaa34134ca5d73f957a156f504cdc0b3f9a2fd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 30 Oct 2022 16:42:54 +0100 Subject: [PATCH 49/66] NEw translation for shipping method API cf https://github.com/Dolibarr/dolibarr/pull/22699 --- htdocs/api/class/api_setup.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 406172590d7..54f08cb1df3 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1188,6 +1188,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number {@min 0} * @param int $active Shipping methodsm is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the method must be translated to * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" * * @url GET dictionary/shipping_methods @@ -1196,7 +1197,7 @@ class Setup extends DolibarrApi * * @throws RestException 400 */ - public function getShippingModes($limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') { $list = array(); @@ -1232,7 +1233,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $method = $this->db->fetch_object($result); + $this->translateLabel($method, $lang, '', array('dict')); + $list[] = $method; } } else { throw new RestException(400, $this->db->lasterror()); From 55d233e2da43880acfe3806938c56601676e80a2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 30 Oct 2022 17:19:32 +0100 Subject: [PATCH 50/66] NEW translate for contact type API cf #22699 --- htdocs/api/class/api_setup.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 406172590d7..aa05b5fc588 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -779,6 +779,7 @@ class Setup extends DolibarrApi * @param string $type To filter on type of contact * @param string $module To filter on module contacts * @param int $active Contact's type is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the civility must be translated to * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return array List of Contacts types * @@ -786,7 +787,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') + public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang ='', $sqlfilters = '') { $list = array(); @@ -827,7 +828,9 @@ class Setup extends DolibarrApi $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); + $contact_type = $this->db->fetch_object($result); + $this->translateLabel($contact_type, $lang, 'TypeContact_'.$contact_type->type.'_'.$contact_type->source.'_', array("eventorganization", "resource", "projects", "contracts", "bills", "orders", "agenda", "propal", "stocks", "supplier_proposal", "interventions", "sendings", "ticket")); + $list[] = $contact_type; } } else { throw new RestException(503, 'Error when retrieving list of contacts types : '.$this->db->lasterror()); From 82da70841fe8b293a4ee9734aafd6cd2200d33b5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 30 Oct 2022 16:20:15 +0000 Subject: [PATCH 51/66] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index aa05b5fc588..c671053f84f 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -787,7 +787,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang ='', $sqlfilters = '') + public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang = '', $sqlfilters = '') { $list = array(); From 39f7b8399d575855ce40b407ce6270d6496f30c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Oct 2022 19:06:26 +0100 Subject: [PATCH 52/66] css --- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index c70416fec6e..e361941b704 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -68,9 +68,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } print ''; print ''.$objectlink->getNomUrl(1).''; - print ''.$objectlink->ref_client.''; + print ''.dol_escape_htmltag($objectlink->ref_client).''; print ''.dol_print_date($objectlink->date, 'day').''; - print ''; + print ''; if (!empty($objectlink) && $objectlink->element == 'facture' && $user->hasRight('facture', 'lire')) { $sign = 1; if ($objectlink->type == Facture::TYPE_CREDIT_NOTE) { From b616a1eccbee06594c6a81827d81406340cb6320 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Oct 2022 19:08:54 +0100 Subject: [PATCH 53/66] css --- htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index d7e68e274fa..1bca663e1ef 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?> trans("RepeatableInvoice"); ?> - getNomUrl(1); ?> + getNomUrl(1); ?> date_when, 'day'); ?> Date: Mon, 31 Oct 2022 08:13:11 +0100 Subject: [PATCH 54/66] Debug v17 - use of 'mode' for user list and filter on categories --- ChangeLog | 6 +- htdocs/adherents/list.php | 6 +- htdocs/compta/bank/list.php | 6 +- htdocs/compta/facture/list.php | 12 +++- htdocs/contact/list.php | 18 +++++- htdocs/core/class/html.formcategory.class.php | 16 +++-- htdocs/core/class/html.formother.class.php | 4 +- htdocs/core/menus/init_menu_auguria.sql | 4 +- htdocs/core/menus/standard/eldy.lib.php | 4 +- htdocs/fourn/facture/list.php | 14 ++++- .../knowledgerecord_list.php | 6 +- htdocs/product/inventory/list.php | 55 ++++++---------- htdocs/product/list.php | 19 +++--- htdocs/product/stock/list.php | 6 +- htdocs/projet/list.php | 6 +- htdocs/projet/tasks/list.php | 6 +- htdocs/societe/list.php | 12 +++- htdocs/user/hierarchy.php | 34 +++++++--- htdocs/user/list.php | 62 +++++++++++-------- 19 files changed, 187 insertions(+), 109 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9432bdea4d7..18e2b1cdc72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + ***** ChangeLog for 17.0.0 compared to 16.0.0 ***** For users: @@ -25,9 +26,10 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product * Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead. -* All functions fetch_all() are deprecated for naming consitency, use fetchAll() instead -* Code standardization: $user->rights->propale is now $user->rights->propal everywhere. +* All functions fetch_all() have been set to deprecated for naming consitency, use fetchAll() instead. +* Code standardization: '$user->rights->propale' is now '$user->rights->propal' everywhere. * Deprecated method set_billed() on shipment and reception class has been removed. Use setBilled() instead. +* Tables llx_prelevement_facture and llx_prelevement_facture_demande have been renamed into llx_prelevement and llx_prelevement_demande. ***** ChangeLog for 16.0.1 compared to 16.0.0 ***** diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 4b3a5cdb82c..394a650d7ee 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -370,7 +370,11 @@ if (!empty($searchCategoryContactList)) { if (intval($searchCategoryContact) == -2) { $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member)"; } elseif (intval($searchCategoryContact) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + if ($searchCategoryContactOperator == 0) { + $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie = ".((int) $searchCategoryContact).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + } } } if ($listofcategoryid) { diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 1f4fc60397e..54cd0f2b58c 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -222,7 +222,11 @@ if (!empty($searchCategoryBankList)) { if (intval($searchCategoryBank) == -2) { $searchCategoryBankSqlList[] = "NOT EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account)"; } elseif (intval($searchCategoryBank) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank); + if ($searchCategoryBankOperator == 0) { + $searchCategoryBankSqlList[] = " EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account AND ck.fk_categorie = ".((int) $searchCategoryBank).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank); + } } } if ($listofcategoryid) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 11fdb6ac982..fb7616e8ab3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -813,7 +813,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { @@ -839,7 +843,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e8396a4299c..ae5deba98f1 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -438,7 +438,11 @@ if (!empty($searchCategoryContactList)) { if (intval($searchCategoryContact) == -2) { $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople)"; } elseif (intval($searchCategoryContact) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + if ($searchCategoryContactOperator == 0) { + $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + } } } if ($listofcategoryid) { @@ -464,7 +468,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { @@ -490,7 +498,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index c0e07b6bb7a..bd2315645db 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -32,11 +32,13 @@ class FormCategory extends Form /** * Return a HTML filter box for a list filter view * - * @param string $type The categorie type (e.g Categorie::TYPE_WAREHOUSE) - * @param Array $preSelected A list with the elements that should pre-selected - * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) + * @param string $type The categorie type (e.g Categorie::TYPE_WAREHOUSE) + * @param array $preSelected A list with the elements that should pre-selected + * @param string $morecss More CSS + * @param int $searchCategoryProductOperator 0 or 1 to enable the checkbox to search with a or (0=not preseleted, 1=preselected) + * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) */ - public function getFilterBox($type, array $preSelected) + public function getFilterBox($type, array $preSelected, $morecss = "minwidth300 widthcentpercentminusx", $searchCategoryProductOperator = -1) { global $langs; @@ -45,6 +47,7 @@ class FormCategory extends Form } $htmlName = "search_category_".$type."_list"; + $htmlName2 = "search_category_".$type."_operator"; $categoryArray = $this->select_all_categories($type, "", "", 64, 0, 1); $categoryArray[-2] = "- ".$langs->trans('NotCategorized')." -"; @@ -55,7 +58,10 @@ class FormCategory extends Form $filter .= '
'; $filter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); //$filter .= $langs->trans('Categories').": "; - $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300 widthcentpercentminusx", 0, 0, '', '', $tmptitle); + $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, $morecss, 0, 0, '', '', $tmptitle); + if ($searchCategoryProductOperator >= 0) { + $filter .= ' '; + } $filter .= "
"; return $filter; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 103b370dcb0..7e14474bc96 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -429,8 +429,7 @@ class FormOther if (!is_numeric($showempty)) { $textforempty = $showempty; } - $moreforfilter .= ''."\n"; - //$moreforfilter .= ''; // Should use -1 to say nothing + $moreforfilter .= ''."\n"; } if (is_array($tab_categs)) { @@ -439,6 +438,7 @@ class FormOther if ($categ['id'] == $selected) { $moreforfilter .= ' selected'; } + $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category', 'class="pictofixedwidth" style="color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel'], 50, 'middle')).'"'; $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').''; } } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 10c50ca99ee..d6945d26fd5 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -473,9 +473,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- HRM - Employee -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->user->user->creer', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); -- HRM - Holiday insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4a6636942c4..22613a331b7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2251,9 +2251,9 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if (isModEnabled('hrm')) { $langs->load("hrm"); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write')); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ddc4036e91b..709204793e9 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -594,7 +594,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { @@ -612,7 +616,7 @@ if (!empty($searchCategorySupplierList)) { } // Search for tag/category ($searchCategoryProductList is an array of ID) $searchCategoryProductList = $search_product_category ? array($search_product_category) : array(); -$searchCategorySupplierOperator = 0; +$searchCategoryProductOperator = 0; if (!empty($searchCategoryProductList)) { $searchCategoryProductSqlList = array(); $listofcategoryid = ''; @@ -620,7 +624,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 217c7c71468..c8df2018ae7 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -293,7 +293,11 @@ if (!empty($searchCategoryKnowledgemanagementList)) { if (intval($searchCategoryKnowledgemanagement) == -2) { $searchCategoryKnowledgemanagementSqlList[] = "NOT EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement)"; } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); + if ($searchCategoryKnowledgemanagementOperator == 0) { + $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie = ".((int) $searchCategoryKnowledgemanagement).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); + } } } if ($listofcategoryid) { diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index d9ed8a37c5e..18104118068 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -270,49 +270,32 @@ foreach ($search as $key => $val) { if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -// Search for tag/category -$searchCategoryProductSqlList = array(); -if ($searchCategoryProductOperator == 1) { - $existsCategoryProductList = array(); +// Search for tag/category ($searchCategoryProductList is an array of ID) +if (!empty($searchCategoryProductList)) { + $searchCategoryProductSqlList = array(); + $listofcategoryid = ''; foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { - $sqlCategoryProductNotExists = " NOT EXISTS ("; - $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; - $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductNotExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; + $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $existsCategoryProductList[] = $db->escape($searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } - if (!empty($existsCategoryProductList)) { - $sqlCategoryProductExists = " EXISTS ("; - $sqlCategoryProductExists .= " SELECT cp.fk_product"; - $sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryProductList)).")"; - $sqlCategoryProductExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductExists; + if ($listofcategoryid) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; - } -} else { - foreach ($searchCategoryProductList as $searchCategoryProduct) { - if (intval($searchCategoryProduct) == -2) { - $sqlCategoryProductNotExists = " NOT EXISTS ("; - $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; - $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductNotExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; - } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "t.fk_product IN (SELECT fk_product FROM ".$db->prefix()."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; + if ($searchCategoryProductOperator == 1) { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } + } else { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } - } - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } } // Add where from extra fields diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 26f6a3a410c..55c5dc396b2 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -45,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (isModEnabled('categorie')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; } // Load translation files required by the page @@ -72,7 +73,7 @@ $search_type = GETPOST("search_type", 'int'); $search_vatrate = GETPOST("search_vatrate", 'alpha'); $searchCategoryProductOperator = 0; if (GETPOSTISSET('formfilteraction')) { - $searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int'); + $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator'); } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) { $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; } @@ -508,7 +509,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { @@ -554,7 +559,6 @@ if ($search_accountancy_code_buy_intra) { if ($search_accountancy_code_buy_export) { $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); } - // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -820,13 +824,8 @@ if ($resql) { // Filter on categories $moreforfilter = ''; if (isModEnabled('categorie') && $user->rights->categorie->lire) { - $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); - $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; - $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); - $moreforfilter .= ' '; - $moreforfilter .= '
'; + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $searchCategoryProductList, 'minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0); } //Show/hide child products. Hidden by default diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index af2bb49b05e..b0c33e61484 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -270,7 +270,11 @@ if (!empty($searchCategoryWarehouseList)) { if (intval($searchCategoryWarehouse) == -2) { $searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)"; } elseif (intval($searchCategoryWarehouse) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); + if ($searchCategoryWarehouseOperator == 0) { + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); + } } } if ($listofcategoryid) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 696888a75dd..9ef64174325 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -570,7 +570,11 @@ if (!empty($searchCategoryProjectList)) { if (intval($searchCategoryProject) == -2) { $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)"; } elseif (intval($searchCategoryProject) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + if ($searchCategoryProjectOperator == 0) { + $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + } } } if ($listofcategoryid) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 76261480ffe..fdec5c6a958 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -444,7 +444,11 @@ if (!empty($searchCategoryProjectList)) { if (intval($searchCategoryProject) == -2) { $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)"; } elseif (intval($searchCategoryProject) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + if ($searchCategoryProjectOperator == 0) { + $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + } } } if ($listofcategoryid) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f32317163ad..c0f50a5e7b0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -536,7 +536,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { @@ -562,7 +566,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index c48eda2312e..44ab46193d9 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; // Load translation files required by page -$langs->loadLangs(array('users', 'companies')); +$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries')); // Security check (for external users) $socid = 0; @@ -40,16 +40,15 @@ if ($user->socid > 0) { } $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('optioncss', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search +$mode = GETPOST("mode", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -// Load mode employee -$mode = GETPOST("mode", 'alpha'); $search_statut = GETPOST('search_statut', 'int'); - if ($search_statut == '' || $search_statut == '0') { $search_statut = '1'; } @@ -58,18 +57,30 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_statut = ""; } +if ($contextpage == 'employeelist') { + $search_employee = 1; +} + $userstatic = new User($db); // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); -if (!$user->hasRight("user", "user", "read") && !$user->admin) { - accessforbidden(); +// Permission to list +if ($contextpage == 'employeelist' && $search_employee == 1) { + if (!$user->hasRight("salaries", "read")) { + accessforbidden(); + } +} else { + if (!$user->hasRight("user", "user", "read") && empty($user->admin)) { + accessforbidden(); + } } $childids = $user->getAllChildIds(1); + /* * View */ @@ -77,7 +88,11 @@ $childids = $user->getAllChildIds(1); $form = new Form($db); $help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer'; -$title = $langs->trans("Users"); +if ($contextpage == 'employeelist' && $search_employee == 1) { + $title = $langs->trans("Employees"); +} else { + $title = $langs->trans("Users"); +} $arrayofjs = array( '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', @@ -152,6 +167,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { //var_dump($data); $param = "&search_statut=".urlencode($search_statut); + $param = "&contextpage=".urlencode($contextpage); $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 05d2f88c035..dacf572d175 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -41,9 +41,10 @@ $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST("mode", 'alpha'); // Security check (for external users) $socid = 0; @@ -51,9 +52,6 @@ if ($user->socid > 0) { $socid = $user->socid; } -// Load mode employee -$mode = GETPOST("mode", 'alpha'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -125,7 +123,7 @@ $arrayfields = array( 'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20), 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22), - 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25), + 'u.employee'=>array('label'=>"Employee", 'checked'=>($contextpage == 'employeelist' ? 1 : 0), 'position'=>25), 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27), 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30), 'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31), @@ -164,6 +162,17 @@ $search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_warehouse = GETPOST('search_warehouse', 'alpha'); $search_supervisor = GETPOST('search_supervisor', 'intcomma'); $search_categ = GETPOST("search_categ", 'int'); +$searchCategoryUserOperator = 0; +if (GETPOSTISSET('formfilteraction')) { + $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator'); +} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) { + $searchCategoryUserOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; +} +$searchCategoryUserList = GETPOST('search_category_user_list', 'array'); +$catid = GETPOST('catid', 'int'); +if (!empty($catid) && empty($searchCategoryUserList)) { + $searchCategoryUserList = array($catid); +} $catid = GETPOST('catid', 'int'); if (!empty($catid) && empty($search_categ)) { $search_categ = $catid; @@ -173,7 +182,7 @@ if (!empty($catid) && empty($search_categ)) { if ($search_statut == '') { $search_statut = '1'; } -if ($mode == 'employee' && !GETPOSTISSET('search_employee')) { +if ($contextpage == 'employeelist' && !GETPOSTISSET('search_employee')) { $search_employee = 1; } @@ -192,7 +201,7 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $error = 0; // Permission to list -if ($mode == 'employee') { +if ($contextpage == 'employeelist' && $search_employee == 1) { if (!$user->hasRight("salaries", "read")) { accessforbidden(); } @@ -428,35 +437,39 @@ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -// Search for tag/category ($searchCategoryProductList is an array of ID) -$searchCategoryProductList = array($search_categ); -if (!empty($searchCategoryProductList)) { - $searchCategoryProductSqlList = array(); +// Search for tag/category ($searchCategoryUserList is an array of ID) +$searchCategoryUserList = array($search_categ); +if (!empty($searchCategoryUserList)) { + $searchCategoryUserSqlList = array(); $listofcategoryid = ''; - foreach ($searchCategoryProductList as $searchCategoryProduct) { - if (intval($searchCategoryProduct) == -2) { - $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)"; - } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + foreach ($searchCategoryUserList as $searchCategoryUser) { + if (intval($searchCategoryUser) == -2) { + $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)"; + } elseif (intval($searchCategoryUser) > 0) { + if ($searchCategoryUserOperator == 0) { + $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie = ".((int) $searchCategoryUser).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser); + } } } if ($listofcategoryid) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } - if ($searchCategoryProductOperator == 1) { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + if ($searchCategoryUserOperator == 1) { + if (!empty($searchCategoryUserSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")"; } } else { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; + if (!empty($searchCategoryUserSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")"; } } } if ($search_warehouse > 0) { $sql .= " AND u.fk_warehouse = ".((int) $search_warehouse); } -if ($mode == 'employee' && !$user->hasRight("salaries", "readall")) { +if ($contextpage == 'employeelist' && !$user->hasRight("salaries", "readall")) { $sql .= " AND u.rowid IN (".$db->sanitize(join(',', $childids)).")"; } // Add where from extra fields @@ -523,7 +536,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -$title = $langs->trans("ListOfUsers"); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); @@ -626,7 +638,7 @@ print ''; print ''; print ''; -$url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu='; +$url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu='; if (!empty($socid)) { $url .= '&socid='.urlencode($socid); } From 840428200c77dde31a98c79d5c503428b520d906 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Oct 2022 08:27:25 +0100 Subject: [PATCH 55/66] Add fields to allow SEPA payments of salaries --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_prelevement.sql | 4 ++-- htdocs/install/mysql/tables/llx_prelevement_demande.sql | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index ce81740b50d..119dda91a2e 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -366,3 +366,5 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_prelevement_facture RENAME TO llx_prelevement; ALTER TABLE llx_prelevement_facture_demande RENAME TO llx_prelevement_demande; +ALTER TABLE llx_prelevement ADD COLUMN fk_salary INTEGER NULL AFTER fk_facture_fourn; +ALTER TABLE llx_prelevement_demande ADD COLUMN fk_salary INTEGER NULL AFTER fk_facture_fourn; diff --git a/htdocs/install/mysql/tables/llx_prelevement.sql b/htdocs/install/mysql/tables/llx_prelevement.sql index b1fd80ef78b..597cdb4a79f 100644 --- a/htdocs/install/mysql/tables/llx_prelevement.sql +++ b/htdocs/install/mysql/tables/llx_prelevement.sql @@ -20,7 +20,7 @@ create table llx_prelevement ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NULL, - fk_facture_fourn integer NULL, + fk_facture_fourn integer NULL, + fk_salary integer NULL, fk_prelevement_lignes integer NOT NULL - )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_prelevement_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_demande.sql index bfad4d7fa6a..b0b1b87f77f 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_demande.sql @@ -23,6 +23,7 @@ create table llx_prelevement_demande entity integer DEFAULT 1 NOT NULL, fk_facture integer NULL, fk_facture_fourn integer NULL, + fk_salary integer NULL, sourcetype varchar(32), amount double(24,8) NOT NULL, date_demande datetime NOT NULL, From 754881a6efe9f3e29a4f6b3fca5c8c24de0e7554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 31 Oct 2022 10:42:40 +0100 Subject: [PATCH 56/66] strftime is deprecated in php 8.1 --- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 2 +- htdocs/adherents/stats/index.php | 2 +- htdocs/comm/propal/stats/index.php | 2 +- htdocs/commande/stats/index.php | 2 +- htdocs/compta/deplacement/stats/index.php | 2 +- htdocs/compta/facture/stats/index.php | 2 +- htdocs/compta/journal/purchasesjournal.php | 2 +- htdocs/compta/journal/sellsjournal.php | 2 +- htdocs/compta/localtax/clients.php | 2 +- htdocs/compta/localtax/index.php | 2 +- htdocs/compta/localtax/quadri_detail.php | 2 +- htdocs/compta/resultat/result.php | 2 +- htdocs/compta/stats/index.php | 2 +- htdocs/compta/stats/supplier_turnover.php | 2 +- htdocs/core/lib/accounting.lib.php | 4 ++-- htdocs/don/stats/index.php | 2 +- htdocs/expensereport/stats/index.php | 2 +- htdocs/fichinter/stats/index.php | 2 +- htdocs/product/stock/fiche-valo.php | 2 +- htdocs/product/stock/valo.php | 2 +- htdocs/projet/stats/index.php | 2 +- htdocs/projet/tasks/stats/index.php | 2 +- htdocs/reception/stats/index.php | 2 +- htdocs/salaries/card.php | 2 +- htdocs/salaries/stats/index.php | 2 +- htdocs/ticket/stats/index.php | 2 +- scripts/accountancy/export-thirdpartyaccount.php | 2 +- 28 files changed, 29 insertions(+), 29 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index f632a1ea9c7..1d0f0d92c16 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -40,7 +40,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = strftime("%Y", time()); +$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index bb65a1047a8..e7195d4ee30 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -42,7 +42,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = strftime("%Y", time()); +$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 11447dcd8bb..30b79f4bd76 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -47,7 +47,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = strftime("%Y", time()); +$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 9e2e485c92a..db85490e1bb 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -52,7 +52,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 15642da2d39..9052ed7ab27 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -65,7 +65,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 50848654a71..1bf7706bf87 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -62,7 +62,7 @@ if ($userid > 0) { } } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 7bb430489b2..760a0eca4c8 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -64,7 +64,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 28eee624db2..e71a85004d1 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -74,7 +74,7 @@ llxHeader('', $langs->trans("PurchasesJournal"), '', '', 0, 0, '', '', $morequer $form = new Form($db); -$year_current = strftime("%Y", dol_now()); +$year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index d704e09ad68..0fc5a192271 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -77,7 +77,7 @@ $morequery = '&date_startyear='.$date_startyear.'&date_startmonth='.$date_startm llxHeader('', $langs->trans("SellsJournal"), '', '', 0, 0, '', '', $morequery); -$year_current = strftime("%Y", dol_now()); +$year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 7f8e181f121..d5aef47c285 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -39,7 +39,7 @@ $local = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year_start = $year_current; } else { $year_current = $year; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index e9aab173337..ad0b86a161d 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -38,7 +38,7 @@ $localTaxType = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year_start = $year_current; } else { $year_current = $year; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 9e03f156848..66c58580df6 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -49,7 +49,7 @@ $local = GETPOST('localTaxType', 'int'); // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year_start = $year_current; } else { $year_current = $year; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 15c369b7a52..3f3e14e2d61 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -59,7 +59,7 @@ $nbofyear = 1; // Date range $year = GETPOST('year', 'int'); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $month_current = strftime("%m", dol_now()); $year_start = $year_current - ($nbofyear - 1); } else { diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 8e20f5b0afd..4d65c201ffd 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -371,7 +371,7 @@ print ''; $now_show_delta = 0; $minyear = substr($minyearmonth, 0, 4); $maxyear = substr($maxyearmonth, 0, 4); -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $nowyearmonth = strftime("%Y-%m", dol_now()); $maxyearmonth = max($maxyearmonth, $nowyearmonth); $now = dol_now(); diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index 53446163183..88e04e89303 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -310,7 +310,7 @@ print ''; $now_show_delta = 0; $minyear = substr($minyearmonth, 0, 4); $maxyear = substr($maxyearmonth, 0, 4); -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $nowyearmonth = strftime("%Y-%m", dol_now()); $maxyearmonth = max($maxyearmonth, $nowyearmonth); $now = dol_now(); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 4dbdd9f5be8..7d4483de6cf 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -304,7 +304,7 @@ function getDefaultDatesForTransfer() $date_end = dol_get_last_day($year_end, $month_end); } } elseif ($periodbydefaultontransfer == 1) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $pastmonth = strftime("%m", dol_now()); $pastmonthyear = $year_current; if ($pastmonth == 0) { @@ -312,7 +312,7 @@ function getDefaultDatesForTransfer() $pastmonthyear--; } } else { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 4109c30d335..e9c2b82ae22 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -41,7 +41,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b4d11320411..e9fdd03a2be 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -54,7 +54,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'expensereport', $id, ''); -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index f1ab4b08fec..162afb68077 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -43,7 +43,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index b4277e559b1..0e3f9367e16 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -106,7 +106,7 @@ if ($id > 0) { /* ************************************************************************** */ print "
\n"; - $year = strftime("%Y", time()); + $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png'; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 6bf59ebeb0e..af98ee98540 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -52,7 +52,7 @@ if ($page < 0) { $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -$year = strftime("%Y", time()); +$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); /* diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index ba293dea744..32498121045 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -41,7 +41,7 @@ if ($user->socid > 0) { $action = ''; $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index dd807b7bb93..07b0199d480 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -44,7 +44,7 @@ if ($user->socid > 0) { $action = ''; $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index b1f5dbdc7f9..1e26bf5871a 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -36,7 +36,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 9ee2e52a226..5ba1b818137 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -459,7 +459,7 @@ if ($id > 0) { // Create if ($action == 'create') { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index 4dfd0c84e0c..ba5d254f22b 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -51,7 +51,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'salaries', '', '', ''); -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 52965da8182..7e94af1a431 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -45,7 +45,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -$nowyear = strftime("%Y", dol_now()); +$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index a8a4363ba5c..d7793c3ced1 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -45,7 +45,7 @@ if (!$user->admin) { // Date range $year = GETPOST("year"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $month_current = strftime("%m", dol_now()); $year_start = $year_current; } else { From 88152eccda95c3c8f2ad9941e1e389c116399b03 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 31 Oct 2022 12:30:01 +0100 Subject: [PATCH 57/66] NEW add constant PROPAL_BYPASS_VALIDATED_STATUS --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 0d560d741ce..07a950c5d5e 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -462,7 +462,7 @@ if ($action == "nosign" && $permissiontoclose) { $error = 0; foreach ($toselect as $checked) { if ($tmpproposal->fetch($checked) > 0) { - if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { + if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED || !empty($conf->global->PROPAL_BYPASS_VALIDATED_STATUS)) { $tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED; if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); From 1e76422a500075a84aadcf159300bd8c966e3bd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Oct 2022 13:00:41 +0100 Subject: [PATCH 58/66] NEW Show picto and color into combo for selection of tags --- htdocs/categories/class/categorie.class.php | 1 + htdocs/comm/propal/list.php | 13 +++--- htdocs/core/class/html.form.class.php | 41 +++++++++++++------ htdocs/core/class/html.formcategory.class.php | 38 ++++++++++++----- htdocs/product/list.php | 2 +- 5 files changed, 66 insertions(+), 29 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d9a7eb4b1c7..b5719d388f3 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1152,6 +1152,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['color'] = $obj->color; $this->cats[$obj->rowid]['visible'] = $obj->visible; $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; + $this->cats[$obj->rowid]['picto'] = 'category'; $i++; } } else { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 0d560d741ce..8b057a6c702 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -50,6 +50,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (isModEnabled('categorie')) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); @@ -1080,13 +1084,12 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view products - if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'read') && ($user->rights->produit->lire || $user->rights->service->lire)) { + $searchCategoryProductOperator = -1; include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, (empty($conf->dol_optimize_smallscreen) ? 'maxwidth300 widthcentpercentminusx' : 'maxwidth250 widthcentpercentminusx'), 1); - $moreforfilter .= '
'; + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, array($search_product_category), 'maxwidth300', $searchCategoryProductOperator, 0, 0, $tmptitle); } if (isModEnabled('categorie') && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b104509a0c8..32f2fb9cde4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4859,7 +4859,7 @@ class Form * - int (id of category) * - string (categories ids seprated by comma) * - array (list of categories ids) - * @param int $outputmode 0=HTML select string, 1=Array + * @param int $outputmode 0=HTML select string, 1=Array, 2=Array extended * @param int $include [=0] Removed or 1=Keep only * @param string $morecss More CSS * @return string|array @@ -4892,7 +4892,7 @@ class Form while ($i < $num) { $objp = $this->db->fetch_object($result); if ($objp) { - $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label); + $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label, 'color'=>'', 'picto'=>'category'); } $i++; } @@ -4905,8 +4905,9 @@ class Form $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); } - $output = ''; if (is_array($cate_arbo)) { if (!count($cate_arbo)) { $output .= ''; @@ -4918,7 +4919,11 @@ class Form } else { $add = ''; } - $output .= ''; + $output .= '