I changed the code at this moment just a little bit more and you could do this to if you are in my situation:
If you have for example 3 groups:
- Guest
- Registered
- Service
You also have 4 departments:
- General (only viewable for the "Guest" and "Registered" group)
- Service (only viewable for the "Guest" and "Registered" group)
- Hardware (only viewable for the "Group1" group)
- Software (only viewable for the "Group1" group)
The departments "Hardware" and "Software" are a kind of sub departments.
Now I have one user who is a member of "Group1".
When he/she submit a new ticket the ticket ID would be "HAR-123456" or "SOF-123456".
But because those are sub departments of "Service" I want the ticket ID's start with "SER-123456".
If you have the same situation as I descriped above then follow this tutorial.
Before we start make sure that the name of your "default" departments (those who will be viewable for the "Guest" and the "Registered" group) does have the same name as your group name. (So if your department is called "Service" your group should also be named "Service". This does not affect the standerd 2 groups like the "Guest" and the "Registered" group.)
Open:
Code:
\modules\tickets\functions_ticketcore.php
Search for:
Code:
function createTicket
Seach inside that function for:
Code:
$ticketmaskid = generateTicketMask(); // Generate the unique ticket mask
Replace this line by:
Code:
$ticketmaskid = generateTicketMask($departmentid, $userid); // Generate the unique ticket mask
Search for:
Code:
function generateTicketMask()
Replace this whole function by:
Code:
function generateTicketMask($departmentid, $userid)
{
global $dbCore, $_SWIFT;
mt_srand ((double) microtime() * 1000000);
$num = mt_rand(100000,999999);
$dbCore->query("SELECT ". TABLE_PREFIX ."usergroups.usergroupid, title FROM ". TABLE_PREFIX ."usergroups INNER JOIN ". TABLE_PREFIX ."users ON ". TABLE_PREFIX ."usergroups.usergroupid = ". TABLE_PREFIX ."users.usergroupid WHERE userid = '". $dbCore->escape($userid) ."';");
$dbCore->nextRecord();
$record = $dbCore->Record["title"];
$usergroupid = $dbCore->Record["usergroupid"];
if ($usergroupid != 1 && $usergroupid != 2)
{
$department_title = strtoupper(substr($record, 0, 3));
}
else
{
$dbCore->query("SELECT `title` FROM `". TABLE_PREFIX ."departments` WHERE `departmentid` = '". $dbCore->escape($departmentid) ."';");
$dbCore->nextRecord();
$record = $dbCore->Record["title"];
$department_title = strtoupper(substr($record, 0, 3));
}
$ticketmaskid = $department_title . "-" . $num;
$_maskcheck = $dbCore->queryFetch("SELECT ticketmaskid FROM `". TABLE_PREFIX ."tickets` WHERE `ticketmaskid` = '". $dbCore->escape($ticketmaskid) ."';");
if (!empty($_maskcheck["ticketmaskid"]))
{
return generateTicketMask();
}
return $ticketmaskid;
}
Save the file and enjoy!