| 1 | rodolico | 1 | <?php include_once( 'header.php' ); ?>
 | 
        
           |  |  | 2 | <?xml version="1.0" encoding="utf-8"?>
 | 
        
           |  |  | 3 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
        
           |  |  | 4 | <html xmlns="http://www.w3.org/1999/xhtml">
 | 
        
           |  |  | 5 | <head>
 | 
        
           |  |  | 6 |   <title>Daily Data - Computer Asset Management Program</title>
 | 
        
           |  |  | 7 |   <link rel="stylesheet" type="text/css" href="camp.css">
 | 
        
           |  |  | 8 | </head>
 | 
        
           |  |  | 9 | <body>
 | 
        
           |  |  | 10 | <?php include_once('menu.php'); ?>
 | 
        
           |  |  | 11 |   | 
        
           |  |  | 12 | <div id="content">
 | 
        
           |  |  | 13 | <?php
 | 
        
           | 62 | rodolico | 14 |    $callables = '';
 | 
        
           | 1 | rodolico | 15 |    $client_id = $_GET['client_id'];
 | 
        
           |  |  | 16 |    $site_id = $_GET['site_id'];
 | 
        
           |  |  | 17 |    $where = setAuth();
 | 
        
           |  |  | 18 |    /* 
 | 
        
           |  |  | 19 |       this code will see if the requested data is only one row for clients and 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
 | 
        
           |  |  | 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
 | 
        
           |  |  | 24 |    */
 | 
        
           |  |  | 25 |    if ( ! iAmAdministrator() ) {
 | 
        
           |  |  | 26 |       if (strlen($client_id) + strlen($site_id) == 0) { // we must just be starting out
 | 
        
           |  |  | 27 |          $sql = "select client_id from client where $where";
 | 
        
           |  |  | 28 |          $clients = queryDatabaseExtended( $sql );
 | 
        
           |  |  | 29 |          if ($clients['count'] == 1) {
 | 
        
           |  |  | 30 |             $client_id = $clients['data'][0]['client_id'];
 | 
        
           |  |  | 31 |          }
 | 
        
           |  |  | 32 |       }
 | 
        
           |  |  | 33 |       if ($client_id) { 
 | 
        
           |  |  | 34 |           $sql = "select site_id from site join client on site.client_id = client.client_id where $where";
 | 
        
           |  |  | 35 |           $sites = queryDatabaseExtended( $sql );
 | 
        
           |  |  | 36 |           if ($sites['count'] == 1) {
 | 
        
           |  |  | 37 |             $site_id = $sites['data'][0]['site_id'];
 | 
        
           |  |  | 38 |             $client_id = '';
 | 
        
           |  |  | 39 |           }
 | 
        
           |  |  | 40 |       } // checking if client has only one row
 | 
        
           |  |  | 41 |    } // outer if
 | 
        
           |  |  | 42 |    if ( $client_id ) { // we have a client, show sites
 | 
        
           |  |  | 43 |       $sql = insertValuesIntoQuery(SQL_SHOW_SITES,
 | 
        
           |  |  | 44 |                             array('whereClause' => setAuth(implode( ' and ', 
 | 
        
           |  |  | 45 |                                                                   array("site.client_id = $client_id"
 | 
        
           |  |  | 46 |                                                                   )))));
 | 
        
           | 62 | rodolico | 47 |   | 
        
           | 1 | rodolico | 48 |       $currentScreen = '<a href="edit.html?command=add_site">Add Site</a>';
 | 
        
           | 62 | rodolico | 49 |       $callables = callableOutput( 'client view', array( 'client_id' => $client_id ) );
 | 
        
           | 1 | rodolico | 50 |    } elseif ($site_id) { // we have a site, show devices
 | 
        
           |  |  | 51 |       $sql = insertValuesIntoQuery(SQL_SHOW_DEVICES,
 | 
        
           |  |  | 52 |                             array('whereClause' => setAuth(implode( ' and ', 
 | 
        
           |  |  | 53 |                                                                   array("device.site_id = $site_id"
 | 
        
           |  |  | 54 |                                                                   )))));
 | 
        
           |  |  | 55 |       $currentScreen = '<a href="edit.html?command=add_device">Add Device</a>';
 | 
        
           | 62 | rodolico | 56 |       $callables = callableOutput( 'site view', array( 'site_id' => $site_id ) );
 | 
        
           |  |  | 57 |   | 
        
           | 1 | rodolico | 58 |    } else { // we have nothing, show client list
 | 
        
           |  |  | 59 |       $sql = insertValuesIntoQuery(SQL_SHOW_CLIENTS,
 | 
        
           |  |  | 60 |                             array('whereClause' => setAuth('1')));
 | 
        
           |  |  | 61 |       $currentScreen = '<a href="edit.html?command=add_client">Add Client</a>';
 | 
        
           |  |  | 62 |    }
 | 
        
           |  |  | 63 |    //print "<pre>\n$sql\n</pre>";
 | 
        
           |  |  | 64 |    print queryToTable( $sql );
 | 
        
           |  |  | 65 |    print $currentScreen;
 | 
        
           | 62 | rodolico | 66 |    print $callables;
 | 
        
           | 1 | rodolico | 67 | ?>
 | 
        
           |  |  | 68 | </div>
 | 
        
           |  |  | 69 | </body>
 | 
        
           |  |  | 70 | </html>
 | 
        
           |  |  | 71 |   |