root / src / rack.php @ a9b72d88
Historique | Voir | Annoter | Télécharger (9,04 ko)
1 |
<?php
|
---|---|
2 |
session_start(); |
3 |
require("headers.php"); |
4 |
|
5 |
if ($session->mode == "super") { |
6 |
print("<p><a href='add_box.php'>Add a new box for your Liquid N2 storage.</a></p>"); |
7 |
} |
8 |
|
9 |
if (isset($_REQUEST["action"])) { |
10 |
// print_r($_REQUEST);
|
11 |
$passage = $_REQUEST["passage"]; |
12 |
$container = $_REQUEST["container"]; |
13 |
$rack = $_REQUEST["rack"]; |
14 |
$box = $_REQUEST["box"]; |
15 |
if ($_REQUEST["action"] == "update_storage") { |
16 |
$where_clause = ""; |
17 |
$try_to_update = FALSE; |
18 |
foreach ($_REQUEST as $key => $value) { |
19 |
if (preg_match("/fieldy_fieldx/i", $key)) { |
20 |
$try_to_update = TRUE; |
21 |
$tmp_exp = explode("_", $key); |
22 |
$tmp_field_y = $tmp_exp[2]; |
23 |
$tmp_field_x = $tmp_exp[3]; |
24 |
$where_clause .= "(container='$container' AND rack='$rack' AND box='$box' AND field_y='$tmp_field_y' AND field_x='$tmp_field_x') OR "; |
25 |
// $output .= "<p>$tmp_box $tmp_field***********</p>";
|
26 |
} |
27 |
} |
28 |
$where_clause .= "0"; |
29 |
if ($passage == "drop") { |
30 |
$qry = "UPDATE cl_storage SET cl_passages=NULL WHERE $where_clause"; |
31 |
$result = mysql_query($qry, $connexion); |
32 |
} else {
|
33 |
$qry = "SELECT * FROM cl_storage WHERE $where_clause"; |
34 |
// echo "<br>" . $qry . "<br>";
|
35 |
$result = mysql_query($qry, $connexion); |
36 |
$error = FALSE; |
37 |
while($tmp_passage = mysql_fetch_object($result)) { |
38 |
if (isset($tmp_passage->cl_passages)) { |
39 |
$error = TRUE; |
40 |
echo "<H4 style='background-color: red;'><b>ERROR!</b> $tmp_passage->container $tmp_passage->rack $tmp_passage->box $tmp_passage->field_y $tmp_passage->field_x is not empty.</H4>"; |
41 |
} |
42 |
} |
43 |
if ($try_to_update & $session->mode == "view") { |
44 |
echo "<H4 style='background-color: red;'><b>ERROR!</b> You can't update Liquid N2 storage in view mode.</H4>"; |
45 |
} |
46 |
if (!$error & $session->mode != "view") { |
47 |
$qry = "UPDATE cl_storage SET cl_passages='$passage' WHERE $where_clause"; |
48 |
$result = mysql_query($qry, $connexion); |
49 |
} |
50 |
} |
51 |
} |
52 |
} |
53 |
|
54 |
|
55 |
// $qry = "SELECT * FROM cl_passages";
|
56 |
// $result = mysql_query($qry, $connexion);
|
57 |
// while($tmp_passage = mysql_fetch_object($result)) {
|
58 |
// if (!isset($passage)) {
|
59 |
// $passage = $tmp_passage->ID;
|
60 |
// echo "Passage: $tmp_passage->name $tmp_passage->passage $tmp_passage->date_of_freezing";
|
61 |
// }
|
62 |
// }
|
63 |
|
64 |
|
65 |
$output = ""; |
66 |
$output .= "<form>"; |
67 |
|
68 |
$output .= "Which passage do you want to precise storage?<br>"; |
69 |
$output .= "Passage: <select name='passage' onChange='submit()'>"; |
70 |
$qry = "SELECT * FROM cl_passages"; |
71 |
$result = mysql_query($qry, $connexion); |
72 |
while($tmp_passage = mysql_fetch_object($result)) { |
73 |
if (!isset($passage)) { |
74 |
$passage = $tmp_passage->ID; |
75 |
} |
76 |
$passage == $tmp_passage->ID ? $selected = "selected" : $selected = ""; |
77 |
$output .= "<option value='$tmp_passage->ID' $selected>$tmp_passage->name $tmp_passage->passage $tmp_passage->date_of_freezing</option>"; |
78 |
} |
79 |
$output .= "<option value='drop'>drop</option>"; |
80 |
$output .= "</select><br>"; |
81 |
|
82 |
|
83 |
|
84 |
|
85 |
$output .= "In which container/rack/box?<br>"; |
86 |
|
87 |
|
88 |
|
89 |
|
90 |
$output .= "Container: <select name='container' onChange='submit()'>"; |
91 |
$qry = "SELECT DISTINCT container FROM cl_storage ORDER BY container"; |
92 |
$result = mysql_query($qry, $connexion); |
93 |
while($storage = mysql_fetch_object($result)) { |
94 |
if (!isset($container)) { |
95 |
$container = $storage->container; |
96 |
} |
97 |
$container == $storage->container ? $selected = "selected" : $selected = ""; |
98 |
$output .= "<option value='$storage->container' $selected>$storage->container</option>"; |
99 |
} |
100 |
$output .= "</select><br>"; |
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
$output .= "Rack: <select name='rack' onChange='submit()'>"; |
107 |
$qry = "SELECT DISTINCT rack FROM cl_storage WHERE container='$container' ORDER BY rack"; |
108 |
$result = mysql_query($qry, $connexion); |
109 |
$tmp_racks = array(); |
110 |
while($storage = mysql_fetch_object($result)) { |
111 |
array_push($tmp_racks, $storage->rack); |
112 |
} |
113 |
if (isset($rack)) { |
114 |
if (!in_array($rack, $tmp_racks)) { |
115 |
unset($rack); |
116 |
} |
117 |
} |
118 |
foreach ($tmp_racks as $storage_rack) { |
119 |
if (!isset($rack)) { |
120 |
$rack = $storage_rack; |
121 |
} |
122 |
$rack == $storage_rack ? $selected = "selected" : $selected = ""; |
123 |
$output .= "<option value='$storage_rack' $selected>$storage_rack</option>"; |
124 |
} |
125 |
// while($storage = mysql_fetch_object($result)) {
|
126 |
// if (!isset($rack)) {
|
127 |
// $rack = $storage->rack;
|
128 |
// }
|
129 |
// $rack == $storage->rack ? $selected = "selected" : $selected = "";
|
130 |
// $output .= "<option value='$storage->rack' $selected>$storage->rack</option>";
|
131 |
// }
|
132 |
$output .= "</select><br>"; |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
$output .= "Box: <select name='box' onChange='submit()'>"; |
138 |
$qry = "SELECT DISTINCT box FROM cl_storage WHERE container='$container' AND rack='$rack' ORDER BY box"; |
139 |
$result = mysql_query($qry, $connexion); |
140 |
$tmp_boxes = array(); |
141 |
while($storage = mysql_fetch_object($result)) { |
142 |
array_push($tmp_boxes, $storage->box); |
143 |
} |
144 |
if (isset($box)) { |
145 |
if (!in_array($box, $tmp_boxes)) { |
146 |
unset($box); |
147 |
} |
148 |
} |
149 |
foreach ($tmp_boxes as $storage_box) { |
150 |
if (!isset($box)) { |
151 |
$box = $storage_box; |
152 |
} |
153 |
$box == $storage_box ? $selected = "selected" : $selected = ""; |
154 |
$output .= "<option value='$storage_box' $selected>$storage_box</option>"; |
155 |
} |
156 |
$output .= "</select><br>"; |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
$qry = "SELECT name FROM cl_passages WHERE ID='$passage'"; |
162 |
$result = mysql_query($qry, $connexion); |
163 |
$cell_line = mysql_fetch_object($result)->name; |
164 |
|
165 |
|
166 |
|
167 |
$qry = "SELECT * FROM cl_storage, cl_passages WHERE container='$container' AND rack='$rack' AND box='$box' AND cl_storage.cl_passages=cl_passages.ID"; |
168 |
$result = mysql_query($qry, $connexion); |
169 |
$content = array(); |
170 |
$content_index = array(); |
171 |
$content_cell_line = array(); |
172 |
while($joint_passage = mysql_fetch_object($result)) { |
173 |
$key = $joint_passage->container . $joint_passage->rack . $joint_passage->box . $joint_passage->field_y . $joint_passage->field_x;; |
174 |
$value = $joint_passage->name . "<br>" . $joint_passage->passage . "<br>" . $joint_passage->date_of_freezing; |
175 |
$content[$key] = $value; |
176 |
$content_index[$key] = $joint_passage->cl_passages ; |
177 |
$content_cell_line[$key] = $joint_passage->name ; |
178 |
} |
179 |
|
180 |
|
181 |
$box_map = array( |
182 |
"A" => range(1,2), |
183 |
"B" => range(1,3), |
184 |
"C" => range(1,4), |
185 |
"D" => range(1,5), |
186 |
"E" => range(1,6), |
187 |
"F" => range(1,7), |
188 |
"G" => range(1,8), |
189 |
"H" => range(1,9), |
190 |
"I" => range(1,10), |
191 |
"J" => range(1,9), |
192 |
"K" => range(1,4), |
193 |
); |
194 |
|
195 |
$output .= "In which boxes/fields?<br>"; |
196 |
$output .= "<table>"; |
197 |
foreach ($box_map as $field_y => $fields) { |
198 |
$output .= "<tr><td >"; |
199 |
$output .= $field_y; |
200 |
$output .= "</td>"; |
201 |
$output .= "<td>"; |
202 |
$output .= "<center><table ><tr>"; |
203 |
foreach($fields as $field_x) { |
204 |
$key = $container . $rack . $box . $field_y . $field_x; |
205 |
isset($content[$key]) ? $color="LightGray" : $color="LightGreen"; |
206 |
@$content_cell_line[$key] == $cell_line ? $color="PowderBlue": $color=$color; |
207 |
@$content_index[$key] == $passage ? $color="RoyalBlue": $color=$color; |
208 |
$output .= "<td style='background-color: $color; width:80; border: 1px solid black;''>"; |
209 |
if ($session->mode != "view") { |
210 |
$output .= "<input type='checkbox' name='fieldy_fieldx_" . $field_y . "_" . $field_x . " value='on'>$field_x</input><br>"; |
211 |
} else {
|
212 |
$output .= "<b>$field_x</b><br>"; |
213 |
} |
214 |
$output .= isset($content[$key]) ? $content[$key] : "empty<br><br><br>"; |
215 |
$output .= "</td>"; |
216 |
} |
217 |
$output .= "</tr></table></center>"; |
218 |
$output .= "</td></tr>"; |
219 |
} |
220 |
$output .= "</table>"; |
221 |
|
222 |
$output .= "<input type='hidden' name='action' value='update_storage'>\n"; |
223 |
$output .= "<input type='submit' value='update storage or view'>\n"; |
224 |
|
225 |
$output .= "</table>"; |
226 |
|
227 |
$output .= "</form>"; |
228 |
|
229 |
echo $output; |
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
$output2 = "<table class='pme-main'><tr class='pme-header'><th class='pme-header'>Cell Line</th><th class='pme-header'>#Vials</th><th class='pme-header'>Note</th></tr>"; |
244 |
|
245 |
$qry = "SELECT name, COUNT(cl_passages) as cnt FROM cl_storage, cl_passages WHERE cl_storage.cl_passages=cl_passages.ID GROUP BY name"; |
246 |
$result = mysql_query($qry, $connexion); |
247 |
$content = array(); |
248 |
$content_index = array(); |
249 |
while($joint_passage = mysql_fetch_object($result)) { |
250 |
if ($joint_passage->cnt <= 5) { |
251 |
$note = "<blink><b>Please freeze additional passages to maintain frozen stocks!</b></blink>"; |
252 |
} else {
|
253 |
$note = "Sufficient stock."; |
254 |
} |
255 |
$output2 .= "<tr class='pme-row-0'><td class='pme-cell-0'>$joint_passage->name</td><td class='pme-cell-0'>$joint_passage->cnt</td><td class='pme-cell-0'>$note</td></tr>"; |
256 |
// print($joint_passage->name . " " . $joint_passage->cnt . "<pre>");
|
257 |
// print_r($joint_passage);
|
258 |
// print("</pre>");
|
259 |
// $key = $joint_passage->container . $joint_passage->rack . $joint_passage->box . $joint_passage->field_y . $joint_passage->field_x;;
|
260 |
// $value = $joint_passage->name . "<br>" . $joint_passage->passage . "<br>" . $joint_passage->date_of_freezing;
|
261 |
// $content[$key] = $value;
|
262 |
// $content_index[$key] = $joint_passage->cl_passages ;
|
263 |
} |
264 |
$output2 .= "</table>"; |
265 |
|
266 |
print($output2); |
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
// session_start ();
|
277 |
require("footers.php"); |
278 |
|
279 |
|
280 |
?>
|
281 |
|
282 |
|