source: schedule/function/SplitDelete.php@ 16894

Last change on this file since 16894 was 16894, checked in by tanio, 11 years ago
File size: 35.7 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") 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 //$time_new = $date_time->format('H:i:s')
30 if($days == $timestamp2)
31 {
32 ?>
33 cnt++;
34
35<<<<<<< .mine
36$('#save').hide();
37 $('#update').show();
38
39 var div= document.createElement("div");
40 div.setAttribute('id','TableHolder');
41=======
42 $('#save').hide();
43 $('#update').show();
44 var div= document.createElement("div");
45 div.setAttribute('id','TableHolder');
46>>>>>>> .r16893
47 var table = document.createElement("table");
48 table.setAttribute('id',"table"+cnt);
49 table.setAttribute('width','100%');
50 var tr = document.createElement('tr');
51 var td3=document.createElement('td');
52 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
53 td3.appendChild(
54 input = document.createElement("input"),
55 input.setAttribute("type","time"),
56 input.setAttribute("id","Time"),
57 input.setAttribute("max","24"),
58 input.setAttribute("min","1"),
59 input.setAttribute("required",true),
60 input.setAttribute("value",'<?php echo $date_time; ?>')
61
62 );
63 td3.appendChild(
64 button=document.createElement('input'),
65 button.setAttribute('type','button'),
66 button.setAttribute('value','[+]'),
67 button.setAttribute('id','btnAddTime'),
68 button.setAttribute('name','#table'+cnt),
69 button.onclick=function(){
70
71
72<<<<<<< .mine
73
74 if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 01;
75=======
76 if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 01;
77>>>>>>> .r16893
78
79 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
80
81 function pad(number, length) {
82
83 var str = '' + number;
84 while (str.length < length) {
85 str = '0' + str;
86 }
87
88 return str;
89
90 }
91 var s = 0; var get;
92 var nn;
93 nn = $(this).attr('name');
94 $("table").each(function() {
95 if($(this).attr("name")==nn){
96
97 get = "#"+$(this).attr("id");
98 //get = $(this).attr("name");
99 s =1;
100 }else{
101 if(s==0){
102 get = '#table'+cnt;
103 }
104 }
105 });
106
107
108
109 getTableId =get;
110
111<<<<<<< .mine
112
113 name="name"; value=""; meas = "name"; meas2 = "time"; //getTableId = $(this).attr('name');
114 split1(); }else{ alert("please enter value for time to add measurement"); }
115
116=======
117
118 name="name"; value=""; meas = "name"; meas2 = "time"; // getTableId = $(this).attr('name');
119 split1(); }else{ alert("please enter value for time to add measurement"); }
120
121>>>>>>> .r16893
122
123 }
124 );
125 var td=document.createElement('td');
126 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
127 td.appendChild(
128 sourcecbo= document.createElement('select'),
129 sourcecbo.setAttribute('id','source'),
130<?php
131 $source=mysql_query("SELECT*FROM source");
132 while($rowsource=mysql_fetch_array($source))
133 {
134?>
135 sourcecbo.appendChild(
136 option=document.createElement('option'),
137
138 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
139 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
140
141
142 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
143
144
145 ),
146<?php
147 }
148?>
149 sourcecbo.setAttribute('id','source')
150
151 );
152 var td1=document.createElement('td');
153 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
154 td1.appendChild(
155 measurementcbo= document.createElement('select'),
156 measurementcbo.setAttribute('id','measurement'),
157<?php
158 $measure=mysql_query("SELECT*FROM measurement");
159 while($rowmeasure=mysql_fetch_array($measure))
160 {
161?>
162 measurementcbo.appendChild(
163 option=document.createElement('option'),
164 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
165
166 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
167
168 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
169 ),
170<?php
171 }
172?>
173 measurementcbo.setAttribute('id','measurement')
174 );
175 td1.appendChild(
176 button=document.createElement('input'),
177 button.setAttribute('type','button'),
178 button.setAttribute('value','[+]'),
179 button.setAttribute('id','btnAddTime'),
180 button.setAttribute('name','#table'+cnt),
181 button.onclick=function(){
182 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"); }
183
184
185 }
186 );
187 var td2=document.createElement('td');
188 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
189 td2.appendChild(
190 input = document.createElement('input'),
191 input.setAttribute('type','text'),
192 input.setAttribute('id','txtData'),
193 input.setAttribute('value','<?php echo $rows['fData']; ?>')
194
195
196 );
197 var td4=document.createElement('td');
198 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
199 td4.appendChild(
200<<<<<<< .mine
201=======
202 button = document.createElement('input'),
203 button.setAttribute("type",'button'),
204 button.setAttribute('id','btnSplit'),
205 button.setAttribute('value','Split'),
206 button.setAttribute('name','#table'+cnt),
207 button.onclick= function()
208 {
209
210 if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 30;
211
212
213 var limit = 60;
214 var adds =0;
215 adds = (Number(splitting[1]) + Number(add));
216 if(adds >= limit){
217 adds = Number(adds) - Number(limit);
218 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
219
220 }else{
221
222 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
223 }
224 function pad(number, length) {
225
226 var str = '' + number;
227 while (str.length < length) {
228 str = '0' + str;
229 }
230
231 return str;
232
233 };
234
235
236 name="name"; value="";
237 meas = "name"; meas2 = "time";
238 getTableId = $(this).attr('name');
239 split1();
240 }else{ alert("please enter value for time to add measurement"); }
241
242
243
244 }
245 );
246 td4.appendChild(
247>>>>>>> .r16893
248 button=document.createElement('input'),
249 button.setAttribute('type','button'),
250 button.setAttribute('value','Delete'),
251 button.setAttribute('id','btnDelete'),
252 button.onclick=function(){
253 $('#table'+cnt).remove();
254 }
255 );
256
257 tr.appendChild(td3);
258 tr.appendChild(td1);
259 tr.appendChild(td);
260
261 tr.appendChild(td2);
262 tr.appendChild(td4);
263 table.appendChild(tr);
264 div.appendChild(table);
265 $('#TableH1').append(div);
266
267 <?php
268 }
269 }
270 ?>
271
272 if(cnt==0)
273 {
274 $('#save').show();
275 $('#update').hide();
276 var div= document.createElement("div");
277 div.setAttribute('id','TableHolder');
278 var table = document.createElement("table");
279 table.setAttribute('id',"table2");
280 table.setAttribute('width','100%');
281 var tr = document.createElement('tr');
282 tr.setAttribute('id','');
283 tr.setAttribute('class','');
284 var td3=document.createElement('td');
285 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
286 td3.appendChild(
287 input = document.createElement("input"),
288 input.setAttribute("type","time"),
289 input.setAttribute("id","Time"),
290 input.setAttribute("max","24"),
291 input.setAttribute("min","1"),
292 input.setAttribute("required",true)
293 );
294 td3.appendChild(
295 button=document.createElement('input'),
296 button.setAttribute('type','button'),
297 button.setAttribute('value','[+]'),
298 button.setAttribute('id','btnAddTime'),
299 button.setAttribute('name','#table2'),
300 button.onclick=function(){
301<<<<<<< .mine
302var aa;
303 $('div#TableHolder #table2 #Time').each(function(){
304 aa = $(this).val();
305 });
306 if(aa != ""){ var splitting =aa.split(':'); var add = 01;
307=======
308 var aa;
309 $('div#TableHolder #table2 #Time').each(function(){
310 aa = $(this).val();
311 });
312 if(aa != ""){ var splitting =aa.split(':'); var add = 01;
313>>>>>>> .r16893
314
315 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
316
317 function pad(number, length) {
318
319 var str = '' + number;
320 while (str.length < length) {
321 str = '0' + str;
322 }
323
324 return str;
325
326 };
327
328 var s = 0; var get;
329
330$("table").each(function() {
331 if($(this).attr("name")=='#table2'){
332 get = "#"+$(this).attr("id");
333
334 s =1;
335 }else{
336 if(s==0){
337 get = '#table'+cnt;
338 }
339 }
340 });
341getTableId =get;
342name="name"; value="";
343 name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
344 split2(); }else{ alert("please enter value for time to add measurement"); }
345
346
347 }
348 );
349 var td=document.createElement('td');
350 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
351 td.appendChild(
352 sourcecbo= document.createElement('select'),
353 sourcecbo.setAttribute('id','source'),
354<?php
355 $source=mysql_query("SELECT*FROM source");
356 while($rowsource=mysql_fetch_array($source))
357 {
358?>
359 sourcecbo.appendChild(
360 option=document.createElement('option'),
361 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
362 option.setAttribute('selected',true),
363 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
364
365 ),
366<?php
367 }
368 ?>
369 sourcecbo.setAttribute('id','source')
370
371 );
372 var td1=document.createElement('td');
373 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
374 td1.appendChild(
375 measurementcbo= document.createElement('select'),
376 measurementcbo.setAttribute('id','measurement'),
377<?php
378 $measure=mysql_query("SELECT*FROM measurement");
379 while($rowmeasure=mysql_fetch_array($measure))
380 {
381?>
382 measurementcbo.appendChild(
383 option=document.createElement('option'),
384 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
385 option.setAttribute('selected',true),
386 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
387 ),
388<?php
389 }
390?>
391 measurementcbo.setAttribute('id','measurement')
392 );
393 td1.appendChild(
394 button=document.createElement('input'),
395 button.setAttribute('type','button'),
396 button.setAttribute('value','[+]'),
397 button.setAttribute('id','btnAddTime'),
398 button.setAttribute('name','#table2'),
399 button.onclick=function(){
400 var aa;
401 $('div#TableHolder #table2 #Time').each(function(){
402 aa = $(this).val();
403 });
404 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"); }
405
406
407 }
408 );
409 var td2=document.createElement('td');
410 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
411 td2.appendChild(
412 input = document.createElement('input'),
413 input.setAttribute('type','text'),
414 input.setAttribute('id','txtData')
415
416 );
417 var td4=document.createElement('td');
418 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
419
420 td4.appendChild(
421<<<<<<< .mine
422=======
423 button = document.createElement('input'),
424 button.setAttribute("type",'button'),
425 button.setAttribute('id','btnSplit'),
426 button.setAttribute('value','Split'),
427 button.setAttribute('name','#table2'),
428 button.onclick= function()
429 {
430 var aa;
431 $('div#TableHolder #table2 #Time').each(function(){
432 aa = $(this).val();
433 });
434 if(aa != ""){ var splitting = aa.split(':'); var add = 30; var limit = 60;
435 var adds =0;
436 adds = (Number(splitting[1]) + Number(add));
437 if(adds >= limit){
438 adds = Number(adds) - Number(limit);
439 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
440
441 }else{
442
443 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
444 }
445 function pad(number, length) {
446
447 var str = '' + number;
448 while (str.length < length) {
449 str = '0' + str;
450 }
451
452 return str;
453
454 }
455
456 meas = "name"; meas2 = "time"; getTableId = $(this).attr('name');
457 split2(); }else{ alert("please enter value for time to add measurement"); }
458
459 }
460 );
461 td4.appendChild(
462>>>>>>> .r16893
463 button=document.createElement('input'),
464 button.setAttribute('type','button'),
465 button.setAttribute('value','Delete'),
466 button.setAttribute('id','btnDelete'),
467 button.onclick=function(){
468 $('#table2').remove();
469
470 }
471 );
472
473 tr.appendChild(td3);
474 tr.appendChild(td1);
475 tr.appendChild(td);
476
477 tr.appendChild(td2);
478 tr.appendChild(td4);
479 table.appendChild(tr);
480<<<<<<< .mine
481 div.appendChild(table);
482 $('#TableH1').append(div);
483
484 var div= document.createElement("div");
485 div.setAttribute('id','TableHolder');
486=======
487 div.appendChild(table);
488 $('#TableH1').append(div);
489
490 var div= document.createElement("div");
491 div.setAttribute('id','TableHolder');
492>>>>>>> .r16893
493 var table = document.createElement("table");
494 table.setAttribute('id',"table1");
495 table.setAttribute('width','100%');
496 var tr = document.createElement('tr');
497 tr.setAttribute('id','');
498 tr.setAttribute('class','');
499 var td3=document.createElement('td');
500 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
501 td3.appendChild(
502 input = document.createElement("input"),
503 input.setAttribute("type","time"),
504 input.setAttribute("id","Time"),
505 input.setAttribute("max","24"),
506 input.setAttribute("min","1"),
507 input.setAttribute("required",true)
508 );
509 td3.appendChild(
510 button=document.createElement('input'),
511 button.setAttribute('type','button'),
512 button.setAttribute('value','[+]'),
513 button.setAttribute('id','btnAddTime'),
514 button.setAttribute('name','#table1'),
515 button.onclick=function(){
516<<<<<<< .mine
517 var aa;
518 $('div#TableHolder #table2 #Time').each(function(){
519 aa = $(this).val();
520 });
521 if(aa !='') { var splitting =aa.split(':'); var add = 01;
522=======
523 var aa;
524 $('div#TableHolder #table1 #Time').each(function(){
525 aa = $(this).val();
526 });
527
528 if(aa != ""){ var splitting = aa.split(':'); var add = 01;
529>>>>>>> .r16893
530
531 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
532
533 function pad(number, length) {
534
535 var str = '' + number;
536 while (str.length < length) {
537 str = '0' + str;
538 }
539
540 return str;
541
542<<<<<<< .mine
543 };
544
545
546 var s = 0; var get;
547
548$("table").each(function() {
549 if($(this).attr("name")=='#table2'){
550 get = "#"+$(this).attr("id");
551
552 s =1;
553 }else{
554 if(s==0){
555 get = '#table'+cnt;
556 }
557 }
558 });
559getTableId =get;
560name="name"; value="";
561
562name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
563split2(); }else{ alert("please enter value for time to add measurement"); }
564=======
565 };
566
567
568 var s = 0; var get;
569
570$("table").each(function() {
571 if($(this).attr("name")=='#table1'){
572 get = "#"+$(this).attr("id");
573
574 s =1;
575 }else{
576 if(s==0){
577 get = '#table'+cnt;
578 }
579 }
580 });
581getTableId =get;
582>>>>>>> .r16893
583
584
585 name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
586 split2(); }else{ alert("please enter value for time to add measurement"); }
587
588
589 }
590 );
591 var td=document.createElement('td');
592 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
593 td.appendChild(
594 sourcecbo= document.createElement('select'),
595 sourcecbo.setAttribute('id','source'),
596<?php
597 $source=mysql_query("SELECT*FROM source");
598 while($rowsource=mysql_fetch_array($source))
599 {
600?>
601 sourcecbo.appendChild(
602 option=document.createElement('option'),
603 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
604 option.setAttribute('selected',true),
605 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
606
607 ),
608<?php
609 }
610 ?>
611 sourcecbo.setAttribute('id','source')
612
613 );
614 var td1=document.createElement('td');
615 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
616 td1.appendChild(
617 measurementcbo= document.createElement('select'),
618 measurementcbo.setAttribute('id','measurement'),
619<?php
620 $measure=mysql_query("SELECT*FROM measurement");
621 while($rowmeasure=mysql_fetch_array($measure))
622 {
623?>
624 measurementcbo.appendChild(
625 option=document.createElement('option'),
626 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
627 option.setAttribute('selected',true),
628 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
629 ),
630<?php
631 }
632?>
633 measurementcbo.setAttribute('id','measurement')
634 );
635 td1.appendChild(
636 button=document.createElement('input'),
637 button.setAttribute('type','button'),
638 button.setAttribute('value','[+]'),
639 button.setAttribute('id','btnAddTime'),
640 button.setAttribute('name','#table1'),
641 button.onclick=function(){
642<<<<<<< .mine
643 $('div#TableHolder #table1 #Time').each(function(){
644 aa = $(this).val();
645 });
646
647 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"); }
648=======
649 var aa;
650 $('div#TableHolder #table1 #Time').each(function(){
651 aa = $(this).val();
652 });
653
654 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"); }
655>>>>>>> .r16893
656
657
658 }
659 );
660 var td2=document.createElement('td');
661 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
662 td2.appendChild(
663 input = document.createElement('input'),
664 input.setAttribute('type','text'),
665 input.setAttribute('id','txtData')
666
667 );
668 var td4=document.createElement('td');
669 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
670
671 td4.appendChild(
672<<<<<<< .mine
673=======
674 button = document.createElement('input'),
675 button.setAttribute("type",'button'),
676 button.setAttribute('id','btnSplit'),
677 button.setAttribute('value','Split'),
678 button.setAttribute('name','#table1'),
679 button.onclick= function()
680 {
681 var aa;
682 $('div#TableHolder #table1 #Time').each(function(){
683 aa = $(this).val();
684 });
685 if(aa != ""){ var splitting = aa.split(':'); var add = 30;
686
687 var limit = 60;
688 var adds =0;
689 adds = (Number(splitting[1]) + Number(add));
690 if(adds >= limit){
691 adds = Number(adds) - Number(limit);
692 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
693
694 }else{
695
696 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
697 }
698 function pad(number, length) {
699
700 var str = '' + number;
701 while (str.length < length) {
702 str = '0' + str;
703 }
704
705 return str;
706
707 }
708
709
710 name="name"; value="";
711
712meas = "class"; meas2 = "time";
713
714 getTableId = $(this).attr('name');
715 split2(); }else{ alert("please enter value for time to add measurement"); }
716
717 }
718 );
719 td4.appendChild(
720>>>>>>> .r16893
721 button=document.createElement('input'),
722 button.setAttribute('type','button'),
723 button.setAttribute('value','Delete'),
724 button.setAttribute('id','btnDelete'),
725 button.onclick=function(){
726 $('#table1').remove();
727
728 }
729 );
730
731 tr.appendChild(td3);
732 tr.appendChild(td1);
733 tr.appendChild(td);
734
735 tr.appendChild(td2);
736 tr.appendChild(td4);
737 table.appendChild(tr);
738 div.appendChild(table);
739 $('#TableH1').append(div);
740
741
742 }
743 var meas;
744<<<<<<< .mine
745 var timeValue;
746 var pad;
747 if(cnt==0){ cnt=2; }
748 function split2()
749=======
750 var timeValue;
751 var pad;
752 if(cnt==0){ cnt=2; }
753 function split2()
754>>>>>>> .r16893
755 {
756
757 cnt++;
758 var div= document.createElement("div");
759 div.setAttribute('id','TableHolder');
760 var table = document.createElement("table");
761 table.setAttribute('id',"table"+cnt);
762 table.setAttribute('width','100%');
763 table.setAttribute(name,value);
764 var tr = document.createElement('tr');
765 tr.setAttribute('id','');
766 tr.setAttribute('class','');
767
768 var td3=document.createElement('td');
769 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
770 td3.setAttribute('class','first');
771
772 td3.appendChild(
773 input = document.createElement("input"),
774 input.setAttribute("type","time"),
775 input.setAttribute("id","Time"),
776 input.setAttribute("max","24"),
777 input.setAttribute("min","1"),
778 input.setAttribute("required",true),
779 input.setAttribute(meas,meas2),
780 input.setAttribute("value",timeValue)
781
782
783 );
784 td3.appendChild(
785 button=document.createElement('input'),
786 button.setAttribute('type','button'),
787 button.setAttribute('value','[+]'),
788 button.setAttribute('id','btnAddTime'),
789 button.setAttribute(meas,meas2),
790 button.setAttribute('name','#table'+cnt),
791
792 button.onclick=function(){
793 var aa;
794 $('div#TableHolder #table'+cnt+' #Time').each(function(){
795 aa = $(this).val();
796 });
797 if(aa != ""){var splitting = aa.split(':'); var add = 01;
798
799
800 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
801
802 function pad(number, length) {
803
804 var str = '' + number;
805 while (str.length < length) {
806 str = '0' + str;
807 }
808
809 return str;
810
811 }
812
813<<<<<<< .mine
814 var s = 0; var get;
815 var nn;
816 nn = $(this).attr('name');
817 $("table").each(function() {
818 if($(this).attr("name")==nn){
819
820 get = "#"+$(this).attr("id");
821 //get = $(this).attr("name");
822 s =1;
823 }else{
824 if(s==0){
825 get = '#table'+cnt;
826 }
827 }
828 });
829
830name="name"; value=$(this).attr('name');
831meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
832
833=======
834 var s = 0; var get;
835 var nn;
836 nn = $(this).attr('name');
837 $("table").each(function() {
838 if($(this).attr("name")==nn){
839
840 get = "#"+$(this).attr("id");
841 //get = $(this).attr("name");
842 s =1;
843 }else{
844 if(s==0){
845 get = '#table'+cnt;
846 }
847 }
848 });
849
850name="name"; value=$(this).attr('name');
851 meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
852
853>>>>>>> .r16893
854
855 }
856 );
857
858 var td=document.createElement('td');
859 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
860 td.appendChild(
861 sourcecbo= document.createElement('select'),
862 sourcecbo.setAttribute('id','source'),
863<?php
864 $source=mysql_query("SELECT*FROM source");
865 while($rowsource=mysql_fetch_array($source))
866 {
867?>
868 sourcecbo.appendChild(
869 option=document.createElement('option'),
870 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
871 option.setAttribute('selected',true),
872 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
873
874 ),
875<?php
876 }
877 ?>
878 sourcecbo.setAttribute('id','source')
879
880 );
881<<<<<<< .mine
882var td1=document.createElement('td');
883td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
884td1.appendChild(
885measurementcbo= document.createElement('select'),
886measurementcbo.setAttribute('id','measurement'),
887=======
888 var td1=document.createElement('td');
889 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
890 td1.appendChild(
891 measurementcbo= document.createElement('select'),
892 measurementcbo.setAttribute('id','measurement'),
893>>>>>>> .r16893
894<?php
895 $measure=mysql_query("SELECT*FROM measurement");
896 while($rowmeasure=mysql_fetch_array($measure))
897 {
898?>
899measurementcbo.appendChild(
900option=document.createElement('option'),
901option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
902option.setAttribute('selected',true),
903option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
904 ),
905<?php
906 }
907?>
908 measurementcbo.setAttribute('id','measurement')
909 );
910 td1.appendChild(
911 button=document.createElement('input'),
912 button.setAttribute('type','button'),
913 button.setAttribute('value','[+]'),
914 button.setAttribute('id','btnAddTime'),
915 button.setAttribute('name','#table'+cnt),
916 button.onclick=function(){
917 var aa;
918 $('div#TableHolder #table'+cnt+' #Time').each(function(){
919 aa = $(this).val();
920 });
921 if(aa != "")
922 {
923 name = "name";
924 value = "#table"+cnt;
925 timeValue = aa;
926 meas = "hidden";
927 meas2 = true;
928 getTableId = $(this).attr('name');
929 split1();
930 }
931 else
932 {
933 alert("please enter value for time to add measurement");
934 }
935
936
937 }
938 );
939
940 var td2=document.createElement('td');
941 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
942 td2.appendChild(
943 input = document.createElement('input'),
944 input.setAttribute('type','text'),
945 input.setAttribute('id','txtData')
946
947 );
948 var td4=document.createElement('td');
949 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
950
951 td4.appendChild(
952<<<<<<< .mine
953=======
954 button = document.createElement('input'),
955 button.setAttribute("type",'button'),
956 button.setAttribute('id','btnSplit'),
957 button.setAttribute('value','Split'),
958 button.setAttribute('name','#table'+cnt),
959 button.onclick=function(){
960 var aa;
961 $('div#TableHolder #table'+cnt+' #Time').each(function(){
962 aa = $(this).val();
963 });
964 if(aa != ""){ var splitting = aa.split(':'); var add = 30;
965
966 var limit = 60;
967 var adds =0;
968 adds = (Number(splitting[1]) + Number(add));
969 if(adds >= limit){
970 adds = Number(adds) - Number(limit);
971 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
972
973 }else{
974
975 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
976 }
977 function pad(number, length) {
978
979 var str = '' + number;
980 while (str.length < length) {
981 str = '0' + str;
982 }
983
984 return str;
985
986 }
987
988 meas = "class"; meas2 = "time";
989
990
991 getTableId = $(this).attr('name');
992 split2(); }else{ alert("please enter value for time to add measurement"); }
993 }
994 );
995 td4.appendChild(
996>>>>>>> .r16893
997 button=document.createElement('input'),
998 button.setAttribute('type','button'),
999 button.setAttribute('value','Delete'),
1000 button.setAttribute('id','btnDelete'),
1001 button.onclick=function(){
1002 $('#table'+cnt).remove();
1003 cnt--;
1004 }
1005 );
1006
1007 tr.appendChild(td3);
1008 tr.appendChild(td1);
1009 tr.appendChild(td);
1010
1011 tr.appendChild(td2);
1012 tr.appendChild(td4);
1013 table.appendChild(tr);
1014 div.appendChild(table);
1015 $(div).insertAfter($(getTableId));
1016
1017
1018
1019 }
1020 function split1()
1021 {
1022
1023 cnt++;
1024 var div= document.createElement("div");
1025 div.setAttribute('id','TableHolder');
1026 var table = document.createElement("table");
1027 table.setAttribute('id',"table"+cnt);
1028 table.setAttribute('width','100%');
1029 table.setAttribute(name,value);
1030 var tr = document.createElement('tr');
1031 tr.setAttribute('id','');
1032 tr.setAttribute('class','');
1033
1034 var td3=document.createElement('td');
1035 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
1036 td3.setAttribute('class','first');
1037 td3.appendChild(
1038 input = document.createElement("input"),
1039 input.setAttribute("type","time"),
1040 input.setAttribute("id","Time"),
1041 input.setAttribute("max","24"),
1042 input.setAttribute("min","1"),
1043 input.setAttribute("required",true),
1044 input.setAttribute(meas,meas2),
1045 input.setAttribute("value",timeValue)
1046 );
1047 td3.appendChild(
1048 button=document.createElement('input'),
1049 button.setAttribute('type','button'),
1050 button.setAttribute('value','[+]'),
1051 button.setAttribute('id','btnAddTime'),
1052 button.setAttribute(meas,meas2),
1053 button.setAttribute('name','#table'+cnt),
1054
1055 button.onclick=function(){
1056 var aa;
1057 $('div#TableHolder #table'+cnt+' #Time').each(function(){
1058 aa = $(this).val();
1059 });
1060 if(aa != ""){ var splitting = aa.split(':'); var add = 01;
1061
1062 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
1063
1064 function pad(number, length) {
1065
1066 var str = '' + number;
1067 while (str.length < length) {
1068 str = '0' + str;
1069 }
1070
1071 return str;
1072
1073 }
1074 var s = 0; var get;
1075 var nn;
1076 nn = $(this).attr('name');
1077 $("table").each(function() {
1078 if($(this).attr("name")==nn){
1079
1080 get = "#"+$(this).attr("id");
1081 //get = $(this).attr("name");
1082 s =1;
1083 }else{
1084 if(s==0){
1085 get = '#table'+cnt;
1086 }
1087 }
1088 });
1089
1090 name="name"; value=""; meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
1091
1092
1093 }
1094 );
1095
1096 var td=document.createElement('td');
1097 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
1098 td.appendChild(
1099 sourcecbo= document.createElement('select'),
1100 sourcecbo.setAttribute('id','source'),
1101<?php
1102 $source=mysql_query("SELECT*FROM source");
1103 while($rowsource=mysql_fetch_array($source))
1104 {
1105?>
1106 sourcecbo.appendChild(
1107 option=document.createElement('option'),
1108 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
1109 option.setAttribute('selected',true),
1110 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
1111
1112 ),
1113<?php
1114 }
1115 ?>
1116 sourcecbo.setAttribute('id','source')
1117
1118 );
1119 var td1=document.createElement('td');
1120 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
1121
1122 td1.appendChild(
1123 measurementcbo= document.createElement('select'),
1124 measurementcbo.setAttribute('id','measurement'),
1125<?php
1126 $measure=mysql_query("SELECT*FROM measurement");
1127 while($rowmeasure=mysql_fetch_array($measure))
1128 {
1129?>
1130 measurementcbo.appendChild(
1131 option=document.createElement('option'),
1132 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
1133 option.setAttribute('selected',true),
1134 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
1135 ),
1136<?php
1137 }
1138?>
1139 measurementcbo.setAttribute('id','measurement')
1140 );
1141 td1.appendChild(
1142 button=document.createElement('input'),
1143 button.setAttribute('type','button'),
1144 button.setAttribute('value','[+]'),
1145 button.setAttribute('id','btnAddTime'),
1146 button.setAttribute('name','#table'+cnt),
1147 button.onclick=function(){
1148<<<<<<< .mine
1149
1150 if($('#Time').val() != ""){ timeValue = $('#Time').val();
1151 name = "name"; value = $(this).attr('name'); meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split1(); }else{ alert("please enter value for time to add measurement"); }
1152=======
1153 var aa;
1154 $('div#TableHolder #table'+cnt+' #Time').each(function(){
1155 aa = $(this).val();
1156 });
1157 if(aa != ""){ timeValue = aa;
1158 name = "name"; value = $(this).attr('name'); meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split1(); }else{ alert("please enter value for time to add measurement"); }
1159>>>>>>> .r16893
1160
1161
1162 }
1163 );
1164
1165 var td2=document.createElement('td');
1166 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
1167 td2.appendChild(
1168 input = document.createElement('input'),
1169 input.setAttribute('type','text'),
1170 input.setAttribute('id','txtData')
1171
1172 );
1173 var td4=document.createElement('td');
1174 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
1175
1176 td4.appendChild(
1177<<<<<<< .mine
1178=======
1179 button = document.createElement('input'),
1180 button.setAttribute("type",'button'),
1181 button.setAttribute('id','btnSplit'),
1182 button.setAttribute('value','Split'),
1183 button.setAttribute('name','#table'+cnt),
1184 button.onclick=function(){
1185 var aa;
1186 $('div#TableHolder #table'+cnt+' #Time').each(function(){
1187 aa = $(this).val();
1188 });
1189 if(aa != ""){ var splitting = aa.split(':'); var add = 30;
1190
1191 var limit = 60;
1192 var adds =0;
1193 adds = (Number(splitting[1]) + Number(add));
1194 if(adds >= limit){
1195 adds = Number(adds) - Number(limit);
1196 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
1197
1198 }else{
1199
1200 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
1201 }
1202 function pad(number, length) {
1203
1204 var str = '' + number;
1205 while (str.length < length) {
1206 str = '0' + str;
1207 }
1208
1209 return str;
1210
1211 }
1212
1213 meas = "name"; meas2 = "time"; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
1214 }
1215 );
1216 td4.appendChild(
1217>>>>>>> .r16893
1218 button=document.createElement('input'),
1219 button.setAttribute('type','button'),
1220 button.setAttribute('value','Delete'),
1221 button.setAttribute('id','btnDelete'),
1222 button.onclick=function(){
1223 $('#table'+cnt).remove();
1224 cnt--;
1225 });
1226
1227 tr.appendChild(td3);
1228 tr.appendChild(td1);
1229 tr.appendChild(td);
1230
1231 tr.appendChild(td2);
1232 tr.appendChild(td4);
1233 table.appendChild(tr);
1234 div.appendChild(table);
1235 $(div).insertAfter($(getTableId));
1236 }
1237
1238 });
1239 </script>
Note: See TracBrowser for help on using the repository browser.