From 9954a0e4bb654dae4cfe40ced290e3ad8c48cb01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Jul 2021 00:40:06 +0200 Subject: [PATCH] Fix status of tickets --- htdocs/langs/en_US/ticket.lang | 8 +++++--- htdocs/ticket/card.php | 20 ++++++++++++++++---- htdocs/ticket/class/ticket.class.php | 27 ++++++++++++++------------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 3c074688b8e..0b54b1d5fa8 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -66,7 +66,7 @@ NeedMoreInformation=Waiting for reporter feedback NeedMoreInformationShort=Waiting for feedback Answered=Answered Waiting=Waiting -Closed=Closed +SolvedClosed=Solved Deleted=Deleted # Dict @@ -186,9 +186,11 @@ TicketSeverity=Severity ShowTicket=See ticket RelatedTickets=Related tickets TicketAddIntervention=Create intervention -CloseTicket=Close ticket -CloseATicket=Close a ticket +CloseTicket=Close|Solve ticket +AbandonTicket=Abandon ticket +CloseATicket=Close|Solve a ticket ConfirmCloseAticket=Confirm ticket closing +ConfirmAbandonTicket=Do you confirm the closing of the ticket to status 'Abandonned' ConfirmDeleteTicket=Please confirm ticket deleting TicketDeletedSuccess=Ticket deleted with success TicketMarkedAsClosed=Ticket marked as closed diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5faa7b201b7..cbdb0f7a6df 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -426,10 +426,10 @@ if (empty($reshook)) { } } - if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { + if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - if ($object->close($user)) { + 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'); @@ -749,7 +749,7 @@ if ($action == 'create' || $action == 'presend') { print ''; print ''; */ -} elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' +} elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'abandon' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { if ($res > 0) { // or for unauthorized internals users @@ -764,6 +764,13 @@ if ($action == 'create' || $action == 'presend') { print '
'; } } + // Confirmation abandon + if ($action == 'abandon') { + print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("AbandonTicket"), $langs->trans("ConfirmAbandonTicket"), "confirm_abandon", '', '', 1); + if ($ret == 'html') { + print '
'; + } + } // Confirmation delete if ($action == 'delete') { print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1); @@ -1296,8 +1303,13 @@ if ($action == 'create' || $action == 'presend') { print '
'.$langs->trans('CloseTicket').'
'; } + // Abadon ticket if statut is read + if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { + print '
'.$langs->trans('AbandonTicket').'
'; + } + // Re-open ticket - if (!$user->socid && $object->fk_statut == Ticket::STATUS_CLOSED && !$user->socid) { + if (!$user->socid && ($object->fk_statut == Ticket::STATUS_CLOSED || $object->fk_statut == Ticket::STATUS_CANCELED) && !$user->socid) { print '
'.$langs->trans('ReOpen').'
'; } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 89f239db6c6..b67d7922d97 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -218,8 +218,8 @@ class Ticket extends CommonObject const STATUS_IN_PROGRESS = 3; const STATUS_NEED_MORE_INFO = 5; const STATUS_WAITING = 7; // on hold - const STATUS_CLOSED = 8; - const STATUS_CANCELED = 9; + const STATUS_CLOSED = 8; // Closed - Solved + const STATUS_CANCELED = 9; // Closed - Not solved /** @@ -272,8 +272,8 @@ class Ticket extends CommonObject 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'), 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>1), - 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')), + //'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'SolvedClosed', 9 => 'Deleted')), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), ); // END MODULEBUILDER PROPERTIES @@ -295,7 +295,7 @@ class Ticket extends CommonObject self::STATUS_IN_PROGRESS => 'InProgress', self::STATUS_WAITING => 'OnHold', self::STATUS_NEED_MORE_INFO => 'NeedMoreInformationShort', - self::STATUS_CLOSED => 'Closed', + self::STATUS_CLOSED => 'SolvedClosed', self::STATUS_CANCELED => 'Canceled' ); $this->statuts = array( @@ -305,7 +305,7 @@ class Ticket extends CommonObject self::STATUS_IN_PROGRESS => 'InProgress', self::STATUS_WAITING => 'OnHold', self::STATUS_NEED_MORE_INFO => 'NeedMoreInformation', - self::STATUS_CLOSED => 'Closed', + self::STATUS_CLOSED => 'SolvedClosed', self::STATUS_CANCELED => 'Canceled' ); } @@ -1747,21 +1747,22 @@ class Ticket extends CommonObject /** * Close a ticket * - * @param User $user User that close - * @return int <0 if KO, >0 if OK + * @param User $user User that close + * @param int $mode 0=Close solved, 1=Close abandonned + * @return int <0 if KO, >0 if OK */ - public function close(User $user) + public function close(User $user, $mode = 0) { global $conf, $langs; - if ($this->fk_statut != Ticket::STATUS_CLOSED) { // not closed + if ($this->fk_statut != Ticket::STATUS_CLOSED && $this->fk_statut != Ticket::STATUS_CANCELED) { // not closed $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; - $sql .= " SET fk_statut=".Ticket::STATUS_CLOSED.", progress=100, date_close='".$this->db->idate(dol_now())."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut=".($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED).", progress=100, date_close='".$this->db->idate(dol_now())."'"; + $sql .= " WHERE rowid = ".((int) $this->id); - dol_syslog(get_class($this)."::close sql=".$sql); + dol_syslog(get_class($this)."::close mode=".$mode); $resql = $this->db->query($sql); if ($resql) { $error = 0;