From 879e4ba243a478e30cb2dd051c684bc88fec7897 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Mon, 15 Oct 2012 13:28:53 -0400
Subject: [PATCH] Add IP to ticket source display Add SLA to ticket info table.
 Move subject to the top of ticket thread.

---
 include/class.pdf.php             | 47 ++++++++++++++++++++++---------
 include/staff/ticket-view.inc.php | 28 ++++++++++++------
 2 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/include/class.pdf.php b/include/class.pdf.php
index 17c2e0588..87fcd69ad 100644
--- a/include/class.pdf.php
+++ b/include/class.pdf.php
@@ -57,11 +57,8 @@ class Ticket2PDF extends FPDF
 		$this->SetFont('Times', 'B', 16);
 		$this->Image(FPDF_DIR . 'print-logo.png', null, 10, 0, 20);
 		$this->SetX(200, 15);
-		$this->Cell(0, 15, "Support Ticket System", 0, 1, 'R', 0);
+		$this->Cell(0, 15, $cfg->getTitle(), 0, 1, 'R', 0);
 		//$this->SetY(40);
-        $this->SetXY(60, 25);
-		$this->SetFont('Arial', 'B', 16);
-		$this->Cell(0, 3, 'Ticket #'.$this->getTicket()->getExtId(), 0, 2, 'L');
         $this->SetX($this->lMargin);
         $this->Cell(0, 3, '', "B", 2, 'L');
         $this->SetFont('Arial', 'I',10);
@@ -77,7 +74,7 @@ class Ticket2PDF extends FPDF
 		$this->SetY(-15);
         $this->Cell(0, 2, '', "T", 2, 'L');
 		$this->SetFont('Arial', 'I', 9);
-		$this->Cell(0, 7, 'Ticket printed by '.$thisstaff->getUserName().' on '.date('r'), 0, 0, 'L');
+		$this->Cell(0, 7, 'Ticket #'.$this->getTicket()->getNumber().' printed by '.$thisstaff->getUserName().' on '.date('r'), 0, 0, 'L');
 		//$this->Cell(0,10,'Page '.($this->PageNo()-$this->pageOffset).' of {nb} '.$this->pageOffset.' '.$this->PageNo(),0,0,'R');
 		$this->Cell(0, 7, 'Page ' . ($this->PageNo() - $this->pageOffset), 0, 0, 'R');
 	}
@@ -109,6 +106,16 @@ class Ticket2PDF extends FPDF
         $w =(($this->w/2)-$this->lMargin);
         $l = 35;
         $c = $w-$l;
+
+        
+        $this->SetFont('Arial', 'B', 11);
+        $this->cMargin = 0;
+        $this->SetFont('Arial', 'B', 11);
+        $this->SetTextColor(10, 86, 142);
+        $this->Cell($w, 7,'Ticket #'.$ticket->getNumber(), 0, 0, 'L');
+        $this->Ln(7);
+        $this->cMargin = 3;
+        $this->SetTextColor(0);
         $this->SetDrawColor(220, 220, 220);
         $this->SetFillColor(244, 250, 255);
         $this->SetX($this->lMargin);
@@ -143,14 +150,17 @@ class Ticket2PDF extends FPDF
         $this->SetFont('Arial', 'B', 11);
         $this->Cell($l, 7, 'Source', 1, 0, 'L', true);
         $this->SetFont('');
-        $this->Cell($c, 7, ucfirst($ticket->getSource()), 1, 0, 'L', true);
+        $source = ucfirst($ticket->getSource());
+        if($ticket->getIP())
+            $source.='  ('.$ticket->getIP().')';
+        $this->Cell($c, 7, $source, 1, 0, 'L', true);
         $this->Ln(15);
 
         $this->SetFont('Arial', 'B', 11);
         if($ticket->isOpen()) {
             $this->Cell($l, 7, 'Assigned To', 1, 0, 'L', true);
             $this->SetFont('');
-            $this->Cell($c, 7, $ticket->isAssigned()?implode('/', $ticket->getAssignees()):' -- ', 1, 0, 'L', true);
+            $this->Cell($c, 7, $ticket->isAssigned()?$ticket->getAssigned():' -- ', 1, 0, 'L', true);
         } else {
 
             $closedby = 'unknown';
@@ -163,17 +173,18 @@ class Ticket2PDF extends FPDF
         }
 
         $this->SetFont('Arial', 'B', 11);
-        $this->Cell($l, 7, 'Subject', 1, 0, 'L', true);
+        $this->Cell($l, 7, 'Help Topic', 1, 0, 'L', true);
         $this->SetFont('');
-        $this->Cell($c, 7, $ticket->getSubject(), 1, 1, 'L', true);
+        $this->Cell($c, 7, $ticket->getHelpTopic(), 1, 1, 'L', true);
         $this->SetFont('Arial', 'B', 11);
