-
Notifications
You must be signed in to change notification settings - Fork 7
/
dashboard.php
executable file
·299 lines (283 loc) · 8.6 KB
/
dashboard.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?php
require_once('includes/load.php');
$page_title = 'Dashboard';
// Checkin What level user has permission to view this page
page_require_level(2);
$c_equipment = count_by_id('equipments');
$c_transfer = count_by_id('transfers');
$c_sector = count_by_id('sectors');
$c_user = count_by_id('users');
$pieChartEquipmentPerTyperEquip = pieChartEquipmentPerTyperEquip();
$barChartLoansPerSector = barChartLoanPerSector();
$horizontalBarChartEquipmentPerManufacturer = horizontalBarChartEquipmentPerManufacturer();
$pieChartEquipmentPerSituation = pieChartEquipmentPerSituation();
$recent_equipments = find_recent_equipment_added('5');
$recent_transfers = find_recent_transfer_added('5');
?>
<?php include_once('layouts/header.php'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css"/>
<div class="row">
<div class="col-md-6">
<?= display_msg($msg); ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-green">
<i class="glyphicon glyphicon-user"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top"> <?= $c_user['total']; ?> </h2>
<p class="text-muted">Usuários</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-red">
<i class="glyphicon glyphicon-th-large"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top"> <?= $c_equipment['total']; ?> </h2>
<p class="text-muted">Equipamentos</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-blue">
<i class="glyphicon glyphicon-random"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top"> <?= $c_transfer['total']; ?> </h2>
<p class="text-muted">Transferências</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-box clearfix">
<div class="panel-icon pull-left bg-yellow">
<i class="glyphicon glyphicon-object-align-vertical"></i>
</div>
<div class="panel-value pull-right">
<h2 class="margin-top"> <?= $c_sector['total']; ?></h2>
<p class="text-muted">Setores</p>
</div>
</div>
</div>
</div>
<hr>
<!-- Charts -->
<div class="row" style="background-color:white">
<div>
<div class="col-md-7">
<canvas id="pieChart" width="500" height="200"></canvas>
</div>
<div class="col-md-5">
<canvas id="barChart" width="300" height="200"></canvas>
</div>
</div>
</div>
<hr>
<div class="row" style="background-color:white">
<div>
<div class="col-md-5">
<canvas id="horizontalBar" width="300" height="200"></canvas>
</div>
<div class="col-md-7">
<canvas id="doughnutChart" width="500" height="200"></canvas>
</div>
</div>
</div>
<!-- /Charts -->
<hr>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Equipamentos adicionados recentemente</span>
</strong>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Tombo</th>
<th>Especificações</th>
</tr>
</thead>
<tbody>
<?php foreach ($recent_equipments as $r_e): ?>
<tr>
<td><?= remove_junk(first_character($r_e['tombo'])); ?></td>
<td><?= remove_junk(ucfirst($r_e['specifications'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Transferências feitas recentemente</span>
</strong>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Tombo</th>
<th>Tipo de equipamento</th>
<th>Usuário Responsável</th>
</tr>
</thead>
<tbody>
<?php foreach ($recent_transfers as $recent_transfer): ?>
<tr>
<td><?= remove_junk(first_character($recent_transfer['tombo'])); ?></td>
<td><?= remove_junk(ucfirst($recent_transfer['type_equip'])); ?></td>
<td><?= remove_junk(first_character($recent_transfer['responsible_user'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
// pie chart
var ctx = document.getElementById('pieChart');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: [
<?php foreach ($pieChartEquipmentPerTyperEquip as $count_type_equip): ?>
"<?= $count_type_equip['name'] ?>",
<?php endforeach; ?>
],
datasets: [{
label: 'Tipo de Equipamento',
data: [
<?php foreach ($pieChartEquipmentPerTyperEquip as $count_type_equip): ?>
"<?= $count_type_equip['count'] ?>",
<?php endforeach; ?>
],
backgroundColor: [
<?php foreach ($pieChartEquipmentPerTyperEquip as $count_type_equip):
$rand1 = mt_rand(0, 255); $rand2 = mt_rand(0, 255); $rand3 = mt_rand(0, 255); ?>
'<?= "rgba($rand1, $rand2, $rand3)" ?>',
<?php endforeach; ?>
]
}]
},
});
// bar chart
var ctx = document.getElementById('barChart');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [
<?php foreach ($barChartLoansPerSector as $count_sector): ?>
"<?= $count_sector['name'] ?>",
<?php endforeach; ?>
],
datasets: [{
label: 'Transferências por Setor',
data: [
<?php foreach ($barChartLoansPerSector as $count_sector): ?>
"<?= $count_sector['count'] ?>",
<?php endforeach; ?>
],
backgroundColor: [
<?php foreach ($barChartLoansPerSector as $count_sector):
$rand1 = mt_rand(0, 255); $rand2 = mt_rand(0, 255); $rand3 = mt_rand(0, 255); ?>
'<?= "rgba($rand1, $rand2, $rand3)" ?>',
<?php endforeach; ?>
]
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
// bar horizontal chart
new Chart(document.getElementById("horizontalBar"), {
type: "horizontalBar",
data: {
labels: [
<?php foreach ($horizontalBarChartEquipmentPerManufacturer as $count_manufacturer): ?>
"<?= $count_manufacturer['name'] ?>",
<?php endforeach; ?>
],
datasets: [{
label: "Equipamentos por Fabricante",
data: [
<?php foreach ($horizontalBarChartEquipmentPerManufacturer as $count_manufacturer): ?>
"<?= $count_manufacturer['count'] ?>",
<?php endforeach; ?>
],
fill: false,
backgroundColor: [
<?php foreach ($horizontalBarChartEquipmentPerManufacturer as $count_manufacturer):
$rand1 = mt_rand(0, 255); $rand2 = mt_rand(0, 255); $rand3 = mt_rand(0, 255); ?>
'<?= "rgba($rand1, $rand2, $rand3)" ?>',
<?php endforeach; ?>
],
"borderWidth": 1
}]
},
"options": {
"scales": {
"xAxes": [{
"ticks": {
"beginAtZero": true
}
}]
}
}
});
// doughnut chart
var ctxD = document.getElementById("doughnutChart").getContext('2d');
var myLineChart = new Chart(ctxD, {
type: 'doughnut',
data: {
labels: [
<?php foreach ($pieChartEquipmentPerSituation as $count_situation): ?>
"<?= $count_situation['name'] ?>",
<?php endforeach; ?>
],
datasets: [{
data: [
<?php foreach ($pieChartEquipmentPerSituation as $count_situation): ?>
"<?= $count_situation['count'] ?>",
<?php endforeach; ?>
],
backgroundColor: [
<?php foreach ($pieChartEquipmentPerSituation as $count_situation):
$rand1 = mt_rand(0, 255); $rand2 = mt_rand(0, 255); $rand3 = mt_rand(0, 255); ?>
'<?= "rgba($rand1, $rand2, $rand3)" ?>',
<?php endforeach; ?>
]
}]
},
options: {
responsive: true
}
});
</script>
<?php include_once('layouts/footer.php'); ?>