Home > osTicket > Add Post Number, Sender Name, and Time Duration in Each Message of osTicket

Add Post Number, Sender Name, and Time Duration in Each Message of osTicket

Both osTicket version 1.6 RC4 and 1.6 RC5 have not included the post number, the sender name of client, and duration time in each message. That is why I made this modification. It is important for you as staff or admin of your ticketing system, if you want to know quickly how much time needed to respond between one post and the next post in one current ticket. Moreover, you will also know how much total time taken for the opened ticket when you view the certain ticket in full-mode.

Follow these instructions below.

  1. Create a new file, copy-paste the following code to this file, then put it to \include\ sub directory of your osTicket System, and save it as class.duration.php
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    <?php
     
    /**************************************************************************/
    /* [MOD] Add #Post, SenderName, Time Duration in Each Message,            */ 
    /*       by Masino Sinaga, May 7, 2009                                    */ 
    /* Website: - http://www.masinosinaga.com                                 */
    /*          - http://osticket.masinosinaga.com                            */
    /**************************************************************************/
     
    class Duration {
     
    	var $begindate;
    	var $enddate;
     
      function Duration($parambegindate, $paramenddate) {
        $this->begindate = strtotime($parambegindate);
        $this->enddate = strtotime($paramenddate);
        $diff = intval($this->enddate) - intval($this->begindate);                 
        $diffday = intval(floor($diff/86400));
        $modday = ($diff%86400);
        $diffhour = intval(floor($modday/3600));
        $diffminute = intval(floor(($modday%3600)/60));
        $diffsecond = ($modday%60);
        return round($diffday)." Day(s), ".round($diffhour)." Hour(s), ".round($diffminute,0)." Minute(s), ".round($diffsecond,0)." Second(s).";
      }
    }
    ?>
  2. Open \scp\tickets.php file, and find this code:
    21
    
    require_once(INCLUDE_DIR.'class.banlist.php');

    after that code, add the following code:

    22
    23
    24
    
    // MOD Show Post#, SenderName, and Duration on Each Message by Masino Sinaga, July 20, 2009
    require_once(INCLUDE_DIR.'class.duration.php');
    // MOD Show Post#, SenderName, and Duration on Each Message by Masino Sinaga, July 20, 2009
  3. Open \include\staff\viewticket.inc.php file, and find this code:
    274
    275
    276
    
            $msgres =db_query($sql);
            while ($msg_row = db_fetch_array($msgres)) {
                ?>

    replace with:

    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    
          $msgres =db_query($sql);
          $i=1;
          while ($msg_row = db_fetch_array($msgres)) {  
            if ($i!=1) { 
              $dateend = $msg_row['created'];
            } else if ($i==1) {
              $datebegin = $msg_row['created'];
              $firstdate = $datebegin;
              $dateend = $msg_row['created'];
            }
            $lastdate = $dateend;                 
            $datediff = new Duration($datebegin,$dateend);
            $resultdiff=$datediff->Duration($datebegin,$dateend);
            $datebegin = $dateend;        
            ?>

    find this code:

    288
    289
    290
    291
    292
    293
    294
    
                <table align="center" class="message" cellspacing="0" cellpadding="1" width="100%" border=0>
                    <tr><th><?=Format::db_daydatetime($msg_row['created'])?></th></tr>
                    <?if($msg_row['attachments']>0){ ?>
                    <tr class="header"><td><?=$ticket->getAttachmentStr($msg_row['msg_id'],'M')?></td></tr> 
                    <?}?>
                    <tr><td><?=Format::display($msg_row['message'])?>&nbsp;</td></tr>
                </table>

    replace with:

    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    
            <table align="center" class="message" cellspacing="0" cellpadding="1" width="100%" border=0>
              <tr><th><?php echo "(#".$i.") "; echo Format::db_daydatetime($msg_row['created']); echo " - ".Format::htmlchars($ticket->getName()); ?></th>
              </tr>
              <?php if($msg_row['attachments']>0){ ?>
              <tr class="header"><td><?php echo $ticket->getAttachmentStr($msg_row['msg_id'],'M')?></td></tr> 
              <?php }?>
              <tr><td>
              <?php echo Format::display($msg_row['message']); ?>
              </td></tr>
              <tr class="header"><td align="right"><?php echo "Duration: ".$resultdiff."<br />";    ?></td></tr>
            </table>

    find this code:

    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    
                $resp =db_query($sql);
                while ($resp_row = db_fetch_array($resp)) {
                    $respID=$resp_row['response_id'];
                    ?>
                    <table align="center" class="response" cellspacing="0" cellpadding="1" width="100%" border=0>
                        <tr><th><?=Format::db_daydatetime($resp_row['created'])?>&nbsp;-&nbsp;<?=$resp_row['staff_name']?></th></tr>
                        <?if($resp_row['attachments']>0){ ?>
                        <tr class="header">
                            <td><?=$ticket->getAttachmentStr($respID,'R')?></td></tr>
                        <?}?>
                        <tr><td> <?=Format::display($resp_row['response'])?></td></tr>
                    </table>
                <?}
                $msgid =$msg_row['msg_id'];
            }?>
        </div>
    </div>

    replace with:

    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    
            $resp =db_query($sql);
            $j=1;
            while ($resp_row = db_fetch_array($resp)) {
              $i++;
              $respID=$resp_row['response_id'];
              $dateend = $resp_row['created']; 
              $lastdate = $dateend;          
              $datediff = new Duration($datebegin,$dateend);
              $resultdiff=$datediff->Duration($datebegin,$dateend);            
              ?>
              <table align="center" class="response" cellspacing="0" cellpadding="1" width="100%" border=0>
                <tr><th><?php echo "(#".$i.") "; echo Format::db_daydatetime($resp_row['created'])?>&nbsp;-&nbsp;<?php echo $resp_row['staff_name']?></th>
                </tr>
                <?php if($resp_row['attachments']>0){ ?>
                <tr class="header">
                  <td><?php echo $ticket->getAttachmentStr($respID,'R')?></td></tr>
                <?php }?>
                <tr><td><?php echo Format::display($resp_row['response']); ?></td></tr>
                <tr class="header"><td align="right"><?php echo "Duration: ".$resultdiff."<br />";    ?></td></tr>
              </table>            
              <?php     
              $datebegin = $dateend;
              $j++;
            }
            $msgid =$msg_row['msg_id']; 
            $i++;
          } 
          $datediff = new Duration($firstdate,$lastdate);
          $resultdiff=$datediff->Duration($firstdate,$lastdate);    
          ?>
        </div>
    </div>
    <?php 
      $totalpost = $i-1;
      if ($ticket->getStatus()=='open') {
        echo "<div align='right'><br /><b>Total: ".$totalpost." post(s), Duration: ".$resultdiff."</b></div>";
        $lastdate = date("Y-m-d H:i:s"); //userdate();   //date("Y-m-d H:i:s");
        $datediff = new Duration($firstdate,$lastdate);
        $resultdiff=$datediff->Duration($firstdate,$lastdate);    
        echo "<div align='right'><br /><b>Ticket still opened, Total Duration: ".$resultdiff."</b></div>";
      } else {
        echo "<div align='right'><br /><b>Total: ".$totalpost." post(s), Duration: ".$resultdiff."</b></div>";
      }    
    ?>

