Remind Staff about Assigned Ticket in osTicket System v1.6 RC5

There is an interesting feature request in osTicket Discussion Forum about how to send an email to an already assigned staff member to remind them to get on their tickets. To implement this new feature, I made a modification.

  1. Open \include\staff\viewticket.inc.php file, and find this code:

    91
    92
    93
    94
    95
    
    <table align="center" class="ticketinfo" cellspacing="1" cellpadding="3" width="100%" border=0>
    <tr>
    <th>Assigned Staff:</th>
    <td><?=$staff?Format::htmlchars($staff->getName()):'- unassigned -'?></td>
    </tr>

    then replace with this following code:

    91
    92
    93
    94
    95
    96
    97
    
            <table align="center" class="ticketinfo" cellspacing="1" cellpadding="3" width="100%" border=0>
                <tr>
                    <th>Assigned Staff:</th>
                    <td><?php $assigned_staff=$staff?Format::htmlchars($staff->getName()):'- unassigned -'?>
                    <?php echo $assigned_staff; ?> 
    		</td>
                </tr>

    find this code around line 135:

    135
    136
    137
    
        </tr>
    </table>
    <div>

    then replace with this following code:

    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    
        </tr>
    </table>
     
    <?php if ($assigned_staff!='- unassigned -') { ?>
    <form action="tickets.php?id=<?=$id?>" name="frmremindstaff" method="post" enctype="multipart/form-data">
      <input type="hidden" name="ticket_id" value="<?=$id?>" />
      <input type="hidden" name="a" value="remind" />
      <input type="hidden" name="staffId" value="<? echo $staff->getId(); ?>" />
      <input type="hidden" name="remind_message" value="Reminded" />
      <input class="button" type='submit' value='Remind <?php echo $assigned_staff ?> for this ticket!' />
    </form>             
    <?php } ?>
     
    <div>
  2. Open \include\class.ticket.php file, and find this code:

    1336
    1337
    
    }
    ?>

    before the first line of that code above, insert the following code:

    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    
        //Remind: staff
        function remindStaff($staffId,$message,$alertstaff=true) {
            global $thisuser,$cfg;
     
            $staff = new Staff($staffId);
            if(!$staff || !$staff->isAvailable() || !$thisuser)
    	  return false;
     
            // if($this->setStaffId($staff->getId())){
                //Reopen the ticket if cloed.                
                if($this->isClosed()) //Assigned ticket Must be open.
                    $this->reopen();
                //Send Notice + Message to assignee. (if directed)
                if($alertstaff && $staff->getId()!=$thisuser->getId()) { //No alerts for self assigned.
                    //Send Notice + Message to assignee.
                    $dept=$this->getDept();  // Updated by Masino Sinaga, before: $dept=$ticket->getDept(); 
                    if(!$dept || !($tplId=$dept->getTemplateId()))
                        $tplId=$cfg->getDefaultTemplateId();
     
                    $sql='SELECT assigned_alert_subj,assigned_alert_body FROM '.EMAIL_TEMPLATE_TABLE.
                     ' WHERE cfg_id='.db_input($cfg->getId()).' AND tpl_id='.db_input($tplId);
                    if(($resp=db_query($sql)) && db_num_rows($resp) && list($subj,$body)=db_fetch_row($resp)){
     
                        $body=$this->replaceTemplateVars($body);
                        $subj=$this->replaceTemplateVars($subj);
                        $body = str_replace('%note',$message,$body);
                        $body = str_replace("%message", $message,$body); //Previous versions used message.
     
                        if(!($email=$cfg->getAlertEmail()))
                            $email=$cfg->getDefaultEmail();
     
                        if($email) {
                            $email->send($staff->getEmail(),$subj,$body);
                        }
                    }else {
                        Sys::log(LOG_WARNING,'Template Fetch Error',"Unable to fetch 'assigned' alert template #$tplId");
                    }
                }
                return true;
            // }
            // return false;
        }
  3. Open \scp\tickets.php file, and find this code:

    127
    128
    
            case 'assign':
                $fields=array();

    before the first line of that code above, insert the following code:

    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    
            case 'remind':
                $fields=array();
                $fields['staffId']          = array('type'=>'int',  'required'=>1, 'error'=>'Select assignee');
                $fields['remind_message']   = array('type'=>'text',  'required'=>1, 'error'=>'Message required');
                $params = new Validator($fields);
                if(!$params->validate($_POST)){
                    $errors=array_merge($errors,$params->errors());
                }
                if(!$errors && $ticket->remindStaff($_POST['staffId'],$_POST['remind_message'])){
                    $msg="This staff has been reminded.";
                }else{
                    $errors['err']=$errors['err']?$errors['err']:'Unable to remind staff at the moment. Please try again later.';
                }
                break;
  4. Open again \include\class.ticket.php file, and find this code:

    408
    409
    410
    
        //Replace base variables.
        function replaceTemplateVars($text){
            global $cfg;

    then replace with this following code:

    408
    409
    410
    411
    
        //Replace base variables.
        function replaceTemplateVars($text){
            global $cfg;
            global $thisuser;

    find again this code:

    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    
            $search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/',
                            '/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/');
            $replace = array($this->getId(),
                             $this->getExtId(),
                             $this->getEmail(),
                             $this->getName(),
                             $this->getSubject(),
                             $this->getHelpTopic(),
                             $this->getPhoneNumber(),
                             $this->getStatus(),
                             $this->getPriority(),
                             ($dept?$dept->getName():''),
                             ($staff?$staff->getName():''),
                             Format::db_daydatetime($this->getCreateDate()),
                             Format::db_daydatetime($this->getDueDate()),
                             Format::db_daydatetime($this->getCloseDate()),
                             $cfg->getBaseUrl());

    then replace with this following code:

    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    
            $search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/',
                            '/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/','/%assignee/','/%assigner/');
            $replace = array($this->getId(),
                             $this->getExtId(),
                             $this->getEmail(),
                             $this->getName(),
                             $this->getSubject(),
                             $this->getHelpTopic(),
                             $this->getPhoneNumber(),
                             $this->getStatus(),
                             $this->getPriority(),
                             ($dept?$dept->getName():''),
                             ($staff?$staff->getName():''),
                             Format::db_daydatetime($this->getCreateDate()),
                             Format::db_daydatetime($this->getDueDate()),
                             Format::db_daydatetime($this->getCloseDate()),
                             $cfg->getBaseUrl(),
    			 ($staff?$staff->getName():''),
    			 $thisuser->getUsername());
Share

1,254 viewsPrint This Post Print This Post

Speak Your Mind

*


*