-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmoduleLogSortById.php
More file actions
39 lines (33 loc) · 992 Bytes
/
moduleLogSortById.php
File metadata and controls
39 lines (33 loc) · 992 Bytes
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
<?php
if (!defined('WHMCS')) {
exit('This file cannot be accessed directly');
}
/**
* Module Log: sort by ID (found in the a href)
*/
add_hook('AdminAreaFooterOutput', 100, function($vars){
if ($vars['pagetitle'] == 'System Module Debug Log'):
$output = <<<HTML
<script>
/* Hook: moduleLogSortById */
jQuery(document).ready(function($) {
if ( $('#tblModuleLog tbody tr').length < 2 ) return;
//Add ID column header
$('#tblModuleLog thead tr').prepend('<th width="20">ID</th>');
//Add ID column values
$('#tblModuleLog tbody tr').each(function(){
href = $(this).find('td a').attr('href');
id = href.split('/').pop();
$(this).prepend('<td>' + id + '</td>');
});
//Sort by first column
tbody = $('#tblModuleLog').find('tbody');
tbody.find('tr').sort(function(a, b) {
return $('td:first', a).text().localeCompare($('td:first', b).text(), undefined, {'numeric': true});
}).appendTo(tbody);
});
</script>
HTML;
return $output;
endif;
});