diff --git a/include/class.ticket.php b/include/class.ticket.php index 275ef78c26b88c7dc306e18753c7196b2b8cf51d..aa20928f50cec3533f8cada581d7fc8645257260 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -802,7 +802,7 @@ class Ticket{ //TODO: log reopen event here - $this->logEvent('reopened'); + $this->logEvent('reopened', 'closed'); return (db_query($sql) && db_affected_rows()); } @@ -1463,13 +1463,21 @@ class Ticket{ } // History log -- used for statistics generation (pretty reports) - function logEvent($state, $staff=null) { + function logEvent($state, $annul=null, $staff=null) { global $thisstaff; if ($staff === null) { if ($thisstaff) $staff=$thisstaff->getUserName(); 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 .' SET ticket_id='.db_input($this->getId()) diff --git a/setup/inc/sql/abe9c0cb-3c2e0f54.patch.sql b/setup/inc/sql/abe9c0cb-3c2e0f54.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..8594a47ac085684c7969739b2c63e20b1ee8977e --- /dev/null +++ b/setup/inc/sql/abe9c0cb-3c2e0f54.patch.sql @@ -0,0 +1,14 @@ +/** + * 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'; diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql index fbd2059bab92027cac455a893689ddc9e80445ca..625342f65ac3e43b69ab87e45d02701a18dc8306 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql +++ b/setup/inc/sql/osticket-v1.7-mysql.sql @@ -616,6 +616,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_event` ( `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL, `staff` varchar(255) NOT NULL default 'SYSTEM', `timestamp` datetime NOT NULL, + `annulled` tinyint(1) unsigned NOT NULL defalt '0', KEY `ticket_state` (`ticket_id`, `state`, `timestamp`), KEY `ticket_stats` (`timestamp`, `state`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 index 23011d006ad5e19d75630760bff1cfa872db12ec..fb57be3edd4a636ffb6b0a28daa00c338a4602b3 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 +++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 @@ -1 +1 @@ -abe9c0cb845be52c10fcd7b3e626a589 +3c2e0f54d9e08bad38028cd42767c7c9