source: schedule/function/SplitDelete.php@ 16738

Last change on this file since 16738 was 16738, checked in by tanio, 11 years ago
File size: 27.1 KB
Line 
1<script type="text/javascript">
2 $(document).ready(function(){
3
4 var timeValue;
5var meas;
6var meas2;
7var getTableId;
8 window.cnt=0;
9
10
11
12
13 //-------------------------------- fetch----------------------------//
14
15
16
17 //-----------------------------------------------//
18 //end fetch
19
20 //------------------------------------------------//
21 var x = 0;
22
23 <?php
24
25
26 include '../include/factdb.php';
27
28
29 if(isset($_GET['days'])){
30 $day = $_GET['days'];
31 }else{
32
33 $day =date("Y-m-d");
34
35 }
36
37
38 $days = Date('Y-m-d',strtotime($day));
39 ?>
40 //alert('<?php echo $day; ?>');
41
42 <?php
43
44
45 $fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
46
47 while($rows = mysql_fetch_array($fetch)){
48 $timestamp=strtotime($rows['fLastUpdate']);
49 $timestamp2 = date('Y-m-d',$timestamp);
50 $date_time = date('H:i',$timestamp);
51 //$time_new = $date_time->format('H:i:s')
52 if($days == $timestamp2){
53
54
55 ?>
56 cnt++;
57
58
59
60 var table = document.createElement("table");
61 table.setAttribute('id',"table"+cnt);
62 table.setAttribute('width','100%');
63 var tr = document.createElement('tr');
64 var td3=document.createElement('td');
65 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
66 td3.appendChild(
67 input = document.createElement("input"),
68 input.setAttribute("type","time"),
69 input.setAttribute("id","Time"+cnt),
70 input.setAttribute("max","24"),
71 input.setAttribute("min","1"),
72 input.setAttribute("required",true),
73 input.setAttribute("value",'<?php echo $date_time; ?>')
74
75 );
76 td3.appendChild(
77 button=document.createElement('input'),
78 button.setAttribute('type','button'),
79 button.setAttribute('value','[+]'),
80 button.setAttribute('id','btnAddTime'),
81 button.onclick=function(){
82
83
84
85 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01;
86
87 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
88
89 function pad(number, length) {
90
91 var str = '' + number;
92 while (str.length < length) {
93 str = '0' + str;
94 }
95
96 return str;
97
98 }
99
100 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
101
102
103 }
104 );
105 var td=document.createElement('td');
106 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
107 td.appendChild(
108 sourcecbo= document.createElement('select'),
109 sourcecbo.setAttribute('id','source'+cnt),
110<?php
111 $source=mysql_query("SELECT*FROM source");
112 while($rowsource=mysql_fetch_array($source))
113 {
114?>
115 sourcecbo.appendChild(
116 option=document.createElement('option'),
117
118 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
119 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
120
121
122 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
123
124
125 ),
126<?php
127 }
128?>
129 sourcecbo.setAttribute('id','source'+cnt)
130
131 );
132 var td1=document.createElement('td');
133 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
134 td1.appendChild(
135 measurementcbo= document.createElement('select'),
136 measurementcbo.setAttribute('id','measurement'+cnt),
137<?php
138 $measure=mysql_query("SELECT*FROM measurement");
139 while($rowmeasure=mysql_fetch_array($measure))
140 {
141?>
142 measurementcbo.appendChild(
143 option=document.createElement('option'),
144 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
145
146 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
147
148 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
149 ),
150<?php
151 }
152?>
153 measurementcbo.setAttribute('id','measurement'+cnt)
154 );
155 td1.appendChild(
156 button=document.createElement('input'),
157 button.setAttribute('type','button'),
158 button.setAttribute('value','[+]'),
159 button.setAttribute('id','btnAddTime'),
160 button.onclick=function(){
161 if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
162
163
164 }
165 );
166 var td2=document.createElement('td');
167 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
168 td2.appendChild(
169 input = document.createElement('input'),
170 input.setAttribute('type','text'),
171 input.setAttribute('id','txtData'+cnt),
172 input.setAttribute('value','<?php echo $rows['fData']; ?>')
173
174
175 );
176 var td4=document.createElement('td');
177 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
178 td4.appendChild(
179 button = document.createElement('input'),
180 button.setAttribute("type",'button'),
181 button.setAttribute('id','btnSplit'),
182 button.setAttribute('value','Split'),
183 button.onclick= function()
184 {
185
186 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 30;
187
188
189 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
190
191 function pad(number, length) {
192
193 var str = '' + number;
194 while (str.length < length) {
195 str = '0' + str;
196 }
197
198 return str;
199
200 };
201
202 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
203
204
205
206 }
207 );
208 td4.appendChild(
209 button=document.createElement('input'),
210 button.setAttribute('type','button'),
211 button.setAttribute('value','Delete'),
212 button.setAttribute('id','btnDelete'),
213 button.onclick=function(){
214 $('#table'+cnt).remove();
215 }
216 );
217
218 tr.appendChild(td3);
219 tr.appendChild(td1);
220 tr.appendChild(td);
221
222 tr.appendChild(td2);
223 tr.appendChild(td4);
224 table.appendChild(tr);
225
226 $('#TableH1').append(table);
227
228 <?php
229 }
230 }
231 ?>
232
233 if(cnt==0){
234 var table = document.createElement("table");
235 table.setAttribute('id',"table2");
236 table.setAttribute('width','100%');
237 var tr = document.createElement('tr');
238 tr.setAttribute('id','');
239 tr.setAttribute('class','');
240 var td3=document.createElement('td');
241 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
242 td3.appendChild(
243 input = document.createElement("input"),
244 input.setAttribute("type","time"),
245 input.setAttribute("id","Time1"),
246 input.setAttribute("max","24"),
247 input.setAttribute("min","1"),
248 input.setAttribute("required",true)
249 );
250 td3.appendChild(
251 button=document.createElement('input'),
252 button.setAttribute('type','button'),
253 button.setAttribute('value','[+]'),
254 button.setAttribute('id','btnAddTime'),
255 button.onclick=function(){
256 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;
257
258 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
259
260 function pad(number, length) {
261
262 var str = '' + number;
263 while (str.length < length) {
264 str = '0' + str;
265 }
266
267 return str;
268
269 }; meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
270
271
272 }
273 );
274 var td=document.createElement('td');
275 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
276 td.appendChild(
277 sourcecbo= document.createElement('select'),
278 sourcecbo.setAttribute('id','source1'),
279<?php
280 $source=mysql_query("SELECT*FROM source");
281 while($rowsource=mysql_fetch_array($source))
282 {
283?>
284 sourcecbo.appendChild(
285 option=document.createElement('option'),
286 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
287 option.setAttribute('selected',true),
288 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
289
290 ),
291<?php
292 }
293 ?>
294 sourcecbo.setAttribute('id','source1')
295
296 );
297 var td1=document.createElement('td');
298 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
299 td1.appendChild(
300 measurementcbo= document.createElement('select'),
301 measurementcbo.setAttribute('id','measurement1'),
302<?php
303 $measure=mysql_query("SELECT*FROM measurement");
304 while($rowmeasure=mysql_fetch_array($measure))
305 {
306?>
307 measurementcbo.appendChild(
308 option=document.createElement('option'),
309 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
310 option.setAttribute('selected',true),
311 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
312 ),
313<?php
314 }
315?>
316 measurementcbo.setAttribute('id','measurement1')
317 );
318 td1.appendChild(
319 button=document.createElement('input'),
320 button.setAttribute('type','button'),
321 button.setAttribute('value','[+]'),
322 button.setAttribute('id','btnAddTime'),
323 button.onclick=function(){
324 if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); meas = "hidden"; meas2 = true; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
325
326
327 }
328 );
329 var td2=document.createElement('td');
330 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
331 td2.appendChild(
332 input = document.createElement('input'),
333 input.setAttribute('type','text'),
334 input.setAttribute('id','txtData1')
335
336 );
337 var td4=document.createElement('td');
338 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
339 td4.appendChild(
340 button = document.createElement('input'),
341 button.setAttribute("type",'button'),
342 button.setAttribute('id','btnSplit'),
343 button.setAttribute('value','Split'),
344 button.onclick= function()
345 {
346 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 30;
347
348 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
349
350 function pad(number, length) {
351
352 var str = '' + number;
353 while (str.length < length) {
354 str = '0' + str;
355 }
356
357 return str;
358
359 }
360
361 meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
362
363 }
364 );
365 td4.appendChild(
366 button=document.createElement('input'),
367 button.setAttribute('type','button'),
368 button.setAttribute('value','Delete'),
369 button.setAttribute('id','btnDelete'),
370 button.onclick=function(){
371 $('#table1').remove();
372
373 }
374 );
375
376 tr.appendChild(td3);
377 tr.appendChild(td1);
378 tr.appendChild(td);
379
380 tr.appendChild(td2);
381 tr.appendChild(td4);
382 table.appendChild(tr);
383
384 $('#TableH1').append(table);
385
386 var table = document.createElement("table");
387 table.setAttribute('id',"table1");
388 table.setAttribute('width','100%');
389 var tr = document.createElement('tr');
390 tr.setAttribute('id','');
391 tr.setAttribute('class','');
392 var td3=document.createElement('td');
393 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
394 td3.appendChild(
395 input = document.createElement("input"),
396 input.setAttribute("type","time"),
397 input.setAttribute("id","Time2"),
398 input.setAttribute("max","24"),
399 input.setAttribute("min","1"),
400 input.setAttribute("required",true)
401 );
402 td3.appendChild(
403 button=document.createElement('input'),
404 button.setAttribute('type','button'),
405 button.setAttribute('value','[+]'),
406 button.setAttribute('id','btnAddTime'),
407 button.onclick=function(){
408 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;
409
410 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
411
412 function pad(number, length) {
413
414 var str = '' + number;
415 while (str.length < length) {
416 str = '0' + str;
417 }
418
419 return str;
420
421 }; meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
422
423
424 }
425 );
426 var td=document.createElement('td');
427 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
428 td.appendChild(
429 sourcecbo= document.createElement('select'),
430 sourcecbo.setAttribute('id','source2'),
431<?php
432 $source=mysql_query("SELECT*FROM source");
433 while($rowsource=mysql_fetch_array($source))
434 {
435?>
436 sourcecbo.appendChild(
437 option=document.createElement('option'),
438 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
439 option.setAttribute('selected',true),
440 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
441
442 ),
443<?php
444 }
445 ?>
446 sourcecbo.setAttribute('id','source2')
447
448 );
449 var td1=document.createElement('td');
450 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
451 td1.appendChild(
452 measurementcbo= document.createElement('select'),
453 measurementcbo.setAttribute('id','measurement2'),
454<?php
455 $measure=mysql_query("SELECT*FROM measurement");
456 while($rowmeasure=mysql_fetch_array($measure))
457 {
458?>
459 measurementcbo.appendChild(
460 option=document.createElement('option'),
461 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
462 option.setAttribute('selected',true),
463 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
464 ),
465<?php
466 }
467?>
468 measurementcbo.setAttribute('id','measurement2')
469 );
470 td1.appendChild(
471 button=document.createElement('input'),
472 button.setAttribute('type','button'),
473 button.setAttribute('value','[+]'),
474 button.setAttribute('id','btnAddTime'),
475 button.onclick=function(){
476 if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); meas = "hidden"; meas2 = true; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
477
478
479 }
480 );
481 var td2=document.createElement('td');
482 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
483 td2.appendChild(
484 input = document.createElement('input'),
485 input.setAttribute('type','text'),
486 input.setAttribute('id','txtData2')
487
488 );
489 var td4=document.createElement('td');
490 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
491 td4.appendChild(
492 button = document.createElement('input'),
493 button.setAttribute("type",'button'),
494 button.setAttribute('id','btnSplit'),
495 button.setAttribute('value','Split'),
496 button.onclick= function()
497 {
498 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 30;
499
500 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
501
502 function pad(number, length) {
503
504 var str = '' + number;
505 while (str.length < length) {
506 str = '0' + str;
507 }
508
509 return str;
510
511 }
512
513 meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
514
515 }
516 );
517 td4.appendChild(
518 button=document.createElement('input'),
519 button.setAttribute('type','button'),
520 button.setAttribute('value','Delete'),
521 button.setAttribute('id','btnDelete'),
522 button.onclick=function(){
523 $('#table1').remove();
524
525 }
526 );
527
528 tr.appendChild(td3);
529 tr.appendChild(td1);
530 tr.appendChild(td);
531
532 tr.appendChild(td2);
533 tr.appendChild(td4);
534 table.appendChild(tr);
535
536 $('#TableH1').append(table);
537
538
539 }
540 var meas;
541 var timeValue;
542 var pad;
543 if(cnt==0){ cnt=2; }
544 function split()
545 {
546
547 cnt++;
548 var table = document.createElement("table");
549 table.setAttribute('id',"table"+cnt);
550 table.setAttribute('width','100%');
551 var tr = document.createElement('tr');
552 tr.setAttribute('id','');
553 tr.setAttribute('class','');
554
555 var td3=document.createElement('td');
556 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
557 td3.setAttribute('class','first');
558
559 td3.appendChild(
560 input = document.createElement("input"),
561 input.setAttribute("type","time"),
562 input.setAttribute("id","Time"+cnt),
563 input.setAttribute("max","24"),
564 input.setAttribute("min","1"),
565 input.setAttribute("required",true),
566 input.setAttribute(meas,meas2),
567 input.setAttribute("value",timeValue)
568
569 );
570 td3.appendChild(
571 button=document.createElement('input'),
572 button.setAttribute('type','button'),
573 button.setAttribute('value','[+]'),
574 button.setAttribute('id','btnAddTime'),
575 button.setAttribute(meas,meas2),
576 button.onclick=function(){
577 if($('#Time'+cnt).val() != ""){var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
578
579 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
580
581 function pad(number, length) {
582
583 var str = '' + number;
584 while (str.length < length) {
585 str = '0' + str;
586 }
587
588 return str;
589
590 } meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
591
592
593 }
594 );
595
596 var td=document.createElement('td');
597 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
598 td.appendChild(
599 sourcecbo= document.createElement('select'),
600 sourcecbo.setAttribute('id','source'+cnt),
601<?php
602 $source=mysql_query("SELECT*FROM source");
603 while($rowsource=mysql_fetch_array($source))
604 {
605?>
606 sourcecbo.appendChild(
607 option=document.createElement('option'),
608 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
609 option.setAttribute('selected',true),
610 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
611
612 ),
613<?php
614 }
615 ?>
616 sourcecbo.setAttribute('id','source'+cnt)
617
618 );
619 var td1=document.createElement('td');
620 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
621 td1.appendChild(
622 measurementcbo= document.createElement('select'),
623 measurementcbo.setAttribute('id','measurement'+cnt),
624<?php
625 $measure=mysql_query("SELECT*FROM measurement");
626 while($rowmeasure=mysql_fetch_array($measure))
627 {
628?>
629 measurementcbo.appendChild(
630 option=document.createElement('option'),
631 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
632 option.setAttribute('selected',true),
633 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
634 ),
635<?php
636 }
637?>
638 measurementcbo.setAttribute('id','measurement'+cnt)
639 );
640 td1.appendChild(
641 button=document.createElement('input'),
642 button.setAttribute('type','button'),
643 button.setAttribute('value','[+]'),
644 button.setAttribute('id','btnAddTime'),
645 button.onclick=function(){
646
647 if($('#Time'+cnt).val() != "")
648 {
649 timeValue = $('#Time'+cnt).val();
650 meas = "hidden";
651 meas2 = true;
652 getTableId = '#table'+cnt;
653 split1();
654 }
655 else
656 {
657 alert("please enter value for time to add measurement");
658 }
659
660
661 }
662 );
663
664 var td2=document.createElement('td');
665 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
666 td2.appendChild(
667 input = document.createElement('input'),
668 input.setAttribute('type','text'),
669 input.setAttribute('id','txtData'+cnt)
670
671 );
672 var td4=document.createElement('td');
673 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
674 td4.appendChild(
675 button = document.createElement('input'),
676 button.setAttribute("type",'button'),
677 button.setAttribute('id','btnSplit'),
678 button.setAttribute('value','Split'),
679 button.onclick=function(){
680 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
681
682 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
683
684 function pad(number, length) {
685
686 var str = '' + number;
687 while (str.length < length) {
688 str = '0' + str;
689 }
690
691 return str;
692
693 }
694
695 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split(); }else{ alert("please enter value for time to add measurement"); }
696 }
697 );
698 td4.appendChild(
699 button=document.createElement('input'),
700 button.setAttribute('type','button'),
701 button.setAttribute('value','Delete'),
702 button.setAttribute('id','btnDelete'),
703 button.onclick=function(){
704 $('#table'+cnt).remove();
705 cnt--;
706 }
707 );
708
709 tr.appendChild(td3);
710 tr.appendChild(td1);
711 tr.appendChild(td);
712
713 tr.appendChild(td2);
714 tr.appendChild(td4);
715 table.appendChild(tr);
716
717 $(table).insertAfter($(getTableId));
718
719
720
721 }
722 function split1()
723 {
724
725 cnt++;
726 var table = document.createElement("table");
727 table.setAttribute('id',"table"+cnt);
728 table.setAttribute('width','100%');
729 var tr = document.createElement('tr');
730 tr.setAttribute('id','');
731 tr.setAttribute('class','');
732
733 var td3=document.createElement('td');
734 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
735 td3.setAttribute('class','first');
736 td3.appendChild(
737 input = document.createElement("input"),
738 input.setAttribute("type","time"),
739 input.setAttribute("id","Time"+cnt),
740 input.setAttribute("max","24"),
741 input.setAttribute("min","1"),
742 input.setAttribute("required",true),
743 input.setAttribute(meas,meas2),
744 input.setAttribute("value",timeValue)
745 );
746 td3.appendChild(
747 button=document.createElement('input'),
748 button.setAttribute('type','button'),
749 button.setAttribute('value','[+]'),
750 button.setAttribute('id','btnAddTime'),
751 button.setAttribute(meas,meas2),
752 button.onclick=function(){
753 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
754
755 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
756
757 function pad(number, length) {
758
759 var str = '' + number;
760 while (str.length < length) {
761 str = '0' + str;
762 }
763
764 return str;
765
766 } meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
767
768
769 }
770 );
771
772 var td=document.createElement('td');
773 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
774 td.appendChild(
775 sourcecbo= document.createElement('select'),
776 sourcecbo.setAttribute('id','source'+cnt),
777<?php
778 $source=mysql_query("SELECT*FROM source");
779 while($rowsource=mysql_fetch_array($source))
780 {
781?>
782 sourcecbo.appendChild(
783 option=document.createElement('option'),
784 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
785 option.setAttribute('selected',true),
786 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
787
788 ),
789<?php
790 }
791 ?>
792 sourcecbo.setAttribute('id','source'+cnt)
793
794 );
795 var td1=document.createElement('td');
796 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
797
798 td1.appendChild(
799 measurementcbo= document.createElement('select'),
800 measurementcbo.setAttribute('id','measurement'+cnt),
801<?php
802 $measure=mysql_query("SELECT*FROM measurement");
803 while($rowmeasure=mysql_fetch_array($measure))
804 {
805?>
806 measurementcbo.appendChild(
807 option=document.createElement('option'),
808 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
809 option.setAttribute('selected',true),
810 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
811 ),
812<?php
813 }
814?>
815 measurementcbo.setAttribute('id','measurement'+cnt)
816 );
817 td1.appendChild(
818 button=document.createElement('input'),
819 button.setAttribute('type','button'),
820 button.setAttribute('value','[+]'),
821 button.setAttribute('id','btnAddTime'),
822 button.onclick=function(){
823
824 if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
825
826
827 }
828 );
829
830 var td2=document.createElement('td');
831 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
832 td2.appendChild(
833 input = document.createElement('input'),
834 input.setAttribute('type','text'),
835 input.setAttribute('id','txtData'+cnt)
836
837 );
838 var td4=document.createElement('td');
839 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
840 td4.appendChild(
841 button = document.createElement('input'),
842 button.setAttribute("type",'button'),
843 button.setAttribute('id','btnSplit'),
844 button.setAttribute('value','Split'),
845 button.onclick=function(){
846 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
847
848 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
849
850 function pad(number, length) {
851
852 var str = '' + number;
853 while (str.length < length) {
854 str = '0' + str;
855 }
856
857 return str;
858
859 }
860
861 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split(); }else{ alert("please enter value for time to add measurement"); }
862 }
863 );
864 td4.appendChild(
865 button=document.createElement('input'),
866 button.setAttribute('type','button'),
867 button.setAttribute('value','Delete'),
868 button.setAttribute('id','btnDelete'),
869 button.onclick=function(){
870 $('#table'+cnt).remove();
871 cnt--;
872 });
873
874 tr.appendChild(td3);
875 tr.appendChild(td1);
876 tr.appendChild(td);
877
878 tr.appendChild(td2);
879 tr.appendChild(td4);
880 table.appendChild(tr);
881
882 $(table).insertAfter($(getTableId));
883 }
884
885 });
886 </script>
Note: See TracBrowser for help on using the repository browser.