From 327e5ebe780e42cc96e8bccb38bdb0d139e6de60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Jul 2019 19:09:38 +0200 Subject: [PATCH] FIX Show list of events on tickets --- htdocs/admin/agenda.php | 5 +- htdocs/public/ticket/view.php | 10 +-- htdocs/ticket/class/actions_ticket.class.php | 86 ++++---------------- htdocs/ticket/class/ticket.class.php | 13 ++- 4 files changed, 26 insertions(+), 88 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 649bfab3d979d..4c5c02d0b3d77 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -40,7 +40,7 @@ $search_event = GETPOST('search_event', 'alpha'); // Get list of triggers available -$sql = "SELECT a.rowid, a.code, a.label, a.elementtype"; +$sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position"; $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql.= " ORDER BY a.rang ASC"; $resql=$db->query($sql); @@ -55,6 +55,7 @@ $triggers[$i]['code'] = $obj->code; $triggers[$i]['element'] = $obj->elementtype; $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); + $triggers[$i]['position'] = $obj->position; $i++; } @@ -65,6 +66,8 @@ dol_print_error($db); } +//$triggers = dol_sort_array($triggers, 'code', 'asc', 0, 0, 1); + /* * Actions diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 69a77413b2e76..2c23ba1bc7174 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -150,7 +150,7 @@ if ($display_ticket) { // Confirmation close if ($action == 'close') { - print $form->form_confirm($_SERVER["PHP_SELF"] . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"] . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1); } print '
'; @@ -287,13 +287,7 @@ // Message list print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket'); - $object->viewTicketMessages(false); - - print '
'; - - // Logs list - print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticket'); - $object->viewTicketLogs(false); + $object->viewTicketMessages(false, true, $object->dao); } else { print ''; } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 912b6cb298ce2..3e9daabec757b 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -167,72 +167,12 @@ public function getTitle($action = '') } } - /** - * View html list of logs - * - * @param boolean $show_user Show user who make action - * @return void - */ - public function viewTicketLogs($show_user = true) - { - global $conf, $langs; - - // Load logs in cache - $ret = $this->dao->loadCacheLogsTicket(); - - if (is_array($this->dao->cache_logs_ticket) && count($this->dao->cache_logs_ticket) > 0) { - print ''; - - print ''; - - print ''; - - if ($show_user) { - print ''; - } - - foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) { - print ''; - print ''; - - if ($show_user) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - } - - print '
'; - print $langs->trans('DateCreation'); - print ''; - print $langs->trans('User'); - print '
'; - print dol_print_date($arraylogs['datec'], 'dayhour'); - print ''; - if ($arraylogs['fk_user_create'] > 0) { - $userstat = new User($this->db); - $res = $userstat->fetch($arraylogs['fk_user_create']); - if ($res) { - print $userstat->getNomUrl(1); - } - } - print '
'; - print dol_nl2br($arraylogs['message']); - - print '
'; - } else { - print '
' . $langs->trans('NoLogForThisTicket') . '
'; - } - } - /** * Show ticket original message * * @param User $user User wich display * @param string $action Action mode - * @param Ticket $object Object ticket + * @param Ticket $object Object ticket * @return void */ public function viewTicketOriginalMessage($user, $action, $object) @@ -300,29 +240,31 @@ public function viewTicketOriginalMessage($user, $action, $object) /** * View html list of message for ticket * - * @param boolean $show_private Show private messages - * @param boolean $show_user Show user who make action - * @return void + * @param boolean $show_private Show private messages + * @param boolean $show_user Show user who make action + * @param Ticket $object Object ticket + * @return void */ - public function viewTicketMessages($show_private, $show_user = true) + public function viewTicketMessages($show_private, $show_user, $object) { global $conf, $langs, $user; // Load logs in cache $ret = $this->dao->loadCacheMsgsTicket(); - $action = GETPOST('action'); + if ($ret < 0) dol_print_error($this->dao->db); - $this->viewTicketOriginalMessage($user, $action); + $action = GETPOST('action', 'alpha'); - if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { - print load_fiche_titre($langs->trans('TicketMailExchanges')); + $this->viewTicketOriginalMessage($user, $action, $object); + if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) + { print ''; print ''; print ''; if ($show_user) { @@ -342,9 +284,9 @@ public function viewTicketMessages($show_private, $show_user = true) print ''; if ($show_user) { print '
'; - print $langs->trans('DateCreation'); + print $langs->trans('TicketMessagesList'); print ''; - if ($arraymsgs['fk_user_action'] > 0) { + if ($arraymsgs['fk_user_author'] > 0) { $userstat = new User($this->db); - $res = $userstat->fetch($arraymsgs['fk_user_action']); + $res = $userstat->fetch($arraymsgs['fk_user_author']); if ($res) { print $userstat->getNomUrl(0); } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 132cce1e52b00..7ab32f2085125 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1660,20 +1660,19 @@ public function createTicketMessage($user, $notrigger = 0) } /** - * Charge la liste des messages sur le ticket + * Load the list of event on ticket into ->cache_msgs_ticket * - * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko + * @return int Nb of lines loaded, 0 if already loaded, <0 if KO */ public function loadCacheMsgsTicket() { - global $langs; - if (is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) { return 0; } - // Cache deja charge - $sql = "SELECT rowid, fk_user_author, datec, label, message, visibility"; + // Cache already loaded + + $sql = "SELECT id as rowid, fk_user_author, datec, label, note as message, visibility"; $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm"; $sql .= " WHERE fk_element = " . (int) $this->id; $sql .= " AND elementtype = 'ticket'"; @@ -1687,7 +1686,7 @@ public function loadCacheMsgsTicket() while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->cache_msgs_ticket[$i]['id'] = $obj->rowid; - $this->cache_msgs_ticket[$i]['fk_user_action'] = $obj->fk_user_action; + $this->cache_msgs_ticket[$i]['fk_user_author'] = $obj->fk_user_author; $this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); $this->cache_msgs_ticket[$i]['subject'] = $obj->label; $this->cache_msgs_ticket[$i]['message'] = $obj->message;