Add switch view behavior

This commit is contained in:
John Botella 2019-09-16 13:56:07 +02:00
parent 84640d0cd5
commit 010e58d957
4 changed files with 66 additions and 20 deletions

View File

@ -108,7 +108,21 @@ function ticket_prepare_head($object)
// History // History
$head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; $ticketViewType = "messaging";
if(empty($_SESSION['ticket-view-type'])){
$_SESSION['ticket-view-type'] = $ticketViewType;
}
else{
$ticketViewType = $_SESSION['ticket-view-type'];
}
if($ticketViewType == "messaging"){
$head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id;
}
else{
// $ticketViewType == "list"
$head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id;
}
$head[$h][1] = $langs->trans('Events'); $head[$h][1] = $langs->trans('Events');
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
{ {
@ -118,11 +132,6 @@ function ticket_prepare_head($object)
$head[$h][2] = 'tabTicketLogs'; $head[$h][2] = 'tabTicketLogs';
$h++; $h++;
// History
$head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id;
$head[$h][1] = $langs->trans('Messaging');
$head[$h][2] = 'tabTicketMessaging';
$h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove');

View File

@ -139,6 +139,8 @@ TicketViewNonClosedOnly=View only open tickets
TicketStatByStatus=Tickets by status TicketStatByStatus=Tickets by status
OrderByDateAsc=Sort by ascending date OrderByDateAsc=Sort by ascending date
OrderByDateDesc=Sort by descending date OrderByDateDesc=Sort by descending date
MessagingViewType=Show as messaging list
MessageListViewType=Show as table list
# #
# Ticket card # Ticket card

View File

@ -103,6 +103,12 @@ $parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if(empty($reshook))
{
// Set view style
$_SESSION['ticket-view-type'] = "list";
}
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
@ -225,7 +231,23 @@ if (!empty($object->id))
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); $morehtmlright = '';
$messagingUrl = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id;
$morehtmlright .= dolGetButtonTitle($langs->trans('MessagingViewType'), '', 'fa fa-comments', $messagingUrl, $id = '', $status = 1);
// Show link to add a message (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
$url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init';
$morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-title-button', $btnstatus);
// Show link to add event (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
$url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]);
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-calendar-plus', $url, 'add-new-ticket-even-button', $btnstatus);
print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
// List of all actions // List of all actions
$filters=array(); $filters=array();

View File

@ -103,6 +103,12 @@ $parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if(empty($reshook))
{
// Set view style
$_SESSION['ticket-view-type'] = "messaging";
}
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
@ -143,7 +149,7 @@ if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) {
} }
$head = ticket_prepare_head($object); $head = ticket_prepare_head($object);
dol_fiche_head($head, 'tabTicketMessaging', $langs->trans("Ticket"), 0, 'ticket'); dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket');
$morehtmlref ='<div class="refidno">'; $morehtmlref ='<div class="refidno">';
$morehtmlref.= $object->subject; $morehtmlref.= $object->subject;
@ -227,20 +233,27 @@ if (!empty($object->id))
$morehtmlright = ''; $morehtmlright = '';
if($sortorder === 'desc') { if($sortorder === 'desc') {
$sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=asc' . $param; $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=asc' . $param;
$morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateAsc'), 'fa fa-sort-numeric-down', $sortUrl, $id = '', $status = 1); $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateAsc'), 'fa fa-sort-numeric-down', $sortUrl, $id = '', $status = 1);
} }
else{ else{
$sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=desc' . $param; $sortUrl = $_SERVER["PHP_SELF"] . '?sortfield=a.datep&sortorder=desc' . $param;
$morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateDesc'), 'fa fa-sort-numeric-down-alt', $sortUrl, $id = '', $status = 1); $morehtmlright .= dolGetButtonTitle($langs->trans('Date'), $langs->trans('OrderByDateDesc'), 'fa fa-sort-numeric-down-alt', $sortUrl, $id = '', $status = 1);
} }
// Show link to add a message (if read and not closed) $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id;
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-tasks', $messagingUrl, $id = '', $status = 1);
$url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init';
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-comment', $url, 'add-new-ticket-title-button', $btnstatus);
// Show link to add a message (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
$url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init';
$morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-title-button', $btnstatus);
// Show link to add event (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
$url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]);
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-calendar-plus', $url, 'add-new-ticket-even-button', $btnstatus);
print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);