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/main.inc.php b/main.inc.php
index fdd1a6863cc1e4b2210235415af5dbe49ee7634f..1850eb31b462c05fc2c6f6064fc240a2f8ebed6e 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -55,7 +55,7 @@
 
     #Current version && schema signature (Changes from version to version)
     define('THIS_VERSION','1.7-DPR2'); //Shown on admin panel
-    define('SCHEMA_SIGNATURE','abe9c0cb845be52c10fcd7b3e626a589'); //MD5 signature of the db schema. (used to trigger upgrades)
+    define('SCHEMA_SIGNATURE','bbb021fbeb377ca66b6997b77e0167cc'); //MD5 signature of the db schema. (used to trigger upgrades)
 
     #load config info
     $configfile='';
diff --git a/setup/inc/sql/abe9c0cb-bbb021fb.patch.sql b/setup/inc/sql/abe9c0cb-bbb021fb.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..0a3248db4569aebd2ce75eed39cfff3da68d559c
--- /dev/null
+++ b/setup/inc/sql/abe9c0cb-bbb021fb.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 `staff`;
+
+-- Finished with patch
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='bbb021fbeb377ca66b6997b77e0167cc';
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql
index fbd2059bab92027cac455a893689ddc9e80445ca..6c22f9919f812dcac571b4d846ca158b8b5421b8 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql
@@ -615,6 +615,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_event` (
   `topic_id` int(11) unsigned NOT NULL,
   `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL,
   `staff` varchar(255) NOT NULL default 'SYSTEM',
+  `annulled` tinyint(1) unsigned NOT NULL defalt '0',
   `timestamp` datetime NOT NULL,
   KEY `ticket_state` (`ticket_id`, `state`, `timestamp`),
   KEY `ticket_stats` (`timestamp`, `state`)
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
index 23011d006ad5e19d75630760bff1cfa872db12ec..e9497d0ebd591cb32c577721f38ddcc283fbf937 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
@@ -1 +1 @@
-abe9c0cb845be52c10fcd7b3e626a589
+bbb021fbeb377ca66b6997b77e0167cc