Index: schedule/Module/control.php
===================================================================
--- schedule/Module/control.php	(revision 17428)
+++ schedule/Module/control.php	(revision 17428)
@@ -0,0 +1,508 @@
+<script language="javascript">
+
+	var ctr;
+	
+	function clearNode(node){
+		var child = node.childNodes[0];
+		while(child != null)
+		{
+			node.removeChild(child);
+			child = node.childNodes[0];
+		}	
+	}
+	
+	function addRow(table){
+		var targetView = table;
+		var cctr=$('.dataTable tr').length;
+		 ctr=cctr+1;
+		// CREATE ELEMENT	
+		var newtr = document.createElement("tr");
+			newtr.setAttribute("class","tr");
+		var newtd_c1 = document.createElement("td");
+			newtd_c1.setAttribute("width","147");
+			newtd_c1.setAttribute("align","center");
+			newtd_c1.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","time"),
+				input_data.setAttribute("size","10"),
+				input_data.setAttribute("autofocus","true"),
+				input_data.setAttribute("hidden","true")
+			);
+		var newtd_c2 = document.createElement("td");
+			newtd_c2.setAttribute("width","138");
+			newtd_c2.setAttribute("align","center");
+			newtd_c2.appendChild(
+				select = document.createElement("select"),
+				select.setAttribute("class","measure"),
+				$.ajax({																	//Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
+				type:"post",
+				url:"Transaction/measurement.php",
+				success:function(data){
+					var obj=$.parseJSON(data);
+					$.each(obj,function(){
+						select.appendChild(
+						option = document.createElement("option"),
+						option.setAttribute('value',this['fMeasurementKey']),
+						option.appendChild(document.createTextNode(this['fMeasurement']))
+						)
+					})
+				}
+				})																				// End of retrieving
+			);
+			newtd_c2.setAttribute("width","115");
+			newtd_c2.setAttribute("align","center");
+			newtd_c2.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","button"),
+				input_data.setAttribute("value","+"),
+				input_data.onclick = function(){ return addRow(newtr);
+					ctr++;
+				}
+			);
+		var newtd_c3 = document.createElement("td");
+			newtd_c3.setAttribute("width","98");
+			newtd_c3.setAttribute("align","center");
+			newtd_c3.appendChild(
+					selection = document.createElement("select"),
+					selection.setAttribute("class","source"),
+					$.ajax({																	//Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
+						type:"post",
+						url:"Transaction/source.php",
+						success:function(data)
+						{
+							var obj = $.parseJSON(data);
+							$.each(obj,function(){
+							selection.appendChild(
+								option=document.createElement('option'),
+								option.setAttribute('value',this['fSourceKEY']),
+								option.appendChild(document.createTextNode(this['fSourceName']))
+								)
+							});
+						}
+					})																			// End of retrieving		
+			);
+		var newtd_c4 = document.createElement("td");
+			newtd_c4.setAttribute("width","119");
+			newtd_c4.setAttribute("align","center");
+			newtd_c4.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","text"),
+				input_data.setAttribute("class","selected"),
+				input_data.setAttribute("size","12"),
+				input_data.setAttribute("placeholder","Value")
+			);
+		var newtd_c5 = document.createElement("td");
+			newtd_c5.setAttribute("width","115");
+			newtd_c5.setAttribute("align","center");
+			newtd_c5.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","button"),
+				input_data.setAttribute("value","Delete"),
+				input_data.onclick = function(){ return clearNode(newtr); }
+			);
+		
+		newtr.appendChild(newtd_c2);
+		newtr.appendChild(newtd_c3);
+		newtr.appendChild(newtd_c4);
+		newtr.appendChild(newtd_c5);
+		
+		$(targetView).after(newtr);
+	}
+function deleteRow(tableID){
+		try{
+			var table = document.getElementById(tableID);
+			var rowCount = table.rows.length;
+			
+			for(var i = 0; i < rowCount; i++){
+				var row = table.rows[i];
+				var chkbox = row.cells[0].childNodes[0];
+				if(null != chkbox && true == chkbox.checked){
+					if(rowCount <= 1){
+						alert("Cannot delete all the rows.");
+						break;
+					}
+					table.deleteRow(i);
+					rowCount--; 
+					i--;
+				}
+			}
+		}catch(e){
+			alert(e);
+		}
+	}
+
+<?php
+$cnt=0;
+if(isset($_GET['days']))
+{ 
+ $day = $_GET['days'];
+}
+else
+{
+ $day =date("Y-m-d");		 
+}
+
+//	$day=$_GET['days'];
+$days = Date('Y-m-d',strtotime($day));	
+$prev_time = array();
+?>
+function addRowClone1(nextrow){
+	var targetView = document.getElementById("Data");
+	// CREATE ELEMENT
+	// COUNT LIST
+	var list     = $(".datalisting").length;
+	var newlist = list+1;
+	var cctr=$('.dataTable tr').length;
+		 ctr=cctr+1;
+	var newdiv   = document.createElement("div");
+		newdiv.setAttribute("id","list_"+newlist);
+		newdiv.setAttribute("class","datalisting");
+		newdiv.setAttribute("style","margin:5px 0;");
+	var newtable = document.createElement("table");
+		newtable.setAttribute("class","dataTable");
+		newtable.setAttribute("width","100%");
+		newtable.setAttribute("border","1");
+		newtable.setAttribute("cellspacing","0");
+		newtable.setAttribute("cellpadding","0");
+	var newInnertable = document.createElement("table");
+		newInnertable.setAttribute("class","dataTable");
+		newInnertable.setAttribute("width","100%");
+		newInnertable.setAttribute("border","1");
+		
+		newInnertable.setAttribute("cellspacing","0");
+		newInnertable.setAttribute("cellpadding","0");
+		
+	var newtr = document.createElement("tr");
+		newtr.setAttribute('class','tr');
+	var newtd_c1 = document.createElement("td");
+		newtd_c1.setAttribute("width","200");
+		newtd_c1.setAttribute("align","center");
+		newtd_c1.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","time"),
+			input_data.setAttribute("class","time"),
+			input_data.setAttribute("size","10"),
+			input_data.setAttribute("autofocus","true")
+		);
+		newtd_c1.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){
+				addRowClone1("list_"+newlist);
+			}
+		);
+	var newtd_c2 = document.createElement("td");
+	
+		newtd_c2.setAttribute("width","138");
+		newtd_c2.setAttribute("align","center");
+		newtd_c2.appendChild(
+			select = document.createElement("select"),
+			select.setAttribute("class","measure"),
+			$.ajax({																	//Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
+			type:"post",
+			url:"Transaction/measurement.php",
+			success:function(data){
+				var obj=$.parseJSON(data);
+				$.each(obj,function(){
+				select.appendChild(
+				option = document.createElement("option"),
+				option.setAttribute('value',this['fMeasurementKey']),
+				option.appendChild(document.createTextNode(this['fMeasurement']))
+				)
+				})
+			
+			}
+			})																			// End of retrieving
+			
+		);
+		newtd_c2.setAttribute("width","115");
+		newtd_c2.setAttribute("align","center");
+		newtd_c2.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){ 
+			return addRow(newtr);
+				ctr++;
+			});
+	var newtd_c3 = document.createElement("td");
+		newtd_c3.setAttribute("width","98");
+		newtd_c3.setAttribute("align","center");
+		newtd_c3.appendChild(
+			selection = document.createElement("select"),
+			selection.setAttribute("class","source"),
+			$.ajax({																	//Retrieving Measurement name and id in Database september 13,2013 modify by Jaypee Tanio
+				type:"post",
+				url:"Transaction/source.php",
+				success:function(data)
+				{
+					var obj = $.parseJSON(data);
+					$.each(obj,function(){
+					selection.appendChild(
+						option=document.createElement('option'),
+						option.setAttribute('value',this['fSourceKEY']),
+						option.appendChild(document.createTextNode(this['fSourceName']))
+						)
+					});
+				}
+			})																			// End of retrieving
+		);
+	var newtd_c4 = document.createElement("td");
+		newtd_c4.setAttribute("width","119");
+		newtd_c4.setAttribute("align","center");
+		newtd_c4.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","text"),
+			input_data.setAttribute("class","selected"),
+			input_data.setAttribute("size","12"),
+			input_data.setAttribute("placeholder","Value")
+		);
+	var newtd_c5 = document.createElement("td");
+		newtd_c5.setAttribute("width","115");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.setAttribute("width","115");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete"),
+			input_data.onclick = function(){ return clearNode(newtr);
+			}
+		);
+	newtr.appendChild(newtd_c2);
+	newtr.appendChild(newtd_c3);
+	newtr.appendChild(newtd_c4);
+	newtr.appendChild(newtd_c5);
+	newInnertable.appendChild(newtr);
+	var newtd_c6 = document.createElement("td");
+		newtd_c6.appendChild(newInnertable);
+
+	var newtd_c7 = document.createElement("td");
+		newtd_c7.setAttribute("width","115");
+		newtd_c7.setAttribute("align","center");
+		newtd_c7.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete Main"),
+			input_data.onclick = function(){ return clearNode(newdiv); }
+		);
+
+	var newOutertr = document.createElement("tr");
+
+	newtable.appendChild(newtd_c1);
+	newtable.appendChild(newtd_c6);
+	newtable.appendChild(newtd_c7);
+
+	newdiv.appendChild(newtable);
+	if(nextrow != null){	
+		var doc = document.getElementById(nextrow);
+		$(doc).after(newdiv);
+	}else{
+		targetView.appendChild(newdiv);
+	}
+}
+
+function addRowClone(nextrow){
+<?php
+$fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fScheduleID AND fMeasurementID ASC") or die(mysql_error());
+$cnt3=0;
+$cnt2=0;
+$cnt4 = 0;
+$cnt5 = 0;
+//$data  = array();
+//$counter=0;
+	while($rows = mysql_fetch_array($fetch))
+	{
+		$timestamp=strtotime($rows['fStart']);
+		$timestamp2 = date('Y-m-d',$timestamp);
+		$date_time = date('H:i:s',$timestamp);
+		$prev_time[$cnt3]= $date_time;
+			?>
+			$('#save').attr('value','UPDATE');
+			var targetView = document.getElementById("Data");
+			// CREATE ELEMENT
+			// COUNT LIST
+			var list     = $(".datalisting").length;
+			var newlist = list+1;
+			
+			var cctr=$('.dataTable tr').length;
+				 ctr=cctr+1;
+				 
+			var newdiv   = document.createElement("div");
+				newdiv.setAttribute("id","list_"+newlist);
+				newdiv.setAttribute("class","datalisting");
+				newdiv.setAttribute("style","margin:5px 0;");
+			
+			var newtable = document.createElement("table");
+				newtable.setAttribute("class","dataTable");
+				newtable.setAttribute("width","100%");
+				newtable.setAttribute("border","1");
+				newtable.setAttribute("cellspacing","0");
+				newtable.setAttribute("cellpadding","0");
+
+			
+			var newInnertable = document.createElement("table");
+				newInnertable.setAttribute("class","dataTable");
+				newInnertable.setAttribute("width","100%");
+				newInnertable.setAttribute("border","1");
+				
+				newInnertable.setAttribute("cellspacing","0");
+				newInnertable.setAttribute("cellpadding","0");
+			
+			var newtd_c1 = document.createElement("td");
+				newtd_c1.setAttribute("width","200");
+				newtd_c1.setAttribute("align","center");
+				newtd_c1.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","time"),
+					input_data.setAttribute("class","time"),
+					input_data.setAttribute("size","10"),
+					input_data.setAttribute("value","<?php echo $date_time; ?>"),
+					input_data.setAttribute("autofocus","true")
+				);
+				newtd_c1.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+					input_data.setAttribute("value","+"),
+					input_data.onclick = function(){
+						addRowClone1("list_<?php echo $cnt; ?>");
+					}
+				);
+			
+			var newtr<?php echo $cnt; ?> = document.createElement("tr");
+				newtr<?php echo $cnt; ?>.setAttribute('class','tr');
+			
+			var newtd_c2 = document.createElement("td");
+				newtd_c2.setAttribute("width","138");
+				newtd_c2.setAttribute("align","center");
+				newtd_c2.appendChild(
+					selection = document.createElement("select"),
+		<?php   
+		$selectm = mysql_query("SELECT * FROM measurement");
+		while($rowmeasure = mysql_fetch_array($selectm))
+		{
+		?>
+					selection.appendChild(
+					option = document.createElement("option"),
+					option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),
+					<?php  if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";}   ?>
+					option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
+					),
+		<?php 
+		} 
+		?>
+						
+						
+					selection.setAttribute('id','measure'),
+					selection.setAttribute('class','measure')
+				);
+				newtd_c2.setAttribute("width","115");
+				newtd_c2.setAttribute("align","center");
+				newtd_c2.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+					input_data.setAttribute("value","+"),
+					input_data.onclick = function(){ 
+					return addRow(newtr<?php echo $cnt; ?>);
+						ctr++;
+					});
+			var newtd_c3 = document.createElement("td");
+				newtd_c3.setAttribute("width","98");
+				newtd_c3.setAttribute("align","center");
+				newtd_c3.appendChild(
+					selection = document.createElement("select"),
+		<?php
+		$select = mysql_query("SELECT * FROM source");
+		while($rowsource = mysql_fetch_array($select))
+		{
+		?>
+						selection.appendChild(
+						option = document.createElement("option"),
+						option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
+						<?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?>
+						option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
+						),
+		<?php
+		} 
+		?>
+					
+					selection.setAttribute('id','source'),																			// End of retrieving
+					selection.setAttribute('class','source')																			// End of retrieving
+				);
+			var newtd_c4 = document.createElement("td");
+				newtd_c4.setAttribute("width","119");
+				newtd_c4.setAttribute("align","center");
+				newtd_c4.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","text"),
+					input_data.setAttribute("class","selected"),
+					input_data.setAttribute("size","12"),
+					input_data.setAttribute("value","<?php echo $rows['fData']; ?>"),
+					input_data.setAttribute("placeholder","Value")
+				);
+			var newtd_c5 = document.createElement("td");
+				newtd_c5.setAttribute("width","115");
+				newtd_c5.setAttribute("align","center");
+				newtd_c5.setAttribute("width","115");
+				newtd_c5.setAttribute("align","center");
+				newtd_c5.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+					input_data.setAttribute("value","Delete"),
+					input_data.onclick = function(){ return clearNode(newtr<?php echo $cnt; ?>);
+					}
+				);
+			newtr<?php echo $cnt; ?>.appendChild(newtd_c2);
+			newtr<?php echo $cnt; ?>.appendChild(newtd_c3);
+			newtr<?php echo $cnt; ?>.appendChild(newtd_c4);
+			newtr<?php echo $cnt; ?>.appendChild(newtd_c5);
+			newInnertable.appendChild(newtr<?php echo $cnt; ?>);
+			
+			
+			var newtd_c6 = document.createElement("td");
+				newtd_c6.appendChild(newInnertable);
+
+			var newtd_c7 = document.createElement("td");
+				newtd_c7.setAttribute("width","115");
+				newtd_c7.setAttribute("align","center");
+				newtd_c7.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+					input_data.setAttribute("value","Delete Main"),
+					input_data.onclick = function(){ return clearNode(newdiv); }
+				);
+
+			var newOutertr = document.createElement("tr");
+
+			newtable.appendChild(newtd_c1);
+			newtable.appendChild(newtd_c6);
+			newtable.appendChild(newtd_c7);
+
+			newdiv.appendChild(newtable);
+			if(nextrow != null){	
+				var doc = document.getElementById(nextrow);
+				$(doc).after(newdiv);
+			}else{
+				targetView.appendChild(newdiv);
+				//$(targetView).after(newtr<?php echo $cnt; ?>);
+			}
+	<?php
+//$rows = mysql_fetch_array($fetch);	
+			
+		$cnt++;
+	}
+if(mysql_num_rows($fetch)<1)
+{
+?>
+	$('#save').attr('value','SAVE');
+	addRowClone1();
+<?php
+}
+
+?>
+
+			
+}
+ </script>
+	
