- Timestamp:
- 02/13/14 18:17:34 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/Module/control.php
r17543 r17555 2 2 'use strict'; 3 3 var ctr; 4 var testdata = "old data";5 var pastdata = false;6 4 var transPrevNight = 1; 7 5 … … 25 23 // CREATE ELEMENT 26 24 var newtr = document.createElement("tr"); 27 newtr.setAttribute("class","tr"); 25 newtr.setAttribute("class","tr"); 26 newtr.setAttribute("width", "100%"); 28 27 var newtd_c1 = document.createElement("td"); 29 newtd_c1.setAttribute("width","147");28 //newtd_c1.setAttribute("width","120"); 30 29 newtd_c1.setAttribute("align","center"); 31 30 newtd_c1.appendChild( … … 37 36 ); 38 37 var newtd_c2 = document.createElement("td"); 39 newtd_c2.setAttribute("width"," 138");38 newtd_c2.setAttribute("width","20%"); 40 39 newtd_c2.setAttribute("align","center"); 41 40 newtd_c2.appendChild( 42 select = document.createElement("select"), 41 select = document.createElement("select"), 42 select.setAttribute("style", "width=100px"), 43 43 select.setAttribute("class","measure"), 44 44 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio … … 57 57 }) // End of retrieving 58 58 ); 59 newtd_c2.setAttribute("width","115"); 60 newtd_c2.setAttribute("align","center"); 59 newtd_c2.setAttribute("align","center"); 61 60 newtd_c2.appendChild( 62 61 input_data = document.createElement("input"), … … 68 67 ); 69 68 var newtd_c3 = document.createElement("td"); 70 newtd_c3.setAttribute("width"," 98");69 newtd_c3.setAttribute("width","20%"); 71 70 newtd_c3.setAttribute("align","center"); 72 71 newtd_c3.appendChild( 73 selection = document.createElement("select"), 72 selection = document.createElement("select"), 73 selection.setAttribute("style", "width=100px"), 74 74 selection.setAttribute("class","source"), 75 75 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio … … 78 78 success:function(data) 79 79 { 80 var obj = $.parseJSON(data); 80 var obj = $.parseJSON(data); 81 selection.appendChild( 82 option = document.createElement('option'), 83 option.setAttribute('value', 0), 84 option.appendChild(document.createTextNode("---")) 85 ); 81 86 $.each(obj,function(){ 82 87 selection.appendChild( … … 90 95 ); 91 96 var newtd_c4 = document.createElement("td"); 92 newtd_c4.setAttribute("width"," 119");97 newtd_c4.setAttribute("width","50%"); 93 98 newtd_c4.setAttribute("align","center"); 94 99 newtd_c4.appendChild( … … 96 101 input_data.setAttribute("type","text"), 97 102 input_data.setAttribute("class","selected"), 98 input_data.setAttribute("size"," 12"),103 input_data.setAttribute("size","50"), 99 104 input_data.setAttribute("placeholder","Value") 100 105 ); 101 106 var newtd_c5 = document.createElement("td"); 102 newtd_c5.setAttribute("width","115");103 newtd_c5.setAttribute("align","center");107 newtd_c5.setAttribute("align","center"); 108 newtd_c5.setAttribute("width", "10%"); 104 109 newtd_c5.appendChild( 105 110 input_data = document.createElement("input"), … … 129 134 $day =date("Y-m-d"); 130 135 } 131 $prev = mysql_query("SELECT date(fStart) AS PrevDate FROM schedule WHERE (date(fStart) < '2014-01-26') ORDER BY date(fStart) DESC LIMIT 1"); 136 if(isset($_GET['prev'])) 137 { 138 $prevday = $_GET['prev']; 139 } 140 else 141 { 142 $prevday = 'false'; 143 } 144 145 /*$prev = mysql_query("SELECT date(fStart) AS PrevDate FROM schedule WHERE (date(fStart) < '2014-01-26') ORDER BY date(fStart) DESC LIMIT 1"); 132 146 $prevnight = mysql_fetch_array($prev); 133 147 if(mysql_num_rows($prevnight) > 0) { … … 137 151 } 138 152 $prevday = date('Y-m-d', strtotime($day .' -1 day')); 139 $prev_time = array(); 153 $prev_time = array();*/ 140 154 ?> 141 155 142 156 function addRowCloneNew(nextrow){ 143 var targetView = document.getElementById("Data"); 157 var targetView = document.getElementById("Data"); 158 targetView.setAttribute("width", "100%"); 144 159 // CREATE ELEMENT 145 160 // COUNT LIST … … 155 170 newdiv.setAttribute("id","list_"+newlist); 156 171 newdiv.setAttribute("class","datalisting"); 157 newdiv.setAttribute("style","margin:5px 0;"); 172 newdiv.setAttribute("style","margin:5px 0;"); 173 newdiv.setAttribute("width", "100%"); 158 174 var newtable = document.createElement("table"); 159 175 newtable.setAttribute("class","dataTable"); … … 166 182 newInnertable.setAttribute("width","100%"); 167 183 newInnertable.setAttribute("border","1"); 168 169 184 newInnertable.setAttribute("cellspacing","0"); 170 185 newInnertable.setAttribute("cellpadding","0"); 171 186 172 187 var newtr = document.createElement("tr"); 173 newtr.setAttribute('class','tr'); 188 newtr.setAttribute('class','tr'); 189 newtr.setAttribute("width", "100%"); 174 190 var newtd_c1 = document.createElement("td"); 175 newtd_c1.setAttribute("width"," 200");191 newtd_c1.setAttribute("width","15%"); 176 192 newtd_c1.setAttribute("align","center"); 177 193 newtd_c1.setAttribute("valign", "top"); … … 179 195 input_data = document.createElement("input"), 180 196 input_data.setAttribute("type","time"), 181 input_data.setAttribute("class","time"), 182 input_data.setAttribute("size","10"), 197 input_data.setAttribute("class","time"), 198 //input_data.setAttribute("width", "50%"), 199 input_data.setAttribute("size","5"), 183 200 input_data.setAttribute("autofocus","true") 184 201 ); … … 193 210 var newtd_c2 = document.createElement("td"); 194 211 195 newtd_c2.setAttribute("width"," 138");212 newtd_c2.setAttribute("width","20%"); 196 213 newtd_c2.setAttribute("align","center"); 197 214 newtd_c2.appendChild( … … 215 232 216 233 ); 217 newtd_c2.setAttribute("width","115"); 218 newtd_c2.setAttribute("align","center"); 219 newtd_c2.appendChild( 234 newtd_c2.appendChild( 220 235 input_data = document.createElement("input"), 221 236 input_data.setAttribute("type","button"), … … 226 241 }); 227 242 var newtd_c3 = document.createElement("td"); 228 newtd_c3.setAttribute("width"," 98");243 newtd_c3.setAttribute("width","20%"); 229 244 newtd_c3.setAttribute("align","center"); 230 245 newtd_c3.appendChild( … … 236 251 success:function(data) 237 252 { 238 var obj = $.parseJSON(data); 239 $.each(obj,function(){ 240 selection.appendChild( 253 var obj = $.parseJSON(data); 254 selection.appendChild( 255 option = document.createElement('option'), 256 option.setAttribute('value', 0), 257 option.appendChild(document.createTextNode("---")) 258 ); 259 $.each(obj,function(){ 260 selection.appendChild( 241 261 option=document.createElement('option'), 242 262 option.setAttribute('value',this['fSourceKEY']), … … 248 268 ); 249 269 var newtd_c4 = document.createElement("td"); 250 newtd_c4.setAttribute("width"," 119");270 newtd_c4.setAttribute("width","50%"); 251 271 newtd_c4.setAttribute("align","center"); 252 272 newtd_c4.appendChild( 253 273 input_data = document.createElement("input"), 254 274 input_data.setAttribute("type","text"), 255 input_data.setAttribute("class","selected"), 256 input_data.setAttribute("size","12"), 275 input_data.setAttribute("class","selected"), 276 //input_data.setAttribute("width", "100%"), 277 input_data.setAttribute("size","50"), 257 278 input_data.setAttribute("placeholder","Value") 258 279 ); 259 var newtd_c5 = document.createElement("td"); 260 newtd_c5.setAttribute("width","115"); 261 newtd_c5.setAttribute("align","center"); 262 newtd_c5.setAttribute("width","115"); 263 newtd_c5.setAttribute("align","center"); 264 newtd_c5.appendChild( 265 input_data = document.createElement("input"), 280 var newtd_c5 = document.createElement("td"); 281 newtd_c5.setAttribute("width", "10%"); 282 newtd_c5.setAttribute("align","center"); 283 newtd_c5.appendChild( 284 input_data = document.createElement("input"), 266 285 input_data.setAttribute("type","button"), 267 286 input_data.setAttribute("value","Delete"), … … 277 296 newtd_c6.appendChild(newInnertable); 278 297 279 280 newtd_c7.setAttribute("width","115");298 var newtd_c7 = document.createElement("td"); 299 newtd_c7.setAttribute("width", "10%"); 281 300 newtd_c7.setAttribute("align","center"); 282 301 newtd_c7.setAttribute("valign", "top"); … … 306 325 <?php 307 326 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 308 $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$day' ");327 $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC"); 309 328 $cnt3=0; 310 329 $cnt2=0; … … 314 333 $cntrow = 0; 315 334 $pastdate = 'false'; 316 $pasttime = ' false';335 $pasttime = 'true'; 317 336 date_default_timezone_set("UTC"); 318 //$data = array();319 //$counter=0;320 337 while($times = mysql_fetch_array($observationsTime)) 321 338 { … … 323 340 $testdate = date('Y-m-d H:i:s', $times['fStart']); 324 341 $testing = date('Y-m-d H:i', $timestamp); 342 $curSchedId = $times['fScheduleID']; 325 343 $actualtime = date('Y-m-d H:i:s', $timestamp); 326 if(strtotime(date('Y-m-d', $timestamp)) == strtotime(date('Y-m-d', time()))) { 327 $fetch_next = mysql_query("SELECT * FROM schedule WHERE (fStart > '$testing' AND date(fStart) = '$day') ORDER BY fStart LIMIT 1"); 328 $next_data = mysql_fetch_array($fetch_next); 329 if (mysql_num_rows($fetch_next) > 0) { 330 $next_date = strtotime($next_data['fStart']); 331 $test = date('Y-m-d H:i', $next_date); 332 if(strtotime(date('Y-m-d H:i', $next_date)) > strtotime(date('Y-m-d H:i', time()))) { 333 $pasttime = 'true'; 334 } else { 335 $pasttime = 'false'; 336 } 337 } else { 338 $pasttime = 'true'; 339 } 340 } 341 else { 342 $pasttime = 'false'; 343 } 344 $timestamp2 = date('Y-m-d',$timestamp); 345 $date_time = date('H:i',$timestamp); 346 $prev_time[$cnt3]= $date_time; 347 348 344 if($prevday == 'false') { 349 345 if(strtotime(date('Y-m-d H:i', $timestamp)) < strtotime(date('Y-m-d H:i', time()))) { 350 346 $pastdate = 'true'; … … 353 349 $pastdate = 'false'; 354 350 } 351 } 352 353 if(strtotime(date('Y-m-d', $timestamp)) == strtotime(date('Y-m-d', time()))) { 354 $fetch_next = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE (fStart > '$testing' AND date(fStart) = '$day') ORDER BY fScheduleID ASC LIMIT 1"); 355 $next_data = mysql_fetch_array($fetch_next); 356 if ($pasttime == 'true') { 357 if (mysql_num_rows($fetch_next) > 0) { 358 $next_date = strtotime($next_data['fStart']); 359 $test = date('H:i', $next_date); 360 if(strtotime(date('H:i', $next_date)) < strtotime(date('H:i', time()))) { 361 $pasttime = 'true'; 362 } else { 363 $pasttime = 'false'; 364 } 365 } else { 366 $pasttime = 'false'; 367 } 368 } 369 if((strtotime(date('Hi', $timestamp)) >= strtotime('0000')) && (strtotime(date('Hi', $timestamp)) <= strtotime('0800'))) { 370 $pastdate = 'false'; 371 } 372 } 373 else { 374 $pasttime = 'false'; 375 } 376 377 $date_time = date('H:i', $timestamp); 378 $prev_time[$cnt3]= $date_time; 379 355 380 ?> 381 356 382 $('#save').attr('value','UPDATE'); 357 383 var targetView = document.getElementById("Data"); … … 389 415 newInnertable.setAttribute("cellspacing","0"); 390 416 newInnertable.setAttribute("cellpadding","0"); 391 417 392 418 var newtd_c1 = document.createElement("td"); 393 newtd_c1.setAttribute("width"," 200");419 newtd_c1.setAttribute("width","15%"); 394 420 newtd_c1.setAttribute("align","center"); 395 421 newtd_c1.setAttribute("valign", "top"); … … 399 425 input_data.setAttribute("type","time"), 400 426 input_data.setAttribute("class","time"), 401 input_data.setAttribute("size"," 10"),427 input_data.setAttribute("size","5"), 402 428 input_data.setAttribute("value","<?php echo $date_time; ?>"), 403 429 input_data.setAttribute("autofocus","true"), … … 409 435 input_data.setAttribute("type","time"), 410 436 input_data.setAttribute("class","time"), 411 input_data.setAttribute("size"," 10"),437 input_data.setAttribute("size","5"), 412 438 input_data.setAttribute("value","<?php echo $date_time; ?>"), 413 439 input_data.setAttribute("autofocus","true") … … 418 444 input_data = document.createElement("input"), 419 445 input_data.setAttribute("type","button"), 420 input_data.setAttribute("value","+"), 446 input_data.setAttribute("value","+"), 447 input_data.setAttribute("disabled", "disabled"), 421 448 input_data.onclick = function(){ 422 449 addRowCloneNew("list_<?php echo $cnt; ?>"); … … 433 460 } 434 461 ); 435 <?php } else { ?>462 <?php } else { ?> 436 463 newtd_c1.appendChild( 437 464 input_data = document.createElement("input"), … … 442 469 } 443 470 ); 444 <?php } 471 <?php }} 445 472 $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'"); 446 473 … … 455 482 <?php if ($pastdate == 'true') { ?> 456 483 var newtd_c2 = document.createElement("td"); 457 newtd_c2.setAttribute("width"," 138");484 newtd_c2.setAttribute("width","20%"); 458 485 newtd_c2.setAttribute("align","center"); 459 486 <?php 460 487 $cur_measurement = $rows[fMeasurementTypeKey]; 461 $selectm = mysql_query("SELECT fMeasurementFROM measurement WHERE fMeasurementKey = '$cur_measurement'");488 $selectm = mysql_query("SELECT * FROM measurement WHERE fMeasurementKey = '$cur_measurement'"); 462 489 $rowmeasure = mysql_fetch_array($selectm); 463 490 ?> 464 491 newtd_c2.appendChild( 465 selection = document.createElement("input"), 466 selection.setAttribute("value", "<?php echo $rowmeasure['fMeasurement']; ?>"), 467 selection.setAttribute("type","text"), 468 selection.setAttribute("class","selected"), 469 selection.setAttribute("size", "12"), 470 selection.setAttribute("placeholder", "Value"), 471 selection.setAttribute("disabled", "disabled") 472 ); 473 newtd_c2.setAttribute("width","115"); 474 newtd_c2.setAttribute("align","center"); 492 selection = document.createElement("select"), 493 selection.appendChild( 494 option = document.createElement("option"), 495 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")), 496 option.setAttribute("value", "<?php echo $rowmeasure['fMeasurementKey']; ?>"), 497 option.setAttribute('selected', true) 498 ), 499 selection.setAttribute('id', 'measure'), 500 selection.setAttribute('class','measure'), 501 selection.setAttribute('disabled', 'disabled'), 502 selection.setAttribute("style", "width:100px") 503 ); 475 504 newtd_c2.appendChild( 476 505 input_data = document.createElement("input"), … … 484 513 485 514 var newtd_c3 = document.createElement("td"); 486 newtd_c3.setAttribute("width"," 98");515 newtd_c3.setAttribute("width","20%"); 487 516 newtd_c3.setAttribute("align","center"); 488 517 <?php 489 518 $cur_source = $rows['fSourceKey']; 490 $select = mysql_query("SELECT fSourceName FROM source WHERE fSourceKey = '$cur_source'"); 491 $rowsource = mysql_fetch_array($select); ?> 519 $select = mysql_query("SELECT * FROM source WHERE fSourceKey = '$cur_source'"); 520 if(mysql_num_rows($select)<1) { 521 $sourcename = '---'; 522 $sourcekey = 0; 523 } 524 else { 525 $rowsource = mysql_fetch_array($select); 526 $sourcename = $rowsource['fSourceName']; 527 $sourcekey = $rowsource['fSourceKey']; 528 }?> 492 529 newtd_c3.appendChild( 493 selection = document.createElement("input"), 494 selection.setAttribute("value", "<?php echo $rowsource['fSourceName']; ?>"), 495 selection.setAttribute("type","text"), 496 selection.setAttribute("class","selected"), 497 selection.setAttribute("size", "12"), 498 selection.setAttribute("placeholder", "Value"), 499 selection.setAttribute("disabled", "disabled") 530 selection = document.createElement("select"), 531 selection.appendChild( 532 option = document.createElement("option"), 533 option.appendChild(document.createTextNode("<?php echo $sourcename; ?>")), 534 option.setAttribute("value", "<?php echo $sourcekey; ?>"), 535 option.setAttribute('selected', true) 536 ), 537 selection.setAttribute('id', 'source'), 538 selection.setAttribute('class','source'), 539 selection.setAttribute('disabled', 'disabled'), 540 selection.setAttribute("style", "width:120px") 541 500 542 ); 501 543 502 544 var newtd_c4 = document.createElement("td"); 503 newtd_c4.setAttribute("width"," 119");545 newtd_c4.setAttribute("width","50%"); 504 546 newtd_c4.setAttribute("align","center"); 505 547 newtd_c4.appendChild( … … 507 549 input_data.setAttribute("type","text"), 508 550 input_data.setAttribute("class","selected"), 509 input_data.setAttribute("size"," 12"),551 input_data.setAttribute("size","50"), 510 552 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 511 553 input_data.setAttribute("placeholder","Value"), 512 input_data.setAttribute("disabled", "dis baled")554 input_data.setAttribute("disabled", "disabled") 513 555 ); 514 556 515 557 var newtd_c5 = document.createElement("td"); 516 newtd_c5.setAttribute("width","115"); 517 newtd_c5.setAttribute("align","center"); 518 newtd_c5.setAttribute("width","115"); 558 newtd_c5.setAttribute("width", "10%"); 519 559 newtd_c5.setAttribute("align","center"); 520 560 newtd_c5.appendChild( … … 529 569 <?php } else { ?> 530 570 var newtd_c2 = document.createElement("td"); 531 newtd_c2.setAttribute("width"," 138");571 newtd_c2.setAttribute("width","20%"); 532 572 newtd_c2.setAttribute("align","center"); 533 573 newtd_c2.appendChild( … … 548 588 ?> 549 589 selection.setAttribute('id','measure'), 550 selection.setAttribute('class','measure') 590 selection.setAttribute('class','measure'), 591 selection.setAttribute("style", "width=100px") 551 592 ); 552 newtd_c2.setAttribute("width","115");553 newtd_c2.setAttribute("align","center");554 593 newtd_c2.appendChild( 555 594 input_data = document.createElement("input"), … … 562 601 563 602 var newtd_c3 = document.createElement("td"); 564 newtd_c3.setAttribute("width"," 98");603 newtd_c3.setAttribute("width","20%"); 565 604 newtd_c3.setAttribute("align","center"); 566 605 newtd_c3.appendChild( 567 606 selection = document.createElement("select"), 607 selection.appendChild( 608 option = document.createElement("option"), 609 option.setAttribute('value', 0), 610 <?php 611 if($rows['fSourceKey'] == 0) { echo "option.setAttribute('selected', true),"; }?> 612 option.appendChild(document.createTextNode("---"))), 568 613 <?php 569 614 $select = mysql_query("SELECT * FROM source"); 615 570 616 while($rowsource = mysql_fetch_array($select)) 571 617 { … … 574 620 option = document.createElement("option"), 575 621 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 576 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 622 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ 623 echo "option.setAttribute('selected',true),"; 624 }?> 577 625 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 578 626 ), … … 581 629 ?> 582 630 selection.setAttribute('id','source'), // End of retrieving 583 selection.setAttribute('class','source') // End of retrieving 631 selection.setAttribute('class','source'), 632 selection.setAttribute("style", "width=100px")// End of retrieving 584 633 ); 585 634 586 635 var newtd_c4 = document.createElement("td"); 587 newtd_c4.setAttribute("width"," 119");636 newtd_c4.setAttribute("width","50%"); 588 637 newtd_c4.setAttribute("align","center"); 589 638 newtd_c4.appendChild( … … 591 640 input_data.setAttribute("type","text"), 592 641 input_data.setAttribute("class","selected"), 593 input_data.setAttribute("size"," 12"),642 input_data.setAttribute("size","50"), 594 643 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 595 644 input_data.setAttribute("placeholder","Value") … … 597 646 598 647 var newtd_c5 = document.createElement("td"); 599 newtd_c5.setAttribute("width","115"); 600 newtd_c5.setAttribute("align","center"); 601 newtd_c5.setAttribute("width","115"); 602 newtd_c5.setAttribute("align","center"); 603 newtd_c5.appendChild( 648 newtd_c5.setAttribute("width", "10%"); 649 newtd_c5.setAttribute("align","center"); 650 newtd_c5.appendChild( 604 651 input_data = document.createElement("input"), 605 652 input_data.setAttribute("type","button"), … … 625 672 newtd_c6.appendChild(newInnertable); 626 673 627 628 newtd_c7.setAttribute("width","115");629 674 var newtd_c7 = document.createElement("td"); 675 newtd_c7.setAttribute("width", "10%"); 676 newtd_c7.setAttribute("align","center"); 630 677 newtd_c7.setAttribute("valign", "top"); 631 678 <?php if ($pastdate == 'true') { ?> … … 658 705 }else{ 659 706 targetView.appendChild(newdiv<?php echo $cnt;?>); 660 //$(targetView).after(newtr<?php echo $cnt; ?>);661 707 } 662 708 <?php … … 664 710 if(mysql_num_rows($fetch)<1) 665 711 { 712 if(strtotime(Date('Y-m-d', strtotime($day))) >= strtotime(Date('Y-m-d'))) { 666 713 ?> 667 714 $('#save').attr('value','SAVE'); 668 addRowCloneNew(); 715 addRowCloneNew(); 716 $('#LoadPrev').removeAttr("disabled"); 717 $('#save').removeAttr("disabled"); 669 718 <?php 719 } 720 else {?> 721 $('#LoadPrev').attr('disabled', 'disabled'); 722 $('#save').attr('disabled', 'disabled'); 723 <?php } 670 724 } 671 672 725 ?> 673 674 726 } 675 676 $('#LoadPrev').click(function() {677 if(transPrevNight == 1) {678 $('#Scheduling').load('Module/Scheduling.php?days=<?php echo $prevday;?>');679 transPrevNight = 0;680 }681 });682 683 727 </script> 684 728
Note:
See TracChangeset
for help on using the changeset viewer.