Title: Ticket Id&#039;s
Last modified: August 24, 2016

---

# Ticket Id's

 *  Resolved [Pawlio](https://wordpress.org/support/users/pawlio/)
 * (@pawlio)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/ticket-ids/)
 * I would like to change the random Ticket Id numbers to Sequential Numbers.
    E.
   G 001,002,003 for the benifit of the customer how would I go this.
 * Im not great with functions so I would need to change
 * function getRandomTicketId() {
    $query = “SELECT ticketid FROM `" . jssupportticket::
   $_db->prefix . "js_ticket_tickets`“; do { $ticketid = “”; $length = 9; $possible
   = “2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ”; // we refer to the length
   of $possible a few times, so let’s grab it now $maxlength = strlen($possible);
   if ($length > $maxlength) { // check for length overflow and truncate if necessary
   $length = $maxlength; } // set up a counter for how many characters are in the
   ticketid so far $i = 0; // add random characters to $password until $length is
   reached while ($i < $length) { // pick a random character from the possible ones
   $char = substr($possible, mt_rand(0, $maxlength – 1), 1); if (!strstr($ticketid,
   $char)) { if ($i == 0) { if (ctype_alpha($char)) { $ticketid .= $char; $i++; }}
   else { $ticketid .= $char; $i++; } } } $rows = jssupportticket::$_db->get_results(
   $query); foreach ($rows as $row) { if ($ticketid == $row->ticketid) $match = ‘
   Y’; else $match = ‘N’; } }while ($match == ‘Y’); return $ticketid; }
 * But with what?
 * [https://wordpress.org/plugins/js-support-ticket/](https://wordpress.org/plugins/js-support-ticket/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [JoomSky](https://wordpress.org/support/users/rabilal/)
 * (@rabilal)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958319)
 * Hi,
 * Try this code.
 * function getRandomTicketId() {
    $query = “SELECT MAX(ticketid) FROM `" . jssupportticket::
   $_db->prefix . "js_ticket_tickets`“; $ticketid = “”; $length = 5; $maxticketid
   = jssupportticket::$_db->get_var($query); if(!is_numeric($maxticketid)) $maxticketid
   = 0; $ticketid = $maxticketid + 1; $currentlength = strlen($ticketid); if($length
   == $currentlength){ $length = 15; } for($i = 0; $i < ($length – $currentlength);
   $i++){ $ticketid = ‘0’.$ticketid; } return $ticketid; }
 * Regards,
    Ahmad Bilal
 *  [andisites](https://wordpress.org/support/users/andisites/)
 * (@andisites)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958535)
 * What file needs to be edited to do this?
 *  Plugin Author [JoomSky](https://wordpress.org/support/users/rabilal/)
 * (@rabilal)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958536)
 * Hi,
 * To make ticket id to random number.
 * **Edit** ../plugins/js-support-ticket/modules/ticket/model.php
 * **Find**
 * function getRandomTicketId
 * **Find**
 * > $possible = “2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ”;
   >  // we refer 
   > to the length of $possible a few times, so let’s grab it now $maxlength = strlen(
   > $possible); if ($length > $maxlength) { // check for length overflow and truncate
   > if necessary $length = $maxlength; } // set up a counter for how many characters
   > are in the ticketid so far $i = 0; // add random characters to $password until
   > $length is reached while ($i < $length) { // pick a random character from the
   > possible ones $char = substr($possible, mt_rand(0, $maxlength – 1), 1); if (!
   > strstr($ticketid, $char)) { if ($i == 0) { if (ctype_alpha($char)) { $ticketid.
   > = $char; $i++; } } else { $ticketid .= $char; $i++; } } } $rows = jssupportticket::
   > $_db->get_results($query);
 * **Replace with**
 * > $possible = “012346789”;
   >  // we refer to the length of $possible a few times,
   > so let’s grab it now $maxlength = strlen($possible); if ($length > $maxlength){//
   > check for length overflow and truncate if necessary $length = $maxlength; }//
   > set up a counter for how many characters are in the ticketid so far $i = 0;//
   > add random characters to $password until $length is reached while ($i < $length){//
   > pick a random character from the possible ones $char = substr($possible, mt_rand(
   > 0, $maxlength – 1), 1); $ticketid .= $char; $i++; } $rows = jssupportticket::
   > $_db->get_results($query);
 * Best regards,
 * Ahmad Bilal
 *  [Sting.nu](https://wordpress.org/support/users/stingnu/)
 * (@stingnu)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958537)
 * Hi!
    I can’t get the Ticket Id numbers to Sequential Numbers. E.G 001,002,003
   to work!
 * I have replaced the code in module.php, but it only creates TicketID 00001 on
   every new ticket.
 *  [andisites](https://wordpress.org/support/users/andisites/)
 * (@andisites)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958538)
 * I tried this and got an unexpected “;” error. Would it be possible to post the
   complete model.php, just in case I’m not cutting and pasting properly? Thanks
   so much!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Ticket Id's’ is closed to new replies.

 * ![](https://ps.w.org/js-support-ticket/assets/icon-256x256.png?rev=3583992)
 * [JS Help Desk – AI-Powered Support & Ticketing System](https://wordpress.org/plugins/js-support-ticket/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/js-support-ticket/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/js-support-ticket/)
 * [Active Topics](https://wordpress.org/support/plugin/js-support-ticket/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/js-support-ticket/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/js-support-ticket/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [andisites](https://wordpress.org/support/users/andisites/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/ticket-ids/#post-5958538)
 * Status: resolved