source: schedule/function/SplitDelete.php@ 16949

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