Blame | Last modification | View Log | Download | RSS feed
<?php
/*
* This is the callable library for the license module.
* routines are assumed to be called from other modules, returning
* HTML data.
* All routines will receive one array containing the parameters to
* be used. Parameters may be
* client_id - A client_id to be used for queries
* device_id - A device_id to be used for queries
* site_id - A site_id to be used for queries
* htmlDirectory - the HTML path to the module
*/
function maintenanceView ( $parameters ) {
// this is an array containing the columns we will display in the
// query. The query will be generated as
// select $key '$value', $key '$value
if ( isset( $parameters['device_id'] ) ) {
$query =
"select
maintenance_task.description 'Task',
DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()) 'Due',
DATE(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY)) 'Date Due',
login.email 'Technician'
from maintenance_schedule join maintenance_performed on
maintenance_performed.maintenance_task_id = maintenance_schedule.maintenance_task_id
and maintenance_performed.device_id = maintenance_schedule.device_id
join login on login.login_id = maintenance_schedule.login_id
join maintenance_task on maintenance_task.maintenance_task_id = maintenance_schedule.maintenance_task_id
join device on maintenance_schedule.device_id = device.device_id
join site on device.site_id = site.site_id
join client on site.client_id = client.client_id
join (select max(maintenance_performed_id) last_maintenance
from maintenance_performed group by device_id,maintenance_task_id) last_performed on maintenance_performed.maintenance_performed_id = last_performed.last_maintenance
where device.removed_date is null
and site.removed_date is null
and client.removed_date is null
and maintenance_schedule.removed_date is null
and maintenance_schedule.device_id = $parameters[device_id]
order by DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()),
client.name,site.name,device.name, maintenance_task.description";
return queryToTable( $query );
}
}
?>