1 <?php |
|
2 /***************************************************************************** |
|
3 * Copyright (C) 2014-2015 |
|
4 * |
|
5 * Michiel Broek <mbroek at mbse dot eu> |
|
6 * |
|
7 * This file is part of ThermFerm |
|
8 * |
|
9 * This is free software; you can redistribute it and/or modify it |
|
10 * under the terms of the GNU General Public License as published by the |
|
11 * Free Software Foundation; either version 2, or (at your option) any |
|
12 * later version. |
|
13 * |
|
14 * ThermFerm is distributed in the hope that it will be useful, but |
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 * General Public License for more details. |
|
18 * |
|
19 * You should have received a copy of the GNU General Public License |
|
20 * along with ThermFerm; see the file COPYING. If not, write to the Free |
|
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
22 *****************************************************************************/ |
|
23 |
|
24 require_once('utilities.php'); |
|
25 $my_style = 'ui-redmond'; |
|
26 |
|
27 |
|
28 /* |
|
29 * Each time this page is loaded, get the profiles from the server. |
|
30 * $arr contains the complete reply of he PROFILE LIST command. |
|
31 */ |
|
32 $answer = send_cmd("PROFILE LIST"); |
|
33 $arr = explode("\r\n", $answer); |
|
34 |
|
35 |
|
36 |
|
37 if (isset($_GET['action'])) { |
|
38 switch ($_GET['action']) { |
|
39 case 'edit': profile_edit(); |
|
40 break; |
|
41 case 'esteps': profile_steps(); |
|
42 break; |
|
43 default: break; |
|
44 } |
|
45 } elseif (isset($_POST['action'])) { |
|
46 switch ($_POST['action']) { |
|
47 case 'testdata': testdata(); |
|
48 break; |
|
49 case 'teststeps': teststeps(); |
|
50 break; |
|
51 default: break; |
|
52 } |
|
53 } else { |
|
54 profile_list(); |
|
55 } |
|
56 |
|
57 exit; |
|
58 |
|
59 |
|
60 |
|
61 /* |
|
62 * Profile steps |
|
63 */ |
|
64 function profile_steps() |
|
65 { |
|
66 global $arr; |
|
67 $UUID = $_GET['UUID']; |
|
68 |
|
69 /* |
|
70 * $steps contains all steps of a profile |
|
71 */ |
|
72 $steps = array ( |
|
73 1 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
74 2 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
75 3 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
76 4 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
77 5 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
78 6 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
79 7 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
80 8 => array("steptime" => 0, "resttime" => 0, "target_lo" => 19.8, "target_hi" => 20.2, "fridge_mode" => 0 ), |
|
81 ); |
|
82 |
|
83 $answer = send_cmd("PROFILE GETS ".$UUID); |
|
84 $psteps = explode("\r\n", $answer); |
|
85 |
|
86 if (startsWith($arr[0], "212")) { |
|
87 $j = 1; |
|
88 while (1) { |
|
89 if (strcmp($psteps[$j], ".") == 0) |
|
90 break; |
|
91 $f = explode(",", $psteps[$j]); |
|
92 $steps[$j]["steptime"] = $f[0]; |
|
93 $steps[$j]["resttime"] = $f[1]; |
|
94 $steps[$j]["target_lo"] = $f[2]; |
|
95 $steps[$j]["target_hi"] = $f[3]; |
|
96 $steps[$j]["fridge_mode"] = $f[4]; |
|
97 $j++; |
|
98 } |
|
99 } |
|
100 |
|
101 edit_steps($UUID, $steps, "", "ThermFerm - Edit Profile Steps"); |
|
102 } |
|
103 |
|
104 |
|
105 function edit_steps($UUID, $steps, $error_message, $heading) |
|
106 { |
|
107 $outstr = build_header($heading); |
|
108 $outstr .= ' <div id="errors">'.PHP_EOL; |
|
109 $outstr .= ' '.$error_message.PHP_EOL; |
|
110 $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
|
111 $outstr .= ' <div id="etable">'.PHP_EOL; |
|
112 $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
|
113 $outstr .= ' <table class="editor">'.PHP_EOL; |
|
114 $outstr .= ' <tr class="trhead">'.PHP_EOL; |
|
115 $outstr .= ' <td>Step</td>'.PHP_EOL; |
|
116 $outstr .= ' <td>Steptime</td>'.PHP_EOL; |
|
117 $outstr .= ' <td>Resttime</td>'.PHP_EOL; |
|
118 $outstr .= ' <td>Temp low</td>'.PHP_EOL; |
|
119 $outstr .= ' <td>Temp high</td>'.PHP_EOL; |
|
120 $outstr .= ' <td>Fridge mode</td>'.PHP_EOL; |
|
121 $outstr .= ' </tr>'.PHP_EOL; |
|
122 |
|
123 for ($i = 1; $i <= 8; $i++) { |
|
124 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
125 $outstr .= ' <td>Step '.$i.'</td>'.PHP_EOL; |
|
126 $outstr .= ' <td><input type="text" name="steptime'.$i.'" size="4" value="'.$steps[$i]["steptime"].'"></td>'.PHP_EOL; |
|
127 $outstr .= ' <td><input type="text" name="resttime'.$i.'" size="4" value="'.$steps[$i]["resttime"].'"></td>'.PHP_EOL; |
|
128 $outstr .= ' <td><input type="text" name="target_lo'.$i.'" size="4" value="'.$steps[$i]["target_lo"].'"></td>'.PHP_EOL; |
|
129 $outstr .= ' <td><input type="text" name="target_hi'.$i.'" size="4" value="'.$steps[$i]["target_hi"].'"></td>'.PHP_EOL; |
|
130 $outstr .= ' <td><input type="hidden" name="fridge_mode'.$i.'" value="0"><input type="checkbox" name="fridge_mode'.$i.'" value="100"'; |
|
131 if ($steps[$i]["fridge_mode"] > 0) |
|
132 $outstr .= ' checked'; |
|
133 $outstr .= '></td>'.PHP_EOL; |
|
134 $outstr .= ' </tr>'.PHP_EOL; |
|
135 } |
|
136 |
|
137 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
138 $outstr .= ' <td class="editname"> </td>'.PHP_EOL; |
|
139 $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; |
|
140 $outstr .= ' <td class="editname"><input type="submit" value="Cancel" name="key">'; |
|
141 $outstr .= '<input type="hidden" value="teststeps" name="action">'; |
|
142 $outstr .= '<input type="hidden" value="'.$UUID.'" name="UUID"></td>'.PHP_EOL; |
|
143 $outstr .= ' <td class="editname"> </td>'.PHP_EOL; |
|
144 $outstr .= ' </tr>'.PHP_EOL; |
|
145 $outstr .= ' </table>'.PHP_EOL; |
|
146 $outstr .= ' </form>'.PHP_EOL; |
|
147 $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
|
148 $outstr .= ' <div id="atable" style="margin-left: 100px; width:780px;">'.PHP_EOL; |
|
149 $outstr .= ' The steptime is the time to go from the previous to the target temperature.'.PHP_EOL; |
|
150 $outstr .= ' The resttime is the time in this step holding the target temperature.'.PHP_EOL; |
|
151 $outstr .= ' The duration of the step is steptime + resttime.'.PHP_EOL; |
|
152 $outstr .= ' Steps are valid if the steptime or resttime is greater then zero.'.PHP_EOL; |
|
153 $outstr .= ' Order is important.'.PHP_EOL; |
|
154 $outstr .= ' Lines with a zero steptime and zero resttime are ignored.'.PHP_EOL; |
|
155 $outstr .= ' The step- and resttimes are in hours.'.PHP_EOL; |
|
156 $outstr .= ' </div> <!-- atable -->'.PHP_EOL; |
|
157 $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
|
158 $outstr .= ' $(document).ready(function () {'.PHP_EOL; |
|
159 $outstr .= ' $("#maintenance").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL; |
|
160 $outstr .= ' });'.PHP_EOL; |
|
161 $outstr .= ' </script>'.PHP_EOL; |
|
162 $outstr .= build_footer(); |
|
163 echo $outstr; |
|
164 } |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 /* |
|
170 * Profile add |
|
171 * |
|
172 * @param string $_POST['Name'] The rpofile name |
|
173 */ |
|
174 function profile_add() { |
|
175 |
|
176 if ($_POST['key'] == 'Add') { |
|
177 send_cmd("PROFILE ADD ".$_POST['Name']); |
|
178 } |
|
179 unset($_POST['UUID']); |
|
180 unset($_POST['Name']); |
|
181 unset($_POST['Steps']); |
|
182 unset($_POST['key']); |
|
183 unset($_POST['command']); |
|
184 load('profiles.php'); |
|
185 } |
|
186 |
|
187 |
|
188 |
|
189 /* |
|
190 * Profile update or delete |
|
191 * |
|
192 * @param string $_POST['UUID'] The profile UUID |
|
193 * @param string $_POST['Name'] The profile name |
|
194 * @param string $_POST['Inittemp_lo'] The profile initial temperature low |
|
195 * @param string $_POST['Inittemp_hi'] The profile initial temperature high |
|
196 * @param string $_POST['Fridge_mode'] The profile fridge/beer mode |
|
197 * @param string $_POST['key'] The button pressed. |
|
198 */ |
|
199 function profile_update() { |
|
200 /* |
|
201 * Build the update command |
|
202 */ |
|
203 if ($_POST['key'] == 'Delete') { |
|
204 send_cmd("PROFILE DEL ".$_POST['UUID']); |
|
205 } |
|
206 |
|
207 if ($_POST['key'] == 'Save') { |
|
208 $cmd = array("PROFILE PUT ".$_POST['UUID']); |
|
209 $cmd[] = "NAME,".$_POST['Name']; |
|
210 $cmd[] = "INITTEMP_LO,".$_POST['Inittemp_lo']; |
|
211 $cmd[] = "INITTEMP_HI,".$_POST['Inittemp_hi']; |
|
212 $cmd[] = "FRIDGE_MODE,".$_POST['Fridge_mode']; |
|
213 $cmd[] = "."; |
|
214 send_array($cmd); |
|
215 } |
|
216 |
|
217 unset($_POST['UUID']); |
|
218 unset($_POST['Name']); |
|
219 unset($_POST['Inittemp_lo']); |
|
220 unset($_POST['Inittemp_hi']); |
|
221 unset($_POST['Fridge_mode']); |
|
222 unset($_POST['key']); |
|
223 unset($_POST['command']); |
|
224 load('profiles.php'); |
|
225 } |
|
226 |
|
227 |
|
228 |
|
229 /* |
|
230 * Test input of a modified or new profile. |
|
231 * |
|
232 * @param string $_POST['UUID'] Unique record UUID |
|
233 * @param int $_POST['steptime'n] Profile steptime |
|
234 * @param int $_POST['resttime'n] Profile resttime |
|
235 * @param float $_POST['target_lo'n] Profile target temperature low |
|
236 * @param float $_POST['target_hi'n] Profile target temperature high |
|
237 * @param int $_POST['fridge_mode'n] Profile fridge mode |
|
238 * @param string $_POST['key'] Key choice, Save or Cancel |
|
239 * |
|
240 * Return: 0 = Ok |
|
241 * 1 = Missing data |
|
242 * 3 = A target temperature out of range |
|
243 * 99 = Cancel key |
|
244 */ |
|
245 function test_thesteps() { |
|
246 |
|
247 global $arr; |
|
248 |
|
249 for ($i = 1; $i <= 8; $i++) { |
|
250 if ((! isset($_POST['steptime'.$i])) || (! isset($_POST['resttime'.$i])) || (! isset($_POST['target_lo'.$i])) || (! isset($_POST['target_hi'.$i])) || (! isset($_POST['fridge_mode'.$i]))) |
|
251 return 1; |
|
252 if ((strlen($_POST['steptime'.$i]) == 0) || (strlen($_POST['resttime'.$i]) == 0) || (strlen($_POST['target_lo'.$i]) == 0) || (strlen($_POST['target_hi'.$i]) == 0) || (strlen($_POST['fridge_mode'.$i]) == 0)) |
|
253 return 1; |
|
254 } |
|
255 |
|
256 if (isset($_POST['UUID']) && isset($_POST['key'])) { |
|
257 |
|
258 if ($_POST['key'] == 'Cancel') |
|
259 return 99; |
|
260 |
|
261 for ($i = 1; $i <= 8; $i++) { |
|
262 |
|
263 if (($_POST['target_lo'.$i] < -5) || ($_POST['target_lo'.$i] > 30)) |
|
264 return 3; |
|
265 if (($_POST['target_hi'.$i] < -5) || ($_POST['target_hi'.$i] > 30)) |
|
266 return 3; |
|
267 if ($_POST['target_lo'.$i] > $_POST['target_hi'.$i]) |
|
268 return 3; |
|
269 } |
|
270 } else { |
|
271 return 1; |
|
272 } |
|
273 |
|
274 return 0; |
|
275 } |
|
276 |
|
277 |
|
278 |
|
279 /* |
|
280 * Test result from edit_steps screen and do next action |
|
281 */ |
|
282 function teststeps() { |
|
283 |
|
284 $result = test_thesteps(); |
|
285 $error = ''; |
|
286 |
|
287 switch ($result) { |
|
288 case 0: $cmd = array("PROFILE PUTS ".$_POST['UUID']); |
|
289 for ($i = 1; $i <= 8; $i++) { |
|
290 if (($_POST['steptime'.$i] > 0) || ($_POST['resttime'.$i] > 0)) { |
|
291 $cmd[] = $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target_lo'.$i].','.$_POST['target_hi'.$i].','.$_POST['fridge_mode'.$i]; |
|
292 } |
|
293 unset($_POST['steptime'.$i]); |
|
294 unset($_POST['resttime'.$i]); |
|
295 unset($_POST['target_lo'.$i]); |
|
296 unset($_POST['target_hi'.$i]); |
|
297 unset($_POST['fridge_mode'.$i]); |
|
298 } |
|
299 $cmd[] = "."; |
|
300 send_array($cmd); |
|
301 unset($_POST['UUID']); |
|
302 unset($_POST['key']); |
|
303 load('profiles.php'); |
|
304 return; |
|
305 break; |
|
306 case 1: $error = 'Missing data'; |
|
307 break; |
|
308 case 2: $error = 'A resttime is shorter then the steptime'; |
|
309 break; |
|
310 case 3: $error = 'A target temperature is out of range'; |
|
311 break; |
|
312 case 99: |
|
313 load('profiles.php'); |
|
314 break; |
|
315 } |
|
316 |
|
317 $steps = array ( |
|
318 1 => array("steptime" => $_POST['steptime1'], "resttime" => $_POST['resttime1'], "target_lo" => $_POST['target_lo1'], "target_hi" => $_POST['target_hi1'], "fridge_mode" => $_POST['mode_fridge1'] ), |
|
319 2 => array("steptime" => $_POST['steptime2'], "resttime" => $_POST['resttime2'], "target_lo" => $_POST['target_lo2'], "target_hi" => $_POST['target_hi2'], "fridge_mode" => $_POST['mode_fridge2'] ), |
|
320 3 => array("steptime" => $_POST['steptime3'], "resttime" => $_POST['resttime3'], "target_lo" => $_POST['target_lo3'], "target_hi" => $_POST['target_hi3'], "fridge_mode" => $_POST['mode_fridge3'] ), |
|
321 4 => array("steptime" => $_POST['steptime4'], "resttime" => $_POST['resttime4'], "target_lo" => $_POST['target_lo4'], "target_hi" => $_POST['target_hi4'], "fridge_mode" => $_POST['mode_fridge4'] ), |
|
322 5 => array("steptime" => $_POST['steptime5'], "resttime" => $_POST['resttime5'], "target_lo" => $_POST['target_lo5'], "target_hi" => $_POST['target_hi5'], "fridge_mode" => $_POST['mode_fridge5'] ), |
|
323 6 => array("steptime" => $_POST['steptime6'], "resttime" => $_POST['resttime6'], "target_lo" => $_POST['target_lo6'], "target_hi" => $_POST['target_hi6'], "fridge_mode" => $_POST['mode_fridge6'] ), |
|
324 7 => array("steptime" => $_POST['steptime7'], "resttime" => $_POST['resttime7'], "target_lo" => $_POST['target_lo7'], "target_hi" => $_POST['target_hi7'], "fridge_mode" => $_POST['mode_fridge7'] ), |
|
325 8 => array("steptime" => $_POST['steptime8'], "resttime" => $_POST['resttime8'], "target_lo" => $_POST['target_lo8'], "target_hi" => $_POST['target_hi8'], "fridge_mode" => $_POST['mode_fridge8'] ), |
|
326 ); |
|
327 |
|
328 edit_steps($_POST['UUID'], $steps, $error, "ThermFerm - Edit Profile Steps"); |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 /* |
|
334 * Test input of a modified or new profile. |
|
335 * |
|
336 * @param string $_POST['UUID'] Unique record UUID |
|
337 * @param string $_POST['Name'] Profile name |
|
338 * @param float $_POST['Inittemp_lo'] Profile initial temperature |
|
339 * @param float $_POST['Inittemp_hi'] Profile initial temperature |
|
340 * @param float $_POST['Fridge_mode'] Profile fridge mode |
|
341 * @param string $_POST['key'] Key choice, Save or Cancel |
|
342 * @param string $_POST['command'] Command used, 'add' or 'update' |
|
343 * |
|
344 * Return: 0 = Ok |
|
345 * 1 = Missing data |
|
346 * 2 = Name field too short |
|
347 * 3 = Name already in use |
|
348 * 99 = Cancel key |
|
349 */ |
|
350 function test_thedata() { |
|
351 |
|
352 global $arr; |
|
353 |
|
354 if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Inittemp_lo']) && isset($_POST['Inittemp_hi']) && isset($_POST['key']) && isset($_POST['command'])) { |
|
355 |
|
356 if ($_POST['key'] == 'Cancel') |
|
357 return 99; |
|
358 |
|
359 if (strlen($_POST['Name']) < 2) |
|
360 return 2; |
|
361 |
|
362 if (startsWith($arr[0], "212")) { |
|
363 $j = 1; |
|
364 while (1) { |
|
365 if (strcmp($arr[$j], ".") == 0) |
|
366 break; |
|
367 $f = explode(",", $arr[$j]); |
|
368 if (strcmp($f[0], $_POST['UUID']) && (strcmp($f[1], $_POST['Name']) == 0)) { |
|
369 return 3; |
|
370 } |
|
371 $j++; |
|
372 } |
|
373 } |
|
374 |
|
375 } else { |
|
376 return 1; |
|
377 } |
|
378 |
|
379 return 0; |
|
380 } |
|
381 |
|
382 |
|
383 |
|
384 /* |
|
385 * Test result from edit screen and do next action |
|
386 */ |
|
387 function testdata() { |
|
388 |
|
389 $result = test_thedata(); |
|
390 $error = ''; |
|
391 |
|
392 switch ($result) { |
|
393 case 0: if ($_POST['command'] == 'add') { |
|
394 profile_add(); |
|
395 return; |
|
396 } else if ($_POST['command'] == 'update') { |
|
397 profile_update(); |
|
398 return; |
|
399 } |
|
400 break; |
|
401 case 1: $error = 'Missing data'; |
|
402 break; |
|
403 case 2: $error = 'The name is too short'; |
|
404 break; |
|
405 case 3: $error = 'The name is already in use, choose another one'; |
|
406 break; |
|
407 case 99: |
|
408 load('profiles.php'); |
|
409 break; |
|
410 } |
|
411 |
|
412 if ($_POST['command'] == 'add') { |
|
413 $heading = 'ThermFerm - Add Profile'; |
|
414 } else { |
|
415 $heading = 'ThermFerm - Edit Profile'; |
|
416 } |
|
417 |
|
418 edit_screen($_POST['UUID'], $_POST['command'], $heading, $error); |
|
419 } |
|
420 |
|
421 |
|
422 |
|
423 /* |
|
424 * Profiles edit screen. Used by profile_edit(), profile_add() and testdata() |
|
425 * |
|
426 * @param string $UUID The record UUID (fixed). |
|
427 * @param string $Name The Profile Name. |
|
428 * @param string $command 'add' or 'update' |
|
429 * @param string $heading Pagina heading title. |
|
430 * @Param string $error_message Blank or previous error. |
|
431 */ |
|
432 function edit_screen($UUID, $command, $heading, $error_message) { |
|
433 |
|
434 /* |
|
435 * Get current profile data |
|
436 */ |
|
437 $answer = send_cmd("PROFILE GET ".$UUID); |
|
438 $reply = explode("\r\n", $answer); |
|
439 |
|
440 $outstr = build_header($heading); |
|
441 $outstr .= ' <div id="errors">'.PHP_EOL; |
|
442 $outstr .= ' '.$error_message.PHP_EOL; |
|
443 $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
|
444 $outstr .= ' <div id="etable">'.PHP_EOL; |
|
445 $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
|
446 $outstr .= ' <table class="editor">'.PHP_EOL; |
|
447 |
|
448 if (startsWith($reply[0], "213")) { |
|
449 $i = 1; |
|
450 while (1) { |
|
451 if (strcmp($reply[$i], ".") == 0) |
|
452 break; |
|
453 $f = explode(",", $reply[$i]); |
|
454 |
|
455 if ($f[0] == "NAME") { |
|
456 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
457 $outstr .= ' <td class="editname">Profile Name</td>'.PHP_EOL; |
|
458 $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL; |
|
459 $outstr .= ' </tr>'.PHP_EOL; |
|
460 } |
|
461 if ($f[0] == "INITTEMP_LO") { |
|
462 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
463 $outstr .= ' <td class="editname">Initial temperature low</td>'.PHP_EOL; |
|
464 $outstr .= ' <td class="editfield"><input type="text" name="Inittemp_lo" size="5" value="'.$f[1].'"></td>'.PHP_EOL; |
|
465 $outstr .= ' </tr>'.PHP_EOL; |
|
466 } |
|
467 if ($f[0] == "INITTEMP_HI") { |
|
468 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
469 $outstr .= ' <td class="editname">Initial temperature high</td>'.PHP_EOL; |
|
470 $outstr .= ' <td class="editfield"><input type="text" name="Inittemp_hi" size="5" value="'.$f[1].'"></td>'.PHP_EOL; |
|
471 $outstr .= ' </tr>'.PHP_EOL; |
|
472 } |
|
473 if ($f[0] == "FRIDGE_MODE") { |
|
474 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
475 $outstr .= ' <td class="editname">Fridge mode</td>'.PHP_EOL; |
|
476 $outstr .= ' <td class="editfield"><input type="hidden" name="Fridge_mode" value="0"><input type="checkbox" name="Fridge_mode" value="100"'; |
|
477 if ($f[1] > 0) |
|
478 $outstr .= " checked"; |
|
479 $outstr .= '></td>'.PHP_EOL; |
|
480 $outstr .= ' </tr>'.PHP_EOL; |
|
481 } |
|
482 |
|
483 $i++; |
|
484 } |
|
485 } |
|
486 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
487 $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; |
|
488 $outstr .= ' <td class="editfield"><input type="submit" value="Cancel" name="key">'; |
|
489 $outstr .= '<input type="submit" value="Delete" name="key" style="margin-left: 100px;">'; |
|
490 $outstr .= '<input type="hidden" value="testdata" name="action">'; |
|
491 $outstr .= '<input type="hidden" value="'.$command.'" name="command">'; |
|
492 $outstr .= '<input type="hidden" value="'.$UUID.'" name="UUID"></td>'.PHP_EOL; |
|
493 $outstr .= ' </tr>'.PHP_EOL; |
|
494 $outstr .= ' </table>'.PHP_EOL; |
|
495 $outstr .= ' </form>'.PHP_EOL; |
|
496 $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
|
497 $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
|
498 $outstr .= ' $(document).ready(function () {'.PHP_EOL; |
|
499 $outstr .= ' $("#maintenance").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL; |
|
500 $outstr .= ' });'.PHP_EOL; |
|
501 $outstr .= ' </script>'.PHP_EOL; |
|
502 $outstr .= build_footer(); |
|
503 echo $outstr; |
|
504 } |
|
505 |
|
506 |
|
507 |
|
508 /* |
|
509 * Edit a Profile. Fetches the record data and shows the edit screen. |
|
510 * |
|
511 * @param string $_GET['action'] Must be 'edit'. |
|
512 * @param string $_GET['UUID'] The UUID of the Profile. |
|
513 */ |
|
514 function profile_edit() { |
|
515 if ($_GET['action'] == 'edit') { |
|
516 edit_screen($_GET['UUID'], 'update', 'ThermFerm - Edit Profile', ''); |
|
517 return; |
|
518 } else { |
|
519 load('profiles.php'); |
|
520 } |
|
521 } |
|
522 |
|
523 |
|
524 |
|
525 /* |
|
526 * @link Edit profile |
|
527 * @link Add profile |
|
528 */ |
|
529 function profile_list() { |
|
530 |
|
531 global $arr; |
|
532 |
|
533 $outstr = build_header("ThermFerm - Profiles"); |
|
534 |
|
535 $outstr .= ' <div id="errors">'.PHP_EOL; |
|
536 $outstr .= ' </div> <!-- errors -->'.PHP_EOL; |
|
537 $outstr .= ' <div id="etable">'.PHP_EOL; |
|
538 $outstr .= ' <table class="setup">'.PHP_EOL; |
|
539 $outstr .= ' <tr class="trhead">'.PHP_EOL; |
|
540 $outstr .= ' <td class="setup" style="width: 300px;">UUID</td>'.PHP_EOL; |
|
541 $outstr .= ' <td class="setup" style="width: 300px;">Name</td>'.PHP_EOL; |
|
542 $outstr .= ' <td class="setup" style="width: 40px;">Steps</td>'.PHP_EOL; |
|
543 $outstr .= ' <td class="setup" style="width: 40px;">Edit</td>'.PHP_EOL; |
|
544 $outstr .= ' </tr>'.PHP_EOL; |
|
545 |
|
546 if (startsWith($arr[0], "212")) { |
|
547 $j = 1; |
|
548 while (1) { |
|
549 if (strcmp($arr[$j], ".") == 0) |
|
550 break; |
|
551 $f = explode(",", $arr[$j]); |
|
552 $outstr .= ' <tr class="setup">'.PHP_EOL; |
|
553 $outstr .= ' <td class="setup">'.$f[0].'</td>'.PHP_EOL; |
|
554 $outstr .= ' <td class="setup">'.$f[1].'</td>'.PHP_EOL; |
|
555 if ($f[3] == 1) { |
|
556 $outstr .= ' <td class="setup">'.$f[2].'</td>'.PHP_EOL; |
|
557 $outstr .= ' <td class="setup">Busy</td>'.PHP_EOL; |
|
558 } else { |
|
559 $outstr .= ' <td class="setup"><a href="profiles.php?action=esteps&UUID='.$f[0].'">'.$f[2].'</a></td>'.PHP_EOL; |
|
560 $outstr .= ' <td class="setup"><a href="profiles.php?action=edit&UUID='.$f[0].'">Edit</a></td>'.PHP_EOL; |
|
561 } |
|
562 $outstr .= ' </tr>'.PHP_EOL; |
|
563 $j++; |
|
564 } |
|
565 } |
|
566 |
|
567 $outstr .= ' </table>'.PHP_EOL; |
|
568 $outstr .= ' </div> <!-- etable -->'.PHP_EOL; |
|
569 $outstr .= ' <div id="atable">'.PHP_EOL; |
|
570 |
|
571 $outstr .= ' <form method="POST" action="profiles.php">'.PHP_EOL; |
|
572 $outstr .= ' <table class="editor">'.PHP_EOL; |
|
573 $outstr .= ' <tr class="trhead"><td colspan="3">Add new profile</td></tr>'.PHP_EOL; |
|
574 $outstr .= ' <tr class="editor">'.PHP_EOL; |
|
575 $outstr .= ' <td class="editname">Profile Name</td>'.PHP_EOL; |
|
576 $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value=""></td>'.PHP_EOL; |
|
577 $outstr .= ' <td class="editsub"><input type="submit" value="Add" name="key"></td>'.PHP_EOL; |
|
578 $outstr .= '<input type="hidden" value="testdata" name="action">'; |
|
579 $outstr .= '<input type="hidden" value="add" name="command">'; |
|
580 $outstr .= '<input type="hidden" value="00000000-0000-0000-0000-000000000000" name="UUID">'; |
|
581 $outstr .= '<input type="hidden" value="19.8" name="Inittemp_lo"></td>'; |
|
582 $outstr .= '<input type="hidden" value="20.2" name="Inittemp_hi"></td>'; |
|
583 $outstr .= ' </tr>'.PHP_EOL; |
|
584 $outstr .= ' </table>'.PHP_EOL; |
|
585 $outstr .= ' </form>'.PHP_EOL; |
|
586 |
|
587 $outstr .= ' </div> <!-- atable -->'.PHP_EOL; |
|
588 $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
|
589 $outstr .= ' $(document).ready(function () {'.PHP_EOL; |
|
590 $outstr .= ' $("#maintenance").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL; |
|
591 $outstr .= ' });'.PHP_EOL; |
|
592 $outstr .= ' </script>'.PHP_EOL; |
|
593 $outstr .= build_footer(); |
|
594 echo $outstr; |
|
595 } |
|
596 |
|