How to change the number of digits in the ticket code?

In order to set a different number of digits in the ticket code, some source code modifications will have to be made. The file that will have to be edited is:

/administrator/components/com_rsticketspro/helpers/ticket.php

Here, around line 97, you will be able to find the code section which generated the ticket code:

    // random
    if ($department->generation_rule == RST_DEPARTMENT_RULE_RANDOM)
    {
      // trick to enter the loop below
      $found = true;
      while ($found)
      {
        // add the department prefix
        $code = $department->prefix . '-' . strtoupper(self::generateNumber(10));

        $query = $db->getQuery(true);
        $query->select($db->qn('id'))
          ->from($db->qn('#__rsticketspro_tickets'))
          ->where($db->qn('code') . '=' . $db->q($code));
        $db->setQuery($query);
        $found = $db->loadResult();
      }
    }
    // sequential
    elseif ($department->generation_rule == RST_DEPARTMENT_RULE_SEQUENTIAL)
    {
      // add the department prefix
      $code = $department->prefix . '-' . str_pad($department->next_number, 10, 0, STR_PAD_LEFT);

      $department->save(array(
        'id'          => $department->id,
        'next_number' => $department->next_number + 1
      ));
    }

In the above code section, the following code lines should be adjusted:

$code = $department->prefix . '-' . strtoupper(self::generateNumber(10));

- the above code line should be modified only the value 10 another number of your choice. The value represents the number of digits found by default in the ticket code when the "random" generation rule is set.

$code = $department->prefix . '-' . str_pad($department->next_number, 10, 0, STR_PAD_LEFT);

- in this code line the value 10 should again be changed to another value of your choice. This value represents the number of digits set for a ticket when the "sequential" generation rule is set.


7 persons found this article helpful.


Was this article helpful?

Yes No
Sorry about that