-        $this->Cell($l, 7, 'Last Response', 1, 0, 'L', true);
+        $this->Cell($l, 7, 'SLA Plan', 1, 0, 'L', true);
         $this->SetFont('');
-        $this->Cell($c, 7, Format::db_datetime($ticket->getLastRespDate()), 1, 0, 'L', true);
+        $sla = $ticket->getSLA();
+        $this->Cell($c, 7, $sla?$sla->getName():' -- ', 1, 0, 'L', true);
         $this->SetFont('Arial', 'B', 11);
-        $this->Cell($l, 7, 'Help Topic', 1, 0, 'L', true);
+        $this->Cell($l, 7, 'Last Response', 1, 0, 'L', true);
         $this->SetFont('');
-        $this->Cell($c, 7, $ticket->getHelpTopic(), 1, 1, 'L', true);
+        $this->Cell($c, 7, Format::db_datetime($ticket->getLastRespDate()), 1, 1, 'L', true);
         $this->SetFont('Arial', 'B', 11);
         if($ticket->isOpen()) {
             $this->Cell($l, 7, 'Due Date', 1, 0, 'L', true);
@@ -189,7 +200,15 @@ class Ticket2PDF extends FPDF
         $this->Cell($l, 7, 'Last Message', 1, 0, 'L', true);
         $this->SetFont('');
         $this->Cell($c, 7, Format::db_datetime($ticket->getLastMsgDate()), 1, 1, 'L', true);
-        $this->Ln(10);
+        $this->Ln(5);
+
+        $this->SetFont('Arial', 'B', 11);
+        $this->cMargin = 0;
+        $this->SetTextColor(10, 86, 142);
+        $this->Cell($w, 7,trim($ticket->getSubject()), 0, 0, 'L');
+        $this->Ln(7);
+        $this->SetTextColor(0);
+        $this->cMargin = 3;
 
         //Table header colors (RGB)
         $colors = array('M'=>array(195, 217, 255),
diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php
index 111852e38..c602b7ecb 100644
--- a/include/staff/ticket-view.inc.php
+++ b/include/staff/ticket-view.inc.php
@@ -16,6 +16,7 @@ if($cfg->getLockTime() && !$ticket->acquireLock($thisstaff->getId(),$cfg->getLoc
 $dept  = $ticket->getDept();  //Dept
 $staff = $ticket->getStaff(); //Assigned or closed by..
 $team  = $ticket->getTeam();  //Assigned team.
+$sla   = $ticket->getSLA();
 $lock  = $ticket->getLock();  //Ticket lock obj
 $id    = $ticket->getId();    //Ticket ID.
 
@@ -164,7 +165,15 @@ if($ticket->isOverdue())
                 </tr>
                 <tr>
                     <th>Source:</th>
-                    <td><?php echo Format::htmlchars($ticket->getSource()); ?></td>
+                    <td><?php 
+                        echo Format::htmlchars($ticket->getSource());
+
+                        if($ticket->getIP())
+                            echo '&nbsp;&nbsp; <span class="faded">('.$ticket->getIP().')</span>';
+
+                    
+                        ?>
+                    </td>
                 </tr>
             </table>
         </td>
@@ -204,8 +213,8 @@ if($ticket->isOverdue())
                 <?php
                 } ?>
                 <tr>
-                    <th nowrap>Last Response:</th>
-                    <td><?php echo Format::db_datetime($ticket->getLastRespDate()); ?></td>
+                    <th>SLA Plan:</th>
+                    <td><?php echo $sla?Format::htmlchars($sla->getName()):'<span class="faded">&mdash; none &mdash;</span>'; ?></td>
                 </tr>
                 <?php
                 if($ticket->isOpen()){ ?>
@@ -227,22 +236,23 @@ if($ticket->isOverdue())
         <td width="50%">
             <table cellspacing="0" cellpadding="4" width="100%" border="0">
                 <tr>
-                    <th width="100">Subject:</th>
-                    <td><?php echo Format::htmlchars(Format::truncate($ticket->getSubject(),200)); ?></td>
-                </tr>
-                <tr>
-                    <th>Help Topic:</th>
+                    <th width="100">Help Topic:</th>
                     <td><?php echo Format::htmlchars($ticket->getHelpTopic()); ?></td>
                 </tr>
                 <tr>
                     <th nowrap>Last Message:</th>
                     <td><?php echo Format::db_datetime($ticket->getLastMsgDate()); ?></td>
                 </tr>
+                <tr>
+                    <th nowrap>Last Response:</th>
+                    <td><?php echo Format::db_datetime($ticket->getLastRespDate()); ?></td>
+                </tr>
             </table>
         </td>
     </tr>
 </table>
-<div class="clear" style="padding-bottom:10px;"></div>
+<div class="clear"></div>
+<h2 style="padding:10px 0 5px 0; font-size:11pt;"><?php echo Format::htmlchars($ticket->getSubject()); ?></h2>
 <?php
 $tcount = $ticket->getThreadCount();
 if($cfg->showNotesInline())
-- 
GitLab