Changeset 17451 for schedule/Module/control.php
- Timestamp:
- 01/04/14 07:57:59 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/Module/control.php
r17439 r17451 305 305 306 306 function addRowClone(nextrow){ 307 <?php 308 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 309 $cnt3=0; 310 $cnt2=0; 311 $cnt4 = 0; 312 $cnt5 = 0; 313 //$data = array(); 314 //$counter=0; 315 $prevtimestamp = 0; 316 317 while($rows = mysql_fetch_array($fetch)) 307 <?php 308 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fStart ASC, fMeasurementID ASC") or die(mysql_error()); 309 $observationsCount = mysql_query("SELECT COUNT(DISTINCT fStart) FROM schedule WHERE date(fStart) = '$days'") 310 $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$days'") 311 312 $cnt3=0; 313 $cnt2=0; 314 $cnt4 = 0; 315 $cnt5 = 0; 316 //$data = array(); 317 //$counter=0; 318 $prevtimestamp = 0; 319 320 while($times = mysql_fetch_array($observationsTime)) 318 321 { 319 $scheduleId = $rows['fScheduleID']; 320 $timestamp=strtotime($rows['fStart']); 322 $timestamp=strtotime($times['fStart']); 321 323 $timestamp2 = date('Y-m-d',$timestamp); 322 $date_time = date('H:i:s',$timestamp); 324 $date_time = date('H:i:s',$timestamp); 323 325 $prev_time[$cnt3]= $date_time; 324 ?>325 $('#save').attr('value','UPDATE');326 $('#save').attr('value','UPDATE'); 327 ?> 326 328 var targetView = document.getElementById("Data"); 327 329 // CREATE ELEMENT … … 329 331 var list = $(".datalisting").length; 330 332 var newlist = list+1; 331 333 332 334 var cctr=$('.dataTable tr').length; 333 334 335 ctr=cctr+1; 336 335 337 var newdiv = document.createElement("div"); 336 338 newdiv.setAttribute("id","list_"+newlist); … … 344 346 newtable.setAttribute("cellspacing","0"); 345 347 newtable.setAttribute("cellpadding","0"); 346 347 348 348 349 var newInnertable = document.createElement("table"); … … 351 352 newInnertable.setAttribute("border","1"); 352 353 353 354 354 newInnertable.setAttribute("cellspacing","0"); 355 newInnertable.setAttribute("cellpadding","0"); 355 356 356 357 var newtd_c1 = document.createElement("td"); … … 371 372 input_data.onclick = function(){ 372 373 addRowClone1("list_<?php echo $cnt+1; ?>"); 374 } 375 ); 376 <?php 377 378 $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$timestamp'") 379 380 while($rows = mysql_fetch_array($observations)) 381 { 382 $scheduleId = $rows['fScheduleID']; 383 ?> 384 var newtr<?php echo $cnt; ?> = document.createElement("tr"); 385 newtr<?php echo $cnt; ?>.setAttribute('class','tr'); 386 387 var newtd_c2 = document.createElement("td"); 388 newtd_c2.setAttribute("width","138"); 389 newtd_c2.setAttribute("align","center"); 390 newtd_c2.appendChild( 391 selection = document.createElement("select"), 392 <?php 393 $selectm = mysql_query("SELECT * FROM measurement"); 394 while($rowmeasure = mysql_fetch_array($selectm)) 395 { 396 ?> 397 selection.appendChild( 398 option = document.createElement("option"), 399 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 400 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 401 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 402 ), 403 <?php 404 } 405 ?> 406 selection.setAttribute('id','measure'), 407 selection.setAttribute('class','measure') 408 ); 409 newtd_c2.setAttribute("width","115"); 410 newtd_c2.setAttribute("align","center"); 411 newtd_c2.appendChild( 412 input_data = document.createElement("input"), 413 input_data.setAttribute("type","button"), 414 input_data.setAttribute("value","+"), 415 input_data.onclick = function(){ 416 return addRow(newtr<?php echo $cnt; ?>); 417 ctr++; 418 }); 419 var newtd_c3 = document.createElement("td"); 420 newtd_c3.setAttribute("width","98"); 421 newtd_c3.setAttribute("align","center"); 422 newtd_c3.appendChild( 423 selection = document.createElement("select"), 424 <?php 425 $select = mysql_query("SELECT * FROM source"); 426 while($rowsource = mysql_fetch_array($select)) 427 { 428 ?> 429 selection.appendChild( 430 option = document.createElement("option"), 431 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 432 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 433 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 434 ), 435 <?php 436 } 437 ?> 438 439 selection.setAttribute('id','source'), // End of retrieving 440 selection.setAttribute('class','source') // End of retrieving 441 ); 442 var newtd_c4 = document.createElement("td"); 443 newtd_c4.setAttribute("width","119"); 444 newtd_c4.setAttribute("align","center"); 445 newtd_c4.appendChild( 446 input_data = document.createElement("input"), 447 input_data.setAttribute("type","text"), 448 input_data.setAttribute("class","selected"), 449 input_data.setAttribute("size","12"), 450 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 451 input_data.setAttribute("placeholder","Value") 452 ); 453 var newtd_c5 = document.createElement("td"); 454 newtd_c5.setAttribute("width","115"); 455 newtd_c5.setAttribute("align","center"); 456 newtd_c5.setAttribute("width","115"); 457 newtd_c5.setAttribute("align","center"); 458 newtd_c5.appendChild( 459 input_data = document.createElement("input"), 460 input_data.setAttribute("type","button"), 461 input_data.setAttribute("value","Delete"), 462 input_data.onclick = function(){ return clearNode(newtr<?php echo $cnt; ?>); 463 } 464 ); 465 466 newtr<?php echo $cnt; ?>.appendChild(newtd_c2); 467 newtr<?php echo $cnt; ?>.appendChild(newtd_c3); 468 newtr<?php echo $cnt; ?>.appendChild(newtd_c4); 469 newtr<?php echo $cnt; ?>.appendChild(newtd_c5); 470 newInnertable.appendChild(newtr<?php echo $cnt; ?>); 471 <?php 472 473 $cnt++; 474 $prevtimestamp = $timestamp; 475 } 476 ?> 477 var newtd_c6 = document.createElement("td"); 478 newtd_c6.appendChild(newInnertable); 479 480 var newtd_c7 = document.createElement("td"); 481 newtd_c7.setAttribute("width","115"); 482 newtd_c7.setAttribute("align","center"); 483 newtd_c7.appendChild( 484 input_data = document.createElement("input"), 485 input_data.setAttribute("type","button"), 486 input_data.setAttribute("value","Delete Main"), 487 input_data.onclick = function(){ return clearNode(newdiv); } 488 ); 489 490 var newOutertr = document.createElement("tr"); 491 492 newtable.appendChild(newtd_c1); 493 newtable.appendChild(newtd_c6); 494 newtable.appendChild(newtd_c7); 495 496 newdiv.appendChild(newtable); 497 498 if(nextrow != null){ 499 var doc = document.getElementById(nextrow); 500 $(doc).after(newdiv); 501 } else { 502 targetView.appendChild(newdiv); 503 //$(targetView).after(newtr<?php echo $cnt; ?>); 373 504 } 374 ); 375 376 var newtr<?php echo $cnt; ?> = document.createElement("tr"); 377 newtr<?php echo $cnt; ?>.setAttribute('class','tr'); 378 379 var newtd_c2 = document.createElement("td"); 380 newtd_c2.setAttribute("width","138"); 381 newtd_c2.setAttribute("align","center"); 382 newtd_c2.appendChild( 383 selection = document.createElement("select"), 384 <?php 385 $selectm = mysql_query("SELECT * FROM measurement"); 386 while($rowmeasure = mysql_fetch_array($selectm)) 505 506 <?php 507 } 508 ?> 509 510 if(mysql_num_rows($fetch)<1) 387 511 { 388 ?> 389 selection.appendChild( 390 option = document.createElement("option"), 391 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 392 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 393 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 394 ), 395 <?php 396 } 397 ?> 398 399 400 selection.setAttribute('id','measure'), 401 selection.setAttribute('class','measure') 402 ); 403 newtd_c2.setAttribute("width","115"); 404 newtd_c2.setAttribute("align","center"); 405 newtd_c2.appendChild( 406 input_data = document.createElement("input"), 407 input_data.setAttribute("type","button"), 408 input_data.setAttribute("value","+"), 409 input_data.onclick = function(){ 410 return addRow(newtr<?php echo $cnt; ?>); 411 ctr++; 412 }); 413 var newtd_c3 = document.createElement("td"); 414 newtd_c3.setAttribute("width","98"); 415 newtd_c3.setAttribute("align","center"); 416 newtd_c3.appendChild( 417 selection = document.createElement("select"), 418 <?php 419 $select = mysql_query("SELECT * FROM source"); 420 while($rowsource = mysql_fetch_array($select)) 421 { 422 ?> 423 selection.appendChild( 424 option = document.createElement("option"), 425 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 426 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 427 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 428 ), 429 <?php 430 } 431 ?> 432 433 selection.setAttribute('id','source'), // End of retrieving 434 selection.setAttribute('class','source') // End of retrieving 435 ); 436 var newtd_c4 = document.createElement("td"); 437 newtd_c4.setAttribute("width","119"); 438 newtd_c4.setAttribute("align","center"); 439 newtd_c4.appendChild( 440 input_data = document.createElement("input"), 441 input_data.setAttribute("type","text"), 442 input_data.setAttribute("class","selected"), 443 input_data.setAttribute("size","12"), 444 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 445 input_data.setAttribute("placeholder","Value") 446 ); 447 var newtd_c5 = document.createElement("td"); 448 newtd_c5.setAttribute("width","115"); 449 newtd_c5.setAttribute("align","center"); 450 newtd_c5.setAttribute("width","115"); 451 newtd_c5.setAttribute("align","center"); 452 newtd_c5.appendChild( 453 input_data = document.createElement("input"), 454 input_data.setAttribute("type","button"), 455 input_data.setAttribute("value","Delete"), 456 input_data.onclick = function(){ return clearNode(newtr<?php echo $cnt; ?>); 457 } 458 ); 459 460 newtr<?php echo $cnt; ?>.appendChild(newtd_c2); 461 newtr<?php echo $cnt; ?>.appendChild(newtd_c3); 462 newtr<?php echo $cnt; ?>.appendChild(newtd_c4); 463 newtr<?php echo $cnt; ?>.appendChild(newtd_c5); 464 newInnertable.appendChild(newtr<?php echo $cnt; ?>); 465 466 var newtd_c6 = document.createElement("td"); 467 newtd_c6.appendChild(newInnertable); 468 469 var newtd_c7 = document.createElement("td"); 470 newtd_c7.setAttribute("width","115"); 471 newtd_c7.setAttribute("align","center"); 472 newtd_c7.appendChild( 473 input_data = document.createElement("input"), 474 input_data.setAttribute("type","button"), 475 input_data.setAttribute("value","Delete Main"), 476 input_data.onclick = function(){ return clearNode(newdiv); } 477 ); 478 479 var newOutertr = document.createElement("tr"); 480 481 newtable.appendChild(newtd_c1); 482 newtable.appendChild(newtd_c6); 483 newtable.appendChild(newtd_c7); 484 485 newdiv.appendChild(newtable); 486 487 if(nextrow != null){ 488 var doc = document.getElementById(nextrow); 489 $(doc).after(newdiv); 490 } else { 491 targetView.appendChild(newdiv); 492 //$(targetView).after(newtr<?php echo $cnt; ?>); 493 } 494 <?php 495 //$rows = mysql_fetch_array($fetch); 496 497 $cnt++; 498 $prevtimestamp = $timestamp; 499 } 500 501 502 if(mysql_num_rows($fetch)<1) 503 { 504 ?> 505 $('#save').attr('value','SAVE'); 506 addRowClone1(); 507 <?php 508 } 509 510 ?> 511 512 512 $('#save').attr('value','SAVE'); 513 addRowClone1(); 514 } 513 515 } 514 516 </script>
Note:
See TracChangeset
for help on using the changeset viewer.