From fe3402583d86555a0baef48ae15960a141f93ed0 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Thu, 14 Aug 2014 21:58:44 +0000
Subject: [PATCH] Support adding comments on status change

If a comment is provided it's handled as an internal note - allowing for
alerts to be sent out (if enabled)
---
 include/class.ticket.php | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 5fff02517..328fe9898 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -828,7 +828,7 @@ class Ticket {
     }
 
     //Status helper.
-    function setStatus($status) {
+    function setStatus($status, $comments='') {
         global $thisstaff;
 
         if ($status && is_numeric($status))
@@ -857,6 +857,7 @@ class Ticket {
                 };
                 break;
             case 'open':
+                // TODO: check current status if it allows for reopening
                 if ($this->isClosed()) {
                     $sql.= ',closed=NULL, reopened=NOW() ';
 
@@ -873,12 +874,19 @@ class Ticket {
             return false;
 
         // Log status change b4 reload
-        $note= sprintf('Status changed from %s to %s by %s',
+        $note = sprintf(__('Status changed from %s to %s by %s'),
                 $this->getStatus(),
                 $status,
                 $thisstaff ?: 'SYSTEM');
 
-        $this->logNote('Status Changed', $note, $thisstaff, false);
+        $alert = false;
+        if ($comments) {
+            $note .= sprintf('<hr>%s', $comments);
+            // Send out alerts if comments are included
+            $alert = true;
+        }
+
+        $this->logNote(__('Status Changed'), $note, $thisstaff, $alert);
 
         // Log events via callback
         if ($ecb) $ecb($this);
-- 
GitLab