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