Apa yang akan klien Anda lakukan jika mereka lupa dengan nomor tiket mereka? Khususnya ketika mereka akan memeriksa status tiket setelah beberapa hari yang lalu mereka menerima email yang berisi nomor tiket dari sistem tiket milik Anda? Pada beberapa sistem tiket, mereka sangat direkomendasikan agar membuka kembali tiket baru supaya dapat mengetahui nomor tiket mereka (termasuk nomor tiket yang mereka lupa tadi, tentunya). Demikian juga pada Sistem osTicket versi 1.6 RC5 (versi terakhir yang saya gunakan ketika saya menulis artikel ini), tidak ada fitur mengenai hal ini. osTicket juga merekomendasikan hal yang sama seperti yang sudah saya jelaskan di atas tadi. Lalu, saya membuat modifikasi dengan menyediakan sebuah fitur baru tentang Lupa Nomor Tiket? ke dalam Sistem osTicket.
Modifikasi ini akan menambahkan sebuah tautan yang bernama Forgot Ticket Number? di bawah tombol Check Status pada file index.php. Sehingga, saat klien Anda ingin memeriksa tiket mereka namun tiba-tiba lupa dengan nomor tiketnya, kita mengasumsikan mereka akan mengklik tautan tersebut, dan setelah itu, klien Anda diharapkan memasukkan alamat email mereka dan mengklik tombol Send My Ticket List untuk mendapatkan kembali daftar nomor tiket mereka. Halaman yang muncul ini, sebenarnya, adalah halaman yang sama dengan yang digunakan ketika klien ingin memeriksa status tiket mereka. Anda dapat melihat di bagian atas dari tautan Forgot Ticket Number?, ada tautan yang bernama Ticket Status dan akan disembunyikan isinya ketika bagian Forgot Ticket Number? sedang terbuka. Demikian sebaliknya. Selain itu, modifikasi ini juga akan menambahkan sebuah bagian baru di dalam template email di panel admin. Anda dapat menentukan sendiri template email yang akan dikirim ke klien Anda.
Gambar: http://www.osticket.com/forums/showthread.php?t=2729
- Pertama sekali, Anda harus menambahkan dua field baru ke dalam tabel ost_email_template pada database yang digunakan oleh Sistem osTicket Anda. Jalankan SQL berikut menggunakan phpMyAdmin dari cpanel atau dengan menggunakan tools MySQL lainnya:
ALTER TABLE ost_email_template ADD COLUMN `forgot_ticket_subj` varchar(255) NOT NULL, ADD COLUMN `forgot_ticket_body` text NOT NULL;
- Buka file index.php, lalu cari kode ini:
56 57
<input type="submit" class="button2" value="Check Status"> </fieldset>
lalu ganti dengan:
56 57 58 59 60 61
<input type="submit" class="button2" value="Check Status"> </fieldset> <fieldset> <label> </label> <div class="forgotticketnumber"><a href="forgotticket.php">Forgot Ticket Number?</a></div> </fieldset>
- Buka file \styles\main.css, lalu cari kode ini:
1 2 3 4 5 6 7
body { font-family:arial, helvetica, sans-serif; font-size:9pt; margin:0; padding:0; text-align:center; }setelah baris terakhir di kode tadi, tambahkan kode berikut:
9 10 11 12 13
.forgotticketnumber { font-size:8pt; padding-right:0.1px; padding-left:140px; } - Buat sebuah file baru dan salin kode berikut ke dalamnya, lalu simpan dengan nama forgotticket.php, dan tempatkan di direktori utama atau root dari Sistem osTicket Anda:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<?php /** * @desc Forgot Ticket Number * @author Masino Sinaga * @copyright July 27, 2009 */ require_once('main.inc.php'); if(!defined('INCLUDE_DIR')) die(LOGIN_FATAL_ERROR); define('CLIENTINC_DIR',INCLUDE_DIR.'client/'); define('OSTCLIENTINC',TRUE); //make includes happy require_once(INCLUDE_DIR.'class.client.php'); require_once(INCLUDE_DIR.'class.ticket.php'); include_once(INCLUDE_DIR.'class.email.php'); global $cfg; $forgotmsg='Email required'; if($_POST && (!empty($_POST['femail']) )): $femail=trim($_POST['femail']); if(!$errors && Validator::is_email($femail)) { //$email= new Client($femail); $sqle='SELECT email, ticketID, name FROM '.TICKET_TABLE. ' WHERE email='.db_input($femail).' AND status = "open"'; $respe=db_query($sqle); $ticketNumber = ''; $countRec = db_num_rows($respe); if ($countRec > 0) { $i = 1; $nameForgot = ''; while (list($email,$ticketID,$name) = db_fetch_row($respe)){ if ($i==1) { $ticketNumber .= $ticketID; } else { $ticketNumber .= ", ". $ticketID; } $nameForgot = $name; $i++; } $tplId=$cfg->getDefaultTemplateId(); $sql='SELECT forgot_ticket_subj,forgot_ticket_body FROM '.EMAIL_TEMPLATE_TABLE. ' WHERE cfg_id='.db_input($cfg->getId()).' AND tpl_id='.db_input($tplId); $resp=db_query($sql); if(db_num_rows($resp) && list($subj,$body)=db_fetch_row($resp)){ $body = str_replace("%name", $nameForgot, $body); $body = str_replace("%email", $email, $body); $body = str_replace("%ticketlist", $ticketNumber, $body); if(!$dept || !($email=$dept->getAutoRespEmail())) $email=$cfg->getDefaultEmail(); if($email) $email->send($femail,$subj,$body); } require(CLIENTINC_DIR.'header.inc.php'); echo "We have sent your ticket list. "; echo "Please check your email in a few minutes."; require(CLIENTINC_DIR.'footer.inc.php'); exit; } else { require(CLIENTINC_DIR.'header.inc.php'); echo "<p align='center'>Sorry, but that email does not exist."; echo "<input name='back' type='Button' value='Go Back' onclick='javascript:window.history.back()'>"; require(CLIENTINC_DIR.'footer.inc.php'); exit; } } endif; require(CLIENTINC_DIR.'header.inc.php'); require(CLIENTINC_DIR.'login.inc.php'); require(CLIENTINC_DIR.'footer.inc.php'); ?>
- Buka file \include\client\login.inc.php, lalu cari kode berikut:
5 6 7
$t=Format::htmlchars($_POST['lticket']?$_POST['lticket']:$_GET['t']); ?> <div>
ganti kode tersebut dengan kode berikut ini:
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
$t=Format::htmlchars($_POST['lticket']?$_POST['lticket']:$_GET['t']); $f=Format::htmlchars($_POST['femail']?$_POST['femail']:$_GET['f']); ?> <head> <script type="text/javascript" > <!-- function expand_collapse(divid,imgpath,imgname) {if(document.getElementById(divid).style.display=='none') {document.getElementById(divid).style.display='block';eval("document."+imgname+".src = imgpath + '/col-btn.gif'");} else {document.getElementById(divid).style.display='none';eval("document."+imgname+".src = imgpath + '/exp-btn.gif'");}} //--> </script> </head> <div>
Cari juga kode berikut:
28
<div style="margin:5px 0px 100px 0;text-align:center; width:100%;">
lalu ganti dengan kode di bawah ini:
28 29 30 31 32 33 34 35
<div style="margin:5px 0px 100px 0;text-align:center; width:100%;"> <?php $img = ($loginmsg=='')?'./images/exp-btn.gif':'./images/col-btn.gif'; $disp = ($loginmsg=='')?'display:none':'display:true'; echo '<a href="javascript:void(0);" class="Button" onClick="javascript:expand_collapse(\'ticket_status\',\'./images\',\'email_ticket\');">Ticket Status <img src="'.$img.'" name="email_ticket"></a>'; echo '<div id="ticket_status" style="'.$disp.'">'; ?>
Cari lagi kode berikut:
41
<form action="login.php" method="post">
lalu ganti dengan kode di bawah ini:
41
<form name="login" action="login.php" method="post">
Cari kode berikut:
49 50
</form> </div>
ganti dengan kode di bawah ini:
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
</form> </div> <br /><br /> <?php $img = ($forgotmsg=='')?'./images/exp-btn.gif':'./images/col-btn.gif'; $disp = ($forgotmsg=='')?'display:none':'display:true'; echo '<a href="javascript:void(0);" class="Button" onClick="javascript:expand_collapse(\'forgot_ticket\',\'./images\',\'pwd_exp_col\');">Forgot Ticket Number? <img src="'.$img.'" name="pwd_exp_col"></a>'; echo '<div id="forgot_ticket" style="'.$disp.'">'; ?> <span class="error"><?=Format::htmlchars($forgotmsg)?></span> <form name="forgot" action="forgotticket.php" method="post"> <table cellspacing="1" cellpadding="5" border="0" bgcolor="#000000" align="center"> <tr bgcolor="#EEEEEE"> <td>E-Mail:</td><td><input type="text" name="femail" size="25" value="<?=$f?>"></td> <td><input class="button" type="submit" value="Send My Ticket List"></td> </tr> </table> </form> </div> </div> - Buka file include\class.msgtpl.php, lalu cari kode berikut:
92
$fields['ticket_reply_body'] = array('type'=>'string', 'required'=>1, 'error'=>'Template message required');
ganti dengan kode di bawah ini:
92 93 94 95 96
$fields['ticket_reply_body'] = array('type'=>'string', 'required'=>1, 'error'=>'Template message required'); // MOD Forgot Ticket Number, added by Masino Sinaga, July 27, 2009 $fields['forgot_ticket_subj'] = array('type'=>'string', 'required'=>1, 'error'=>'Subject required'); $fields['forgot_ticket_body'] = array('type'=>'string', 'required'=>1, 'error'=>'Template message required');
Cari juga kode berikut:
143 144
',ticket_reply_body='.db_input(Format::striptags($var['ticket_reply_body'])). ' WHERE tpl_id='.db_input($this->getId());
lalu ganti dengan kode di bawah ini:
143 144 145 146
',ticket_reply_body='.db_input(Format::striptags($var['ticket_reply_body'])). ',forgot_ticket_subj='.db_input(Format::striptags($var['forgot_ticket_subj'])). ',forgot_ticket_body='.db_input(Format::striptags($var['forgot_ticket_body'])). ' WHERE tpl_id='.db_input($this->getId());
Cari lagi kode berikut:
209
',ticket_reply_body='.db_input(Format::striptags($info['ticket_reply_body']));
lalu ganti dengan kode di bawah ini:
209 210 211
',ticket_reply_body='.db_input(Format::striptags($info['ticket_reply_body'])). ',forgot_ticket_subj='.db_input(Format::striptags($var['forgot_ticket_subj'])). ',forgot_ticket_body='.db_input(Format::striptags($var['forgot_ticket_body']));
- Buka file \include\staff\template.inc.php, lalu cari kode berikut:
88 89 90 91 92
<tr> <th>Message Body:</td> <td><textarea rows="7" cols="75" name="ticket_reply_body"><?=$tpl['ticket_reply_body']?></textarea> <font class="error"> <?=$errors['ticket_reply_body']?></font></td> </tr>lalu ganti dengan kode di bawah ini:
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
<tr> <th>Message Body:</td> <td><textarea rows="7" cols="75" name="ticket_reply_body"><?=$tpl['ticket_reply_body']?></textarea> <font class="error"> <?=$errors['ticket_reply_body']?></font></td> </tr> <tr class="header"><td colspan=2 > Forgot Ticket Number</td></tr> <tr class="subheader"><td colspan=2 > Message template used when responding the Forgot Ticket Number request from user. </td></tr> <tr> <th>Subject</th> <td> <input type="text" size="65" name="forgot_ticket_subj" value="<?=$tpl['forgot_ticket_subj']?>"> <font class="error"> <?=$errors['forgot_ticket_subj']?></font></td> </tr> <tr> <th>Message Body:</td> <td><textarea rows="7" cols="75" name="forgot_ticket_body"><?=$tpl['forgot_ticket_body']?></textarea> <font class="error"> <?=$errors['forgot_ticket_body']?></font></td> </tr>
Mohon diingat bahwa Anda pun membutuhkan dua file tambahan berikut.
Kedua file tersebut adalah:
1) col-btn.gif (sama dengan gambar minus)
Collaps button
2) exp-btn.gif (sama dengan gambar plus)
Expand button
Klik kanan di file tersebut, lalu pilih Save File As… untuk menyimpan ke komputer Anda. Kemudian, upload kedua file ini dibutuhkan untuk menampilkan efek collaps dan expand.
Letakkan kedua file ini ke dalam sub direktori \images\ dari Sistem osTicket Anda.
Sebelum mengimplementasikan modifikasi ini di Sistem osTicket Anda, jangan lupa untuk menentukan terlebih dulu template email yang terkait dengan fitur Forgot Ticket Number ini. Silahkan ke panel admin, klik Emails -> Templates, lalu klik item tautan yang bernama osTicket Default Template (satu-satunya record yang terdapat di sana setelah Anda berhasil menginstall Sistem osTicket), lalu isi kedua kotak teks di bagian Forgot Ticket Number seperti berikut ini:
Subject = Forgot Ticket Number
Message Body = %name,
This is the list of your tickets:
%ticketlist
Admin
lalu klik tombol Save Changes untuk menyimpan perubahan.
Selamat menggunakan kode ini!

I implemented the Forgot Ticket Number into my OSTicket system and now I can not update my templates. I guess I implemented the changes before defining the email template. Is there any work around to get this to work? Thanks.
@Colin
Have you re-checked all of your changes regarding this modification? Make sure each step has been already done correctly. Typically, that problem caused by a little mistake such as typo or something like that. Also, make sure you have already had two additional new fields in your ost_email_template table.
@Masino Sinaga
I checked all of the updates and they are all correct. The error message I receive is “Error updating the template. Try again” when I go to enter in the Subject “Forgot Ticket Number” and message body. Should I try to rerun the SQL script. Thanks!
Yes, you should. That’s why I put that step on the first one. It has to be done first of all in order to avoid that error. Please try again.
I am getting the same error with not being able to update the template. I did all the steps in order and was careful to do them precisely–except that I accidently made the forgot_ticket_body field a varchar field at first and implemented. I then changed it to text and tried again, but it does not work–I cannot edit my template. Is there anything that can be done?
Everything is working correctly except the mod is sending a blank email.
Thanks so much.
I’ve got the same pb after installing your MOD: “Error updating the template. Try again”.
Checking and analysing the DB with phpMyAdmin reported no pb.
I entered the email auto-response’s text directly in phpMyAdmin and had no pb to ask for lost tickets thru a fake user and received an answer with opened & closed tx.
Yet, I was still unable to modify my template (Error updating…).
I was then thinking the pb could lie in the ./include/staff/.
Looking in my svn I found that I mistakenly made the change on step 7 at line 42 instead of 88. Me stupid!
This created the mess.
What made me discover this was lines 89 and 105 (step 7), where you read :
Message Body:.
Quite an original ending for a start tag (the orig file has the same error).
Line 43 is Message Body: (orig file has correct html there).
Now it works.
Hope this helps,
Regards.
Ha!
The sytem seems to mess up html tags.
Let’s try this way.
… where you read :
Message Body:.
Quite an original ending for a start tag (the orig file has the same error).
Line 43 is Message Body: (orig file has correct html there).
I have updated the code from 88 line but still facing the same prob.
Error: “Error updating the template. Try again”
Or if possible please send me “template.inc.php” for version osticket_1.6.rc5
Please suggest.
@Ramesh Kumar
Have you defined your email template from Admin Panel -> Emails -> Templates -> osTicket Default Template -> Forgot Ticket Number ?
Error updating template usually happened if you have not defined the related template, yet. Make sure you have defined it. See the latest section/instruction in my article above.
Good luck!
@Francois
Glad to hear good news from you.
I am having the same problem with saving the template, I have read all of the above and checked I have everything in the right place but still no joy.
I have noticed in phpmyadmin that the two new tables are empty at present, is this correct?
Can you shed any light on my problem?
Thanks
Yogiman
Very appreciative of this Mod…I did follow all the steps, then noticed at the end that I was suppose to define the e-mail template…When I tried to do this, after I clicked “Add”, I got a blank page and could not define any variables…I tried reruning the MySql Script but I got the message that those fields already exist…I am a little stuck as to what to do…I am running the newest version of OSTicket as I just downloaded it…please help. Thank you so much.
~Chris
Hi,
I’ve just implemented this, but I dont see the EMail setup in the templates section.
Se debe colocar al final, archivo “template.inc.php”
Forgot Ticket Number
Message template used when responding the Forgot Ticket Number request from user.
Subject
<input type="text" size="65" name="forgot_ticket_subj" value="”>
Message Body:
Hi
Thank you for this wonderful mod.
But i am facing problem in implementing it.
I guess i am using 1.6 ST is the main cause .. but still most preferred option will be to ask..
Whether this MOD will work on 1.6ST?
Because in your step # 5
instead of
$t=Format::htmlchars($_POST['lticket']?$_POST['lticket']:$_GET['t']);
in 1.6ST i do have
$t=Format::input($_POST['lticket']?$_POST['lticket']:$_GET['t']);
so not sure about replacing it or not…
so afraid to proceed below that step..
please guide me for 1.6ST