root/caffeine/trunk/main.inc.php

Revision 8, 3.2 kB (checked in by pmurphy2, 1 year ago)

Added caffeine project files

  • Property svn:executable set to *
Line 
1 <?php
2
3 require('funcs.inc.php');
4
5 function dump_dispense()
6 {
7    require "main.inc.php";
8    mysql_select_db("soda", $db);
9
10    $sodas = mysql_query("SELECT time,acm_integrate.users.netid,sodas.name,price FROM acm_integrate.users left join acm_integrate.vending using(uid) left join sodas using(sid) ORDER BY time", $db);
11    echo "<table>\n<tr class=\"header\"><td>time</td><td></td><td></td><td>user</td><td>soda</td><td>price</td></tr>";
12
13    while ($soda = mysql_fetch_row($sodas))
14       echo "<tr><td><?=$soda[0]?></td><td></td><td></td><td><?=$soda[1]?></td><td><?=$soda[2]?></td> <td><?=$soda[3]?></td> </tr>";
15
16    echo "</table>";
17 }
18
19 function dump_users()
20 {
21    global $db;
22    $users = mysql_query("SELECT * FROM users ORDER BY username", $db);
23    echo "<table> <tr class=header><td>cardid</td><td>username</td><td>first</td><td>last</td><td>email</td> <td>balance</td><td>lpbalance</td><td>notify_balance</td><td>calories</td><td>caffeine</td> <td>spent</td><td>sodas</td><td>margin</td><td>admin</td></tr>";
24
25    while ($user = mysql_fetch_row($users))
26       echo "<tr><td><?=$user[1]?></td> <td><?=$user[2]?></td><td><?=$user[3]?></td><td><?=$user[4]?></td> <td><?=$user[5]?></td><td><?=$user[7]?></td><td><?=$user[8]?></td><td><?=$user[9]?></td> <td><?=$user[10]?></td><td><?=$user[11]?></td><td><?=$user[12]?></td><td><?=$user[13]?></td> <td><?=$user[14]?></td><td><?=$user[15]?></td> </tr>";
27 }
28
29 function admin_section()
30 {
31    global $db;
32    // this is stuff that should only appear for administrators
33    echo "<h1>Administrator Options</h1>\n";
34    // machine update
35    echo "<h2>Machine Update</h2>\n";
36    require("status.php");
37    machine_update_menu($db);
38
39   
40    $a = mysql_fetch_row(mysql_query("SELECT ROUND(SUM(balance),2) FROM acm_integrate.vending WHERE balance >= 0", $db));
41    $balance = $a[0];
42    echo "<p>Total Outstanding Balance: \$ $balance</p>\n";
43   // $a = mysql_fetch_row(mysql_query("SELECT ROUND(SUM(balance),2) FROM acm_integrate.vending WHERE balance < 0", $db));
44    $balance = $a[0];
45  //  echo "<p>Total Outstanding Negative Balance: \$ $balance</p>\n";
46    // change user status
47
48    // add soda
49 //   echo "<h2>Add Soda Type</h2>";
50 }
51
52 function machine_update_menu()
53 {
54    global $db;
55
56    echo "<form action=\"user_admin.php\" method=\"POST\">";
57    echo "<input type=\"hidden\" name=\"op\" value=\"change\">";
58    echo "<table border=\"0\" cellspacing=\"5\" cellpadding=\"5\">";
59    echo "<tr class=header><td>Tray</td><td>Beverage</td><td>Quantity</td></tr>";
60    echo "<tr>";
61    echo "<td>";
62    echo "<select class=\"dropdown\" name=\"tray\">";
63    echo " <option value=\"4\">4 - Left</option>";
64    echo " <option value=\"3\">3</option>";
65    echo " <option value=\"2\">2</option>";
66    echo " <option value=\"1\">1</option>";
67    echo " <option value=\"0\">0 - Right</option>";
68    echo "</select>";
69    echo "</td>";
70    echo "<td>";
71    echo "<select class=\"dropdown\" name=\"soda\">";
72
73    $slist = mysql_query("SELECT sid,name FROM sodas ORDER BY name", $db);
74    while ($s = mysql_fetch_row($slist))
75       echo "\t<option value=\"{$s[0]}\">{$s[1]}</option>\n";
76
77    echo "</select></td>\n";
78    echo "<td><input type=\"text\" size=\"2\" name=\"qty\"></td>\n";
79    echo "<td><input type=\"submit\" name=\"submit\" value=\"Change\"></td>\n";
80    echo "</table></form>\n";
81 }
82
83 function show_user()
84 {
85 }
86
87 ?>
88
Note: See TracBrowser for help on using the browser.