Menambahkan Lampiran pada Catatan Internal di osTicket v1.6 RC5
Artikel berikut akan menunjukkan kepada Anda bagaimana menambahkan file lampiran pada Internal Note di osTicket v1.6 RC5. Jika Anda ingin mengimplementasikan hal ini pada v1.6 RC4, silahkan baca artikel yang mirip yang saya tulis dua hari yang lalu: Lampiran pada Catatan Internal di osTicket v1.6 RC4 .
- Pertama sekali, ubah tabel ticket_attachment dengan menambahkan sebuah nilai enum yang baru, yaitu: “N” ke dalam field ref_type, di samping nilai yang sudah ada: M dan R. Nilai N berarti: Note atau Internal Note dalam hal ini. Pastikan Anda tidak melewati langkah yang satu ini!
-
Buka file \include\staff\viewticket.inc.php, lalu cari kode ini:
219
<tr><td><?=Format::display($row['note'])?></td></tr>
setelah baris terakhir di kode tadi, tambahkan kode berikut:
220 221 222 223
<?php // added by Masino Sinaga, October 10, 2009, attachment on Internal Notes ?> <tr class="header"> <td><?php echo $ticket->getAttachmentStr($row['note_id'],'N')?></td> </tr>
-
Cari lagi kode yang ini:
363 364 365 366 367
<div style="margin-top: 3px;"> <label for="note" valign="top">Enter note content. <font class="error">* <?=$errors['note']?></font></label><br/> <textarea name="note" id="note" cols="80" rows="7" wrap="soft" style="width:90%"><?=$info['note']?></textarea> </div>setelah baris terakhir dari kode tadi, tambahkan kode di bawah ini:
368 369 370 371 372 373 374
<?php if($cfg->canUploadFiles()){ //TODO: may be allow anyways and simply email out attachment?? ?> <div style="margin-top: 3px;"> <label for="attachment" >Attach File:</label> <input type="file" name="attachment" id="attachment2" size=30px value="<?php echo $info['attachment']; ?>" /> <font class="error"> <?php echo $errors['attachment']; ?></font> </div> <?php }?>
-
Buka file \scp\tickets.php, dan cari kode ini:
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
case 'postnote': $fields=array(); $fields['title'] = array('type'=>'string', 'required'=>1, 'error'=>'Title required'); $fields['note'] = array('type'=>'string', 'required'=>1, 'error'=>'Note message required'); $params = new Validator($fields); if(!$params->validate($_POST)) $errors=array_merge($errors,$params->errors()); if(!$errors && $ticket->postNote($_POST['title'],$_POST['note'])){ $msg='Internal note posted'; if(isset($_POST['ticket_status']) && $_POST['ticket_status']) $ticket->setStatus($_POST['ticket_status']); }else{ $errors['err']=$errors['err']?$errors['err']:'Error(s) occured. Unable to post the note.'; } break;
lalu timpa dengan kode berikut ini:
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
case 'postnote': $fields=array(); $fields['title'] = array('type'=>'string', 'required'=>1, 'error'=>'Title required'); $fields['note'] = array('type'=>'string', 'required'=>1, 'error'=>'Note message required'); $params = new Validator($fields); if(!$params->validate($_POST)) $errors=array_merge($errors,$params->errors()); // Added by Masino Sinaga, October 10, 2009 for attachment on Internal Notes //Check attachments restrictions. if($_FILES['attachment'] && $_FILES['attachment']['size']) { if(!$_FILES['attachment']['name'] || !$_FILES['attachment']['tmp_name']) $errors['attachment']='Invalid attachment'; elseif(!$cfg->canUploadFiles()) //TODO: saved vs emailed attachments...admin config?? $errors['attachment']='upload dir invalid. Contact admin.'; elseif(!$cfg->canUploadFileType($_FILES['attachment']['name'])) $errors['attachment']='Invalid file type'; } // Added by Masino Sinaga, October 10, 2009, attachment on Internal Notes if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note'],$_POST['alert_assigned'],''))) { $msg='Internal note posted'; if(isset($_POST['ticket_status']) && $_POST['ticket_status']) $ticket->setStatus($_POST['ticket_status']); // Added by Masino Sinaga, October 10, 2009, attachment on Internal Notes //Finally upload attachment if any if($_FILES['attachment'] && $_FILES['attachment']['size']){ $ticket->uploadAttachment($_FILES['attachment'],$noteID,'N'); } }else{ $errors['err']=$errors['err']?$errors['err']:'Error(s) occured. Unable to post the note.'; } break;
Itu saja. Selamat mengkode!
Cetak Artikel Ini



Thanks a bunch!
You’re welcome.
Thanks Masino! I would like to implement this code in the recent 1.6 stable (and I tried) but it would appear that there were some minor changes to the scp/tickets.php that I just can’t get this working. Think you could assist?
Thanks again
@Rob
Sure. Get the answer from here: Add Attachment on Internal Note in osTicket v1.6 ST (Stable). Hope it helps.