forked from craigrodway/printmaster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
82 lines (59 loc) · 2.12 KB
/
index.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
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
80
81
82
<?php
/*
Copyright (C) 2010 Craig A Rodway.
This file is part of Print Master.
Print Master is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Print Master is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Print Master. If not, see <http://www.gnu.org/licenses/>.
*/
include_once('inc/core.php');
// Do not show page title beneath menu (two columns have own titles)
$tpl->set('hidetitle', TRUE);
// Set page title
$tpl->set('title', 'Home');
$tpl->place('header');
/**
* Consumable stock
*/
// Get consumables
$sql = "SELECT
consumables.*,
( round( ( (consumables.qty) / (SELECT MAX(qty) FROM consumables) ) * 100 ) ) AS qty_percent,
GROUP_CONCAT(CAST(CONCAT(manufacturers.name, ' ', models.name) AS CHAR) SEPARATOR ', ') AS model
FROM consumables
LEFT JOIN consumables_models ON consumables.id = consumables_models.consumable_id
LEFT JOIN models ON consumables_models.model_id = models.id
LEFT JOIN manufacturers ON models.manufacturer_id = manufacturers.id
GROUP BY consumables.id
ORDER BY models.name ASC, consumables.name ASC";
$consumables = $db->query($sql)->asObjects();
// Get the most consumables in stock
$sql = 'SELECT MAX(qty) AS max FROM consumables';
$max_consumables = $db->query($sql)->fetchRow();
$max_consumables = $max_consumables['max'];
/**
* Quick add
*/
// List of printers
$printers = Printer::getSimple($db);
// List of models and which consumables are available
$models_consumables = Consumable::getForModels($db);
$models_consumables_json = fJSON::encode($models_consumables);
?>
<br />
<div class="grid_5 suffix_1">
<?php include 'views/home/quickadd.php'; ?>
</div>
<div class="grid_6">
<?php include 'views/home/stock.php'; ?>
</div>
<?php
$tpl->place('footer');
?>