-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinventory_controller.php
More file actions
79 lines (66 loc) · 2.04 KB
/
Copy pathinventory_controller.php
File metadata and controls
79 lines (66 loc) · 2.04 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
use munkireport\lib\Listing;
class Inventory_controller extends Module_controller
{
// Require authentication
public function __construct()
{
// Store module path
$this->module_path = dirname(__FILE__) .'/';
$this->view_path = $this->module_path . 'views/';
$this->modules = getMrModuleObj()->loadInfo();
}
public function index()
{
echo "You've loaded the inventory module!";
}
public function get_data($serial_number = '')
{
// Protect this handler
if (! $this->authorized()) {
redirect('auth/login');
}
$out = Inventory_model::select('name', 'version', 'bundleid', 'path')
->where('inventoryitem.serial_number', $serial_number)
->filter()
->get();
$obj = new View();
$obj->view('json', array('msg' => $out));
}
/**
* Get versions and count from an application
*
* @param string $app Appname
**/
public function appVersions($app = '')
{
// Protect this handler
if (! $this->authorized()) {
redirect('auth/login');
}
$app = rawurldecode($app);
// Detect wildcard character
if (preg_match('/[_%]/', $app)) {
$comparator = 'like';
}else{
$comparator = '=';
}
$out = Inventory_model::selectRaw('version, COUNT(*) AS count')
->where('name', $comparator, $app)
->filter()
->groupBy('version')
->orderBy('version', 'desc')
->get();
$obj = new View();
$obj->view('json', array('msg' => $out));
}
public function items($name = '', $version = '')
{
$data['page'] = 'clients';
$name = rawurldecode($name);
$version = rawurldecode($version);
$data['js_init'] = "initializeInventory('$name', '$version')";
$listing = new Listing($this->modules->getListing('inventory', 'inventory_detail'));
$listing->render($data);
}
}