Menambahkan Lampiran pada Catatan Internal di osTicket v1.6 ST (Stabil)

Karena adanya sedikit perbedaan kode di dalam berkas /scp/tickets.php antara osTicket v1.6 RC5 dan osTicket v1.6 ST (Stabil; versi terakhir saat artikel ini saya tulis), dan juga adanya sebuah permintaan yang ditujukan kepada saya melalui tulisan di Forum Diskusi osTicket, maka modifikasi yang saya buat ini ditujukan khusus kepada mereka yang ingin mengimplementasikan Lampiran di Catatan Internal pada osTicket v1.6 ST.

  1. Pertama sekali, Anda harus mengubah tabel ticket_attachment dengan menambahkan sebuah nilai enum, yaitu: “N” ke dalam field ref_type, di samping nilai yang sudah ada: M dan R. Nilai N ini artinya adalah: Note atau Internal Note dalam hal ini. Pastikan sekali lagi bahwa Anda tidak melewatkan langkah yang ini!
  2. Buka file \include\staff\viewticket.inc.php, dan temukan kode ini:

    219
    
                <tr><td><?=Format::display($row['note'])?></td></tr>

    setelah baris terakhir dari kode tadi, tambahkan kode berikut ini:

    220
    221
    222
    223
    
                <?php // added by Masino Sinaga, Februari 26, 2009, attachment on Internal Notes osTicket v1.6 ST ?>
                <tr class="header">
                  <td><?php echo $ticket->getAttachmentStr($row['note_id'],'N')?></td>
                </tr>
  3. 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">*&nbsp;<?=$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 berikut 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">&nbsp;<?php echo $errors['attachment']; ?></font>
                            </div>
                            <?php }?>
  4. Buka file \scp\tickets.php, dan temukan kode yang ini:

    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());
     
                if(!$errors && $ticket->postNote($_POST['title'],$_POST['note'])){
                    $msg='Internal note posted';
                    if(isset($_POST['ticket_status']) && $_POST['ticket_status']){
                        if($ticket->setStatus($_POST['ticket_status']) && $ticket->reload()){
                            $msg.=' and status set to '.($ticket->isClosed()?'closed':'open');
                            if($ticket->isClosed())
                                $page=$ticket=null; //Going back to main listing.
                        }
                    }
                }elseif(!$errors['err']) {
                    $errors['err']='Error(s) occured. Unable to post the note.';
                }
                break;

    lalu timpa dengan kode berikut:

    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    
            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, February 26, 2010 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, February 26, 2010 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']){
                        if($ticket->setStatus($_POST['ticket_status']) && $ticket->reload()){
                            $msg.=' and status set to '.($ticket->isClosed()?'closed':'open');
                            if($ticket->isClosed())
                                $page=$ticket=null; //Going back to main listing.
                        }
                    } 
                    // Added by Masino Sinaga, February 26, 2010, 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;

Itulah semuanya. Saya sudah mencobanya, dan semuanya nampak berjalan dengan baik. Selamat menikmati kode yang indah!

Share

3,829 kali dibacaCetak Artikel Ini Cetak Artikel Ini

Komentar

  1. steve mengatakan:

    can someone point me to a tutorial on how to do this?
    ———-
    alter the ticket_attachment table by adding a new enum value, that is: “N” into ref_type field
    ——-

    thanks!

  2. steve mengatakan:

    figured it out – you can change this by editing the re_type row under the ‘structure’ tab in the ticket_attachment table using phpMyAdmin.

  3. Brett mengatakan:

    Fantastic!

  4. Mads Kikkenborg mengatakan:

    Hi,

    After this implement, then I can’t see the internal notes “Closed by…”

    Can anyone help me?

  5. bebo mengatakan:

    thanks for the codes needed help on my website

  6. Curcio mengatakan:

    @Mads Kikkenborg
    First of all, congratulations Mr. Sinaga for your great work.

    To solve the closed by problem, you have to invest the last part of the code, like this:

         case 'postnote':
                $fields=array();
                $fields['title']    = array('type'=>'string',   'required'=>1, 'error'=>'Titulo necessário');
                $fields['note']     = array('type'=>'string',   'required'=>1, 'error'=>'Mensagem necessária');
                $params = new Validator($fields);
                if(!$params->validate($_POST))
                    $errors=array_merge($errors,$params->errors());
     
                // Added by Masino Sinaga, February 26, 2010 for attachment on Internal Notes
                //Check attachments restrictions.  
                if($_FILES['attachment'] && $_FILES['attachment']['size']) {
                    if(!$_FILES['attachment']['name'] || !$_FILES['attachment']['tmp_name'])
                        $errors['attachment']='anexo invalido';
                    elseif(!$cfg->canUploadFiles()) //TODO: saved vs emailed attachments...admin config??
                        $errors['attachment']='Diretorio upload invalido. Contate admin.';
                    elseif(!$cfg->canUploadFileType($_FILES['attachment']['name']))
                        $errors['attachment']='Tipo de arquivo invalido';
                }
     
                // Added by Masino Sinaga, February 26, 2010 attachment on Internal Notes
                if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note'],$_POST['alert_assigned'],''))) {  
                    $msg='Nota interna postada';
                       //Finally upload attachment if any
                    if($_FILES['attachment'] && $_FILES['attachment']['size']){
                        $ticket->uploadAttachment($_FILES['attachment'],$noteID,'N');
                    }
     
    		if(isset($_POST['ticket_status']) && $_POST['ticket_status']){
                        if($ticket->setStatus($_POST['ticket_status']) && $ticket->reload()){
                            $msg.=' e status alterado para '.($ticket->isClosed()?'aberto':'fechado');
                            if($ticket->isClosed())
                                $page=$ticket=null; //Going back to main listing.
                        }
                    } 
                    // Added by Masino Sinaga, February 26, 2010, attachment on Internal Notes
     
     
                }else{
                    $errors['err']=$errors['err']?$errors['err']:'Erro(s) ocorrido(s)! Tente novamente..';
                }
                break;
  7. Jorge Aguilar mengatakan:

    if someone have problems with this mood and email to all with internal notes (Not sending mails)

    in the line code:

    if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note'],$_POST['alert_assigned'],''))) {

    change for

    if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note']))){
  8. Jorge Aguilar mengatakan:

    the mod not work to mail to all

    when i change for:

    if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note']))){

    the attachment not upload, but when i write:

    if(!$errors && ($noteID=$ticket->postNote($_POST['title'],$_POST['note'],$_POST['alert_assigned'],''))) {

    Attachment succesfull upload but not mail to all

  9. glenn mengatakan:

    This is a great fix for as issue which stopped me using osticket.

    The only downside I see is that I can open the attachment when looking in the ticket. It says the note and description but shows nothing. Checking in the file I can see the attachment is there. How can I resolve this

    Thanks

Utarakan pikiran Anda

*


*