source: schedule/function/SplitDelete.php@ 16953

Last change on this file since 16953 was 16953, checked in by tanio, 12 years ago
File size: 16.3 KB
Line 
1<?php include '../include/factdb.php'; ?>
2<script language="javascript">
3var timeval = 0;
4var name = "";
5var hid = "";
6var opt = "";
7window.cnt=0;
8 function clearNode(node){
9 var child = node.childNodes[0];
10 while(child != null)
11 {
12 node.removeChild(child);
13 child = node.childNodes[0];
14 }
15 }
16 function addRow(table){
17 var targetView = table;
18 // CREATE ELEMENT
19 var newtr = document.createElement("tr");
20
21 var newtd_c1 = document.createElement("td");
22 newtd_c1.setAttribute("width","115");
23 newtd_c1.setAttribute("align","center");
24 newtd_c1.appendChild(
25 input_data = document.createElement("input"),
26 input_data.setAttribute("type","time"),
27 input_data.setAttribute("autofocus","true"),
28 input_data.setAttribute("id","Time"),
29 input_data.setAttribute("max","24"),
30 input_data.setAttribute("min","1"),
31 input_data.setAttribute("required",true),
32 input_data.setAttribute("hidden",true),
33 input_data.setAttribute("value",timeval)
34 );
35 var newtd_c2 = document.createElement("td");
36 newtd_c2.setAttribute("width","40");
37 newtd_c2.setAttribute("align","center");
38 newtd_c2.appendChild(
39 selection = document.createElement("select"),
40 <?php
41 $selectm = mysql_query("SELECT * FROM measurement");
42 while($rowmeasure = mysql_fetch_array($selectm)){
43
44 ?>
45 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
46 <?php } ?>
47
48
49
50 selection.setAttribute('id','source')
51 );
52 newtd_c2.appendChild(
53 input_data = document.createElement("input"),
54 input_data.setAttribute("class","button"),
55 input_data.setAttribute("type","button"),
56 input_data.setAttribute("value","+"),
57 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){
58 val = $(this).val();
59
60 });
61 timeval = val; return addRow(table); }
62 );
63 var newtd_c3 = document.createElement("td");
64 newtd_c3.setAttribute("width","88");
65 newtd_c3.setAttribute("align","center");
66 newtd_c3.appendChild(
67 selection = document.createElement("select"),
68 <?php
69
70 $select = mysql_query("SELECT * FROM source");
71
72 while($rowsource = mysql_fetch_array($select)){
73
74 ?>
75 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
76 <?php } ?>
77 selection.setAttribute('id','measurement')
78 );
79 var newtd_c4 = document.createElement("td");
80 newtd_c4.setAttribute("width","180");
81 newtd_c4.setAttribute("align","center");
82 newtd_c4.appendChild(
83 input_data = document.createElement("input"),
84 input_data.setAttribute("type","text"),
85 input_data.setAttribute("size","20"),
86 input_data.setAttribute("placeholder","Value")
87 );
88 var newtd_c5 = document.createElement("td");
89 newtd_c5.setAttribute("width","95");
90 newtd_c5.setAttribute("align","center");
91 newtd_c5.appendChild(
92 input_data = document.createElement("input"),
93 input_data.setAttribute("type","button"),
94 input_data.setAttribute("class","button"),
95 input_data.setAttribute("value","Delete"),
96 input_data.onclick = function(){ return clearNode(newtr); }
97 );
98
99
100 newtr.appendChild(newtd_c1);
101 newtr.appendChild(newtd_c2);
102 newtr.appendChild(newtd_c3);
103 newtr.appendChild(newtd_c4);
104 newtr.appendChild(newtd_c5);
105
106
107 $(targetView).append(newtr);
108 }
109 function deleteRow(tableID){
110 try{
111 var table=document.getElementById(tableID);
112 var rowCount=table.rows.length;
113
114 for(var i=0;i<rowCount;i++){
115 var row=table.rows[i];
116 var chkbox=row.cells[0].childNodes[0];
117 if(null!=chkbox&&true==chkbox.checked){
118 if(rowCount<=1){
119 alert("Cannot delete all the rows.");
120 break;
121 }
122 table.deleteRow(i);
123 rowCount--;i--;
124 }
125 }
126 }catch(e){
127 alert(e);
128 }
129 }
130
131
132function addRowClone(){
133 var targetView = document.getElementById("Data");
134 // CREATE ELEMENT
135
136 var newdiv = document.createElement("div");
137 newdiv.setAttribute("style","margin:30px 0;");
138 var newtable = document.createElement("table");
139 newtable.setAttribute("class","dataTable");
140 newtable.setAttribute("width","100%");
141 newtable.setAttribute("border","1");
142 newtable.setAttribute("cellspacing","0");
143 newtable.setAttribute("cellpadding","0");
144
145 var newtr = document.createElement("tr");
146
147 var newtd_c1 = document.createElement("td");
148 newtd_c1.setAttribute("width","115");
149 newtd_c1.setAttribute("align","center");
150 newtd_c1.appendChild(
151 input_data = document.createElement("input"),
152 input_data.setAttribute("type","time"),
153 input_data.setAttribute("autofocus","true"),
154 input_data.setAttribute("id","Time"),
155 input_data.setAttribute("max","24"),
156 input_data.setAttribute("min","1"),
157 input_data.setAttribute("required",true)
158
159 );
160 var newtd_c2 = document.createElement("td");
161 newtd_c2.setAttribute("width","40");
162 newtd_c2.setAttribute("align","center");
163 newtd_c2.appendChild(
164 selection = document.createElement("select"),
165 <?php
166 $selectm = mysql_query("SELECT * FROM measurement");
167 while($rowmeasure = mysql_fetch_array($selectm)){
168
169 ?>
170 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
171 <?php } ?>
172
173
174 selection.setAttribute('id','source')
175 );
176 newtd_c2.appendChild(
177 input_data = document.createElement("input"),
178 input_data.setAttribute("class","button"),
179 input_data.setAttribute("type","button"),
180 input_data.setAttribute("value","+"),
181 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){
182 val = $(this).val();
183
184 });
185timeval = val;
186 return addRow(newtable);}
187 );
188 var newtd_c3 = document.createElement("td");
189 newtd_c3.setAttribute("width","88");
190 newtd_c3.setAttribute("align","center");
191 newtd_c3.appendChild(
192 selection = document.createElement("select"),
193 <?php
194
195 $select = mysql_query("SELECT * FROM source");
196
197 while($rowsource = mysql_fetch_array($select)){
198
199 ?>
200 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
201 <?php } ?>
202
203 selection.setAttribute('id','measurement')
204 );
205 var newtd_c4 = document.createElement("td");
206 newtd_c4.setAttribute("width","180");
207 newtd_c4.setAttribute("align","center");
208 newtd_c4.appendChild(
209 input_data = document.createElement("input"),
210 input_data.setAttribute("type","text"),
211 input_data.setAttribute("size","20"),
212 input_data.setAttribute("placeholder","Value")
213 );
214 var newtd_c5 = document.createElement("td");
215 newtd_c5.setAttribute("width","95");
216 newtd_c5.setAttribute("align","center");
217 newtd_c5.appendChild(
218 input_data = document.createElement("input"),
219 input_data.setAttribute("type","button"),
220 input_data.setAttribute("class","button"),
221 input_data.setAttribute("value","Delete Main"),
222 input_data.onclick = function(){ return clearNode(newdiv); }
223 );
224
225
226 newtr.appendChild(newtd_c1);
227 newtr.appendChild(newtd_c2);
228 newtr.appendChild(newtd_c3);
229 newtr.appendChild(newtd_c4);
230 newtr.appendChild(newtd_c5);
231
232
233 newtable.appendChild(newtr);
234 newdiv.appendChild(newtable);
235
236 targetView.appendChild(newdiv);
237}
238
239
240
241
242<?php
243
244 if(isset($_GET['days']))
245 {
246 $day = $_GET['days'];
247 }
248 else
249 {
250 $day =date("Y-m-d");
251 }
252 $days = Date('Y-m-d',strtotime($day));
253 $fetch = mysql_query("SELECT * FROM schedule ORDER BY fScheduleID ASC") or die(mysql_error());
254 while($rows = mysql_fetch_array($fetch))
255 {
256 $timestamp=strtotime($rows['fStart']);
257 $timestamp2 = date('Y-m-d',$timestamp);
258 $date_time = date('H:i',$timestamp);
259
260 if($days == $timestamp2)
261 {
262 ?>
263 cnt++;
264
265 $('#save').attr('value','UPDATE');
266
267 var targetView = document.getElementById("Data");
268 // CREATE ELEMENT
269 var newdiv = document.createElement("div");
270 newdiv.setAttribute("style","margin:5px 0;");
271 var newtable = document.createElement("table");
272 newtable.setAttribute("class","dataTable");
273 newtable.setAttribute("id","dataTable"+cnt);
274 newtable.setAttribute("width","100%");
275 newtable.setAttribute("border","1");
276 newtable.setAttribute("cellspacing","0");
277 newtable.setAttribute("cellpadding","0");
278
279 var newtr = document.createElement("tr");
280
281 var newtd_c1 = document.createElement("td");
282 newtd_c1.setAttribute("width","115");
283 newtd_c1.setAttribute("align","center");
284 newtd_c1.appendChild(
285 input_data = document.createElement("input"),
286 input_data.setAttribute("type","time"),
287 input_data.setAttribute("autofocus","true"),
288 input_data.setAttribute("id","Time"),
289 input_data.setAttribute("max","24"),
290 input_data.setAttribute("min","1"),
291 input_data.setAttribute("required",true),
292 input_data.setAttribute("value",'<?php echo $date_time; ?>')
293 );
294 var newtd_c2 = document.createElement("td");
295 newtd_c2.setAttribute("width","40");
296 newtd_c2.setAttribute("align","center");
297 newtd_c2.appendChild(
298 selection = document.createElement("select"),
299 <?php
300 $selectm = mysql_query("SELECT * FROM measurement");
301 while($rowmeasure = mysql_fetch_array($selectm)){
302
303 ?>
304 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
305 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} } ?>
306
307
308 selection.setAttribute('id','source')
309 );
310 newtd_c2.appendChild(
311 input_data = document.createElement("input"),
312 input_data.setAttribute("class","button"),
313 input_data.setAttribute("type","button"),
314 input_data.setAttribute("value","+"),
315 input_data.setAttribute("name","dataTable"+cnt),
316 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){
317 val = $(this).val();
318
319 });
320timeval = val; //alert();
321 return addRow("#"+$(this).attr('name')); }
322 );
323 var newtd_c3 = document.createElement("td");
324 newtd_c3.setAttribute("width","88");
325 newtd_c3.setAttribute("align","center");
326 newtd_c3.appendChild(
327 selection = document.createElement("select"),
328
329 <?php
330
331 $select = mysql_query("SELECT * FROM source");
332
333 while($rowsource = mysql_fetch_array($select)){
334
335 ?>
336 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
337 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
338
339 <?php } ?>
340 selection.setAttribute('id','measurement')
341 );
342 var newtd_c4 = document.createElement("td");
343 newtd_c4.setAttribute("width","180");
344 newtd_c4.setAttribute("align","center");
345 newtd_c4.appendChild(
346 input_data = document.createElement("input"),
347 input_data.setAttribute("type","text"),
348 input_data.setAttribute("size","20"),
349 input_data.setAttribute("placeholder","Value"),
350 input_data.setAttribute('value','<?php echo $rows['fData']; ?>')
351 );
352 var newtd_c5 = document.createElement("td");
353 newtd_c5.setAttribute("width","95");
354 newtd_c5.setAttribute("align","center");
355 newtd_c5.appendChild(
356 input_data = document.createElement("input"),
357 input_data.setAttribute("type","button"),
358 input_data.setAttribute("class","button"),
359 input_data.setAttribute("value","Delete Main"),
360 input_data.onclick = function(){ return clearNode(newdiv); }
361 );
362
363
364 newtr.appendChild(newtd_c1);
365 newtr.appendChild(newtd_c2);
366 newtr.appendChild(newtd_c3);
367 newtr.appendChild(newtd_c4);
368 newtr.appendChild(newtd_c5);
369
370
371 newtable.appendChild(newtr);
372 newdiv.appendChild(newtable);
373
374 targetView.appendChild(newdiv);
375
376
377
378 <?php } } ?>
379
380
381
382
383
384
385
386window.onload = function(){
387
388
389
390
391if(cnt==0){
392
393 var targetView = document.getElementById("Data");
394 // CREATE ELEMENT
395 var newdiv = document.createElement("div");
396 newdiv.setAttribute("style","margin:5px 0;");
397 var newtable = document.createElement("table");
398 newtable.setAttribute("class","dataTable");
399 newtable.setAttribute("width","100%");
400 newtable.setAttribute("border","1");
401 newtable.setAttribute("cellspacing","0");
402 newtable.setAttribute("cellpadding","0");
403
404 var newtr = document.createElement("tr");
405
406 var newtd_c1 = document.createElement("td");
407 newtd_c1.setAttribute("width","115");
408 newtd_c1.setAttribute("align","center");
409 newtd_c1.appendChild(
410 input_data = document.createElement("input"),
411 input_data.setAttribute("type","time"),
412 input_data.setAttribute("autofocus","true"),
413 input_data.setAttribute("id","Time"),
414 input_data.setAttribute("max","24"),
415 input_data.setAttribute("min","1"),
416 input_data.setAttribute("required",true)
417 );
418 var newtd_c2 = document.createElement("td");
419 newtd_c2.setAttribute("width","40");
420 newtd_c2.setAttribute("align","center");
421 newtd_c2.appendChild(
422 selection = document.createElement("select"),
423 <?php
424 $selectm = mysql_query("SELECT * FROM measurement");
425 while($rowmeasure = mysql_fetch_array($selectm)){
426
427 ?>
428 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
429 <?php } ?>
430
431
432 selection.setAttribute('id','source')
433 );
434 newtd_c2.appendChild(
435 input_data = document.createElement("input"),
436 input_data.setAttribute("class","button"),
437 input_data.setAttribute("type","button"),
438 input_data.setAttribute("value","+"),
439 input_data.onclick = function(){ var val; $('div#Data .dataTable #Time').each(function(){
440 val = $(this).val();
441
442 });
443timeval = val; return addRow(newtable);}
444 );
445 var newtd_c3 = document.createElement("td");
446 newtd_c3.setAttribute("width","88");
447 newtd_c3.setAttribute("align","center");
448 newtd_c3.appendChild(
449 selection = document.createElement("select"),
450 <?php
451
452 $select = mysql_query("SELECT * FROM source");
453
454 while($rowsource = mysql_fetch_array($select)){
455
456 ?>
457 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
458 <?php } ?>
459
460 selection.setAttribute('id','measurement')
461 );
462 var newtd_c4 = document.createElement("td");
463 newtd_c4.setAttribute("width","180");
464 newtd_c4.setAttribute("align","center");
465 newtd_c4.appendChild(
466 input_data = document.createElement("input"),
467 input_data.setAttribute("type","text"),
468 input_data.setAttribute("size","20"),
469 input_data.setAttribute("placeholder","Value")
470 );
471 var newtd_c5 = document.createElement("td");
472 newtd_c5.setAttribute("width","95");
473 newtd_c5.setAttribute("align","center");
474 newtd_c5.appendChild(
475 input_data = document.createElement("input"),
476 input_data.setAttribute("type","button"),
477 input_data.setAttribute("class","button"),
478 input_data.setAttribute("value","Delete Main"),
479 input_data.onclick = function(){ return clearNode(newdiv); }
480 );
481
482
483 newtr.appendChild(newtd_c1);
484 newtr.appendChild(newtd_c2);
485 newtr.appendChild(newtd_c3);
486 newtr.appendChild(newtd_c4);
487 newtr.appendChild(newtd_c5);
488
489 newtable.appendChild(newtr);
490 newdiv.appendChild(newtable);
491
492 targetView.appendChild(newdiv);
493}
494 }
495
496
497
498</script>
Note: See TracBrowser for help on using the repository browser.