Ada sebuah permintaan fitur yang cukup menarik di Forum Diskusi osTicket tentang bagaimana cara mengirim email kepada seorang staf yang sudah ditugaskan untuk mengingatkan kembali staf tersebut terhadap tiket tadi. Untuk mengimplementasikan fitur baru ini, saya berhasil membuat modifikasi.
-
Buka file \include\staff\viewticket.inc.php, lalu cari kode ini:
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>
ganti dengan kode di bawah ini:
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>selanjutnya cari kode ini di sekitar baris 135:
135 136 137
</tr> </table> <div>
kemudian ganti dengan kode di bawah ini:
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>
-
Buka file \include\class.ticket.php, lalu cari kode ini:
1336 1337
} ?>
sebelum baris pertama dari kode di atas, sisipkan kode berikut ini:
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; }
-
Buka file \scp\tickets.php, dan cari kode ini:
127 128
case 'assign': $fields=array();
sebelum baris pertama dari kode di atas, sisipkan kode berikut ini:
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;
-
Buka kembali file \include\class.ticket.php, lalu cari kode ini:
408 409 410
//Replace base variables. function replaceTemplateVars($text){ global $cfg;
kemudian ganti dengan kode berikut ini:
408 409 410 411
//Replace base variables. function replaceTemplateVars($text){ global $cfg; global $thisuser;
cari lagi kode yang ini:
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());
kemudian ganti dengan kode yang ini:
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());

Komentar Terakhir