Changeset 17516
- Timestamp:
- 01/17/14 12:28:45 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/Module/control.php
r17511 r17516 1 1 <script> 2 2 'use strict'; 3 var ctr; 3 var ctr; 4 var testdata = "old data"; 5 var pastdata = false; 4 6 5 7 function clearNode(node){ … … 138 140 <?php 139 141 $cnt=0; 140 $day=0; 142 $pastdate = 'false'; 143 $day=0; 141 144 if(isset($_GET['days'])) 142 145 { … … 315 318 316 319 function addRowClone(nextrow){ 317 318 320 <?php 321 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 319 322 $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$day'"); 320 323 $cnt3=0; … … 324 327 $cnt = 0; 325 328 $cntrow = 0; 329 $pastdate = 'false' ; 330 $pasttime = 'false'; 326 331 //$data = array(); 327 332 //$counter=0; … … 329 334 { 330 335 $timestamp=strtotime($times['fStart']); 336 $curdate = strtotime(date('Y-m-d')); 331 337 $actualtime = date('Y-m-d H:i:s', $timestamp); 332 338 $timestamp2 = date('Y-m-d',$timestamp); 333 339 $date_time = date('H:i',$timestamp); 334 $prev_time[$cnt3]= $date_time; 335 ?> 336 $('#save').attr('value','UPDATE'); 337 var targetView = document.getElementById("Data"); 340 $prev_time[$cnt3]= $date_time; 341 if(strtotime($timestamp2) < strtotime(date('Y-m-d'))) { 342 $pastdate = 'true'; 343 } 344 else if(strtotime($timestamp2) == strtotime(date('Y-m-d'))) { 345 if(strtotime($date_time) < strtotime(date('H:i'))) { 346 $pastdate = 'true'; 347 } 348 } else { 349 $pastdate = 'false'; 350 } 351 ?> 352 $('#save').attr('value','UPDATE'); 353 var targetView = document.getElementById("Data"); 338 354 // CREATE ELEMENT 339 355 // COUNT LIST … … 344 360 var cctr=$('.dataTable tr').length; 345 361 ctr=cctr+1; 362 var select; 346 363 var input_data; 347 var select;348 364 var option; 349 365 var selection; … … 374 390 newtd_c1.setAttribute("align","center"); 375 391 newtd_c1.setAttribute("valign", "top"); 376 newtd_c1.appendChild( 377 input_data = document.createElement("input"), 378 input_data.setAttribute("type","time"), 392 <?php if ($pastdate == 'true') { ?> 393 newtd_c1.appendChild( 394 input_data = document.createElement("input"), 395 input_data.setAttribute("type","time"), 379 396 input_data.setAttribute("class","time"), 380 397 input_data.setAttribute("size","10"), 381 398 input_data.setAttribute("value","<?php echo $date_time; ?>"), 382 input_data.setAttribute("autofocus","true") 383 ); 384 newtd_c1.appendChild( 385 input_data = document.createElement("input"), 386 input_data.setAttribute("type","button"), 387 input_data.setAttribute("value","+"), 388 input_data.onclick = function(){ 399 input_data.setAttribute("autofocus","true"), 400 input_data.setAttribute("disabled") 401 ); 402 newtd_c1.appendChild( 403 input_data = document.createElement("input"), 404 input_data.setAttribute("type","button"), 405 input_data.setAttribute("value","+"), 406 input_data.setAttribute("disabled"), 407 input_data.onclick = function(){ 389 408 addRowCloneNew("list_<?php echo $cnt; ?>"); 390 409 } 410 ); 411 412 <?php } else { ?> 413 newtd_c1.appendChild( 414 input_data = document.createElement("input"), 415 input_data.setAttribute("type","time"), 416 input_data.setAttribute("class","time"), 417 input_data.setAttribute("size","10"), 418 input_data.setAttribute("value","<?php echo $date_time; ?>"), 419 input_data.setAttribute("autofocus","true") 420 ); 421 newtd_c1.appendChild( 422 input_data = document.createElement("input"), 423 input_data.setAttribute("type","button"), 424 input_data.setAttribute("value","+"), 425 input_data.onclick = function(){ 426 addRowCloneNew("list_<?php echo $cnt; ?>"); 427 } 428 ); 429 <?php } 430 $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'"); 431 432 while($rows = mysql_fetch_array($observations)) 433 { 434 $cntrow++; 435 ?> 436 437 var newtr<?php echo $cntrow; ?> = document.createElement("tr"); 438 newtr<?php echo $cntrow; ?>.setAttribute('class','tr'); 439 440 <?php if ($pastdate == 'true') { ?> 441 var newtd_c2 = document.createElement("td"); 442 newtd_c2.setAttribute("width","138"); 443 newtd_c2.setAttribute("align","center"); 444 newtd_c2.appendChild( 445 selection = document.createElement("select"), 446 <?php 447 $selectm = mysql_query("SELECT * FROM measurement"); 448 while($rowmeasure = mysql_fetch_array($selectm)) 449 { 450 ?> 451 selection.appendChild( 452 option = document.createElement("option"), 453 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 454 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 455 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 456 ), 457 <?php 458 } 459 ?> 460 selection.setAttribute('id','measure'), 461 selection.setAttribute('class','measure'), 462 selection.setAttribute("disabled") 463 ); 464 newtd_c2.setAttribute("width","115"); 465 newtd_c2.setAttribute("align","center"); 466 newtd_c2.appendChild( 467 input_data = document.createElement("input"), 468 input_data.setAttribute("type","button"), 469 input_data.setAttribute("value","+"), 470 input_data.setAttribute("disabled"), 471 input_data.onclick = function(){ 472 return addRow(newtr<?php echo $cntrow; ?>); 473 ctr++; 474 }); 475 476 var newtd_c3 = document.createElement("td"); 477 newtd_c3.setAttribute("width","98"); 478 newtd_c3.setAttribute("align","center"); 479 newtd_c3.appendChild( 480 selection = document.createElement("select"), 481 <?php 482 $select = mysql_query("SELECT * FROM source"); 483 while($rowsource = mysql_fetch_array($select)) 484 { 485 ?> 486 selection.appendChild( 487 option = document.createElement("option"), 488 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 489 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 490 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 491 ), 492 <?php 493 } 494 ?> 495 selection.setAttribute('id','source'), // End of retrieving 496 selection.setAttribute('class','source'), 497 selection.setAttribute("disabled") 498 // End of retrieving 391 499 ); 392 393 <?php 394 $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'"); 395 396 while($rows = mysql_fetch_array($observations)) 397 { 398 $cntrow++; 399 ?> 400 401 var newtr<?php echo $cntrow; ?> = document.createElement("tr"); 402 newtr<?php echo $cntrow; ?>.setAttribute('class','tr'); 403 404 var newtd_c2 = document.createElement("td"); 500 501 var newtd_c4 = document.createElement("td"); 502 newtd_c4.setAttribute("width","119"); 503 newtd_c4.setAttribute("align","center"); 504 newtd_c4.appendChild( 505 input_data = document.createElement("input"), 506 input_data.setAttribute("type","text"), 507 input_data.setAttribute("class","selected"), 508 input_data.setAttribute("size","12"), 509 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 510 input_data.setAttribute("placeholder","Value"), 511 input_data.setAttribute("disabled") 512 ); 513 514 var newtd_c5 = document.createElement("td"); 515 newtd_c5.setAttribute("width","115"); 516 newtd_c5.setAttribute("align","center"); 517 newtd_c5.setAttribute("width","115"); 518 newtd_c5.setAttribute("align","center"); 519 newtd_c5.appendChild( 520 input_data = document.createElement("input"), 521 input_data.setAttribute("type","button"), 522 input_data.setAttribute("value","Delete"), 523 input_data.setAttribute("disabled"), 524 input_data.onclick = function(){ 525 return clearNode(newtr<?php echo $cntrow; ?>); 526 } 527 ); 528 <?php } else { ?> 529 var newtd_c2 = document.createElement("td"); 405 530 newtd_c2.setAttribute("width","138"); 406 newtd_c2.setAttribute("align","center"); 407 newtd_c2.appendChild( 408 selection = document.createElement("select"), 409 <?php 410 $selectm = mysql_query("SELECT * FROM measurement"); 411 while($rowmeasure = mysql_fetch_array($selectm)) 412 { 413 ?> 414 selection.appendChild( 415 option = document.createElement("option"), 416 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 417 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 418 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 419 ), 420 <?php 421 } 422 ?> 423 424 425 selection.setAttribute('id','measure'), 426 selection.setAttribute('class','measure') 427 ); 428 newtd_c2.setAttribute("width","115"); 429 newtd_c2.setAttribute("align","center"); 430 newtd_c2.appendChild( 531 newtd_c2.setAttribute("align","center"); 532 newtd_c2.appendChild( 533 selection = document.createElement("select"), 534 <?php 535 $selectm = mysql_query("SELECT * FROM measurement"); 536 while($rowmeasure = mysql_fetch_array($selectm)) 537 { 538 ?> 539 selection.appendChild( 540 option = document.createElement("option"), 541 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 542 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 543 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 544 ), 545 <?php 546 } 547 ?> 548 selection.setAttribute('id','measure'), 549 selection.setAttribute('class','measure') 550 ); 551 newtd_c2.setAttribute("width","115"); 552 newtd_c2.setAttribute("align","center"); 553 newtd_c2.appendChild( 431 554 input_data = document.createElement("input"), 432 555 input_data.setAttribute("type","button"), … … 436 559 ctr++; 437 560 }); 438 var newtd_c3 = document.createElement("td"); 561 562 var newtd_c3 = document.createElement("td"); 439 563 newtd_c3.setAttribute("width","98"); 440 564 newtd_c3.setAttribute("align","center"); 441 565 newtd_c3.appendChild( 442 selection = document.createElement("select"), 443 <?php 444 $select = mysql_query("SELECT * FROM source"); 445 while($rowsource = mysql_fetch_array($select)) 446 { 447 ?> 448 selection.appendChild( 449 option = document.createElement("option"), 450 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 451 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 452 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 453 ), 454 <?php 455 } 456 ?> 457 458 selection.setAttribute('id','source'), // End of retrieving 459 selection.setAttribute('class','source') // End of retrieving 566 selection = document.createElement("select"), 567 <?php 568 $select = mysql_query("SELECT * FROM source"); 569 while($rowsource = mysql_fetch_array($select)) 570 { 571 ?> 572 selection.appendChild( 573 option = document.createElement("option"), 574 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 575 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 576 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 577 ), 578 <?php 579 } 580 ?> 581 selection.setAttribute('id','source'), // End of retrieving 582 selection.setAttribute('class','source') // End of retrieving 460 583 ); 461 var newtd_c4 = document.createElement("td"); 584 585 var newtd_c4 = document.createElement("td"); 462 586 newtd_c4.setAttribute("width","119"); 463 587 newtd_c4.setAttribute("align","center"); 464 588 newtd_c4.appendChild( 465 589 input_data = document.createElement("input"), 466 590 input_data.setAttribute("type","text"), … … 470 594 input_data.setAttribute("placeholder","Value") 471 595 ); 472 var newtd_c5 = document.createElement("td"); 596 597 var newtd_c5 = document.createElement("td"); 473 598 newtd_c5.setAttribute("width","115"); 474 599 newtd_c5.setAttribute("align","center"); … … 482 607 483 608 } 484 ); 609 ); 610 <?php } ?> 485 611 newtr<?php echo $cntrow; ?>.appendChild(newtd_c2); 486 612 newtr<?php echo $cntrow; ?>.appendChild(newtd_c3); … … 496 622 497 623 var newtd_c6 = document.createElement("td"); 498 624 newtd_c6.appendChild(newInnertable); 499 625 500 626 var newtd_c7 = document.createElement("td"); … … 502 628 newtd_c7.setAttribute("align","center"); 503 629 newtd_c7.setAttribute("valign", "top"); 504 newtd_c7.appendChild( 630 <?php if ($pastdate == 'true') { ?> 631 newtd_c7.appendChild( 632 input_data = document.createElement("input"), 633 input_data.setAttribute("type","button"), 634 input_data.setAttribute("value","Delete Main"), 635 input_data.setAttribute("disabled"), 636 input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); } 637 ); 638 <?php } else { ?> 639 newtd_c7.appendChild( 505 640 input_data = document.createElement("input"), 506 641 input_data.setAttribute("type","button"), 507 642 input_data.setAttribute("value","Delete Main"), 508 643 input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); } 509 ); 644 ); 645 <?php } ?> 510 646 511 647 var newOutertr = document.createElement("tr"); … … 537 673 538 674 } 539 </script> 675 676 $('#LoadPrev').click(function() { 677 678 }); 679 </script> 540 680
Note:
See TracChangeset
for help on using the changeset viewer.