Changeset 17501
- Timestamp:
- 01/11/14 03:14:44 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/Module/control.php
r17497 r17501 1 1 <script language="javascript"> 2 2 3 var ctr; 3 4 … … 34 35 select = document.createElement("select"), 35 36 select.setAttribute("class","measure"), 36 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio37 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio 37 38 type:"post", 38 39 url:"Transaction/measurement.php", … … 47 48 }) 48 49 } 49 }) // End of retrieving50 }) // End of retrieving 50 51 ); 51 52 newtd_c2.setAttribute("width","115"); … … 65 66 selection = document.createElement("select"), 66 67 selection.setAttribute("class","source"), 67 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio68 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio 68 69 type:"post", 69 70 url:"Transaction/source.php", … … 79 80 }); 80 81 } 81 }) // End of retrieving82 }) // End of retrieving 82 83 ); 83 84 var newtd_c4 = document.createElement("td"); … … 145 146 $days = Date('Y-m-d',strtotime($day)); 146 147 $prev_time = array(); 147 $previousData = "false";148 $transaction = "save";149 150 148 ?> 151 149 function addRowClone1(nextrow){ … … 202 200 select = document.createElement("select"), 203 201 select.setAttribute("class","measure"), 204 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio202 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio 205 203 type:"post", 206 204 url:"Transaction/measurement.php", … … 214 212 ) 215 213 }) 214 216 215 } 217 }) // End of retrieving 216 }) // End of retrieving 217 218 218 ); 219 219 newtd_c2.setAttribute("width","115"); … … 233 233 selection = document.createElement("select"), 234 234 selection.setAttribute("class","source"), 235 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio235 $.ajax({ //Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio 236 236 type:"post", 237 237 url:"Transaction/source.php", … … 247 247 }); 248 248 } 249 }) // End of retrieving249 }) // End of retrieving 250 250 ); 251 251 var newtd_c4 = document.createElement("td"); … … 296 296 297 297 newdiv.appendChild(newtable); 298 298 299 if(nextrow != null){ 299 300 var doc = document.getElementById(nextrow); … … 305 306 306 307 function addRowClone(nextrow){ 307 <?php 308 /*if($previousData == "true") { 309 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) < '$days' ORDER BY date(fStart) DESC, fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 310 $firstRecord = mysql_fetch_array($fetch); 311 if($firstRecord != null) { 312 $firstRecordDate = strtotime($firstRecord['fStart']); 313 $days = date('Y-m-d', $firstRecordDate); 314 } 315 $previousData = "false"; 316 } 317 else { 318 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 319 $transaction = "update"; 320 }*/ 321 322 $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error()); 323 $transaction = "update"; 324 325 $observationsCount = mysql_query("SELECT COUNT(DISTINCT fStart) FROM schedule WHERE date(fStart) = '$days'"); 326 $observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$days'"); 327 328 $cnt3=0; 329 $cnt2=0; 330 $cnt4 = 0; 331 $cnt5 = 0; 332 $prevtimestamp = 0; 333 334 while($times = mysql_fetch_array($observationsTime)) 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)) 335 319 { 336 ?> alert("Fetching data"); <?php 337 $timestamp=strtotime($times['fStart']); 338 $actualtime = date('Y-m-d H:i:s', $timestamp); 339 $timestamp2 = date('Y-m-d',$timestamp); 340 $date_time = date('H:i:s',$timestamp); 341 $prev_time[$cnt3]= $date_time; 342 ?> 343 var targetView = document.getElementById("Data"); 344 // CREATE ELEMENT 345 // COUNT LIST 346 var list = $(".datalisting").length; 347 var newlist = list+1; 348 349 var cctr=$('.dataTable tr').length; 350 ctr=cctr+1; 351 352 var newdiv = document.createElement("div"); 353 newdiv.setAttribute("id","list_"+newlist); 354 newdiv.setAttribute("class","datalisting"); 355 newdiv.setAttribute("style","margin:5px 0;"); 356 357 var newtable = document.createElement("table"); 358 newtable.setAttribute("class","dataTable"); 359 newtable.setAttribute("width","100%"); 360 newtable.setAttribute("border","1"); 361 newtable.setAttribute("cellspacing","0"); 362 newtable.setAttribute("cellpadding","0"); 363 364 var newInnertable = document.createElement("table"); 365 newInnertable.setAttribute("class","dataTable"); 366 newInnertable.setAttribute("width","100%"); 367 newInnertable.setAttribute("border","1"); 320 $scheduleId = $rows['fScheduleID']; 321 $timestamp=strtotime($rows['fStart']); 322 $timestamp2 = date('Y-m-d',$timestamp); 323 $date_time = date('H:i:s',$timestamp); 324 $prev_time[$cnt3]= $date_time; 325 ?> 326 $('#save').attr('value','UPDATE'); 327 var targetView = document.getElementById("Data"); 328 // CREATE ELEMENT 329 // COUNT LIST 330 var list = $(".datalisting").length; 331 var newlist = list+1; 332 333 var cctr=$('.dataTable tr').length; 334 ctr=cctr+1; 335 336 var newdiv = document.createElement("div"); 337 newdiv.setAttribute("id","list_"+newlist); 338 newdiv.setAttribute("class","datalisting"); 339 newdiv.setAttribute("style","margin:5px 0;"); 340 341 var newtable = document.createElement("table"); 342 newtable.setAttribute("class","dataTable"); 343 newtable.setAttribute("width","100%"); 344 newtable.setAttribute("border","1"); 345 newtable.setAttribute("cellspacing","0"); 346 newtable.setAttribute("cellpadding","0"); 347 348 349 var newInnertable = document.createElement("table"); 350 newInnertable.setAttribute("class","dataTable"); 351 newInnertable.setAttribute("width","100%"); 352 newInnertable.setAttribute("border","1"); 368 353 369 newInnertable.setAttribute("cellspacing","0"); 370 newInnertable.setAttribute("cellpadding","0"); 371 372 var newtd_c1 = document.createElement("td"); 373 newtd_c1.setAttribute("width","200"); 374 newtd_c1.setAttribute("align","center"); 375 newtd_c1.appendChild( 376 input_data = document.createElement("input"), 377 input_data.setAttribute("type","time"), 378 input_data.setAttribute("class","time"), 379 input_data.setAttribute("size","10"), 380 input_data.setAttribute("value","<?php echo $date_time; ?>"), 381 input_data.setAttribute("autofocus","true") 382 ); 383 newtd_c1.appendChild( 384 input_data = document.createElement("input"), 385 input_data.setAttribute("type","button"), 386 input_data.setAttribute("value","+"), 387 input_data.onclick = function(){ 388 addRowClone1("list_<?php echo $cnt+1; ?>"); 389 } 390 ); 391 392 <?php 393 394 $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'"); 395 396 while($rows = mysql_fetch_array($observations)) 354 newInnertable.setAttribute("cellspacing","0"); 355 newInnertable.setAttribute("cellpadding","0"); 356 357 var newtd_c1 = document.createElement("td"); 358 newtd_c1.setAttribute("width","200"); 359 newtd_c1.setAttribute("align","center"); 360 newtd_c1.appendChild( 361 input_data = document.createElement("input"), 362 input_data.setAttribute("type","time"), 363 input_data.setAttribute("class","time"), 364 input_data.setAttribute("size","10"), 365 input_data.setAttribute("value","<?php echo $date_time; ?>"), 366 input_data.setAttribute("autofocus","true") 367 ); 368 newtd_c1.appendChild( 369 input_data = document.createElement("input"), 370 input_data.setAttribute("type","button"), 371 input_data.setAttribute("value","+"), 372 input_data.onclick = function(){ 373 addRowClone1("list_<?php echo $cnt+1; ?>"); 374 } 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)) 397 388 { 398 389 ?> 399 var newtr<?php echo $cnt; ?> = document.createElement("tr"); 400 newtr<?php echo $cnt; ?>.setAttribute('class','tr'); 401 402 var newtd_c2 = document.createElement("td"); 403 newtd_c2.setAttribute("width","138"); 404 newtd_c2.setAttribute("align","center"); 405 newtd_c2.appendChild( 406 selection = document.createElement("select"), 407 <?php 408 $selectm = mysql_query("SELECT * FROM measurement"); 409 while($rowmeasure = mysql_fetch_array($selectm)) 410 { 411 ?> 412 selection.appendChild( 413 option = document.createElement("option"), 414 option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"), 415 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 416 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 417 ), 418 <?php 419 } 420 ?> 421 selection.setAttribute('id','measure'), 422 selection.setAttribute('class','measure') 423 ); 424 newtd_c2.setAttribute("width","115"); 425 newtd_c2.setAttribute("align","center"); 426 newtd_c2.appendChild( 427 input_data = document.createElement("input"), 428 input_data.setAttribute("type","button"), 429 input_data.setAttribute("value","+"), 430 input_data.onclick = function(){ 431 return addRow(newtr<?php echo $cnt; ?>); 432 ctr++; 433 }); 434 var newtd_c3 = document.createElement("td"); 435 newtd_c3.setAttribute("width","98"); 436 newtd_c3.setAttribute("align","center"); 437 newtd_c3.appendChild( 438 selection = document.createElement("select"), 439 <?php 440 $select = mysql_query("SELECT * FROM source"); 441 while($rowsource = mysql_fetch_array($select)) 442 { 443 ?> 444 selection.appendChild( 445 option = document.createElement("option"), 446 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 447 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?> 448 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 449 ), 450 <?php 451 } 452 ?> 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"), 419 <?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 ?> 453 433 454 selection.setAttribute('id','source'), // End of retrieving 455 selection.setAttribute('class','source') // End of retrieving 456 ); 457 var newtd_c4 = document.createElement("td"); 458 newtd_c4.setAttribute("width","119"); 459 newtd_c4.setAttribute("align","center"); 460 newtd_c4.appendChild( 461 input_data = document.createElement("input"), 462 input_data.setAttribute("type","text"), 463 input_data.setAttribute("class","selected"), 464 input_data.setAttribute("size","12"), 465 input_data.setAttribute("value","<?php echo $rows['fData']; ?>"), 466 input_data.setAttribute("placeholder","Value") 467 ); 468 var newtd_c5 = document.createElement("td"); 469 newtd_c5.setAttribute("width","115"); 470 newtd_c5.setAttribute("align","center"); 471 newtd_c5.setAttribute("width","115"); 472 newtd_c5.setAttribute("align","center"); 473 newtd_c5.appendChild( 474 input_data = document.createElement("input"), 475 input_data.setAttribute("type","button"), 476 input_data.setAttribute("value","Delete"), 477 input_data.onclick = function(){ return clearNode(newtr<?php echo $cnt; ?>); 478 } 479 ); 480 481 newtr<?php echo $cnt; ?>.appendChild(newtd_c2); 482 newtr<?php echo $cnt; ?>.appendChild(newtd_c3); 483 newtr<?php echo $cnt; ?>.appendChild(newtd_c4); 484 newtr<?php echo $cnt; ?>.appendChild(newtd_c5); 485 newInnertable.appendChild(newtr<?php echo $cnt; ?>); 486 <?php 487 $cnt++; 488 $prevtimestamp = $timestamp; 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; ?>); 489 494 } 490 ?> 491 var newtd_c6 = document.createElement("td"); 492 newtd_c6.appendChild(newInnertable); 493 494 var newtd_c7 = document.createElement("td"); 495 newtd_c7.setAttribute("width","115"); 496 newtd_c7.setAttribute("align","center"); 497 newtd_c7.appendChild( 498 input_data = document.createElement("input"), 499 input_data.setAttribute("type","button"), 500 input_data.setAttribute("value","Delete Main"), 501 input_data.onclick = function(){ return clearNode(newdiv); } 502 ); 503 504 var newOutertr = document.createElement("tr"); 505 506 newtable.appendChild(newtd_c1); 507 newtable.appendChild(newtd_c6); 508 newtable.appendChild(newtd_c7); 509 510 newdiv.appendChild(newtable); 511 512 if(nextrow != null){ 513 var doc = document.getElementById(nextrow); 514 $(doc).after(newdiv); 515 } else { 516 targetView.appendChild(newdiv); 517 } 518 <?php 495 <?php 496 //$rows = mysql_fetch_array($fetch); 497 498 $cnt++; 499 $prevtimestamp = $timestamp; 519 500 } 520 501 521 if(mysql_num_rows($fetch)<1) 522 { 523 ?> 524 $('#save').attr('value','SAVE'); 525 addRowClone1(); 526 <?php 527 } 528 ?> 502 503 if(mysql_num_rows($fetch)<1) 504 { 505 ?> 506 $('#save').attr('value','SAVE'); 507 addRowClone1(); 508 <?php 529 509 } 530 510 531 /*function loadPreviousData(){ 532 <?php $previousData = "true"; ?> 533 addRowClone();534 } */511 ?> 512 513 514 } 535 515 </script> 536 516
Note:
See TracChangeset
for help on using the changeset viewer.