Index: schedule/function/SplitDelete.php
===================================================================
--- schedule/function/SplitDelete.php	(revision 16949)
+++ schedule/function/SplitDelete.php	(revision 16949)
@@ -0,0 +1,453 @@
+<?php include '../include/factdb.php'; ?>
+<script language="javascript">
+
+window.cnt=0;
+	function clearNode(node){
+		var child = node.childNodes[0];
+		while(child != null)
+		{
+			node.removeChild(child);
+			child = node.childNodes[0];
+		}	
+	}
+	function addRow(table){
+		var targetView = table;
+		// CREATE ELEMENT	
+		var newtr = document.createElement("tr");
+		
+		var newtd_c1 = document.createElement("td");
+			newtd_c1.setAttribute("width","115");
+			newtd_c1.setAttribute("align","center");
+			newtd_c1.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","time"),
+				input_data.setAttribute("autofocus","true"),
+				input_data.setAttribute("id","Time"),
+				input_data.setAttribute("max","24"),
+				input_data.setAttribute("min","1"),
+				input_data.setAttribute("required",true)
+			);
+		var newtd_c2 = document.createElement("td");
+			newtd_c2.setAttribute("width","40");
+			newtd_c2.setAttribute("align","center");
+			newtd_c2.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']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
+				<?php } ?>
+				
+			selection.setAttribute('id','source')
+			);
+		var newtd_c3 = document.createElement("td");
+			newtd_c3.setAttribute("width","88");
+			newtd_c3.setAttribute("align","center");
+			newtd_c3.appendChild(
+				selection = document.createElement("select"),
+				selection.appendChild(option = document.createElement("option"),option.setAttribute("select","Source 1"),option.appendChild(document.createTextNode("Source 1"))),
+			
+			selection.setAttribute('id','measurement')
+			);
+		var newtd_c4 = document.createElement("td");
+		newtd_c4.setAttribute("width","180");
+		newtd_c4.setAttribute("align","center");
+		newtd_c4.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","text"),
+			input_data.setAttribute("size","20"),
+			input_data.setAttribute("placeholder","Value")
+		);
+	var newtd_c5 = document.createElement("td");
+		newtd_c5.setAttribute("width","95");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete Main"),
+			input_data.onclick = function(){ return clearNode(newdiv); }
+		);
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){ return addRow(newtable); }
+		);
+		
+		newtr.appendChild(newtd_c1);
+		newtr.appendChild(newtd_c2);
+		newtr.appendChild(newtd_c3);
+		newtr.appendChild(newtd_c4);
+		newtr.appendChild(newtd_c5);
+	
+		
+		targetView.appendChild(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);
+		}
+	}
+
+
+function addRowClone(){
+	var targetView = document.getElementById("Data");
+	// CREATE ELEMENT
+	var newdiv   = document.createElement("div");
+		newdiv.setAttribute("style","margin:30px 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 newtr = document.createElement("tr");
+	
+	var newtd_c1 = document.createElement("td");
+		newtd_c1.setAttribute("width","115");
+		newtd_c1.setAttribute("align","center");
+		newtd_c1.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","time"),
+				input_data.setAttribute("autofocus","true"),
+				input_data.setAttribute("id","Time"),
+				input_data.setAttribute("max","24"),
+				input_data.setAttribute("min","1"),
+				input_data.setAttribute("required",true)
+		);
+	var newtd_c2 = document.createElement("td");
+		newtd_c2.setAttribute("width","40");
+		newtd_c2.setAttribute("align","center");
+		newtd_c2.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']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
+				<?php } ?>
+				
+			selection.setAttribute('id','source')
+			);
+	var newtd_c3 = document.createElement("td");
+		newtd_c3.setAttribute("width","88");
+		newtd_c3.setAttribute("align","center");
+		newtd_c3.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']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
+				<?php  } ?>
+			selection.setAttribute('id','measurement')
+		);
+	var newtd_c4 = document.createElement("td");
+		newtd_c4.setAttribute("width","180");
+		newtd_c4.setAttribute("align","center");
+		newtd_c4.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","text"),
+			input_data.setAttribute("size","20"),
+			input_data.setAttribute("placeholder","Value")
+		);
+	var newtd_c5 = document.createElement("td");
+		newtd_c5.setAttribute("width","95");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete Main"),
+			input_data.onclick = function(){ return clearNode(newdiv); }
+		);
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){ return addRow(newtable); }
+		);
+	
+	newtr.appendChild(newtd_c1);
+	newtr.appendChild(newtd_c2);
+	newtr.appendChild(newtd_c3);
+	newtr.appendChild(newtd_c4);
+	newtr.appendChild(newtd_c5);
+	
+	
+	newtable.appendChild(newtr);
+	newdiv.appendChild(newtable);
+	
+	targetView.appendChild(newdiv);
+}
+
+
+
+
+<?php    
+
+			if(isset($_GET['days']))
+			{ 
+				 $day = $_GET['days'];
+			 }
+			 else
+			 {
+				 $day =date("Y-m-d");		 
+			 }						 
+				$days = Date('Y-m-d',strtotime($day));	
+				$fetch = mysql_query("SELECT * FROM schedule ORDER BY fScheduleID ASC") or die(mysql_error());
+				while($rows = mysql_fetch_array($fetch))
+				{
+					$timestamp=strtotime($rows['fStart']);
+					$timestamp2 = date('Y-m-d',$timestamp);
+					$date_time = date('H:i',$timestamp);
+					
+					if($days == $timestamp2)
+					{
+					?>
+					cnt++;
+				
+					$('#save').attr('value','UPDATE');
+					
+	var targetView = document.getElementById("Data");
+	// CREATE ELEMENT
+	var newdiv   = document.createElement("div");
+		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 newtr = document.createElement("tr");
+	
+	var newtd_c1 = document.createElement("td");
+		newtd_c1.setAttribute("width","115");
+		newtd_c1.setAttribute("align","center");
+		newtd_c1.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","time"),
+				input_data.setAttribute("autofocus","true"),
+				input_data.setAttribute("id","Time"),
+				input_data.setAttribute("max","24"),
+				input_data.setAttribute("min","1"),
+				input_data.setAttribute("required",true),
+				input_data.setAttribute("value",'<?php echo $date_time; ?>')
+		);
+	var newtd_c2 = document.createElement("td");
+		newtd_c2.setAttribute("width","40");
+		newtd_c2.setAttribute("align","center");
+		newtd_c2.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']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
+					<?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
+												
+				<?php } ?>
+		
+			selection.setAttribute('id','source')
+			);
+	var newtd_c3 = document.createElement("td");
+		newtd_c3.setAttribute("width","88");
+		newtd_c3.setAttribute("align","center");
+		newtd_c3.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']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
+				<?php  if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";}  } ?>
+			selection.setAttribute('id','measurement')
+		);
+	var newtd_c4 = document.createElement("td");
+		newtd_c4.setAttribute("width","180");
+		newtd_c4.setAttribute("align","center");
+		newtd_c4.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","text"),
+			input_data.setAttribute("size","20"),
+			input_data.setAttribute("placeholder","Value"),
+			input_data.setAttribute('value','<?php  echo $rows['fData']; ?>')
+		);
+	var newtd_c5 = document.createElement("td");
+		newtd_c5.setAttribute("width","95");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete Main"),
+			input_data.onclick = function(){ return clearNode(newdiv); }
+		);
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){ return addRow(newtable); }
+		);
+	
+	newtr.appendChild(newtd_c1);
+	newtr.appendChild(newtd_c2);
+	newtr.appendChild(newtd_c3);
+	newtr.appendChild(newtd_c4);
+	newtr.appendChild(newtd_c5);
+
+	
+	newtable.appendChild(newtr);
+	newdiv.appendChild(newtable);
+	
+	targetView.appendChild(newdiv);
+					
+				
+					
+					<?php  } } ?>
+
+
+
+
+
+
+
+window.onload = function(){
+
+	
+
+
+if(cnt==0){
+
+	var targetView = document.getElementById("Data");
+	// CREATE ELEMENT
+	var newdiv   = document.createElement("div");
+		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 newtr = document.createElement("tr");
+	
+	var newtd_c1 = document.createElement("td");
+		newtd_c1.setAttribute("width","115");
+		newtd_c1.setAttribute("align","center");
+		newtd_c1.appendChild(
+				input_data = document.createElement("input"),
+				input_data.setAttribute("type","time"),
+				input_data.setAttribute("autofocus","true"),
+				input_data.setAttribute("id","Time"),
+				input_data.setAttribute("max","24"),
+				input_data.setAttribute("min","1"),
+				input_data.setAttribute("required",true)
+		);
+	var newtd_c2 = document.createElement("td");
+		newtd_c2.setAttribute("width","40");
+		newtd_c2.setAttribute("align","center");
+		newtd_c2.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']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
+				<?php } ?>
+		
+			selection.setAttribute('id','source')
+			);
+	var newtd_c3 = document.createElement("td");
+		newtd_c3.setAttribute("width","88");
+		newtd_c3.setAttribute("align","center");
+		newtd_c3.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']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
+				<?php  } ?>
+			selection.setAttribute('id','measurement')
+		);
+	var newtd_c4 = document.createElement("td");
+		newtd_c4.setAttribute("width","180");
+		newtd_c4.setAttribute("align","center");
+		newtd_c4.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","text"),
+			input_data.setAttribute("size","20"),
+			input_data.setAttribute("placeholder","Value")
+		);
+	var newtd_c5 = document.createElement("td");
+		newtd_c5.setAttribute("width","95");
+		newtd_c5.setAttribute("align","center");
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","Delete Main"),
+			input_data.onclick = function(){ return clearNode(newdiv); }
+		);
+		newtd_c5.appendChild(
+			input_data = document.createElement("input"),
+			input_data.setAttribute("type","button"),
+			input_data.setAttribute("value","+"),
+			input_data.onclick = function(){ return addRow(newtable); }
+		);
+	
+	newtr.appendChild(newtd_c1);
+	newtr.appendChild(newtd_c2);
+	newtr.appendChild(newtd_c3);
+	newtr.appendChild(newtd_c4);
+	newtr.appendChild(newtd_c5);
+
+	newtable.appendChild(newtr);
+	newdiv.appendChild(newtable);
+	
+	targetView.appendChild(newdiv);
+}
+	}
+
+
+
+</script>
