source: schedule/function/SplitDelete.php@ 16912

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