Index: schedule/function/SplitDelete.php
===================================================================
--- schedule/function/SplitDelete.php	(revision 16608)
+++ schedule/function/SplitDelete.php	(revision 16721)
@@ -1,13 +1,231 @@
 <script type="text/javascript">
  $(document).ready(function(){
+ 
  var timeValue;
 var meas;
 var meas2;
 var getTableId;
- window.cnt=2;
+ window.cnt=0;
+ 
+	
+
+	
+					//-------------------------------- fetch----------------------------//
+					
+			
+	
+							//-----------------------------------------------//
+									//end fetch						
+
+							//------------------------------------------------//
+	var x = 0;
+	
+	<?php    
+	
+	
+	include '../include/factdb.php';
+						 $day = $_GET['days'];
+						$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']);
+					$timestamp2 = date('Y-m-d',$timestamp);
+					$date_time = date('H:i',$timestamp);
+					//$time_new = $date_time->format('H:i:s')
+					if($days == $timestamp2){
+					
+					
+					?>
+					cnt++;
+				
+ 
+ 
  	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"+cnt),
+					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.onclick=function(){
+			
+			
+			
+			if($('#Time1').val() != ""){  var splitting = $('#Time1').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;
+
+						}
+
+			 meas = "name"; meas2 = "time";   getTableId = '#table'+cnt;  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'+cnt),
+<?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'+cnt)
+					
+		);
+	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'+cnt),
+<?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'+cnt)
+		);
+				td1.appendChild(
+			button=document.createElement('input'),
+			button.setAttribute('type','button'),
+			button.setAttribute('value','[+]'),
+			button.setAttribute('id','btnAddTime'),
+			button.onclick=function(){
+			if($('#Time1').val() != ""){ timeValue = $('#Time1').val();  meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; 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'+cnt),
+			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('id','btnSplit'),
+			button.setAttribute('value','Split'),
+			button.onclick= function()
+			{
+
+			if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 30;   
+
+
+			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
+
+						function pad(number, length) {
+				   
+							var str = '' + number;
+							while (str.length < length) {
+								str = '0' + str;
+							}
+				   
+						return str;
+
+						};
+
+			 meas = "name"; meas2 = "time";  getTableId = '#table'+cnt;  split1();    }else{   alert("please enter value for time to add measurement");   }
+
+				 
+				
+			}
+		);
+		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);
+	
+		$('#TableH1').append(table);
+	
+	<?php
+	}
+			}
+					?>
+					
+					if(cnt==0){
+					var table = document.createElement("table");
 		table.setAttribute('id',"table2");
 		table.setAttribute('width','100%');
 	var tr = document.createElement('tr');
+		tr.setAttribute('id','');
+		tr.setAttribute('class','');
 	var td3=document.createElement('td');
 		td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
@@ -19,5 +237,4 @@
 					input.setAttribute("min","1"),
 					input.setAttribute("required",true)
-				
 		);
 			td3.appendChild(
@@ -27,8 +244,5 @@
 			button.setAttribute('id','btnAddTime'),
 			button.onclick=function(){
-			
-			
-			
-			if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 01;   
+			if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -43,7 +257,5 @@
 						return str;
 
-						}
-
-			 meas = "name"; meas2 = "time";   getTableId = '#table2';  split1();    }else{   alert("please enter value for time to add measurement");   }
+						};  meas = "name"; meas2 = "time";  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -56,21 +268,18 @@
 				sourcecbo.setAttribute('id','source1'),
 <?php
-			$source=mysql_query("SELECT*FROM source");
-			while($rowsource=mysql_fetch_array($source))
-			{
-?>
+				$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']; ?>'),
-								option.setAttribute('selected',true),
-							
-								option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
-							
-				
-				),
-<?php
-			}
-?>
+							option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
+							option.setAttribute('selected',true),
+							option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
+				
+				),
+<?php
+				}
+ ?>
 			sourcecbo.setAttribute('id','source1')
 					
@@ -103,5 +312,5 @@
 			button.setAttribute('id','btnAddTime'),
 			button.onclick=function(){
-			if($('#Time1').val() != ""){ timeValue = $('#Time1').val();  meas = "hidden"; meas2 = true; getTableId = '#table2'; split1();    }else{   alert("please enter value for time to add measurement");   }
+			if($('#Time2').val() != ""){ timeValue = $('#Time2').val();  meas = "hidden"; meas2 = true;  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -114,5 +323,4 @@
 			input.setAttribute('type','text'),
 			input.setAttribute('id','txtData1')
-			
 			
 		);
@@ -126,7 +334,5 @@
 			button.onclick= function()
 			{
-
-			if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 30;   
-
+				 if($('#Time2').val() != ""){  var splitting = $('#Time2').val().split(':'); var add = 30;   
 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
@@ -141,10 +347,8 @@
 						return str;
 
-						};
-
-			 meas = "name"; meas2 = "time";  getTableId = '#table2';  split1();    }else{   alert("please enter value for time to add measurement");   }
-
+						}
+
+			 meas = "name"; meas2 = "time"; getTableId = '#table1';   split();    }else{   alert("please enter value for time to add measurement");   }
 				 
-				
 			}
 		);
@@ -155,8 +359,9 @@
 			button.setAttribute('id','btnDelete'),
 			button.onclick=function(){
-				$('#table2').remove();
-			}
-		);
-		
+				$('#table1').remove();
+
+			}
+		);
+	
 		tr.appendChild(td3);
 		tr.appendChild(td1);
@@ -166,8 +371,6 @@
 		tr.appendChild(td4);
 		table.appendChild(tr);
-	
+		
 		$('#TableH1').append(table);
-	
-		
 		
 	var table = document.createElement("table");
@@ -323,8 +526,10 @@
 		$('#TableH1').append(table);
 		
-		var meas;
+		
+	}
+	var meas;
 		var timeValue;
 		var pad;
-	
+	if(cnt==0){  cnt=2; }	
 	function split()
 	{
