Index: schedule/Module/control.php
===================================================================
--- schedule/Module/control.php	(revision 17506)
+++ schedule/Module/control.php	(revision 17508)
@@ -134,17 +134,16 @@
 <?php
 $cnt=0;
+$day=0;
 if(isset($_GET['days']))
 { 
- $day = $_GET['days'];
+    $day = $_GET['days'];
 }
 else
 {
- $day =date("Y-m-d");		 
+    $day =date("Y-m-d");
 }
-
-//	$day=$_GET['days'];
-$days = Date('Y-m-d',strtotime($day));	
 $prev_time = array();
-?>
+?>addRowClone();
+
 function addRowClone1(nextrow){
 	var targetView = document.getElementById("Data");
@@ -154,5 +153,9 @@
 	var newlist = list+1;
 	var cctr=$('.dataTable tr').length;
-		 ctr=cctr+1;
+        ctr=cctr+1;
+        var input_data;
+        var select;
+        var option;
+        var selection;
 	var newdiv   = document.createElement("div");
 		newdiv.setAttribute("id","list_"+newlist);
@@ -305,15 +308,18 @@
 
 function addRowClone(nextrow){
-<?php
-$fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$days' ORDER BY fScheduleID AND fMeasurementID ASC") or die(mysql_error());
+    <?php
+        $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC, fMeasurementID ASC") or die(mysql_error());
+$observationsTime = mysql_query("SELECT DISTINCT fStart FROM schedule WHERE date(fStart) = '$day'");
 $cnt3=0;
 $cnt2=0;
 $cnt4 = 0;
 $cnt5 = 0;
+$cnt = 0;
 //$data  = array();
 //$counter=0;
-	while($rows = mysql_fetch_array($fetch))
+	while($times = mysql_fetch_array($observationsTime))
 	{
-		$timestamp=strtotime($rows['fStart']);
+            $timestamp=strtotime($times['fStart']);
+        $actualtime = date('Y-m-d H:i:s', $timestamp);
 		$timestamp2 = date('Y-m-d',$timestamp);
 		$date_time = date('H:i:s',$timestamp);
@@ -328,5 +334,9 @@
 			
 			var cctr=$('.dataTable tr').length;
-				 ctr=cctr+1;
+                        ctr=cctr+1;
+                        var input_data;
+                        var select;
+                        var option;
+                        var selection;
 				 
 			var newdiv   = document.createElement("div");
@@ -367,9 +377,16 @@
 					input_data.setAttribute("value","+"),
 					input_data.onclick = function(){
-						addRowClone1("list_<?php echo $cnt; ?>");
+						addRowClone1("list_<?php echo $cnt+1; ?>");
 					}
 				);
-			
-			var newtr<?php echo $cnt; ?> = document.createElement("tr");
+                                
+                                    <?php
+                                    $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'");
+
+                                while($rows = mysql_fetch_array($observations))
+                                {
+                                    ?>
+
+                                    var newtr<?php echo $cnt; ?> = document.createElement("tr");
 				newtr<?php echo $cnt; ?>.setAttribute('class','tr');
 			
@@ -405,5 +422,5 @@
 					input_data.setAttribute("value","+"),
 					input_data.onclick = function(){ 
-					return addRow(newtr<?php echo $cnt; ?>);
+					return addRowClone1(newtr<?php echo $cnt; ?>);
 						ctr++;
 					});
@@ -460,5 +477,11 @@
 			newInnertable.appendChild(newtr<?php echo $cnt; ?>);
 			
-			
+                            <?php
+
+                                $cnt++;
+                        $prevtimestamp = $timestamp;
+                                }
+                                ?>
+
 			var newtd_c6 = document.createElement("td");
 				newtd_c6.appendChild(newInnertable);
@@ -489,8 +512,5 @@
 			}
 	<?php
-//$rows = mysql_fetch_array($fetch);	
-			
-		$cnt++;
-	}
+}
 if(mysql_num_rows($fetch)<1)
 {
