-
Notifications
You must be signed in to change notification settings - Fork 86
/
ClientGroupColorInTicketView.php
47 lines (39 loc) · 1.27 KB
/
ClientGroupColorInTicketView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Client Group Color in Ticket View
*
* @package WHMCS
* @copyright Katamaze
* @link https://katamaze.com
* @author Davide Mantenuto <[email protected]>
*/
use WHMCS\Database\Capsule;
add_hook('AdminAreaHeaderOutput', 1, function($vars)
{
foreach (Capsule::select(Capsule::raw('SELECT t1.id, t2.groupcolour AS color FROM tblclients AS t1 LEFT JOIN tblclientgroups AS t2 ON t1.groupid = t2.id WHERE groupid != "0"')) as $v)
{
$users[$v->id] = $v->color;
}
$users = json_encode($users);
return <<<HTML
<script type="text/javascript">
$(document).on('ready', function() {
var data = {$users};
$("table#sortabletbl2 tr:has(td), table#sortabletbl1 tr:has(td)").each(function () {
var href = $(this).find('td:nth-child(5) a[href^="clientssummary.php?userid="]');
if (typeof href !== undefined)
{
var params = $(href).attr('href');
if (params) {
var params = params.split('=');
var id = params[params.length - 1];
if (typeof data[id] !== 'undefined') {
$(this).find('a[href^="clientssummary.php?userid="]').css('background-color', data[id]);
}
}
}
});
});
</script>
HTML;
});