Merge pull request #13840 from OPEN-DSI/new-ticket-messages-show-on-card

NEW show messages on ticket card
This commit is contained in:
Laurent Destailleur 2020-05-07 21:30:24 +02:00 committed by GitHub
commit b84e9141a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,6 +55,17 @@ $action = GETPOST('action', 'aZ09');
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
$search_agenda_label = GETPOST('search_agenda_label');
// Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ticketcard', 'globalcard')); $hookmanager->initHooks(array('ticketcard', 'globalcard'));
@ -116,17 +127,23 @@ $parameters = array();
$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 ($cancel) if (empty($reshook)) {
{ // Purge search criteria
if (!empty($backtopage)) 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{
{ {
header("Location: ".$backtopage); $actioncode = '';
$search_agenda_label = '';
}
if ($cancel) {
if (!empty($backtopage)) {
header("Location: " . $backtopage);
exit; exit;
} }
$action = 'view'; $action = 'view';
} }
if (GETPOST('add', 'alpha') && $user->rights->ticket->write) { if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
$error = 0; $error = 0;
if (!GETPOST("subject", 'alpha')) { if (!GETPOST("subject", 'alpha')) {
@ -164,8 +181,7 @@ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
$action = 'create'; $action = 'create';
} }
if (!$error) if (!$error) {
{
// Add contact // Add contact
$contactid = GETPOST('contactid', 'int'); $contactid = GETPOST('contactid', 'int');
$type_contact = GETPOST("type", 'alpha'); $type_contact = GETPOST("type", 'alpha');
@ -202,8 +218,7 @@ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
} }
// Auto create fiche intervention // Auto create fiche intervention
if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE) if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE) {
{
$fichinter = new Fichinter($db); $fichinter = new Fichinter($db);
$fichinter->socid = $object->fk_soc; $fichinter->socid = $object->fk_soc;
$fichinter->fk_project = GETPOST('projectid', 'int'); $fichinter->fk_project = GETPOST('projectid', 'int');
@ -225,23 +240,21 @@ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
} }
} }
if (!$error) if (!$error) {
{
// File transfer // File transfer
$object->copyFilesForTicket(); $object->copyFilesForTicket();
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
if (!empty($backtopage)) { if (!empty($backtopage)) {
$url = $backtopage; $url = $backtopage;
} else { } else {
$url = 'card.php?track_id='.$object->track_id; $url = 'card.php?track_id=' . $object->track_id;
} }
header("Location: ".$url); header("Location: " . $url);
exit; exit;
} else { } else {
$db->rollback(); $db->rollback();
@ -250,9 +263,9 @@ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
if ($action == 'edit' && $user->rights->ticket->write) { if ($action == 'edit' && $user->rights->ticket->write) {
$error = 0; $error = 0;
if ($object->fetch(GETPOST('id', 'int')) < 0) { if ($object->fetch(GETPOST('id', 'int')) < 0) {
@ -260,9 +273,9 @@ if ($action == 'edit' && $user->rights->ticket->write) {
array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
$_GET["action"] = $_POST["action"] = ''; $_GET["action"] = $_POST["action"] = '';
} }
} }
if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) { if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) {
$error = 0; $error = 0;
$ret = $object->fetch(GETPOST('id', 'int')); $ret = $object->fetch(GETPOST('id', 'int'));
@ -300,26 +313,25 @@ if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket-
$db->rollback(); $db->rollback();
} }
} }
} }
// Mark as Read // Mark as Read
if ($action == "mark_ticket_read" && $user->rights->ticket->write) { if ($action == "mark_ticket_read" && $user->rights->ticket->write) {
$object->fetch('', '', GETPOST("track_id", 'alpha')); $object->fetch('', '', GETPOST("track_id", 'alpha'));
if ($object->markAsRead($user) > 0) if ($object->markAsRead($user) > 0) {
{
setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); 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 . "&action=view");
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$action = 'view'; $action = 'view';
} }
// Assign to someone // Assign to someone
if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) { if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) {
$object->fetch('', '', GETPOST("track_id", 'alpha')); $object->fetch('', '', GETPOST("track_id", 'alpha'));
$useroriginassign = $object->fk_user_assign; $useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOST('fk_user_assign', 'int'); $usertoassign = GETPOST('fk_user_assign', 'int');
@ -330,8 +342,7 @@ if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->ri
$action = 'view'; $action = 'view';
}*/ }*/
if (!$error) if (!$error) {
{
$ret = $object->assignUser($user, $usertoassign); $ret = $object->assignUser($user, $usertoassign);
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }
@ -355,56 +366,54 @@ if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->ri
if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
} }
if (!$error) if (!$error) {
{
// Log action in ticket logs table // Log action in ticket logs table
$object->fetch_user($usertoassign); $object->fetch_user($usertoassign);
$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); 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 . "&action=view");
exit; exit;
} else { } else {
array_push($object->errors, $object->error); array_push($object->errors, $object->error);
} }
$action = 'view'; $action = 'view';
} }
if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) { if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) {
$ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0)); $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
if ($ret > 0) { if ($ret > 0) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
$url = $backtopage; $url = $backtopage;
} else { } else {
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
} }
header("Location: ".$url); header("Location: " . $url);
exit; exit;
} else { } else {
setEventMessages($object->error, null, 'errors'); setEventMessages($object->error, null, 'errors');
$action = 'presend'; $action = 'presend';
} }
} }
if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) {
{
$object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
if ($object->close($user)) { if ($object->close($user)) {
setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
$url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: ".$url); header("Location: " . $url);
} else { } else {
$action = ''; $action = '';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
$object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) { if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
$object->close($user); $object->close($user);
@ -412,71 +421,71 @@ if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
setEventMessages('<div class="confirm">'.$langs->trans('TicketMarkedAsClosed').'</div>', null, 'mesgs'); setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', null, 'mesgs');
$url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha'); $url = 'card.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha');
header("Location: ".$url); header("Location: " . $url);
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
} }
} }
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
if ($object->delete($user) > 0) { if ($object->delete($user) > 0) {
setEventMessages('<div class="confirm">'.$langs->trans('TicketDeletedSuccess').'</div>', null, 'mesgs'); setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); Header("Location: " . DOL_URL_ROOT . "/ticket/list.php");
exit; exit;
} else { } else {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans($object->error).'</div>'; $mesg = '<div class="error">' . $langs->trans($object->error) . '</div>';
$action = ''; $action = '';
} }
} }
} }
// Set parent company // Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setCustomer(GETPOST('editcustomer', 'int')); $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} }
if ($action == 'set_progression' && $user->rights->ticket->write) { if ($action == 'set_progression' && $user->rights->ticket->write) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setProgression(GETPOST('progress', 'alpha')); $result = $object->setProgression(GETPOST('progress', 'alpha'));
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} }
if ($action == 'setsubject') { if ($action == 'setsubject') {
if ($object->fetch(GETPOST('id', 'int'))) { if ($object->fetch(GETPOST('id', 'int'))) {
if ($action == 'setsubject') { if ($action == 'setsubject') {
$object->subject = trim(GETPOST('subject', 'alpha')); $object->subject = trim(GETPOST('subject', 'alpha'));
} }
if ($action == 'setsubject' && empty($object->subject)) { if ($action == 'setsubject' && empty($object->subject)) {
$mesg .= ($mesg ? '<br>' : '').$langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); $mesg .= ($mesg ? '<br>' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
} }
if (!$mesg) { if (!$mesg) {
if ($object->update($user) >= 0) { if ($object->update($user) >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id); header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id);
exit; exit;
} }
$mesg = $object->error; $mesg = $object->error;
} }
} }
} }
if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) { if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times // prevent browser refresh from reopening ticket several times
if ($object->fk_statut == Ticket::STATUS_CLOSED) { if ($object->fk_statut == Ticket::STATUS_CLOSED) {
@ -485,29 +494,29 @@ if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('ca
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogReopen'); $log_action = $langs->trans('TicketLogReopen');
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} }
} }
} // Categorisation dans projet } // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticket->write) { elseif ($action == 'classin' && $user->rights->ticket->write) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} // Categorisation dans contrat } // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticket->write) { elseif ($action == 'setcontract' && $user->rights->ticket->write) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setContract(GETPOST('contractid', 'int')); $object->setContract(GETPOST('contractid', 'int'));
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} elseif ($action == "set_message" && $user->rights->ticket->manage) { } elseif ($action == "set_message" && $user->rights->ticket->manage) {
// altairis: manage cancel button // altairis: manage cancel button
if (!GETPOST('cancel')) { if (!GETPOST('cancel')) {
$object->fetch('', '', GETPOST('track_id', 'alpha')); $object->fetch('', '', GETPOST('track_id', 'alpha'));
@ -517,7 +526,7 @@ elseif ($action == 'setcontract' && $user->rights->ticket->write) {
$object->message = $fieldtomodify; $object->message = $fieldtomodify;
$ret = $object->update($user); $ret = $object->update($user);
if ($ret > 0) { if ($ret > 0) {
$log_action = $langs->trans('TicketInitialMessageModified')." \n"; $log_action = $langs->trans('TicketInitialMessageModified') . " \n";
// include the Diff class // include the Diff class
dol_include_once('/ticket/class/utils_diff.class.php'); dol_include_once('/ticket/class/utils_diff.class.php');
// output the result of comparing two files as plain text // output the result of comparing two files as plain text
@ -528,8 +537,8 @@ elseif ($action == 'setcontract' && $user->rights->ticket->write) {
} }
$action = 'view'; $action = 'view';
} // Reopen ticket } // Reopen ticket
elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) {
if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int'); $new_status = GETPOST('new_status', 'int');
$old_status = $object->fk_statut; $old_status = $object->fk_statut;
@ -538,36 +547,31 @@ elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETP
// Log action in ticket logs table // 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])); $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?action=view&track_id=' . $object->track_id;
header("Location: ".$url); header("Location: " . $url);
exit(); exit();
} }
} }
} }
// Action to update one extrafield // Action to update one extrafield
if ($action == "update_extras" && !empty($permissiontoadd)) if ($action == "update_extras" && !empty($permissiontoadd)) {
{
$object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
$attributekey = GETPOST('attribute', 'alpha'); $attributekey = GETPOST('attribute', 'alpha');
$attributekeylong = 'options_'.$attributekey; $attributekeylong = 'options_' . $attributekey;
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha'); $object->array_options['options_' . $attributekey] = GETPOST($attributekeylong, ' alpha');
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0) if ($result > 0) {
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
$action = 'view'; $action = 'view';
} } else {
else
{
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'edit_extras'; $action = 'edit_extras';
} }
} }
if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) {
{
$object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
$object->type_code = GETPOST('update_value_type', 'aZ09'); $object->type_code = GETPOST('update_value_type', 'aZ09');
@ -581,28 +585,28 @@ if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') &
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
} }
$action = 'view'; $action = 'view';
}
$permissiondellink = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once
// Actions to build doc
$upload_dir = $conf->ticket->dir_output;
$permissiontoadd = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php';
// Actions to send emails
$triggersendname = 'TICKET_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
$trackid = 'tic' . $object->id;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php';
// Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage';
} }
$permissiondellink = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Actions to build doc
$upload_dir = $conf->ticket->dir_output;
$permissiontoadd = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$triggersendname = 'TICKET_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
$trackid = 'tic'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage';
/* /*
* View * View
*/ */
@ -1213,30 +1217,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
// Set $action to correct value for the case we used presend action to add a message // Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage';
if ($action != 'presend' && $action != 'presend_addmessage') // add a message
{ if ($action == 'presend' || $action == 'presend_addmessage') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show direct link to public interface
print '<br><!-- Link to public interface -->'."\n";
print showDirectPublicLink($object).'<br>';
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'ticket', $socid, 1);
print '</div></div></div>';
}
else
{
$action = 'add_message'; // action to use to post the message $action = 'add_message'; // action to use to post the message
$modelmail = 'ticket_send'; $modelmail = 'ticket_send';
@ -1310,6 +1292,63 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
$formticket->showMessageForm('100%'); $formticket->showMessageForm('100%');
print '</div>'; print '</div>';
} }
// Show messages on card
if (empty($conf->global->TICKET_HIDE_MESSAGES_ON_CARD)) {
$param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($actioncode) $param .= '&actioncode='.urlencode($actioncode);
if ($search_agenda_label) $param .= '&search_agenda_label='.urlencode($search_agenda_label);
$morehtmlright = '';
$messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object->track_id;
$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1);
// Show link to add a message (if read and not closed)
$btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";
$url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init';
$morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $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" && $action != "add_message";;
$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"] . '?track_id=' . $object->track_id);
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus);
print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
// List of all actions
$filters = array();
$filters['search_agenda_label'] = $search_agenda_label;
show_ticket_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
}
if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'add_message') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show direct link to public interface
print '<br><!-- Link to public interface -->'."\n";
print showDirectPublicLink($object).'<br>';
print '</div>';
if (!empty($conf->global->TICKET_HIDE_MESSAGES_ON_CARD)) {
print '<div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'ticket', $socid, 1);
print '</div></div>';
}
print '</div>';
}
} }
} }