root / src / add_box.php @ 2c8001fb
Historique | Voir | Annoter | Télécharger (2,88 ko)
1 | 2c8001fb | Florent Chuffart | <?php
|
---|---|---|---|
2 | 2c8001fb | Florent Chuffart | session_start(); |
3 | 2c8001fb | Florent Chuffart | require("headers.php"); |
4 | 2c8001fb | Florent Chuffart | |
5 | 2c8001fb | Florent Chuffart | $box_map = array( |
6 | 2c8001fb | Florent Chuffart | "A" => range(1,2), |
7 | 2c8001fb | Florent Chuffart | "B" => range(1,3), |
8 | 2c8001fb | Florent Chuffart | "C" => range(1,4), |
9 | 2c8001fb | Florent Chuffart | "D" => range(1,5), |
10 | 2c8001fb | Florent Chuffart | "E" => range(1,6), |
11 | 2c8001fb | Florent Chuffart | "F" => range(1,7), |
12 | 2c8001fb | Florent Chuffart | "G" => range(1,8), |
13 | 2c8001fb | Florent Chuffart | "H" => range(1,9), |
14 | 2c8001fb | Florent Chuffart | "I" => range(1,10), |
15 | 2c8001fb | Florent Chuffart | "J" => range(1,9), |
16 | 2c8001fb | Florent Chuffart | "K" => range(1,4), |
17 | 2c8001fb | Florent Chuffart | ); |
18 | 2c8001fb | Florent Chuffart | |
19 | 2c8001fb | Florent Chuffart | if (isset($_REQUEST["action"])) { |
20 | 2c8001fb | Florent Chuffart | $container = $_REQUEST["container"]; |
21 | 2c8001fb | Florent Chuffart | $rack = $_REQUEST["rack"]; |
22 | 2c8001fb | Florent Chuffart | $box = $_REQUEST["box"]; |
23 | 2c8001fb | Florent Chuffart | if ($_REQUEST["action"] == "add_box_to_db") { |
24 | 2c8001fb | Florent Chuffart | $where_clause = "container='$container' AND rack='$rack' AND box='$box'"; |
25 | 2c8001fb | Florent Chuffart | if (FALSE) { |
26 | 2c8001fb | Florent Chuffart | $qry = "UPDATE cl_storage SET cl_passages=NULL WHERE $where_clause"; |
27 | 2c8001fb | Florent Chuffart | $result = mysql_query($qry, $connexion); |
28 | 2c8001fb | Florent Chuffart | } else {
|
29 | 2c8001fb | Florent Chuffart | $error = FALSE; |
30 | 2c8001fb | Florent Chuffart | $qry = "SELECT COUNT(*) FROM cl_storage WHERE $where_clause"; |
31 | 2c8001fb | Florent Chuffart | $result = mysql_query($qry); |
32 | 2c8001fb | Florent Chuffart | $row = mysql_fetch_row($result); |
33 | 2c8001fb | Florent Chuffart | $count = $row[0]; |
34 | 2c8001fb | Florent Chuffart | if ($count > 0) { |
35 | 2c8001fb | Florent Chuffart | $error = TRUE; |
36 | 2c8001fb | Florent Chuffart | echo "<H4 style='background-color: red;'><b>ERROR!</b> Container $container rack $rack box $box ever exists!</H4>"; |
37 | 2c8001fb | Florent Chuffart | } |
38 | 2c8001fb | Florent Chuffart | if ($session->mode != "super") { |
39 | 2c8001fb | Florent Chuffart | echo "<H4 style='background-color: red;'><b>ERROR!</b> You must be in <b>superuser mode</b> to add a Liquid N2 box.</H4>"; |
40 | 2c8001fb | Florent Chuffart | } |
41 | 2c8001fb | Florent Chuffart | if (!$error & $session->mode == "super") { |
42 | 2c8001fb | Florent Chuffart | $qry_part = array(); |
43 | 2c8001fb | Florent Chuffart | foreach ($box_map as $field_y => $fields) { |
44 | 2c8001fb | Florent Chuffart | foreach($fields as $field_x) { |
45 | 2c8001fb | Florent Chuffart | array_push($qry_part, "(NULL,'$container','$rack','$box','$field_y','$field_x',NULL)"); |
46 | 2c8001fb | Florent Chuffart | } |
47 | 2c8001fb | Florent Chuffart | } |
48 | 2c8001fb | Florent Chuffart | $box_values = implode(",", $qry_part); |
49 | 2c8001fb | Florent Chuffart | $qry = "INSERT INTO `cl_storage` VALUES $box_values"; |
50 | 2c8001fb | Florent Chuffart | $result = mysql_query($qry, $connexion); |
51 | 2c8001fb | Florent Chuffart | if ($result) { |
52 | 2c8001fb | Florent Chuffart | echo "<H4 style='background-color: green;'><b>CONGRATULATION!</b> You succesfully add container $container rack $rack box $box.</H4>"; |
53 | 2c8001fb | Florent Chuffart | } |
54 | 2c8001fb | Florent Chuffart | } |
55 | 2c8001fb | Florent Chuffart | } |
56 | 2c8001fb | Florent Chuffart | } |
57 | 2c8001fb | Florent Chuffart | } |
58 | 2c8001fb | Florent Chuffart | |
59 | 2c8001fb | Florent Chuffart | |
60 | 2c8001fb | Florent Chuffart | $output = ""; |
61 | 2c8001fb | Florent Chuffart | $output .= "<p>You want to add a new Liquid N2 box in your database.</p>"; |
62 | 2c8001fb | Florent Chuffart | $output .= "<form>"; |
63 | 2c8001fb | Florent Chuffart | |
64 | 2c8001fb | Florent Chuffart | $output .= "What is the number on the container?<br>"; |
65 | 2c8001fb | Florent Chuffart | $output .= "Container: <select name='container' >"; |
66 | 2c8001fb | Florent Chuffart | for ($i = 1; $i <= 50; $i++){ |
67 | 2c8001fb | Florent Chuffart | $output .= "<option value='$i'>$i</option>"; |
68 | 2c8001fb | Florent Chuffart | } |
69 | 2c8001fb | Florent Chuffart | $output .= "</select><br>"; |
70 | 2c8001fb | Florent Chuffart | |
71 | 2c8001fb | Florent Chuffart | $output .= "What is the number on the rack?<br>"; |
72 | 2c8001fb | Florent Chuffart | $output .= "Rack: <select name='rack' >"; |
73 | 2c8001fb | Florent Chuffart | for ($i = 1; $i <= 50; $i++){ |
74 | 2c8001fb | Florent Chuffart | $output .= "<option value='$i'>$i</option>"; |
75 | 2c8001fb | Florent Chuffart | } |
76 | 2c8001fb | Florent Chuffart | $output .= "</select><br>"; |
77 | 2c8001fb | Florent Chuffart | |
78 | 2c8001fb | Florent Chuffart | $output .= "What is the number on the box?<br>"; |
79 | 2c8001fb | Florent Chuffart | $output .= "Box: <select name='box' >"; |
80 | 2c8001fb | Florent Chuffart | for ($i = 1; $i <= 100; $i++){ |
81 | 2c8001fb | Florent Chuffart | $output .= "<option value='$i'>$i</option>"; |
82 | 2c8001fb | Florent Chuffart | } |
83 | 2c8001fb | Florent Chuffart | $output .= "<input type='hidden' name='action' value='add_box_to_db'>\n"; |
84 | 2c8001fb | Florent Chuffart | $output .= "<br><input type='submit' value='Add this new box.'>\n"; |
85 | 2c8001fb | Florent Chuffart | $output .= "</select><br>"; |
86 | 2c8001fb | Florent Chuffart | $output .= "</form>"; |
87 | 2c8001fb | Florent Chuffart | |
88 | 2c8001fb | Florent Chuffart | echo $output; |
89 | 2c8001fb | Florent Chuffart | |
90 | 2c8001fb | Florent Chuffart | // session_start ();
|
91 | 2c8001fb | Florent Chuffart | require("footers.php"); |
92 | 2c8001fb | Florent Chuffart | |
93 | 2c8001fb | Florent Chuffart | |
94 | 2c8001fb | Florent Chuffart | ?>
|
95 | 2c8001fb | Florent Chuffart |