Skip to content
Snippets Groups Projects
Commit 0d33dc90 authored by Jared Hancock's avatar Jared Hancock
Browse files

Add annulment support for ticket events

Add the ability of revoking previous ticket state tracking events when new
events are logged for the same ticket. This will allow, for instance, the
ability to revert the 'closed' state of a ticket when the ticket is
reopened.

For statistics tracking, a user could configure whether or not the events
should be counted for each event tracked or just the non-annulled events.
For instance, if a ticket is closed and reopened several times, only the
very last closed event should count toward the statistics for the ticket.
Therefore, when a ticket is reopened, previous closed events should be
marked as annulled.
parent 0833e3d0
Branches
Tags
No related merge requests found
...@@ -802,7 +802,7 @@ class Ticket{ ...@@ -802,7 +802,7 @@ class Ticket{
//TODO: log reopen event here //TODO: log reopen event here
$this->logEvent('reopened'); $this->logEvent('reopened', 'closed');
return (db_query($sql) && db_affected_rows()); return (db_query($sql) && db_affected_rows());
} }
...@@ -1463,13 +1463,21 @@ class Ticket{ ...@@ -1463,13 +1463,21 @@ class Ticket{
} }
// History log -- used for statistics generation (pretty reports) // History log -- used for statistics generation (pretty reports)
function logEvent($state, $staff=null) { function logEvent($state, $annul=null, $staff=null) {
global $thisstaff; global $thisstaff;
if ($staff === null) { if ($staff === null) {
if ($thisstaff) $staff=$thisstaff->getUserName(); if ($thisstaff) $staff=$thisstaff->getUserName();
else $staff='SYSTEM'; # XXX: Security Violation ? else $staff='SYSTEM'; # XXX: Security Violation ?
} }
# Annul previous entries if requested (for instance, reopening a
# ticket will annul an 'closed' entry). This will be useful to
# easily prevent repeated statistics.
if ($annul) {
db_query('UPDATE '.TICKET_EVENT_TABLE.' SET annulled=1'
.' WHERE ticket_id='.db_input($this->getId())
.' AND state='.db_input($annul));
}
return db_query('INSERT INTO '.TICKET_EVENT_TABLE return db_query('INSERT INTO '.TICKET_EVENT_TABLE
.' SET ticket_id='.db_input($this->getId()) .' SET ticket_id='.db_input($this->getId())
......
/**
* Add an 'annulled' column to the %ticket_event table to assist in tracking
* real statistics for reopened and closed tickets -- the events should not
* count more than one time.
*
* @version 1.7-dpr3 ticket-event-annul
*/
ALTER TABLE `%TABLE_PREFIX%ticket_event`
ADD `annulled` tinyint(1) NOT NULL DEFAULT '0' AFTER `timestamp`;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `schema_signature`='3c2e0f54d9e08bad38028cd42767c7c9';
...@@ -616,6 +616,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_event` ( ...@@ -616,6 +616,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_event` (
`state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL, `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL,
`staff` varchar(255) NOT NULL default 'SYSTEM', `staff` varchar(255) NOT NULL default 'SYSTEM',
`timestamp` datetime NOT NULL, `timestamp` datetime NOT NULL,
`annulled` tinyint(1) unsigned NOT NULL defalt '0',
KEY `ticket_state` (`ticket_id`, `state`, `timestamp`), KEY `ticket_state` (`ticket_id`, `state`, `timestamp`),
KEY `ticket_stats` (`timestamp`, `state`) KEY `ticket_stats` (`timestamp`, `state`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
......
abe9c0cb845be52c10fcd7b3e626a589 3c2e0f54d9e08bad38028cd42767c7c9
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment