Bagaimana Menambahkan Field Tambahan pada Form Buka Tiket di Sisi Klien di osTicket v1.6 RC5

Ada banyak pertanyaan yang diajukan mengenai bagaimana cara menambahkan field tambahan atau field baru ke dalam form buka tiket lalu menampilkannya pada halaman viewticket di Sistem osTicket. Salah satu pertanyaan tersebut dapat Anda lihat dengan mengklik tautan ini. Modifikasi berikut saya buat untuk menjawab pertanyaan tadi. Dalam contoh ini, kita akan menambahkan beberapa control checkboxes sebanyak 5 buah, ditambah lagi dengan sebuah textbox, di mana mereka dikelompokkan ke dalam dua field tambahan, masing-masing: applications dan productkey, ke atas form di sisi klien. Kita akan membuatnya juga untuk sisi staf pada artikel yang terpisah di hari selanjutnya.

  1. Pertama sekali, Anda harus mengubah tabel ost_ticket di database osticket yang Anda gunakan dengan menambahkan dua field baru: applications dan productkey. Anda dapat menggunakan skrip SQL berikut (mohon diingat bahwa ost_ adalah nama awalan tabel, dan jika berbeda dengan nama awalan tabel yang Anda gunakan, harap agar Anda sesuaikan sendiri):

    ALTER TABLE ost_ticket
    ADD COLUMN `applications` varchar(100) default '' NOT NULL,
    ADD COLUMN `productkey` varchar(50) default'' NOT NULL;
  2. Buka file \include\client\open.inc.php, dan cari kode ini:

    95
    96
    
        <? }
        }?>

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

    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    
        <tr>
          <td>Applications: </td>
          <td>
            <input name=applications[] type=checkbox value="Application 1" >Application 1
            <input name=applications[] type=checkbox value="Application 2" >Application 2
            <input name=applications[] type=checkbox value="Application 3" >Application 3
            <input name=applications[] type=checkbox value="Application 4" >Application 4
            <input name=applications[] type=checkbox value="Application 5" >Application 5
          </td>
        </tr>
        <tr>
          <td>Product Key: </td>
          <td>
            <input type="text" name="productkey" size="35" value="<?=$info['productkey']?>">
          </td>    
        </tr>
  3. Buka file \include\class.ticket.php, dan cari kode ini:

    44
    
        var $overdue;

    setelah baris kode tersebut, tambahkan kode berikut:

    45
    46
    
        var $applications;
        var $productkey;

    Cari lagi kode ini:

    88
    
                $this->overdue =$row['isoverdue'];

    lalu timpa dengan kode berikut:

    88
    89
    90
    
                $this->overdue =$row['isoverdue'];
                $this->applications =$row['applications'];
                $this->productkey =$row['productkey'];

    Cari lagi kode yang ini:

    140
    141
    142
    
        function getSubject() {
            return $this->subject;
        }

    setelah baris terakhir dari kode tadi, tambahkan kode berikut:

    143
    144
    145
    146
    147
    148
    149
    
        function getApplications() {
            return $this->applications;
        }
     
        function getProductKey() {
            return $this->productkey;
        }

    Cari lagi kode yang ini:

    1107
    
            $fields['message']  = array('type'=>'text',     'required'=>1, 'error'=>'Message required');

    setelah baris kode tadi, tambahkan kode berikut:

    1108
    1109
    
            $fields['applications']  = array('type'=>'text',     'required'=>0, 'error'=>'Applications required');
            $fields['productkey']  = array('type'=>'text',     'required'=>0, 'error'=>'Product key required');

    Cari lagi kode ini:

    1197
    1198
    1199
    
                    Sys::alertAdmin('Overlimit Notice',$msg);
                }
            }

    setelah baris terakhir dari kode tadi, tambahkan kode berikut:

    1201
    1202
    1203
    1204
    1205
    1206
    1207
    
            $mycounter=0;
    	foreach ($var['applications'] as $app)
    	{
    	  $strapp .= ($mycounter==0)?$app:", ".$app."";
    	  $mycounter++;          	
            }
            unset($app);

    Cari lagi kode yang ini:

    1260
    
                    ',ip_address='.db_input($ipaddress).

    lalu timpa dengan kode berikut:

    1260
    1261
    1262
    
                    ',ip_address='.db_input($ipaddress).
    		',applications='.db_input($strapp).
    		',productkey='.db_input($var['productkey']).
  4. Buka file \include\client\viewticket.inc.php, dan cari kode ini:

    27
    28
    29
    30
    
    	<tr>
                    <th>Create Date:</th>
                    <td><?=Format::db_datetime($ticket->getCreateDate())?></td>
                </tr>

    setelah baris terakhir dari kode tadi, tambahkan kode berikut:

    31
    32
    33
    34
    
          <tr>
                    <th>Applications:</th>
                    <td><?=$ticket->getApplications()?></td>
          </tr>

    Cari lagi kode yang ini:

    43
    44
    45
    46
    
                <tr>
                    <th>Phone:</th>
                    <td><?=Format::phone($ticket->getPhoneNumber())?></td>
                </tr>

    setelah baris kode tadi, tambahkan kode berikut:

    47
    48
    49
    50
    
                <tr>
                    <th>Product Key:</th>
                    <td><?=$ticket->getProductKey()?></td>
                </tr>

Itulah semuanya. Semoga bermanfaat.

Share

2,788 kali dibacaCetak Artikel Ini Cetak Artikel Ini

Komentar

  1. Antony Hapsas mengatakan:

    Hello,

    I followed your excellent guide and added more fields in client area. What should I do showing new custom fields in admin area ?
    link could be like this one …/support/scp/tickets.php?id=10

    thank you very much

  2. Masino Sinaga mengatakan:

    Hi Antony,

    I will create that modification, too. So, stay tuned! :-)

  3. Michael Jurovski mengatakan:

    This site is an astonishingly good resource!

    Just ‘Thank you’

    Mike

  4. jason mengatakan:

    Hi masino, when i edit the code, it seems working but found one bug… when user is already online (log in to view his ticket), when he clicks on open new ticket again, it seems the templates got error .. it is not loading the correct / full templates.. can you recheck on this ?
    thanks

  5. bjorn mengatakan:

    Hi Masino,

    where can i find the tutorial about scp part, i have folowed the turtorial above, but can not find the info in the scp part.

    thanks

    bjorn

  6. SIMON mengatakan:

    the fields dont show for the support persion when opening the ticket

    i have customers who tested this and put license keys in
    but when admin or staff view ticket it does not appear
    please help

Utarakan pikiran Anda

*


*