Index: schedule/function/SplitDelete.php
===================================================================
--- schedule/function/SplitDelete.php	(revision 16899)
+++ schedule/function/SplitDelete.php	(revision 16910)
@@ -21,5 +21,5 @@
 			 }						 
 				$days = Date('Y-m-d',strtotime($day));	
-				$fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
+				$fetch = mysql_query("SELECT * FROM schedule ORDER BY fScheduleID ASC") or die(mysql_error());
 				while($rows = mysql_fetch_array($fetch))
 				{
@@ -33,170 +33,170 @@
 					cnt++;
 				
-$('#save').hide();
-	$('#update').show();
-
-	var div= document.createElement("div");
-		div.setAttribute('id','TableHolder');
- 	var table = document.createElement("table");
-		table.setAttribute('id',"table"+cnt);
-		table.setAttribute('width','100%');
-	var tr = document.createElement('tr');
-	var td3=document.createElement('td');
-		td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
-		td3.appendChild(
-			input = document.createElement("input"),
-					input.setAttribute("type","time"),
-					input.setAttribute("id","Time"),
-					input.setAttribute("max","24"),
-					input.setAttribute("min","1"),
-					input.setAttribute("required",true),
-					input.setAttribute("value",'<?php echo $date_time; ?>')
-				
-		);
-			td3.appendChild(
-			button=document.createElement('input'),
-			button.setAttribute('type','button'),
-			button.setAttribute('value','[+]'),
-			button.setAttribute('id','btnAddTime'),
-			button.setAttribute('name','#table'+cnt),
-			button.onclick=function(){
-			
-			
-			
-			if($('#Time').val() != ""){  var splitting = $('#Time').val().split(':'); var add = 01;   
-
-			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
-		
-						function pad(number, length) {
-				   
-							var str = '' + number;
-							while (str.length < length) {
-								str = '0' + str;
+					$('#save').attr('value','UPDATE');
+					
+
+					var div= document.createElement("div");
+						div.setAttribute('id','TableHolder');
+					var table = document.createElement("table");
+						table.setAttribute('id',"table"+cnt);
+						table.setAttribute('width','100%');
+					var tr = document.createElement('tr');
+					var td3=document.createElement('td');
+						td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
+						td3.appendChild(
+							input = document.createElement("input"),
+									input.setAttribute("type","time"),
+									input.setAttribute("id","Time"),
+									input.setAttribute("max","24"),
+									input.setAttribute("min","1"),
+									input.setAttribute("required",true),
+									input.setAttribute("value",'<?php echo $date_time; ?>')
+								
+						);
+							td3.appendChild(
+							button=document.createElement('input'),
+							button.setAttribute('type','button'),
+							button.setAttribute('value','[+]'),
+							button.setAttribute('id','btnAddTime'),
+							button.setAttribute('name','#table'+cnt),
+							button.onclick=function(){
+							
+							
+							
+							if($('#Time').val() != ""){  var splitting = $('#Time').val().split(':'); var add = 01;   
+
+							timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
+						
+										function pad(number, length) {
+								   
+											var str = '' + number;
+											while (str.length < length) {
+												str = '0' + str;
+											}
+								   
+										return str;
+
+										}
+										var s = 0; var	get;
+										var nn;
+										nn = $(this).attr('name');
+								$("table").each(function() {
+								if($(this).attr("name")==nn){
+									
+									get = "#"+$(this).attr("id"); 
+									//get = $(this).attr("name");
+										s =1;
+								}else{
+								if(s==0){
+								get = '#table'+cnt;
+								}
+								}
+								});
+
+					
+									
+								getTableId =get;
+
+
+							name="name"; value=""; meas = "name"; meas2 = "time";   //getTableId = $(this).attr('name'); 
+							split1();    }else{   alert("please enter value for time to add measurement");   }
+
+								
 							}
-				   
-						return str;
-
-						}
-						var s = 0; var	get;
-						var nn;
-						nn = $(this).attr('name');
-				$("table").each(function() {
-				if($(this).attr("name")==nn){
-					
-					get = "#"+$(this).attr("id"); 
-					//get = $(this).attr("name");
-						s =1;
-				}else{
-				if(s==0){
-				get = '#table'+cnt;
-				}
-				}
-				});
-
-	
-					
-				getTableId =get;
-
-
-			name="name"; value=""; meas = "name"; meas2 = "time";   //getTableId = $(this).attr('name'); 
-			split1();    }else{   alert("please enter value for time to add measurement");   }
-
-				
-			}
-		);
-	var td=document.createElement('td');
-		td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
-		td.appendChild(
-			sourcecbo= document.createElement('select'),
-				sourcecbo.setAttribute('id','source'),
-<?php
-			$source=mysql_query("SELECT*FROM source");
-			while($rowsource=mysql_fetch_array($source))
-			{
-?>
-				sourcecbo.appendChild(
-					option=document.createElement('option'),
+						);
+					var td=document.createElement('td');
+						td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
+						td.appendChild(
+							sourcecbo= document.createElement('select'),
+								sourcecbo.setAttribute('id','source'),
+				<?php
+							$source=mysql_query("SELECT*FROM source");
+							while($rowsource=mysql_fetch_array($source))
+							{
+				?>
+								sourcecbo.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
+							}
+				?>
+							sourcecbo.setAttribute('id','source')
+									
+						);
+					var td1=document.createElement('td');
+						td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
+						td1.appendChild(
+							measurementcbo= document.createElement('select'),
+								measurementcbo.setAttribute('id','measurement'),
+				<?php
+							$measure=mysql_query("SELECT*FROM measurement");
+							while($rowmeasure=mysql_fetch_array($measure))
+							{
+				?>
+								measurementcbo.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
+							}
+				?>
+							measurementcbo.setAttribute('id','measurement')
+						);
+								td1.appendChild(
+							button=document.createElement('input'),
+							button.setAttribute('type','button'),
+							button.setAttribute('value','[+]'),
+							button.setAttribute('id','btnAddTime'),
+							button.setAttribute('name','#table'+cnt),
+							button.onclick=function(){
+							if($('#Time').val() != ""){ timeValue = $('#Time').val(); name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; is=1; getTableId = $(this).attr('name'); split1();    }else{   alert("please enter value for time to add measurement");   }
+
+								
+							}
+						);
+					var td2=document.createElement('td');
+						td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
+						td2.appendChild(
+							input = document.createElement('input'),
+							input.setAttribute('type','text'),
+							input.setAttribute('id','txtData'),
+							input.setAttribute('value','<?php  echo $rows['fData']; ?>')
 							
-								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
-			}
-?>
-			sourcecbo.setAttribute('id','source')
-					
-		);
-	var td1=document.createElement('td');
-		td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
-		td1.appendChild(
-			measurementcbo= document.createElement('select'),
-				measurementcbo.setAttribute('id','measurement'),
-<?php
-			$measure=mysql_query("SELECT*FROM measurement");
-			while($rowmeasure=mysql_fetch_array($measure))
-			{
-?>
-				measurementcbo.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
-			}
-?>
-			measurementcbo.setAttribute('id','measurement')
-		);
-				td1.appendChild(
-			button=document.createElement('input'),
-			button.setAttribute('type','button'),
-			button.setAttribute('value','[+]'),
-			button.setAttribute('id','btnAddTime'),
-			button.setAttribute('name','#table'+cnt),
-			button.onclick=function(){
-			if($('#Time').val() != ""){ timeValue = $('#Time').val(); name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; is=1; getTableId = $(this).attr('name'); split1();    }else{   alert("please enter value for time to add measurement");   }
-
-				
-			}
-		);
-	var td2=document.createElement('td');
-		td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
-		td2.appendChild(
-			input = document.createElement('input'),
-			input.setAttribute('type','text'),
-			input.setAttribute('id','txtData'),
-			input.setAttribute('value','<?php  echo $rows['fData']; ?>')
-			
-			
-		);
-	var td4=document.createElement('td');
-		td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
-		td4.appendChild(
-			button=document.createElement('input'),
-			button.setAttribute('type','button'),
-			button.setAttribute('value','Delete'),
-			button.setAttribute('id','btnDelete'),
-			button.onclick=function(){
-				$('#table'+cnt).remove();
-			}
-		);
-		
-		tr.appendChild(td3);
-		tr.appendChild(td1);
-		tr.appendChild(td);
-		
-		tr.appendChild(td2);
-		tr.appendChild(td4);
-		table.appendChild(tr);
-		div.appendChild(table);
-		$('#TableH1').append(div);
-	
+						);
+					var td4=document.createElement('td');
+						td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
+						td4.appendChild(
+							button=document.createElement('input'),
+							button.setAttribute('type','button'),
+							button.setAttribute('value','Delete'),
+							button.setAttribute('id','btnDelete'),
+							button.onclick=function(){
+								$('#table'+cnt).remove();
+							}
+						);
+						
+						tr.appendChild(td3);
+						tr.appendChild(td1);
+						tr.appendChild(td);
+						
+						tr.appendChild(td2);
+						tr.appendChild(td4);
+						table.appendChild(tr);
+						div.appendChild(table);
+						$('#TableH1').append(div);
+					
 	<?php
 	}
@@ -206,6 +206,5 @@
 		if(cnt==0)
 		{
-		$('#save').show();
-		$('#update').hide();
+		$('#save').attr('value','UPDATE');
 	var div= document.createElement("div");
 		div.setAttribute('id','TableHolder');
@@ -568,5 +567,5 @@
 	var timeValue;
 	var pad;
-	if(cnt==0){ cnt=2; }	
+	if(cnt==0){ cnt=1; }	
 	function split2()
 	{
