Subversion Repositories computer_asset_manager_v1

Rev

Rev 37 | Rev 52 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 rodolico 1
<?php
2
 
3
   define(SQL_GET_PACKAGES,
4
          'select client.name,device.name,software.package_name,software_version.version
5
           from client join site on client.client_id = site.client_id
6
                join device on device.site_id = site.site_id
7
                join installed_packages on device.device_id = installed_packages.device_id
8
                join software on installed_packages.software_id = software.software_id
9
                join software_version on installed_packages.software_version_id = software_version.software_version_id
10
           where <whereClause>
11
           order by package_name,version
12
          '
13
   );
14
 
15
   define( SQL_AVAILABLE_PACKAGES,
16
       'select distinct software.software_id,software.package_name 
17
        from installed_packages join software on installed_packages.software_id = software.software_id 
18
        where <whereClause>
19
        order by software.package_name'
20
   );
21
 
22
   define( SQL_DEVICE_LIST,
23
      'select client.name,device.name,device.added_date \'Initial Date\', max(disk_space.added_date) \'Last Update\'
24
        from client join site on site.client_id = client.client_id
25
              join device on device.site_id = site.site_id
26
              join device_type on device_type.device_type_id = device.device_type_id
27
              join disk_info on disk_info.device_id = device.device_id
28
              join disk_space on disk_space.disk_info_id = disk_info.disk_info_id
29
        where <whereClause>
30
        group by client.name,device.name,device.added_date
31
        order by client.name,device.name
32
    '
33
   );
34
 
35
   define( SQL_AVAILABLE_DEVICES,
36
      'select distinct device_id,device.name
37
       from device join site on site.site_id=device.site_id
38
            join client on client.client_id = site.client_id
39
       where <whereClause>
40
       order by device.name
41
      '
42
   );
43
 
44
   define ( SQL_SOFTWARE_UPDATES,
45
      "select date(installed_packages.added_date) 'Added',
46
              date(installed_packages.removed_date) 'Removed',
47
              device.name 'Device',
48
              package_name 'Package', 
49
              version 'Version'
50
       from installed_packages join software on installed_packages.software_id = software.software_id
51
          join software_version on installed_packages.software_version_id = software_version.software_version_id
52
          join device on installed_packages.device_id = device.device_id
53
          join site on device.site_id = site.site_id
54
          join client on site.client_id = client.client_id
55
       where <whereClause>
56
       order by device.name,package_name,installed_packages.added_date
57
      "
58
   );
59
 
60
 
61
   define (SQL_GET_DISKSPACE,
62
           'select device.name,date(disk_space.added_date) \'Date Added\',  space_used/capacity*100 "used %", space_used/1048576 used, capacity/1048576 Part_Size, mount_point,  disk_device, filesystem
63
       from device join disk_info on disk_info.device_id = device.device_id
64
          join disk_space on disk_info.disk_info_id=disk_space.disk_info_id
65
       where disk_info.removed_date is null
66
            and device.removed_date is null
67
            and disk_space.added_date = (select max(added_date) from disk_space b where b.disk_info_id = disk_space.disk_info_id)
68
            and <whereClause>
69
       order by device.name,disk_device
70
      '
71
   );
72
 
73
   define (SQL_DO_MAINTENANCE,
74
      "select login.name 'Maintainer', 
75
            concat(client.name,'<br /> ',site.name) 'Site',
76
            device.name 'Device',
77
            date(date_add(maintenance_performed.maintenance_date,interval maintenance_schedule.schedule day)) 'Next Due',
78
            concat('<INPUT type=\"checkbox\" name=\"',device.device_id,'-',maintenance_task.maintenance_task_id,'_done\"><b>Completed</b><br/>',maintenance_task.description) 'Work',
79
            concat(
80
            '<b>Date</b> <INPUT type=\"text\" name=\"',device.device_id,'-',maintenance_task.maintenance_task_id,'_date\" value=\"',date(now()),'\" size=\"10\" maxlength=\"10\">',
81
            '<br /><textarea name=\"',device.device_id,'-',maintenance_task.maintenance_task_id,'_notes\" cols=\"20\" rows=\"4\"></textarea>') 'Notes'
82
      from device join maintenance_schedule on device.device_id=maintenance_schedule.device_id
83
            join maintenance_task on maintenance_task.maintenance_task_id = maintenance_schedule.maintenance_task_id
84
            join maintenance_performed on maintenance_performed.device_id = maintenance_schedule.device_id
85
               and maintenance_performed.maintenance_task_id = maintenance_schedule.maintenance_task_id
86
            join login on maintenance_schedule.login_id = login.login_id
87
            join site on site.site_id = device.site_id
88
            join client on site.client_id = client.client_id
89
      where device.removed_date is null
90
            and maintenance_task.removed_date is null
91
            and <additionalWhere>
92
      order by login.email,client.name,site.name,device.name,maintenance_task.description"   
93
   );
