Subversion Repositories computer_asset_manager_v1

Rev

Rev 62 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php include_once( 'header.php' ); ?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Daily Data - Computer Asset Management Program</title>
  <link rel="stylesheet" type="text/css" href="camp.css">
</head>
<body>
<?php include_once('menu.php'); ?>

<div id="content">
<?php
   $callables = '';
   $client_id = $_GET['client_id'];
   $site_id = $_GET['site_id'];
   $where = setAuth();
   /* 
      this code will see if the requested data is only one row for clients and sites
      If it is, it will go to the next thing, ie if only one client, then we look at the sites
      If there is only one site, we will look at the devices for that site and fall out
      This way, the user doesn't have to go through multiple screens of only one option each
      Note, this is bypassed for the ADMINSTRATOR
   */
   if (strlen($client_id) + strlen($site_id) == 0) { // we must just be starting out
      $sql = "select distinct( client_id ) from view_client_site_device where $where";
      $clients = queryDatabaseExtended( $sql );
      if ($clients['count'] == 1) {
         $client_id = $clients['data'][0]['client_id'];
      }
   } elseif ($client_id) { 
       $sql = "select site_id from view_client_site_device where $where";
       $sites = queryDatabaseExtended( $sql );
       if ($sites['count'] == 1) {
         $site_id = $sites['data'][0]['site_id'];
         $client_id = '';
       }
   } // checking if client has only one row
   if ( $client_id ) { // we have a client, show sites
      $sql = insertValuesIntoQuery(SQL_SHOW_SITES,
                            array('whereClause' => setAuth(implode( ' and ', 
                                                                  array("client_id = $client_id"
                                                                  )))));
                                                         
      $currentScreen = '<a href="edit.html?command=add_site">Add Site</a>';
      $callables = callableOutput( 'client view', array( 'client_id' => $client_id ) );
   } elseif ($site_id) { // we have a site, show devices
      $sql = insertValuesIntoQuery(SQL_SHOW_DEVICES,
                            array('whereClause' => setAuth(implode( ' and ', 
                                                                  array("site_id = $site_id"
                                                                  )
                                                                  )
                                                         )
                                 )
                                 );
      $currentScreen = '<a href="edit.html?command=add_device">Add Device</a>';
      $callables = callableOutput( 'site view', array( 'site_id' => $site_id ) );

   } else { // we have nothing, show client list
      $sql = insertValuesIntoQuery(SQL_SHOW_CLIENTS,
                            array('whereClause' => setAuth('1')));
      $currentScreen = '<a href="edit.html?command=add_client">Add Client</a>';
   }
   //print "<pre>\n$sql\n</pre>";
   print queryToTable( $sql );
   print $currentScreen;
   print $callables;
?>
</div>
</body>
</html>