Index: schedule/function/SplitDelete.php
===================================================================
--- schedule/function/SplitDelete.php	(revision 16816)
+++ schedule/function/SplitDelete.php	(revision 16873)
@@ -9,55 +9,32 @@
 var is=0;
  window.cnt=0;
- 
-	
-
-	
-					//-------------------------------- fetch----------------------------//
-					
-			
-	
-							//-----------------------------------------------//
-									//end fetch						
-
-							//------------------------------------------------//
 	var x = 0;
-	
 	<?php    
-	
-	
-	include '../include/factdb.php';
-						 
-						 
-						if(isset($_GET['days'])){ 
-						 $day = $_GET['days'];
-						 }else{
-						 
-						 $day =date("Y-m-d");
-						 
-						 }
-						 
-						 
-						$days = Date('Y-m-d',strtotime($day));
-						?>
-						//alert('<?php echo $day; ?>');
-						
-						<?php
-							
-						
-					$fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
-					
-					while($rows = mysql_fetch_array($fetch)){
-					$timestamp=strtotime($rows['fLastUpdate']);
+	include '../include/factdb.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") 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);
 					//$time_new = $date_time->format('H:i:s')
-					if($days == $timestamp2){
-					
-					
+					if($days == $timestamp2)
+					{
 					?>
 					cnt++;
 				
- 
- 
+	$('#save').hide();
+	$('#update').show();
+	var div= document.createElement("div");
+		div.setAttribute('id','TableHolder');
  	var table = document.createElement("table");
 		table.setAttribute('id',"table"+cnt);
@@ -69,5 +46,5 @@
 			input = document.createElement("input"),
 					input.setAttribute("type","time"),
-					input.setAttribute("id","Time"+cnt),
+					input.setAttribute("id","Time"),
 					input.setAttribute("max","24"),
 					input.setAttribute("min","1"),
@@ -81,10 +58,9 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.setAttribute('name','table'+cnt),
-			button.onclick=function(){
-			
-			
-			
-			if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
+			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]; 
@@ -121,5 +97,5 @@
 
 
-			name="name"; value=""; meas = "name"; meas2 = "time";   //getTableId = $(this).attr('name'); 
+			name="name"; value=""; meas = "name"; meas2 = "time";  // getTableId = $(this).attr('name'); 
 			split1();    }else{   alert("please enter value for time to add measurement");   }
 
@@ -131,5 +107,5 @@
 		td.appendChild(
 			sourcecbo= document.createElement('select'),
-				sourcecbo.setAttribute('id','source'+cnt),
+				sourcecbo.setAttribute('id','source'),
 <?php
 			$source=mysql_query("SELECT*FROM source");
@@ -151,5 +127,5 @@
 			}
 ?>
-			sourcecbo.setAttribute('id','source'+cnt)
+			sourcecbo.setAttribute('id','source')
 					
 		);
@@ -158,5 +134,5 @@
 		td1.appendChild(
 			measurementcbo= document.createElement('select'),
-				measurementcbo.setAttribute('id','measurement'+cnt),
+				measurementcbo.setAttribute('id','measurement'),
 <?php
 			$measure=mysql_query("SELECT*FROM measurement");
@@ -175,5 +151,5 @@
 			}
 ?>
-			measurementcbo.setAttribute('id','measurement'+cnt)
+			measurementcbo.setAttribute('id','measurement')
 		);
 				td1.appendChild(
@@ -181,8 +157,8 @@
 			button.setAttribute('type','button'),
 			button.setAttribute('value','[+]'),
-			button.setAttribute('id','btnAddTime'+cnt),
-			button.setAttribute('name','table'+cnt),
-			button.onclick=function(){
-			if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).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");   }
+			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");   }
 
 				
@@ -194,5 +170,5 @@
 			input = document.createElement('input'),
 			input.setAttribute('type','text'),
-			input.setAttribute('id','txtData'+cnt),
+			input.setAttribute('id','txtData'),
 			input.setAttribute('value','<?php  echo $rows['fData']; ?>')
 			
@@ -210,5 +186,5 @@
 			{
 
-			if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
+			if($('#Time').val() != ""){  var splitting = $('#Time').val().split(':'); var add = 30;   
 
 						
@@ -263,6 +239,6 @@
 		tr.appendChild(td4);
 		table.appendChild(tr);
-	
-		$('#TableH1').append(table);
+		div.appendChild(table);
+		$('#TableH1').append(div);
 	
 	<?php
@@ -271,6 +247,11 @@
 					?>
 					
-					if(cnt==0){
-					var table = document.createElement("table");
+		if(cnt==0)
+		{
+		$('#save').show();
+		$('#update').hide();
+	var div= document.createElement("div");
+		div.setAttribute('id','TableHolder');
+		var table = document.createElement("table");
 		table.setAttribute('id',"table2");
 		table.setAttribute('width','100%');
@@ -283,5 +264,5 @@
 			input = document.createElement("input"),
 					input.setAttribute("type","time"),
-					input.setAttribute("id","Time1"),
+					input.setAttribute("id","Time"),
 					input.setAttribute("max","24"),
 					input.setAttribute("min","1"),
@@ -295,5 +276,9 @@
 			button.setAttribute('name','#table2'),
 			button.onclick=function(){
-			if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01;   
+			var aa;
+			$('div#TableHolder #table2 #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != ""){ var splitting =aa.split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -313,5 +298,5 @@
 						
 $("table").each(function() {
-				if($(this).attr("name")=='table2'){
+				if($(this).attr("name")=='#table2'){
 				get = "#"+$(this).attr("id"); 
 				
@@ -335,5 +320,5 @@
 		td.appendChild(
 			sourcecbo= document.createElement('select'),
-				sourcecbo.setAttribute('id','source1'),
+				sourcecbo.setAttribute('id','source'),
 <?php
 				$source=mysql_query("SELECT*FROM source");
@@ -351,5 +336,5 @@
 				}
  ?>
-			sourcecbo.setAttribute('id','source1')
+			sourcecbo.setAttribute('id','source')
 					
 		);
@@ -358,5 +343,5 @@
 		td1.appendChild(
 			measurementcbo= document.createElement('select'),
-				measurementcbo.setAttribute('id','measurement1'),
+				measurementcbo.setAttribute('id','measurement'),
 <?php
 			$measure=mysql_query("SELECT*FROM measurement");
@@ -373,5 +358,5 @@
 			}
 ?>
-			measurementcbo.setAttribute('id','measurement1')
+			measurementcbo.setAttribute('id','measurement')
 		);
 				td1.appendChild(
@@ -382,5 +367,9 @@
 			button.setAttribute('name','#table2'),
 			button.onclick=function(){
-			if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); name="name"; value="table2";  meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name');  split2();    }else{   alert("please enter value for time to add measurement");   }
+			var aa;
+			$('div#TableHolder #table2 #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != ""){ timeValue =aa; name="name"; value=$(this).attr('name');  meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name');  split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -392,5 +381,5 @@
 			input = document.createElement('input'),
 			input.setAttribute('type','text'),
-			input.setAttribute('id','txtData1')
+			input.setAttribute('id','txtData')
 			
 		);
@@ -405,5 +394,9 @@
 			button.onclick= function()
 			{
-				 if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 30; var limit = 60;
+			var aa;
+			$('div#TableHolder #table2 #Time').each(function(){
+					aa = $(this).val();
+					});
+				 if(aa != ""){  var splitting = aa.split(':'); var add = 30; var limit = 60;
 				var adds =0;
 				adds =  (Number(splitting[1]) + Number(add));
@@ -438,5 +431,5 @@
 			button.setAttribute('id','btnDelete'),
 			button.onclick=function(){
-				$('#table1').remove();
+				$('#table2').remove();
 
 			}
@@ -450,7 +443,9 @@
 		tr.appendChild(td4);
 		table.appendChild(tr);
+		div.appendChild(table);
+		$('#TableH1').append(div);
 		
-		$('#TableH1').append(table);
-		
+	var div= document.createElement("div");
+		div.setAttribute('id','TableHolder');	
 	var table = document.createElement("table");
 		table.setAttribute('id',"table1");
@@ -464,5 +459,5 @@
 			input = document.createElement("input"),
 					input.setAttribute("type","time"),
-					input.setAttribute("id","Time2"),
+					input.setAttribute("id","Time"),
 					input.setAttribute("max","24"),
 					input.setAttribute("min","1"),
@@ -476,5 +471,10 @@
 			button.setAttribute('name','#table1'),
 			button.onclick=function(){
-			if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;   
+			var aa;
+			$('div#TableHolder #table1 #Time').each(function(){
+					aa = $(this).val();
+					});
+			
+			if(aa != ""){ var splitting = aa.split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -495,5 +495,5 @@
 						
 $("table").each(function() {
-				if($(this).attr("name")=='table1'){
+				if($(this).attr("name")=='#table1'){
 				get = "#"+$(this).attr("id"); 
 				
@@ -501,5 +501,5 @@
 				}else{
 				if(s==0){
-				get = '#table'+cnt;
+				get =  '#table'+cnt;
 				}
 				}
@@ -518,5 +518,5 @@
 		td.appendChild(
 			sourcecbo= document.createElement('select'),
-				sourcecbo.setAttribute('id','source2'),
+				sourcecbo.setAttribute('id','source'),
 <?php
 				$source=mysql_query("SELECT*FROM source");
@@ -534,5 +534,5 @@
 				}
  ?>
-			sourcecbo.setAttribute('id','source2')
+			sourcecbo.setAttribute('id','source')
 					
 		);
@@ -541,5 +541,5 @@
 		td1.appendChild(
 			measurementcbo= document.createElement('select'),
-				measurementcbo.setAttribute('id','measurement2'),
+				measurementcbo.setAttribute('id','measurement'),
 <?php
 			$measure=mysql_query("SELECT*FROM measurement");
@@ -556,5 +556,5 @@
 			}
 ?>
-			measurementcbo.setAttribute('id','measurement2')
+			measurementcbo.setAttribute('id','measurement')
 		);
 				td1.appendChild(
@@ -565,5 +565,10 @@
 			button.setAttribute('name','#table1'),
 			button.onclick=function(){
-			if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); name="name"; value="table1"; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name'); split2();    }else{   alert("please enter value for time to add measurement");   }
+			var aa;
+			$('div#TableHolder #table1 #Time').each(function(){
+					aa = $(this).val();
+					});
+			
+			if(aa != ""){ timeValue = aa; name="name"; value="#table1"; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name'); split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -575,5 +580,5 @@
 			input = document.createElement('input'),
 			input.setAttribute('type','text'),
-			input.setAttribute('id','txtData2')
+			input.setAttribute('id','txtData')
 			
 		);
@@ -588,5 +593,9 @@
 			button.onclick= function()
 			{
-				 if($('#Time2').val() != ""){  var splitting = $('#Time2').val().split(':'); var add = 30;   
+			var aa;
+			$('div#TableHolder #table1 #Time').each(function(){
+					aa = $(this).val();
+					});
+				 if(aa != ""){  var splitting = aa.split(':'); var add = 30;   
 
 			var limit = 60;
@@ -640,6 +649,6 @@
 		tr.appendChild(td4);
 		table.appendChild(tr);
-		
-		$('#TableH1').append(table);
+		div.appendChild(table);
+		$('#TableH1').append(div);
 		
 		
@@ -653,4 +662,6 @@
 	
 		cnt++;
+		var div= document.createElement("div");
+		div.setAttribute('id','TableHolder');
 		var table = document.createElement("table");
 			table.setAttribute('id',"table"+cnt);
@@ -668,5 +679,5 @@
 				input = document.createElement("input"),
 						input.setAttribute("type","time"),
-						input.setAttribute("id","Time"+cnt),
+						input.setAttribute("id","Time"),
 						input.setAttribute("max","24"),
 						input.setAttribute("min","1"),
@@ -683,8 +694,12 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
-			button.setAttribute('name','table'+cnt),
-			
-			button.onclick=function(){
-			if($('#Time'+cnt).val() != ""){var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
+			button.setAttribute('name','#table'+cnt),
+			
+			button.onclick=function(){
+			var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != ""){var splitting = aa.split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -728,5 +743,5 @@
 			td.appendChild(
 				sourcecbo= document.createElement('select'),
-					sourcecbo.setAttribute('id','source'+cnt),
+					sourcecbo.setAttribute('id','source'),
 <?php
 				$source=mysql_query("SELECT*FROM source");
@@ -744,5 +759,5 @@
 				}
  ?>
-				sourcecbo.setAttribute('id','source'+cnt)
+				sourcecbo.setAttribute('id','source')
 						
 			);
@@ -751,5 +766,5 @@
 			td1.appendChild(
 				measurementcbo= document.createElement('select'),
-					measurementcbo.setAttribute('id','measurement'+cnt),
+					measurementcbo.setAttribute('id','measurement'),
 <?php
 			$measure=mysql_query("SELECT*FROM measurement");
@@ -766,5 +781,5 @@
 			}
 ?>
-			measurementcbo.setAttribute('id','measurement'+cnt)
+			measurementcbo.setAttribute('id','measurement')
 			);
 					td1.appendChild(
@@ -775,10 +790,13 @@
 			button.setAttribute('name','#table'+cnt),
 			button.onclick=function(){
-		
-			if($('#Time'+cnt).val() != "")
+		var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != "")
 			{ 
 				name = "name";
-				value = "table"+cnt;
-				timeValue = $('#Time'+cnt).val();
+				value = "#table"+cnt;
+				timeValue = aa;
 				meas = "hidden"; 
 				meas2 = true;
@@ -800,5 +818,5 @@
 				input = document.createElement('input'),
 				input.setAttribute('type','text'),
-				input.setAttribute('id','txtData'+cnt)
+				input.setAttribute('id','txtData')
 				
 			);
@@ -812,5 +830,9 @@
 				button.setAttribute('name','#table'+cnt),
 				button.onclick=function(){
-				 if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
+				var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+				 if(aa != ""){  var splitting = aa.split(':'); var add = 30;   
 
 			var limit = 60;
@@ -861,6 +883,6 @@
 			tr.appendChild(td4);
 			table.appendChild(tr);
-	
-			$(table).insertAfter($(getTableId));
+			div.appendChild(table);
+			$(div).insertAfter($(getTableId));
 	
 	
@@ -871,4 +893,6 @@
 	
 		cnt++;
+		var div= document.createElement("div");
+		div.setAttribute('id','TableHolder');
 		var table = document.createElement("table");
 			table.setAttribute('id',"table"+cnt);
@@ -885,5 +909,5 @@
 				input = document.createElement("input"),
 						input.setAttribute("type","time"),
-						input.setAttribute("id","Time"+cnt),
+						input.setAttribute("id","Time"),
 						input.setAttribute("max","24"),
 						input.setAttribute("min","1"),
@@ -898,8 +922,12 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
-			button.setAttribute('name','table'+cnt),
-			
-			button.onclick=function(){
-			if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
+			button.setAttribute('name','#table'+cnt),
+			
+			button.onclick=function(){
+			var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != ""){ var splitting = aa.split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -941,5 +969,5 @@
 			td.appendChild(
 				sourcecbo= document.createElement('select'),
-					sourcecbo.setAttribute('id','source'+cnt),
+					sourcecbo.setAttribute('id','source'),
 <?php
 				$source=mysql_query("SELECT*FROM source");
@@ -957,5 +985,5 @@
 				}
  ?>
-				sourcecbo.setAttribute('id','source'+cnt)
+				sourcecbo.setAttribute('id','source')
 						
 			);
@@ -965,5 +993,5 @@
 			td1.appendChild(
 				measurementcbo= document.createElement('select'),
-					measurementcbo.setAttribute('id','measurement'+cnt),
+					measurementcbo.setAttribute('id','measurement'),
 <?php
 			$measure=mysql_query("SELECT*FROM measurement");
@@ -980,5 +1008,5 @@
 			}
 ?>
-			measurementcbo.setAttribute('id','measurement'+cnt)
+			measurementcbo.setAttribute('id','measurement')
 			);
 				td1.appendChild(
@@ -989,6 +1017,9 @@
 			button.setAttribute('name','#table'+cnt),
 			button.onclick=function(){
-		
-			if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); 				
+		var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+			if(aa != ""){ timeValue = aa; 				
 			name = "name"; value = $(this).attr('name');  meas = "hidden"; meas2 = true; getTableId = $(this).attr('name');   split1();    }else{   alert("please enter value for time to add measurement");   }
 
@@ -1002,5 +1033,5 @@
 				input = document.createElement('input'),
 				input.setAttribute('type','text'),
-				input.setAttribute('id','txtData'+cnt)
+				input.setAttribute('id','txtData')
 				
 			);
@@ -1014,5 +1045,9 @@
 				button.setAttribute('name','#table'+cnt),
 				button.onclick=function(){
-				 if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
+				var aa;
+			$('div#TableHolder #table'+cnt+' #Time').each(function(){
+					aa = $(this).val();
+					});
+				 if(aa != ""){  var splitting = aa.split(':'); var add = 30;   
 
 		var limit = 60;
@@ -1058,6 +1093,6 @@
 			tr.appendChild(td4);
 			table.appendChild(tr);
-			
-			$(table).insertAfter($(getTableId));
+			div.appendChild(table);
+			$(div).insertAfter($(getTableId));
 	}
 	
