From ba8f91f3557ae9a7b41aedf70ea96c82743ce3fb Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Mon, 6 Mar 2023 11:43:01 +0100 Subject: [PATCH 1/9] added an option to controle if we want to show the progress bar in the public interface --- htdocs/admin/ticket_public.php | 14 ++++++++++++++ htdocs/langs/en_US/ticket.lang | 2 ++ htdocs/public/ticket/list.php | 12 ++++++++---- htdocs/public/ticket/view.php | 8 +++++--- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index a1bf95d819f..1d6a83fa5f0 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -379,6 +379,20 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print ''; + // Show progression + print ''.$langs->trans("TicketsShowProgression").''; + print ''; + if (empty(getDolGlobalInt('TICKET_SHOW_PROGRESSION'))) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + } else { + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + } + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowProgressionHelp"), 1, 'help'); + print ''; + print ''; + // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 570e7c127aa..cb261bbc378 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -103,6 +103,8 @@ TicketNewEmailBodyHelp=The text specified here will be inserted into the email c TicketParamPublicInterface=Public interface setup TicketsEmailMustExist=Require an existing email address to create a ticket TicketsEmailMustExistHelp=In the public interface, the email address should already be filled in the database to create a new ticket. +TicketsShowProgression=Display the ticket progress in the public interface +TicketsShowProgressionHelp=Enable this option to hide the progress of the ticket in the public interface pages TicketCreateThirdPartyWithContactIfNotExist=Ask name and company name for unknown emails. TicketCreateThirdPartyWithContactIfNotExistHelp=Check if a thirdparty or a contact exists for the email entered. If not, ask a name and a company name to create a third party with contact. PublicInterface=Public interface diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index aafea0365e0..7fdefb5b7fb 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -257,6 +257,9 @@ if ($action == "view_ticketlist") { //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2) //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); + + if (empty($conf->global->TICKET_SHOW_PROGRESSION)) + unset($arrayfields['t.progress']); // Extra fields if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { @@ -341,7 +344,8 @@ if ($action == "view_ticketlist") { $sql .= " t.message,"; $sql .= " t.fk_statut,"; $sql .= " t.resolution,"; - $sql .= " t.progress,"; + if (!empty($conf->global->TICKET_SHOW_PROGRESSION)) + $sql .= " t.progress,"; $sql .= " t.timing,"; $sql .= " t.type_code,"; $sql .= " t.category_code,"; @@ -470,7 +474,7 @@ if ($action == "view_ticketlist") { print ''; } - if (!empty($arrayfields['t.progress']['checked'])) { + if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -535,7 +539,7 @@ if ($action == "view_ticketlist") { if (!empty($arrayfields['severity.code']['checked'])) { print_liste_field_titre($arrayfields['severity.code']['label'], $url_page_current, 'severity.code', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['t.progress']['checked'])) { + if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) { print_liste_field_titre($arrayfields['t.progress']['label'], $url_page_current, 't.progress', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['t.fk_user_create']['checked'])) { @@ -627,7 +631,7 @@ if ($action == "view_ticketlist") { } // Progression - if (!empty($arrayfields['t.progress']['checked'])) { + if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) { print ''; print $obj->progress; print ''; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 1bfc235ff65..ccb5c9ad840 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -328,9 +328,11 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a print ''; // Progression - print ''.$langs->trans("Progression").''; - print ($object->dao->progress > 0 ? dol_escape_htmltag($object->dao->progress) : '0').'%'; - print ''; + if (!empty($conf->global->TICKET_SHOW_PROGRESSION)) { + print ''.$langs->trans("Progression").''; + print ($object->dao->progress > 0 ? dol_escape_htmltag($object->dao->progress) : '0').'%'; + print ''; + } print ''; From 6eb93fdc556a0a1c541883cf51ffd86e037de08e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 6 Mar 2023 10:49:44 +0000 Subject: [PATCH 2/9] Fixing style errors. --- htdocs/public/ticket/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 7fdefb5b7fb..3502da74555 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -257,7 +257,7 @@ if ($action == "view_ticketlist") { //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2) //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); - + if (empty($conf->global->TICKET_SHOW_PROGRESSION)) unset($arrayfields['t.progress']); From de37c01bfab8c875bcb7d46f82d3f46190334150 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Tue, 7 Mar 2023 16:27:25 +0100 Subject: [PATCH 3/9] NEW - Add hook in loadLotStock() in html.formproduct.class.php file --- .../product/class/html.formproduct.class.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index beb84f3e455..14457c312ed 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -865,6 +865,25 @@ class FormProduct // clear cache $this->cache_lot = array(); $productIdList = implode(',', $productIdArray); + + $batch_count = 0; + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + $hookmanager->initHooks(array('productdao')); + $parameters = array('productIdList' => $productIdList); + $reshook = $hookmanager->executeHooks('loadLotStock', $parameters, $this); + if ($reshook < 0) { + $this->error = $hookmanager->error; + return -1; + } + if (!empty($hookmanager->resArray['batch_list']) && is_array($hookmanager->resArray['batch_list'])) { + $this->cache_lot = $hookmanager->resArray['batch_list']; + $batch_count = (int) $hookmanager->resArray['batch_count']; + } + if ($reshook > 0) { + return $batch_count; + } + $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product"; $sql .= " FROM ".$this->db->prefix()."product_batch as pb"; $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as ps on ps.rowid = pb.fk_product_stock"; @@ -889,7 +908,7 @@ class FormProduct $i++; } - return $num; + return $batch_count + $num; } else { dol_print_error($this->db); return -1; From 44e01aeee8a6d5b7c395d1eab24efc8f80552cc0 Mon Sep 17 00:00:00 2001 From: battosai30 Date: Tue, 28 Mar 2023 09:14:27 +0200 Subject: [PATCH 4/9] Update mailing-send.php The delay between email annouunced in prompt is not right : when the delay is called, usleep takes useconds as argument and MAILING_DELAY is multiplied by 1000000, but prompt information doesn't have to. --- scripts/emailings/mailing-send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index f2aeecec444..464a127ce15 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -87,7 +87,7 @@ if (!isModEnabled('mailing')) { print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; if (!empty($conf->global->MAILING_DELAY)) { - print 'A delay of '.((float) $conf->global->MAILING_DELAY * 1000000).' seconds has been set between each email'."\n"; + print 'A delay of '.((float) $conf->global->MAILING_DELAY).' seconds has been set between each email'."\n"; } if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') { From 19dfe73c22ae2de28ff0e3b16248bf448000d0b1 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 29 Mar 2023 11:21:28 +0200 Subject: [PATCH 5/9] fix : Warning: Undefined array key xStartPos in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/class/commondocgenerator.class.php on line 1554 --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1b59d44bdde..7fa56125e6c 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1550,9 +1550,9 @@ abstract class CommonDocGenerator $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); // Add column separator - if (!empty($colDef['border-left'])) { + if (!empty($colDef['border-left']) && isset($colDef['xStartPos'])) { $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); - } + } if (empty($hidetop)) { // save curent cell padding From 846fe52da84bc84666ae7f614b133af435f96ea4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 29 Mar 2023 09:25:45 +0000 Subject: [PATCH 6/9] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7fa56125e6c..283fd3e4437 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1552,7 +1552,7 @@ abstract class CommonDocGenerator // Add column separator if (!empty($colDef['border-left']) && isset($colDef['xStartPos'])) { $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); - } + } if (empty($hidetop)) { // save curent cell padding From 898a4bad159925ac7bdf327af0d118f85fb461e5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Mar 2023 14:30:32 +0200 Subject: [PATCH 7/9] FIX menu force entity = 0 if core module --- htdocs/core/class/menubase.class.php | 10 ++++++++-- htdocs/core/modules/DolibarrModules.class.php | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 3630d137136..19b5535493f 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -49,6 +49,11 @@ class Menubase */ public $id; + /** + * @var int Entity + */ + public $entity; + /** * @var string Menu handler */ @@ -185,6 +190,7 @@ class Menubase if (!isset($this->enabled)) { $this->enabled = '1'; } + $this->entity = (isset($this->entity) ? (int) $this->entity : $conf->entity); $this->menu_handler = trim((string) $this->menu_handler); $this->module = trim((string) $this->module); $this->type = trim((string) $this->type); @@ -246,7 +252,7 @@ class Menubase $sql .= " AND fk_menu = ".((int) $this->fk_menu); $sql .= " AND position = ".((int) $this->position); $sql .= " AND url = '".$this->db->escape($this->url)."'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (0, ".$conf->entity.")"; $result = $this->db->query($sql); if ($result) { @@ -275,7 +281,7 @@ class Menubase $sql .= "usertype"; $sql .= ") VALUES ("; $sql .= " '".$this->db->escape($this->menu_handler)."',"; - $sql .= " '".$this->db->escape($conf->entity)."',"; + $sql .= " '".$this->db->escape($this->entity)."',"; $sql .= " '".$this->db->escape($this->module)."',"; $sql .= " '".$this->db->escape($this->type)."',"; $sql .= " ".($this->mainmenu ? "'".$this->db->escape($this->mainmenu)."'" : "''").","; // Can't be null diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 6c43c945b65..62dbd494082 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1986,7 +1986,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public function insert_menus() { // phpcs:enable - global $user; + global $conf, $user; if (!is_array($this->menu) || empty($this->menu)) { return 0; @@ -1998,6 +1998,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $err = 0; + // Common module + $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity); + $this->db->begin(); foreach ($this->menu as $key => $value) { @@ -2049,6 +2052,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $menu->user = $this->menu[$key]['user']; $menu->enabled = isset($this->menu[$key]['enabled']) ? $this->menu[$key]['enabled'] : 0; $menu->position = $this->menu[$key]['position']; + $menu->entity = $entity; if (!$err) { $result = $menu->create($user); // Save menu entry into table llx_menu @@ -2092,7 +2096,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql .= " WHERE module = '".$this->db->escape($module)."'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (0, ".$conf->entity.")"; dol_syslog(get_class($this)."::delete_menus", LOG_DEBUG); $resql = $this->db->query($sql); From 48333a7205fb77737741612e18d164c5212b1be1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Mar 2023 15:09:43 +0200 Subject: [PATCH 8/9] FIX wrong test --- htdocs/core/class/menubase.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 19b5535493f..2965db0f7c5 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -190,7 +190,7 @@ class Menubase if (!isset($this->enabled)) { $this->enabled = '1'; } - $this->entity = (isset($this->entity) ? (int) $this->entity : $conf->entity); + $this->entity = (isset($this->entity) && (int) $this->entity >= 0 ? (int) $this->entity : $conf->entity); $this->menu_handler = trim((string) $this->menu_handler); $this->module = trim((string) $this->module); $this->type = trim((string) $this->type); From 6860325f96f1abf5c936a005198edbb171caa8ad Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Thu, 30 Mar 2023 11:13:17 +0200 Subject: [PATCH 9/9] Correction --- htdocs/product/class/html.formproduct.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 14457c312ed..f9ea6b54beb 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -867,8 +867,11 @@ class FormProduct $productIdList = implode(',', $productIdArray); $batch_count = 0; - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($this->db); + global $hookmanager; + if (empty($hookmanager)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } $hookmanager->initHooks(array('productdao')); $parameters = array('productIdList' => $productIdList); $reshook = $hookmanager->executeHooks('loadLotStock', $parameters, $this);