Subversion Repositories computer_asset_manager_v1

Rev

Rev 38 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 rodolico 1
<?php
2
   include_once( './maintenance_database.php' ); 
3
 
4
   function postMaintenance($device = '', $task = '', $notes = '', $technician = '', $date = '') {
5
      if ( $device ) { # parameters are being passed directly in
6
         $sql = 'insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id) values (' .
7
               implode( ',', 
8
                  array(
9
                     makeSafeSQLValue($device, 'I'), 
10
                     makeSafeSQLValue( $task, 'I'), 
11
                     makeSafeSQLValue($date, 'I'), 
12
                     makeSafeSQLValue($notes), 
13
                     makeSafeSQLValue($technician, 'I')
14
                  )
15
               ) . ')';
16
         queryDatabaseExtended( $sql );
17
         //print "<pre>$sql</pre>";
18
      } else {
19
         foreach ( $_POST as $parameter => $value ) {
20
            if ( preg_match( '/performed_(\d+)/', $parameter, $id ) ) { // this is the checkbox
21
               if ( $value ) { // and it has a value
22
                  $id = $id[1];
23
                  $sql = array( 'select device_id', 'maintenance_task_id',$_POST["datedone_$id"],makeSafeSQLValue($_POST["notes_$id"],'S'),$_POST["technician_$id"]);
24
                  $sql = implode (',', $sql );
25
                  $sql = 'insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id) ' . $sql . 
26
                        " from maintenance_schedule where maintenance_schedule_id = $id";
27
                  queryDatabaseExtended( $sql );
28
                  //print "<pre>$sql</pre>";
29
               }
30
            }
31
         }
32
      }
33
   }
34
 
35
   function getSoftwareVersions ( $currentOnly = true, $softwareID = '',$computerID='' ) {
36
      $whereClause = array();
37
      if ( $currentOnly ) {
38
         $whereClause[] = 'installed_packages.removed_date is null';
39
      }
40
      if ( $softwareID ) {
41
         $whereClause[] = "package_name like '%$softwareID%'";
42
      }
43
      print '<pre>' . implode( ' and ', $whereClause ) . '</pre>';
44
     return array($sql, implode ( ' and ', $whereClause ), ' order by ');
45
   }
46
 
47
   function EditMaintenanceRecord( $id ) {
48
      global $DATABASE_DEFINITION;
49
      print $id == -1 ? addData( $DATABASE_DEFINITION['maintenance_schedule'] ) : editData( $DATABASE_DEFINITION['maintenance_schedule'], $id );
50
   }
51
 
52
   function postChanges( $id = '' ) {
53
      global $DATABASE_DEFINITION;
54
      if ($id) {
55
         updateData( $DATABASE_DEFINITION['maintenance_schedule'], $id );
56
      } else {
57
         $result = insertData( $DATABASE_DEFINITION['maintenance_schedule'] );
58
         // There MUST be a record in maintenance_performed or this is not visible
59
         $id = $result['insert_id'];
60
         $sql = "insert into maintenance_performed (device_id,maintenance_task_id,maintenance_date,notes,login_id)
61
                  select device_id,maintenance_task_id,added_date,'Added to System',login_id 
62
                  from maintenance_schedule 
63
                  where maintenance_schedule_id = $id";
64
         doSQL($sql);
65
      }
66
   }
67
 
68
 
69
 
70
?>