From 31fd8c089b740612d94566efaa3a1c4a28827547 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Sep 2022 09:24:25 +0200 Subject: [PATCH 1/8] FIX Link missing backtopage --- htdocs/core/lib/ticket.lib.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 79cc5980c16..51e4f3af382 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -664,6 +664,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $actualCycleDate = false; + // Loop on each event to show it foreach ($histo as $key => $value) { $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo @@ -702,14 +703,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= $actionstatic->getNomUrl(1, -1, 'valignmiddle').' '; } - //if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) - //{ - // $out.=''.$langs->trans('Show').''; - //} - if (!empty($user->rights->agenda->allactions->create) || (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && !empty($user->rights->agenda->myactions->create))) { - $out .= ''; + $out .= ''; } $out .= ''; @@ -880,6 +876,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $i++; } + $out .= "\n"; } From 6d189202b1f0d6f12d85dffa233c57bf1f4f37f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Sep 2022 09:25:00 +0200 Subject: [PATCH 2/8] Clean code --- htdocs/ticket/card.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d12d84d00f1..4981aec624e 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -371,7 +371,7 @@ if (empty($reshook)) { if ($object->markAsRead($user) > 0) { setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); - header("Location: card.php?track_id=".$object->track_id."&action=view"); + header("Location: card.php?track_id=".$object->track_id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -429,7 +429,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); - header("Location: card.php?track_id=".$object->track_id."&action=view"); + header("Location: card.php?track_id=".$object->track_id); exit; } else { array_push($object->errors, $object->error); @@ -449,7 +449,7 @@ if (empty($reshook)) { $url = 'card.php?track_id='.urlencode($object->track_id); } } else { - $url = 'card.php?action=view&track_id='.urlencode($object->track_id); + $url = 'card.php?track_id='.urlencode($object->track_id); } header("Location: ".$url); @@ -466,7 +466,7 @@ if (empty($reshook)) { if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) { setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); + $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); header("Location: ".$url); } else { $action = ''; @@ -484,7 +484,7 @@ if (empty($reshook)) { setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); - $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha'); + $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); header("Location: ".$url); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -510,7 +510,7 @@ if (empty($reshook)) { if ($action == 'set_thirdparty' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); + $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); header("Location: ".$url); exit(); } @@ -520,7 +520,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setProgression(GETPOST('progress', 'alpha')); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } @@ -530,7 +530,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setCategories(GETPOST('categories', 'array')); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } @@ -568,7 +568,7 @@ if (empty($reshook)) { // Log action in ticket logs table //$log_action = $langs->trans('TicketLogReopen'); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } else { @@ -581,7 +581,7 @@ if (empty($reshook)) { // Categorisation dans projet if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setProject($projectid); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } @@ -589,7 +589,7 @@ if (empty($reshook)) { // Categorisation dans contrat if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setContract(GETPOST('contractid', 'int')); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } @@ -627,7 +627,7 @@ if (empty($reshook)) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $url = 'card.php?action=view&track_id='.$object->track_id; + $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); } else { @@ -1073,7 +1073,7 @@ if ($action == 'create' || $action == 'presend') { print '
'; print $langs->trans("AssignedTo"); if (isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) { - print ''.img_edit($langs->trans('Modify'), '').''; + print ''.img_edit($langs->trans('Modify'), '').''; } print '
'; print ''; @@ -1219,7 +1219,7 @@ if ($action == 'create' || $action == 'presend') { } else { // Button to edit Properties if (isset($object->status) && $object->status < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) { - print ' '.img_edit($langs->trans('Modify')).''; + print ' '.img_edit($langs->trans('Modify')).''; } } print ''; From 625df49850faa521e1da8cff0f293206f213bbec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Sep 2022 12:31:29 +0200 Subject: [PATCH 3/8] Clean and standardize code --- htdocs/admin/ticket.php | 20 +-- htdocs/core/class/html.formticket.class.php | 150 ++++++++++++-------- htdocs/core/modules/modTicket.class.php | 4 +- htdocs/langs/en_US/ticket.lang | 13 +- htdocs/ticket/card.php | 12 +- htdocs/ticket/class/ticket.class.php | 23 ++- 6 files changed, 125 insertions(+), 97 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index ef5887c58ac..9cebbc3b36d 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -664,28 +664,30 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; } -// Texte d'introduction -$mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''.$langs->trans("TicketMessageMailIntroLabelAdmin"); +// Message header +//$mail_intro = getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText')); +$mail_intro = getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO', ''); +print ''.$langs->trans("TicketMessageMailIntro"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); +$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 90, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help'); print ''; -// Texte de signature -$mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''.$langs->trans("TicketMessageMailSignatureLabelAdmin").''; +// Message footer +//$mail_signature = getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailFooterText')); +$mail_signature = getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE'); +print ''.$langs->trans("TicketMessageMailFooter").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); +$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 90, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70); $doleditor->Create(); print ''; print ''; -print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailFooterHelpAdmin"), 1, 'help'); print ''; print ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cfc066c4295..7cb3bdf58de 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1071,7 +1071,7 @@ class FormTicket console.log("We select a new value into combo child_id="+child_id); - // Hide all selected box that are child of the one modified + // Hide all selected box that are child of the one modified $(".groupticketchild").each(function(){ if ($(this).attr("child_id") > child_id) { console.log("hide child_id="+$(this).attr("child_id")); @@ -1080,7 +1080,7 @@ class FormTicket } }) - // Now we enable the next combo + // Now we enable the next combo $("#'.$htmlname.'_child_'.$levelid.'").val(""); if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.'_child_'.$levelid.' option").length > 1) { console.log($("#'.$htmlname.'_child_'.$levelid.' option").length); @@ -1230,7 +1230,11 @@ class FormTicket dol_delete_dir_recursive($upload_dir); } - $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid + if (!empty($this->trackid)) { // TODO Always use trackid (ticXXX) instead of track_id (abcd123) + $keytoavoidconflict = '-'.$this->trackid; + } else { + $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; + } unset($_SESSION["listofpaths".$keytoavoidconflict]); unset($_SESSION["listofnames".$keytoavoidconflict]); unset($_SESSION["listofmimes".$keytoavoidconflict]); @@ -1278,7 +1282,7 @@ class FormTicket if ($this->param['models'] != 'none') { $model_id = 0; if (array_key_exists('models_id', $this->param)) { - $model_id = $this->param["models_id"]; + $model_id = (int) $this->param["models_id"]; } $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one @@ -1288,8 +1292,13 @@ class FormTicket $listofpaths = array(); $listofnames = array(); $listofmimes = array(); - $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid + if (!empty($this->trackid)) { + $keytoavoidconflict = '-'.$this->trackid; + } else { + $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid + } +//var_dump($keytoavoidconflict); if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { @@ -1297,7 +1306,8 @@ class FormTicket } } } - +//var_dump($_SESSION); +//var_dump($_SESSION["listofpaths".$keytoavoidconflict]); if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); } @@ -1368,6 +1378,7 @@ class FormTicket print ''; print ''; print ''; + print ''; foreach ($this->param as $key => $value) { print ''; } @@ -1395,6 +1406,16 @@ class FormTicket $ticketstat = new Ticket($this->db); $res = $ticketstat->fetch('', '', $this->track_id); + // Private message (not visible by customer/external user) + if (!$user->socid) { + print ''; + $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : ''); + print ' '; + print ''; + print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); + print ''; + } + print ''; $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?'checked':'')); print ' '; @@ -1413,16 +1434,6 @@ class FormTicket print ''; } - // Private message (not visible by customer/external user) - if (!$user->socid) { - print ''; - $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : ''); - print ' '; - print ''; - print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); - print ''; - } - // Subject print ''.$langs->trans('Subject').''; print 'ref.'] '.$langs->trans('TicketNewMessage').'" />'; @@ -1478,7 +1489,8 @@ class FormTicket // Intro // External users can't send message email - if ($user->rights->ticket->write && !$user->socid) { + /* + if ($user->rights->ticket->write && !$user->socid && !empty($conf->global->TICKET_MESSAGE_MAIL_INTRO)) { $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; print '