Subversion Repositories computer_asset_manager_v1

Rev

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

Rev 67 Rev 83
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
   define(VERSION,'1.6.2');
3
   define(VERSION,'1.6.2');
4
   define(BUILD_DATE,'$Date: 2017-07-28 15:26:29 -0500 (Fri, 28 Jul 2017) $');
4
   define(BUILD_DATE,'$Date: 2019-05-11 01:58:43 -0500 (Sat, 11 May 2019) $');
5
   define(SVN_REV,'$Rev: 67 $' );
5
   define(SVN_REV,'$Rev: 83 $' );
6
 
6
 
7
   include_once("database.php");
7
   include_once("database.php");
8
   
8
   
9
   include_once("library.php");
9
   include_once("library.php");
10
   include_once('reports.php');
10
   include_once('reports.php');
Line 23... Line 23...
23
         and a.removed_date is null
23
         and a.removed_date is null
24
         and b.removed_date is null"
24
         and b.removed_date is null"
25
   );
25
   );
26
   
26
   
27
   define ('SQL_SHOW_SITES',
27
   define ('SQL_SHOW_SITES',
28
      "select concat('<a href=\"index.html?site_id=',site.site_id,'\">', site.name,'</a>') 'Site',
28
      "select concat('<a href=\"index.html?site_id=',site_id,'\">', Site,'</a>') 'Site',
29
              count(*) 'Devices',
29
              count(*) 'Devices',
30
              concat('<a href=\"edit.html?site_id=',site.site_id,'\">Edit</a>') Action
30
              concat('<a href=\"edit.html?site_id=',site_id,'\">Edit</a>') Action
31
       from client_site site left outer join current_systems device using (site_id)
31
       from view_client_site_device
32
       where <whereClause>
32
       where <whereClause>
33
       group by site.site_id
33
       group by site_id
34
       order by site.name"
34
       order by view_client_site_device.Site"
35
   );
35
   );
36
   
36
   
37
   define ('SQL_SHOW_DEVICES',
37
   define ('SQL_SHOW_DEVICES',
38
      "select concat('<a href=\"show_device.html?device_id=',device.device_id,'\">',device.name,'</a>') 'Device',
38
      "select concat('<a href=\"show_device.html?device_id=',device_id,'\">',Device,'</a>') 'Device',
39
       device_type.name 'Type',
39
       Device_Type 'Type',
40
       concat('<a href=\"edit.html?device_id=',device.device_id,'\">Edit</a>') Action
40
       concat('<a href=\"edit.html?device_id=',device_id,'\">Edit</a>') Action
41
       from device join device_type on device.device_type_id = device_type.device_type_id
-
 
42
            join site on device.site_id = site.site_id
-
 
43
            join client on site.client_id = client.client_id
-
 
44
       where device_type.show_as_system = 'Y' 
-
 
45
             and device.removed_date is null
41
       from view_client_site_device
46
             and <whereClause>
42
       where <whereClause>
47
       order by device_type.name,device.name"
43
       order by view_client_site_device.Device_Type,view_client_site_device.Device"
48
   );
44
   );
49
   
45
   
50
   define ('SQL_SHOW_CLIENTS',
46
   define ('SQL_SHOW_CLIENTS',
51
      "select max(concat('<a href=\"index.html?client_id=',client.client_id,'\">',client.name,'</a>')) 'Client', 
47
      "select max(concat('<a href=\"index.html?client_id=',client_id,'\">',Client,'</a>')) 'Client', 
52
              count(*) 'Sites',
48
              count(*) 'Sites',
53
              concat('<a href=\"edit.html?client_id=',client.client_id,'\">Edit</a>') Action
49
              concat('<a href=\"edit.html?client_id=',client_id,'\">Edit</a>') Action
54
       from client left outer join site using (client_id)
-
 
55
       where site.removed_date is null and
50
       from view_client_site_device
56
             <whereClause>
51
       where <whereClause>
57
       group by client.client_id
52
       group by client_id
58
       order by client.name"
53
       order by view_client_site_device.Client"
59
   );
54
   );
60
   
55
   
61
   define ('SQL_SHOW_DEVICE', '
56
   define ('SQL_SHOW_DEVICE', '
62
      select device.device_id "ID",
57
      select device.device_id "ID",
63
             concat(client.name, \' - \', site.name) "Site",
58
             concat(client.name, \' - \', site.name) "Site",
Line 95... Line 90...
95
         return false;
90
         return false;
96
      }
91
      }
97
   }
92
   }
98
   
93
   
99
   function setAuth ( $whereClause = 'true' ) {
94
   function setAuth ( $whereClause = 'true' ) {
100
      if ( iAmAdministrator() ) return $whereClause;
-
 
101
      $whereClause = " ($whereClause)"; // ensure that the whereClause passed will not override our limits
-
 
102
      switch ( $_SESSION['where_clause'] ) {
-
 
103
         case '' : $whereClause .= ' and false'; // no login allowed if empty string
-
 
104
                  break;
-
 
105
         default : $whereClause .= ' and ' . $_SESSION['where_clause'];
95
      return " ($whereClause) and " . ( $_SESSION['where_clause'] ? $_SESSION['where_clause'] : '1=0' );
106
      }
-
 
107
      return $whereClause;
-
 
108
   }
96
   }
109
   
97
   
110
   function iAmAdministrator () {
98
   function iAmAdministrator () {
111
      return ($_SESSION['where_clause'] == 'ADMINISTRATOR');
99
      return ($_SESSION['where_clause'] == '1=1');
112
   }
100
   }
113
   
101
   
114
   /*
102
   /*
115
      function takes a screen name and looks it up in $MODULE_REPORTS to translate to a bit position.
103
      function takes a screen name and looks it up in $MODULE_REPORTS to translate to a bit position.
116
      It will then search the report table in the database to determine which reports need to be run, passing the values in the 
104
      It will then search the report table in the database to determine which reports need to be run, passing the values in the