FIX Show list of events on tickets
This commit is contained in:
parent
fafb7956de
commit
327e5ebe78
@ -40,7 +40,7 @@ $cancel = GETPOST('cancel', 'alpha');
|
||||
$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 @@ if ($resql)
|
||||
$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 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
//$triggers = dol_sort_array($triggers, 'code', 'asc', 0, 0, 1);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
||||
@ -150,7 +150,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
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 '<div id="form_view_ticket">';
|
||||
@ -287,13 +287,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
|
||||
// Message list
|
||||
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
|
||||
$object->viewTicketMessages(false);
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Logs list
|
||||
print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticket');
|
||||
$object->viewTicketLogs(false);
|
||||
$object->viewTicketMessages(false, true, $object->dao);
|
||||
} else {
|
||||
print '<div class="error">Not Allowed<br><a href="' . $_SERVER['PHP_SELF'] . '?track_id=' . $object->dao->track_id . '">' . $langs->trans('Back') . '</a></div>';
|
||||
}
|
||||
|
||||
@ -167,72 +167,12 @@ class ActionsTicket
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 '<table class="border" style="width:100%;">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print '<th>';
|
||||
print $langs->trans('DateCreation');
|
||||
print '</th>';
|
||||
|
||||
if ($show_user) {
|
||||
print '<th>';
|
||||
print $langs->trans('User');
|
||||
print '</th>';
|
||||
}
|
||||
|
||||
foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><strong>';
|
||||
print dol_print_date($arraylogs['datec'], 'dayhour');
|
||||
print '</strong></td>';
|
||||
|
||||
if ($show_user) {
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td colspan="2">';
|
||||
print dol_nl2br($arraylogs['message']);
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
} else {
|
||||
print '<div class="info">' . $langs->trans('NoLogForThisTicket') . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class ActionsTicket
|
||||
/**
|
||||
* 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 '<table class="border" style="width:100%;">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print '<td>';
|
||||
print $langs->trans('DateCreation');
|
||||
print $langs->trans('TicketMessagesList');
|
||||
print '</td>';
|
||||
|
||||
if ($show_user) {
|
||||
@ -342,9 +284,9 @@ class ActionsTicket
|
||||
print '<strong></td>';
|
||||
if ($show_user) {
|
||||
print '<td>';
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1660,20 +1660,19 @@ class Ticket extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class Ticket extends CommonObject
|
||||
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user