49 |
rodolico |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This is the callable library for the license module.
|
|
|
5 |
* routines are assumed to be called from other modules, returning
|
|
|
6 |
* HTML data.
|
|
|
7 |
* All routines will receive one array containing the parameters to
|
|
|
8 |
* be used. Parameters may be
|
|
|
9 |
* client_id - A client_id to be used for queries
|
|
|
10 |
* device_id - A device_id to be used for queries
|
|
|
11 |
* site_id - A site_id to be used for queries
|
|
|
12 |
* htmlDirectory - the HTML path to the module
|
|
|
13 |
*/
|
|
|
14 |
|
|
|
15 |
function maintenanceView ( $parameters ) {
|
|
|
16 |
// this is an array containing the columns we will display in the
|
|
|
17 |
// query. The query will be generated as
|
|
|
18 |
// select $key '$value', $key '$value
|
|
|
19 |
|
|
|
20 |
if ( isset( $parameters['device_id'] ) ) {
|
|
|
21 |
$query =
|
|
|
22 |
"select
|
|
|
23 |
maintenance_task.description 'Task',
|
|
|
24 |
DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()) 'Due',
|
|
|
25 |
DATE(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY)) 'Date Due',
|
|
|
26 |
login.email 'Technician'
|
|
|
27 |
from maintenance_schedule join maintenance_performed on
|
|
|
28 |
maintenance_performed.maintenance_task_id = maintenance_schedule.maintenance_task_id
|
|
|
29 |
and maintenance_performed.device_id = maintenance_schedule.device_id
|
|
|
30 |
join login on login.login_id = maintenance_schedule.login_id
|
|
|
31 |
join maintenance_task on maintenance_task.maintenance_task_id = maintenance_schedule.maintenance_task_id
|
|
|
32 |
join device on maintenance_schedule.device_id = device.device_id
|
|
|
33 |
join site on device.site_id = site.site_id
|
|
|
34 |
join client on site.client_id = client.client_id
|
|
|
35 |
join (select max(maintenance_performed_id) last_maintenance
|
|
|
36 |
from maintenance_performed group by device_id,maintenance_task_id) last_performed on maintenance_performed.maintenance_performed_id = last_performed.last_maintenance
|
|
|
37 |
where device.removed_date is null
|
|
|
38 |
and site.removed_date is null
|
|
|
39 |
and client.removed_date is null
|
|
|
40 |
and maintenance_schedule.removed_date is null
|
|
|
41 |
and maintenance_schedule.device_id = $parameters[device_id]
|
|
|
42 |
order by DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()),
|
|
|
43 |
client.name,site.name,device.name, maintenance_task.description";
|
|
|
44 |
return queryToTable( $query );
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
?>
|
|
|
49 |
|