Today I'am have a problem modify code for Program "osTicket (v1.9.12)" for calculate Due Date
I think post ask in forum : http://osticket.com/forum/discussions .. I don't know ... how to use post ask here ? ... where ?
Request : value $row['grace_period'] calculator date for Due Date
Action :
- on select change SLA Plan
- auto active immediately [client site]
- conditions check if (id) [server site]
- query $row['grace_period']
- auto calculate Due Date and Time
- display resulte date and time in text Box [Due Date]
Example :
- select : SLA Plan :Default SLA (48 hours - Active)
- Today : 2015/10/12 14:00:10
- resulte [Due Date] : 2015/10/14 14:00:10
class.sla.php
function getSLAs() {
$slas=array();
$sql='SELECT id, name, isactive, grace_period FROM '.SLA_TABLE.' ORDER BY name';
if(($res=db_query($sql)) && db_num_rows($res)) {
while($row=db_fetch_array($res))
$slas[$row['id']] = sprintf(__('%s (%d hours - %s) '
/* Tokens are <name> (<#> hours - <Active|Disabled>) */),
$row['name'],
$row['grace_period'],
$row['isactive']?__('Active'):__('Disabled'));
}
return $slas;
}
ticket-open.php
<td width="160">
<?php echo __('SLA Plan');?>:
</td>
<td>
<select id="slaId" name="slaId" onchange="choose_sla()">
<option value="0" selected="selected" >— <?php echo __('System Default');?> —</option>
<?php
if($slas=SLA::getSLAs()) {
foreach($slas as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['slaId']==$id)?'selected="selected"':'',$name);
}
}
?>
</select>
<font class="error"> <?php echo $errors['slaId']; ?></font>
</td>
//test selected
<p id="cal_due"></p>
<script>
function choose_sla() {
var x = document.getElementById("slaId").value;
document.getElementById("cal_due").innerHTML = "You selected: " + x;
}
Check out put :
print_r($slas);
//Array ( [1] => Default SLA (48 hours - Active)
//[6] => SLA 93.33% ( 2880 นาที - 48 ชม.) (48 hours - Active)
//[5] => SLA 99.10% (388.8 นาที - 6.29 ชม.) (6 hours - Active)
//[3] => SLA 99.40% (129.6 นาที - 5 ชม.) (5 hours - Active)
//[2] => SLA 99.80% (86.4 นาที - 1.26 ชม.) (1 hours - Active) )
Result Current :
You selected : id = 1 {6,5,3,2} <<< value on select change
I can't query and return value of $row['grace_period'] = {48,6.29,5,1.26} ...
What you have a suggestion for my ?
Thank you very much ...