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 |
*/
|
83 |
rodolico |
25 |
if (strlen($client_id) + strlen($site_id) == 0) { // we must just be starting out
|
|
|
26 |
$sql = "select distinct( client_id ) from view_client_site_device where $where";
|
|
|
27 |
$clients = queryDatabaseExtended( $sql );
|
|
|
28 |
if ($clients['count'] == 1) {
|
|
|
29 |
$client_id = $clients['data'][0]['client_id'];
|
1 |
rodolico |
30 |
}
|
83 |
rodolico |
31 |
} elseif ($client_id) {
|
|
|
32 |
$sql = "select site_id from view_client_site_device where $where";
|
|
|
33 |
$sites = queryDatabaseExtended( $sql );
|
|
|
34 |
if ($sites['count'] == 1) {
|
|
|
35 |
$site_id = $sites['data'][0]['site_id'];
|
|
|
36 |
$client_id = '';
|
|
|
37 |
}
|
|
|
38 |
} // checking if client has only one row
|
1 |
rodolico |
39 |
if ( $client_id ) { // we have a client, show sites
|
|
|
40 |
$sql = insertValuesIntoQuery(SQL_SHOW_SITES,
|
|
|
41 |
array('whereClause' => setAuth(implode( ' and ',
|
83 |
rodolico |
42 |
array("client_id = $client_id"
|
1 |
rodolico |
43 |
)))));
|
62 |
rodolico |
44 |
|
1 |
rodolico |
45 |
$currentScreen = '<a href="edit.html?command=add_site">Add Site</a>';
|
62 |
rodolico |
46 |
$callables = callableOutput( 'client view', array( 'client_id' => $client_id ) );
|
1 |
rodolico |
47 |
} elseif ($site_id) { // we have a site, show devices
|
|
|
48 |
$sql = insertValuesIntoQuery(SQL_SHOW_DEVICES,
|
|
|
49 |
array('whereClause' => setAuth(implode( ' and ',
|
83 |
rodolico |
50 |
array("site_id = $site_id"
|
|
|
51 |
)
|
|
|
52 |
)
|
|
|
53 |
)
|
|
|
54 |
)
|
|
|
55 |
);
|
1 |
rodolico |
56 |
$currentScreen = '<a href="edit.html?command=add_device">Add Device</a>';
|
62 |
rodolico |
57 |
$callables = callableOutput( 'site view', array( 'site_id' => $site_id ) );
|
|
|
58 |
|
1 |
rodolico |
59 |
} else { // we have nothing, show client list
|
|
|
60 |
$sql = insertValuesIntoQuery(SQL_SHOW_CLIENTS,
|
|
|
61 |
array('whereClause' => setAuth('1')));
|
|
|
62 |
$currentScreen = '<a href="edit.html?command=add_client">Add Client</a>';
|
|
|
63 |
}
|
|
|
64 |
//print "<pre>\n$sql\n</pre>";
|
|
|
65 |
print queryToTable( $sql );
|
|
|
66 |
print $currentScreen;
|
62 |
rodolico |
67 |
print $callables;
|
1 |
rodolico |
68 |
?>
|
|
|
69 |
</div>
|
|
|
70 |
</body>
|
|
|
71 |
</html>
|
|
|
72 |
|