Here is the code...
Hi there,
This is the code for MOD in my first post above about "Add #Post, SenderName, Time Duration in Each Message". I also added duration until the date and time while the opened ticket being accessed, beside the total duration from the first post until the last post.
Let's getting started now!
First: Download attachment file, extract, and put it to sub directory \include\
Second: Edit the code below:
Open \scp\tickets.php, FIND:
require_once(INCLUDE_DIR.'class.banlist.php');
AFTER, ADD:
require_once(INCLUDE_DIR.'class.duration.php');
Open \include\staff\viewticket.inc.php, FIND:
$msgres =db_query($sql);
while ($msg_row = db_fetch_array($msgres)) {
?>
REPLACE WITH:
$msgres =db_query($sql);
$i=1;
while ($msg_row = db_fetch_array($msgres)) {
if ($i!=1) {
$dateend = $msg_row;
} else if ($i==1) {
$datebegin = $msg_row;
$firstdate = $datebegin;
$dateend = $msg_row;
}
$lastdate = $dateend;
$datediff = new Duration($datebegin,$dateend);
$resultdiff=$datediff->Duration($datebegin,$dateend);
$datebegin = $dateend;
?>
FIND:
<table align="center" class="message" cellspacing="0" cellpadding="1" width="100%" border=0>
<tr><th><?=Format:($msg_row)?></th></tr>
<?if($msg_row>0){ ?>
<tr class="header"><td><?=$ticket->getAttachmentStr($msg_row,'M')?></td></tr>
<?}?>
<tr><td><?=Format:($msg_row)?> </td></tr>
</table>
REPLACE WITH:
<table align="center" class="message" cellspacing="0" cellpadding="1" width="100%" border=0>
<tr><th><?php echo "(#".$i.") "; echo Format:($msg_row); echo " - ".Format:($ticket->getName()); ?></th>
</tr>
<?php if($msg_row>0){ ?>
<tr class="header"><td><?php echo $ticket->getAttachmentStr($msg_row,'M')?></td></tr>
<?php }?>
<tr><td>
<?php echo Format:($msg_row); ?>
</td></tr>
<tr class="header"><td align="right"><?php echo "Duration: ".$resultdiff."<br />"; ?></td></tr>
</table>
FIND:
$resp =db_query($sql);
while ($resp_row = db_fetch_array($resp)) {
$respID=$resp_row;
?>
<table align="center" class="response" cellspacing="0" cellpadding="1" width="100%" border=0>
<tr><th><?=Format:($resp_row)?> - <?=$resp_row?></th></tr>
<?if($resp_row>0){ ?>
<tr class="header">
<td><?=$ticket->getAttachmentStr($respID,'R')?></td></tr>
<?}?>
<tr><td> <?=Format:($resp_row)?></td></tr>
</table>
<?}
$msgid =$msg_row;
}?>
</div>
</div>
REPLACE WITH:
$resp =db_query($sql);
$j=1;
while ($resp_row = db_fetch_array($resp)) {
$i++;
$respID=$resp_row;
$dateend = $resp_row;
$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:($resp_row)?> - <?php echo $resp_row?></th>
</tr>
<?php if($resp_row>0){ ?>
<tr class="header">
<td><?php echo $ticket->getAttachmentStr($respID,'R')?></td></tr>
<?php }?>
<tr><td><?php echo Format:($resp_row); ?></td></tr>
<tr class="header"><td align="right"><?php echo "Duration: ".$resultdiff."<br />"; ?></td></tr>
</table>
<?php
$datebegin = $dateend;
$j++;
}
$msgid =$msg_row;
$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"); //userdate(); //date("Y-m-d H");
$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>";
}
?>
That's all. Let me know your feedback about this MOD. Thanks.
Best regards,
Masino Sinaga
[class.duration.zip](https://forum.osticket.com/assets/files/migrated/2/ef9d6de039292c26883357f36193216.zip)