Subversion Repositories computer_asset_manager_v1

Rev

Rev 62 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 83
Line 20... Line 20...
20
      If it is, it will go to the next thing, ie if only one client, then we look at the sites
20
      If it is, it will go to the next thing, ie if only one client, then we look at the sites
21
      If there is only one site, we will look at the devices for that site and fall out
21
      If there is only one site, we will look at the devices for that site and fall out
22
      This way, the user doesn't have to go through multiple screens of only one option each
22
      This way, the user doesn't have to go through multiple screens of only one option each
23
      Note, this is bypassed for the ADMINSTRATOR
23
      Note, this is bypassed for the ADMINSTRATOR
24
   */
24
   */
25
   if ( ! iAmAdministrator() ) {
-
 
26
      if (strlen($client_id) + strlen($site_id) == 0) { // we must just be starting out
25
   if (strlen($client_id) + strlen($site_id) == 0) { // we must just be starting out
27
         $sql = "select client_id from client where $where";
26
      $sql = "select distinct( client_id ) from view_client_site_device where $where";
28
         $clients = queryDatabaseExtended( $sql );
27
      $clients = queryDatabaseExtended( $sql );
29
         if ($clients['count'] == 1) {
28
      if ($clients['count'] == 1) {
30
            $client_id = $clients['data'][0]['client_id'];
29
         $client_id = $clients['data'][0]['client_id'];
31
         }
-
 
32
      }
30
      }
33
      if ($client_id) { 
31
   } elseif ($client_id) { 
34
          $sql = "select site_id from site join client on site.client_id = client.client_id where $where";
32
       $sql = "select site_id from view_client_site_device where $where";
35
          $sites = queryDatabaseExtended( $sql );
33
       $sites = queryDatabaseExtended( $sql );
36
          if ($sites['count'] == 1) {
34
       if ($sites['count'] == 1) {
37
            $site_id = $sites['data'][0]['site_id'];
35
         $site_id = $sites['data'][0]['site_id'];
38
            $client_id = '';
36
         $client_id = '';
39
          }
37
       }
40
      } // checking if client has only one row
38
   } // checking if client has only one row
41
   } // outer if
-
 
42
   if ( $client_id ) { // we have a client, show sites
39
   if ( $client_id ) { // we have a client, show sites
43
      $sql = insertValuesIntoQuery(SQL_SHOW_SITES,
40
      $sql = insertValuesIntoQuery(SQL_SHOW_SITES,
44
                            array('whereClause' => setAuth(implode( ' and ', 
41
                            array('whereClause' => setAuth(implode( ' and ', 
45
                                                                  array("site.client_id = $client_id"
42
                                                                  array("client_id = $client_id"
46
                                                                  )))));
43
                                                                  )))));
47
                                                         
44
                                                         
48
      $currentScreen = '<a href="edit.html?command=add_site">Add Site</a>';
45
      $currentScreen = '<a href="edit.html?command=add_site">Add Site</a>';
49
      $callables = callableOutput( 'client view', array( 'client_id' => $client_id ) );
46
      $callables = callableOutput( 'client view', array( 'client_id' => $client_id ) );
50
   } elseif ($site_id) { // we have a site, show devices
47
   } elseif ($site_id) { // we have a site, show devices
51
      $sql = insertValuesIntoQuery(SQL_SHOW_DEVICES,
48
      $sql = insertValuesIntoQuery(SQL_SHOW_DEVICES,
52
                            array('whereClause' => setAuth(implode( ' and ', 
49
                            array('whereClause' => setAuth(implode( ' and ', 
53
                                                                  array("device.site_id = $site_id"
50
                                                                  array("site_id = $site_id"
54
                                                                  )))));
51
                                                                  )
-
 
52
                                                                  )
-
 
53
                                                         )
-
 
54
                                 )
-
 
55
                                 );
55
      $currentScreen = '<a href="edit.html?command=add_device">Add Device</a>';
56
      $currentScreen = '<a href="edit.html?command=add_device">Add Device</a>';
56
      $callables = callableOutput( 'site view', array( 'site_id' => $site_id ) );
57
      $callables = callableOutput( 'site view', array( 'site_id' => $site_id ) );
57
 
58
 
58
   } else { // we have nothing, show client list
59
   } else { // we have nothing, show client list
59
      $sql = insertValuesIntoQuery(SQL_SHOW_CLIENTS,
60
      $sql = insertValuesIntoQuery(SQL_SHOW_CLIENTS,