Loading...
Changes Saved.
Error Occurred!

KnowledgeBase

Building a custom ticket ID

Every ticket is issued a unique identifier which is used to locate that ticket in the system. That ticket ID is then included into all email notification messages sent by the system, and responding to those emails should post a response to that ticket.

If you wish to modify the way ticket ID looks like, you can do so in two ways. One is by changing the setting "Ticket ID Generation" on Administration => Settings => General Settings => Tickets page. There are two options you can choose there:

1. Random - the ticket IDs will be generated randomly, and will consist of 7 digits, followed by a dash ("-"), followed by another 10 digits. The digits are randomly selected.

2. Sequential - every ticket will receive an ID of it's order in the system. First ticket will have an ID "1", second "2", and so on.

 

If none of the allowed ways suit your needs, you can choose to modify the engine that builds the Random ticket ID code. Instead of "1234567-1234567890", you can choose to generate whatever you want.

To modify the ticket ID generation code, you will need to edit the file /admin/functions/ticket.php, and locate a line that has a text "function ticket_generate_id()" in it.

The code that generates ticket IDs looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function ticket_generate_id() {
    global $site;
    $last_id    = (int)ac_sql_select_one('=MAX(`id`)', '#ticket');
    if ( $site['ticket_id_type'] == 'seq' ) {
        return $last_id + 1;
    }
    $today_date = date("dm");
    $today_time = date("Hs");
    $rand       = mt_rand(12010, 98710);
    $rand2      = mt_rand(10, 90);
 
    if ( $last_id > 1000 ) {
        // ticket id is the current ticket id ($last_id),
        // a random number from 10 to 90 ($rand2)
        // the date/month in numbers ($today_date) and the hour/second in numbers ($today_time)
        $ticket_id = $last_id . '-' . $rand2 . $today_date . $today_time;
    } else {
        // ticket id is a random number from 12010 to 98710 ($rand2), the current ticket id ($last_id),
        // a random number from 10 to 90 ($rand2)
        // the date/month in numbers ($today) and the hour/second in numbers ($today_time)
        $ticket_id = $rand . $last_id . '-' . $rand2 . $today_date . $today_time;
    }
    return $ticket_id;
}

Simply modify the above code to return the different ticket ID, in the way you like it. In order to make this change, you will need to have a basic knowledge of PHP programming language.




Related Articles