Rev 38 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
include_once( './maintenance_database.php' );
function postMaintenance($device = '', $task = '', $notes = '', $technician = '', $date = '') {
if ( $device ) { # parameters are being passed directly in
$sql = 'insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id) values (' .
implode( ',',
array(
makeSafeSQLValue($device, 'I'),
makeSafeSQLValue( $task, 'I'),
makeSafeSQLValue($date, 'I'),
makeSafeSQLValue($notes),
makeSafeSQLValue($technician, 'I')
)
) . ')';
queryDatabaseExtended( $sql );
//print "<pre>$sql</pre>";
} else {
foreach ( $_POST as $parameter => $value ) {
if ( preg_match( '/performed_(\d+)/', $parameter, $id ) ) { // this is the checkbox
if ( $value ) { // and it has a value
$id = $id[1];
$sql = array( 'select device_id', 'maintenance_task_id',$_POST["datedone_$id"],makeSafeSQLValue($_POST["notes_$id"],'S'),$_POST["technician_$id"]);
$sql = implode (',', $sql );
$sql = 'insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id) ' . $sql .
" from maintenance_schedule where maintenance_schedule_id = $id";
queryDatabaseExtended( $sql );
//print "<pre>$sql</pre>";
}
}
}
}
}
function getSoftwareVersions ( $currentOnly = true, $softwareID = '',$computerID='' ) {
$whereClause = array();
if ( $currentOnly ) {
$whereClause[] = 'installed_packages.removed_date is null';
}
if ( $softwareID ) {
$whereClause[] = "package_name like '%$softwareID%'";
}
print '<pre>' . implode( ' and ', $whereClause ) . '</pre>';
return array($sql, implode ( ' and ', $whereClause ), ' order by ');
}
function EditMaintenanceRecord( $id ) {
global $DATABASE_DEFINITION;
print $id == -1 ? addData( $DATABASE_DEFINITION['maintenance_schedule'] ) : editData( $DATABASE_DEFINITION['maintenance_schedule'], $id );
}
function postChanges( $id = '' ) {
global $DATABASE_DEFINITION;
if ($id) {
updateData( $DATABASE_DEFINITION['maintenance_schedule'], $id );
} else {
$result = insertData( $DATABASE_DEFINITION['maintenance_schedule'] );
// There MUST be a record in maintenance_performed or this is not visible
$id = $result['insert_id'];
$sql = "insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id)
select device_id,maintenance_task_id,added_date,'Added to System',login_id
from maintenance_schedule
where maintenance_schedule_id = $id";
doSQL($sql);
}
}
?>
Generated by GNU Enscript 1.6.5.90.