94
 
95
   define (SQL_GET_MAINTAINERS,'
96
      select distinct login.login_id,login.name 
97
      from maintenance_schedule join login on maintenance_schedule.login_id = login.login_id
98
      '
99
   );
100
 
101
   define (SQL_GET_MAINTENANCE_CLIENTS,'
102
      select distinct client.client_id,client.name 
103
      from maintenance_schedule join device on maintenance_schedule.device_id = device.device_id 
104
         join site on device.site_id = site.site_id join client on site.client_id = client.client_id
105
      '
106
   );
107
//            DATE(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY)) "Due Date",
108
 
109
   define (SQL_GET_OUTSTANDING_MAINTENANCE, '
110
     select concat( client.name, \' Site \', site.name ) "Site",
38 rodolico 111
            device.device_id "Device ID",
1 rodolico 112
            device.name "Device Name",
113
            device.notes "Device Notes",
37 rodolico 114
            device.restrictions "Restrictions",
1 rodolico 115
            maintenance_task.description "Task",
116
            maintenance_task.notes "Task Notes",
117
            DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()) "Due",
118
            DATE(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY)) "Date Due",
119
            login.email "Technician",
120
            maintenance_schedule.maintenance_schedule_id "ID"
121
      from maintenance_schedule join maintenance_performed on 
122
                  maintenance_performed.maintenance_task_id = maintenance_schedule.maintenance_task_id
123
                  and maintenance_performed.device_id = maintenance_schedule.device_id
124
         join login on login.login_id = maintenance_schedule.login_id
125
         join maintenance_task on maintenance_task.maintenance_task_id = maintenance_schedule.maintenance_task_id
126
         join device on maintenance_schedule.device_id = device.device_id
127
         join site on device.site_id = site.site_id
128
         join client on site.client_id = client.client_id
129
         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
130
      where device.removed_date is null
131
            and site.removed_date is null
132
            and client.removed_date is null
133
            and maintenance_schedule.removed_date is null
134
            and <additionalWhere>
135
     order by DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()),
136
           client.name,site.name,device.name, maintenance_task.description;
137
      '
138
//            and DATEDIFF(DATE_ADD(maintenance_performed.maintenance_date, INTERVAL schedule DAY), now()) <= 7
139
   );
140
 
141
   define (SQL_MAINTENANCE_REPORT, '
142
      select concat( client.name, \' - \', site.name) "Site",
143
             device.name "Device Name",
144
             maintenance_task.description "Task",
145
             DATE(maintenance_performed.maintenance_date) "Date",
146
             maintenance_performed.notes "Notes",
147
             login.email "Technician"
148
      from maintenance_performed join device on maintenance_performed.device_id = device.device_id
149
         join maintenance_task on maintenance_task.maintenance_task_id = maintenance_performed.maintenance_task_id
150
         join login on login.login_id = maintenance_performed.login_id
151
         join site on device.site_id = site.site_id
152
         join client on client.client_id = site.client_id
153
      <whereClause>
154
      <orderBy>
155
   ');
156
 
157
   define (SQL_SHOW_maintenance_schedule, '
158
      select maintenance_schedule.schedule "Period (d)",
159
            maintenance_task.description "Task",
160
            login.email "Technician",
161
            max(date(maintenance_performed.maintenance_date)) "Last Done",
162
            date(maintenance_schedule.added_date) "Added"
163
      from maintenance_schedule join login on maintenance_schedule.login_id = login.login_id 
164
           join maintenance_task on maintenance_schedule.maintenance_task_id = maintenance_task.maintenance_task_id
165
           join maintenance_performed on maintenance_schedule.device_id = maintenance_performed.device_id 
166
                and maintenance_schedule.maintenance_task_id = maintenance_performed.maintenance_task_id
167
      where maintenance_schedule.device_id = <device_id>
168
      group by maintenance_schedule.schedule,
169
               maintenance_task.description,
170
               login.email,
171
               maintenance_schedule.added_date,
172
               maintenance_schedule.removed_date
173
   ');
174
 
175
?>