Subversion Repositories computer_asset_manager_v1

Rev

Rev 62 | Rev 67 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 63
Line 9... Line 9...
9
   include_once('reports.php');
9
   include_once('reports.php');
10
   
10
   
11
   global $MODULE_REPORTS;
11
   global $MODULE_REPORTS;
12
   $MODULE_REPORTS = array('main device screen' => 1);
12
   $MODULE_REPORTS = array('main device screen' => 1);
13
   
13
   
14
   define (SQL_GET_MODULES,
14
   define ('SQL_GET_MODULES',
15
     "select a.key_name 'module',
15
     "select a.key_name 'module',
16
             a.theValue 'script', 
16
             a.theValue 'script', 
17
             b.theValue 'path' 
17
             b.theValue 'path' 
18
      from _system a join _system b using ( key_name )
18
      from _system a join _system b using ( key_name )
19
      where
19
      where
Line 21... Line 21...
21
         and b.group_name = 'Modules' 
21
         and b.group_name = 'Modules' 
22
         and a.removed_date is null
22
         and a.removed_date is null
23
         and b.removed_date is null"
23
         and b.removed_date is null"
24
   );
24
   );
25
   
25
   
26
   define (SQL_SHOW_SITES,
26
   define ('SQL_SHOW_SITES',
27
      "select concat('<a href=\"index.html?site_id=',site.site_id,'\">', site.name,'</a>') 'Site',
27
      "select concat('<a href=\"index.html?site_id=',site.site_id,'\">', site.name,'</a>') 'Site',
28
              count(*) 'Devices',
28
              count(*) 'Devices',
29
              concat('<a href=\"edit.html?site_id=',site.site_id,'\">Edit</a>') Action
29
              concat('<a href=\"edit.html?site_id=',site.site_id,'\">Edit</a>') Action
30
       from client_site site left outer join current_systems device using (site_id)
30
       from client_site site left outer join current_systems device using (site_id)
31
       where <whereClause>
31
       where <whereClause>
32
       group by site.site_id
32
       group by site.site_id
33
       order by site.name"
33
       order by site.name"
34
   );
34
   );
35
   
35
   
36
   define (SQL_SHOW_DEVICES,
36
   define ('SQL_SHOW_DEVICES',
37
      "select concat('<a href=\"show_device.html?device_id=',device.device_id,'\">',device.name,'</a>') 'Device',
37
      "select concat('<a href=\"show_device.html?device_id=',device.device_id,'\">',device.name,'</a>') 'Device',
38
       device_type.name 'Type',
38
       device_type.name 'Type',
39
       concat('<a href=\"edit.html?device_id=',device.device_id,'\">Edit</a>') Action
39
       concat('<a href=\"edit.html?device_id=',device.device_id,'\">Edit</a>') Action
40
       from device join device_type on device.device_type_id = device_type.device_type_id
40
       from device join device_type on device.device_type_id = device_type.device_type_id
41
            join site on device.site_id = site.site_id
41
            join site on device.site_id = site.site_id
Line 44... Line 44...
44
             and device.removed_date is null
44
             and device.removed_date is null
45
             and <whereClause>
45
             and <whereClause>
46
       order by device_type.name,device.name"
46
       order by device_type.name,device.name"
47
   );
47
   );
48
   
48
   
49
   define (SQL_SHOW_CLIENTS,
49
   define ('SQL_SHOW_CLIENTS',
50
      "select max(concat('<a href=\"index.html?client_id=',client.client_id,'\">',client.name,'</a>')) 'Client', 
50
      "select max(concat('<a href=\"index.html?client_id=',client.client_id,'\">',client.name,'</a>')) 'Client', 
51
              count(*) 'Sites',
51
              count(*) 'Sites',
52
              concat('<a href=\"edit.html?client_id=',client.client_id,'\">Edit</a>') Action
52
              concat('<a href=\"edit.html?client_id=',client.client_id,'\">Edit</a>') Action
53
       from client left outer join site using (client_id)
53
       from client left outer join site using (client_id)
54
       where site.removed_date is null and
54
       where site.removed_date is null and
55
             <whereClause>
55
             <whereClause>
56
       group by client.client_id
56
       group by client.client_id
57
       order by client.name"
57
       order by client.name"
58
   );
58
   );
59
   
59
   
60
   define (SQL_SHOW_DEVICE, '
60
   define ('SQL_SHOW_DEVICE', '
61
      select device.device_id "ID",
61
      select device.device_id "ID",
62
             concat(client.name, \' - \', site.name) "Site",
62
             concat(client.name, \' - \', site.name) "Site",
63
             device_type.name "Type",
63
             device_type.name "Type",
64
             device.name "Name",
64
             device.name "Name",
65
             device.serial "Serial",
65
             device.serial "Serial",
Line 176... Line 176...
176
    * index is an array of the form 'device_id' => $device_id
176
    * index is an array of the form 'device_id' => $device_id
177
    * call this as
177
    * call this as
178
    * print callableOutput( 'device view', array( 'device_id' => $device_id );
178
    * print callableOutput( 'device view', array( 'device_id' => $device_id );
179
    */
179
    */
180
   function callableOutput( $screen, $index ) {
180
   function callableOutput( $screen, $index ) {
-
 
181
      $result = '';
181
      $sql = insertValuesIntoQuery(SQL_GET_MODULES,array( 'screen' => $screen ));
182
      $sql = insertValuesIntoQuery(SQL_GET_MODULES,array( 'screen' => $screen ));
182
      $modules = queryDatabaseExtended( $sql );
183
      $modules = queryDatabaseExtended( $sql );
183
      if ( $modules ) {
184
      if ( $modules ) {
184
         $modules = $modules['data'];
185
         $modules = $modules['data'];
185
         $parameters = $index;
186
         $parameters = $index;
-
 
187
/*         $output = array();
-
 
188
         $output = "$screen\n" . print_r( $index, true) . print_r( $modules, true ) . "\n$sql\n"
-
 
189
         file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/file/queryout.sql', implode( "\n", $output)  );
-
 
190
*/
186
         foreach ( $modules as $report ) {
191
         foreach ( $modules as $report ) {
187
            $module = $report['module'];
192
            $module = $report['module'];
188
            list($library, $function ) = explode (':', $report['path'] . $report['script']);
193
            list($library, $function ) = explode (':', $report['path'] . $report['script']);
189
            //print "$library - $function<br />\n";
194
            //print "$library - $function<br />\n";
-
 
195
            if ( file_exists( $library ) ) {
190
            require_once "$library";
196
               require_once "$library";
191
            if ( is_callable( $function ) ) {
197
               if ( is_callable( $function ) ) {
192
               $content = call_user_func( $function, $parameters );
198
                  $content = call_user_func( $function, $parameters );
193
               if ( $content )
199
                  if ( $content )
194
                  return "<div><h4>$module</h4>$content</div>\n";
200
                     $result .= "<div><h4>$module</h4>$content</div>\n";
-
 
201
               }
195
            }
202
            }
196
         }
203
         }
197
      }
204
      }
-
 
205
      return $result;
198
   } // callableOutput
206
   } // callableOutput
199
      
207
      
200
 
208
 
201
?>
209
?>