Page 1 of 1

Tracking ID

Posted: Mon Apr 23, 2012 8:54 pm
by steve
Hi,

I am trying to edit the way HESK generates my Tracking ID's.

I want it to be YYYY-MM-DD-001, where the first ticket created in a day is 001, then each subsequent ticket created that day is increased by one.

Example,

First tracking ID of today would be 2012-04-23-001, throughout the day we created 4 tickets, so the last Tracking ID of the day would be 2012-04-23-004

Here is what I have so far.

Code: Select all

    /* Generate the ID */
    $trackingID  = '';
    $trackingID .= date(Y);
    $trackingID .= '-';
    $trackingID .= date(m);
    $trackingID .= '-';	
    $trackingID .= date(d);
    $trackingID .= '-';	
    $trackingID .= ????;
    $trackingID .= ????;
    $trackingID .= ????;

Re: Tracking ID

Posted: Tue Apr 24, 2012 2:24 pm
by Klemen
Unless you want anyone to access your tickets I would advise against doing so and keep tracking IDs completely random.

That said, your task is not as simple as it seems on the first glance.

Here's how the programming logic should work:
- get latest ID from the database
- get the last part of the ID (you can use explode() function)
- increase this part by 1
- generate new ID using this part
- insert ticket into database

You would also need to change length values of database fields that hold tracking ID values (`trackid` in tickets table, `ticket_id` in attachments), modify function hesk_cleanID() to allow more than 13 chars etc.

Unless MySQL automatically generates IDs (and it can't in such format) there is also the slim chance of duplicate ticket IDs if two requests are submitted at the same time...

Re: Tracking ID

Posted: Tue Apr 24, 2012 3:31 pm
by steve
Thank you for that reply, I thought it might be a little more difficult than it seamed. Ill post any successes i have with that.

I have disabled the customer interface of HESK for my application, so you cannot view tickets without a username and password.