Subversion Repositories computer_asset_manager_v1

Rev

Rev 62 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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