source: schedule/function/SplitDelete.php@ 16926

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