0

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 :

  1. on select change SLA Plan
  2. auto active immediately [client site]
  3. conditions check if (id) [server site]
  4. query $row['grace_period']
  5. auto calculate Due Date and Time
  6. display resulte date and time in text Box [Due Date]

Example :

  1. select : SLA Plan :Default SLA (48 hours - Active)
  2. Today : 2015/10/12 14:00:10
  3. 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" >&mdash; <?php echo __('System Default');?> &mdash;</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>

            &nbsp;<font class="error">&nbsp;<?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 ...

supachok
  • 1
  • 2
  • I 'am fine default code program osTicket .It can open Ticket if select SLA Plan already,ฺBefore system auto calculate Due Date in function getSLADueDate() ....next step to display in ticket page ... End Issue Auto SLA Paln But ... New Issue "Float hours/minute" .. Now it calculate format Integer I find code query line 62 in class.ticket.php .'DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)) as sla_duedate ' – supachok Oct 13 '15 at 07:51
  • Edit : 'DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR_MINUTE)) as sla_duedate ' – supachok Oct 13 '15 at 08:28
  • DATE_ADD(date,INTERVAL expr type) | Type HOUR_MINUTE – supachok Oct 13 '15 at 08:28

0 Answers0