• Resolved Pawlio

    (@pawlio)


    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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author JoomSky

    (@rabilal)

    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

    What file needs to be edited to do this?

    Plugin Author JoomSky

    (@rabilal)

    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

    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.

    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.