Now you can see that there is post number, sender name, and time duration in each message of the current ticket thread. You can also see in the bottom of the ticket thread, duration total for that current ticket. At least, you will get warning especially about the duration total of the opened ticket, thus you can take the respond as quick as you can for that ticket number.

Post Number, Sender Name, and Time Duration in Each Post in osTicket

  • Share/Bookmark
182 views Print This Post Print This Post

  1. Bayu
    September 11th, 2009 at 02:11 | #1

    info yang bermanfaat walau saya masih awam, saya liat osticket tidak ada captcha ya? web anda : http://osticket.masinosinaga.com kok bisa ada capcthanya? apakah ada tutorial cara menambahkan captcha di osticket? dan pilihan bhs indonesia, jika atidak keberatan mohon infoka ke email sy, thanks banget bantuannya…
    semoga web ini semakin berguna… maju terus opensource indonesia…

  2. September 11th, 2009 at 09:56 | #2

    Halo mas Bayu,

    Untuk menambahkan captcha di osTicket System, sudah saya tambahkan artikelnya beberapa menit yang lalu. Silahkan langsung ke sini: http://www.openscriptsolution.com/2009/09/11/how-to-add-captcha-security-code-in-osticket-system-1-6-rc5/

    Semoga dapat membantu.

  3. Bayu
    September 11th, 2009 at 16:09 | #3

    thanks mas, sangat membantu sy yg sedang belajar…

  4. September 11th, 2009 at 21:49 | #4

    Sama-sama mas. Sering-sering saja mampir ke sini. Setiap hari pasti ada saja ilmu baru yang saya share, termasuk mengenai osTicket.

  5. s16pt
    November 21st, 2009 at 09:36 | #5

    can this function use with http://www.openscriptsolution.com/2009/11/08/add-auto-staff-time-sheet-feature-into-osticket-v1-6-rc5/ ? I need these 2 function to be enabled.

  6. November 23rd, 2009 at 13:40 | #6

    @s16pt

    Yes, it can. I had tried implemented both MODs and everything seemed okay.

  1. September 16th, 2009 at 23:33 | #1