Index: /schedule/Module/control.php
===================================================================
--- /schedule/Module/control.php	(revision 17515)
+++ /schedule/Module/control.php	(revision 17516)
@@ -1,5 +1,7 @@
 <script>
 'use strict';
-	var ctr;
+var ctr;
+var testdata = "old data";
+var pastdata = false;
 	
     function clearNode(node){
@@ -138,5 +140,6 @@
 <?php
 $cnt=0;
-        $day=0;
+$pastdate = 'false';
+$day=0;
 if(isset($_GET['days']))
 { 
@@ -315,6 +318,6 @@
 
 function addRowClone(nextrow){
-    <?php
-        $fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart) = '$day' ORDER BY fScheduleID ASC, 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;
@@ -324,4 +327,6 @@
 $cnt = 0;
 $cntrow = 0;
+$pastdate =  'false' ;
+$pasttime = 'false';
 //$data  = array();
 //$counter=0;
@@ -329,11 +334,22 @@
 	{
             $timestamp=strtotime($times['fStart']);
+        $curdate = strtotime(date('Y-m-d'));
         $actualtime = date('Y-m-d H:i:s', $timestamp);
 		$timestamp2 = date('Y-m-d',$timestamp);
 		$date_time = date('H:i',$timestamp);
-		$prev_time[$cnt3]= $date_time;
-			?>
-			$('#save').attr('value','UPDATE');
-			var targetView = document.getElementById("Data");
+                $prev_time[$cnt3]= $date_time;
+                if(strtotime($timestamp2) < strtotime(date('Y-m-d'))) {
+                      $pastdate = 'true';
+                }
+                else if(strtotime($timestamp2) == strtotime(date('Y-m-d'))) {
+                    if(strtotime($date_time) < strtotime(date('H:i'))) {
+                          $pastdate = 'true';
+                    }
+                } else {
+                    $pastdate = 'false';
+                }
+                ?>
+                    $('#save').attr('value','UPDATE');
+		       var targetView = document.getElementById("Data");
 			// CREATE ELEMENT
 			// COUNT LIST
@@ -344,6 +360,6 @@
 			var cctr=$('.dataTable tr').length;
                         ctr=cctr+1;
+                        var select;
                         var input_data;
-                        var select;
                         var option;
                         var selection;
@@ -374,59 +390,166 @@
                                 newtd_c1.setAttribute("align","center");
                                 newtd_c1.setAttribute("valign", "top");
-				newtd_c1.appendChild(
-					input_data = document.createElement("input"),
-					input_data.setAttribute("type","time"),
+                                <?php if ($pastdate == 'true') { ?>
+                                    newtd_c1.appendChild(
+                                        input_data = document.createElement("input"),
+                                        input_data.setAttribute("type","time"),
 					input_data.setAttribute("class","time"),
 					input_data.setAttribute("size","10"),
 					input_data.setAttribute("value","<?php echo $date_time; ?>"),
-					input_data.setAttribute("autofocus","true")
-				);
-				newtd_c1.appendChild(
-					input_data = document.createElement("input"),
-					input_data.setAttribute("type","button"),
-					input_data.setAttribute("value","+"),
-					input_data.onclick = function(){
+                                        input_data.setAttribute("autofocus","true"),
+                                        input_data.setAttribute("disabled")
+                                         );
+                                    newtd_c1.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+                                        input_data.setAttribute("value","+"),
+                                        input_data.setAttribute("disabled"),
+                                        input_data.onclick = function(){
                                             addRowCloneNew("list_<?php echo $cnt; ?>");
                                         }
+				       );
+                                         
+<?php } else { ?>
+                                    newtd_c1.appendChild(
+                                        input_data = document.createElement("input"),
+                                        input_data.setAttribute("type","time"),
+					input_data.setAttribute("class","time"),
+					input_data.setAttribute("size","10"),
+					input_data.setAttribute("value","<?php echo $date_time; ?>"),
+                                        input_data.setAttribute("autofocus","true")
+                                         );
+                                    newtd_c1.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+                                        input_data.setAttribute("value","+"),
+                                        input_data.onclick = function(){
+                                            addRowCloneNew("list_<?php echo $cnt; ?>");
+                                        }
+				       );
+                        <?php }
+                        $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'");
+
+                        while($rows = mysql_fetch_array($observations))
+                        {
+                            $cntrow++;
+                        ?>
+
+                                var newtr<?php echo $cntrow; ?> = document.createElement("tr");
+                                newtr<?php echo $cntrow; ?>.setAttribute('class','tr');
+
+                        <?php if ($pastdate == 'true') { ?>                             		       
+                                var newtd_c2 = document.createElement("td");
+				newtd_c2.setAttribute("width","138");
+                                newtd_c2.setAttribute("align","center");
+                                newtd_c2.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']; ?>"),
+				   <?php  if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";}   ?>
+				   option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
+				   ),
+                                   <?php 
+                                   } 
+                                   ?>
+				   selection.setAttribute('id','measure'),
+                                   selection.setAttribute('class','measure'),
+                                   selection.setAttribute("disabled")
+                                );
+                                newtd_c2.setAttribute("width","115");
+                                newtd_c2.setAttribute("align","center");
+                                newtd_c2.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+                                        input_data.setAttribute("value","+"),
+                                        input_data.setAttribute("disabled"),
+					input_data.onclick = function(){ 
+                                            return addRow(newtr<?php echo $cntrow; ?>);
+                                            	 ctr++;
+					});
+
+                                var newtd_c3 = document.createElement("td");
+				newtd_c3.setAttribute("width","98");
+				newtd_c3.setAttribute("align","center");
+				newtd_c3.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']; ?>'),
+					<?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?>
+					option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
+					),
+                                <?php
+                                } 
+                                ?>
+                                selection.setAttribute('id','source'),																			// End of retrieving
+                                selection.setAttribute('class','source'),
+                                selection.setAttribute("disabled")
+                                    // End of retrieving
 				);
-                                
-                                    <?php
-                                    $observations = mysql_query("SELECT * FROM schedule WHERE fStart = '$actualtime'");
-
-                                while($rows = mysql_fetch_array($observations))
-                                {
-                                    $cntrow++;
-                                          ?>
-
-                                    var newtr<?php echo $cntrow; ?> = document.createElement("tr");
-                                    newtr<?php echo $cntrow; ?>.setAttribute('class','tr');
-                                    		       
-			var newtd_c2 = document.createElement("td");
+
+                                var newtd_c4 = document.createElement("td");
+				newtd_c4.setAttribute("width","119");
+				newtd_c4.setAttribute("align","center");
+                                newtd_c4.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","text"),
+					input_data.setAttribute("class","selected"),
+					input_data.setAttribute("size","12"),
+					input_data.setAttribute("value","<?php echo $rows['fData']; ?>"),
+                                        input_data.setAttribute("placeholder","Value"),
+                                        input_data.setAttribute("disabled")
+				);
+
+                                var newtd_c5 = document.createElement("td");
+				newtd_c5.setAttribute("width","115");
+				newtd_c5.setAttribute("align","center");
+				newtd_c5.setAttribute("width","115");
+                                newtd_c5.setAttribute("align","center");
+                                newtd_c5.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+                                        input_data.setAttribute("value","Delete"),
+                                        input_data.setAttribute("disabled"),
+                                        input_data.onclick = function(){
+                                            return clearNode(newtr<?php echo $cntrow; ?>);
+                                        }
+                                );
+                        <?php } else  { ?>
+                                var newtd_c2 = document.createElement("td");
 				newtd_c2.setAttribute("width","138");
-				newtd_c2.setAttribute("align","center");
-				newtd_c2.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']; ?>"),
-					<?php  if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";}   ?>
-					option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
-					),
-		<?php 
-		} 
-		?>
-						
-						
-					selection.setAttribute('id','measure'),
-					selection.setAttribute('class','measure')
-				);
-				newtd_c2.setAttribute("width","115");
-				newtd_c2.setAttribute("align","center");
-				newtd_c2.appendChild(
+                                newtd_c2.setAttribute("align","center");
+                                newtd_c2.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']; ?>"),
+				   <?php  if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";}   ?>
+				   option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
+				   ),
+                                   <?php 
+                                   } 
+                                   ?>
+				   selection.setAttribute('id','measure'),
+				   selection.setAttribute('class','measure')
+                                );
+                                newtd_c2.setAttribute("width","115");
+                                newtd_c2.setAttribute("align","center");
+                                newtd_c2.appendChild(
 					input_data = document.createElement("input"),
 					input_data.setAttribute("type","button"),
@@ -436,31 +559,32 @@
                                             	 ctr++;
 					});
-			var newtd_c3 = document.createElement("td");
+
+                                var newtd_c3 = document.createElement("td");
 				newtd_c3.setAttribute("width","98");
 				newtd_c3.setAttribute("align","center");
 				newtd_c3.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']; ?>'),
-						<?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?>
-						option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
-						),
-		<?php
-		} 
-		?>
-					
-					selection.setAttribute('id','source'),																			// End of retrieving
-					selection.setAttribute('class','source')																			// End of retrieving
+                                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']; ?>'),
+					<?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo "option.setAttribute('selected',true),"; } ?>
+					option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
+					),
+                                <?php
+                                } 
+                                ?>
+                                selection.setAttribute('id','source'),																			// End of retrieving
+				selection.setAttribute('class','source')																			// End of retrieving
 				);
-			var newtd_c4 = document.createElement("td");
+
+                                var newtd_c4 = document.createElement("td");
 				newtd_c4.setAttribute("width","119");
 				newtd_c4.setAttribute("align","center");
-				newtd_c4.appendChild(
+                                newtd_c4.appendChild(
 					input_data = document.createElement("input"),
 					input_data.setAttribute("type","text"),
@@ -470,5 +594,6 @@
 					input_data.setAttribute("placeholder","Value")
 				);
-			var newtd_c5 = document.createElement("td");
+
+                                var newtd_c5 = document.createElement("td");
 				newtd_c5.setAttribute("width","115");
 				newtd_c5.setAttribute("align","center");
@@ -482,5 +607,6 @@
 
 					}
-				);
+                                );
+                        <?php } ?>
 			newtr<?php echo $cntrow; ?>.appendChild(newtd_c2);
 			newtr<?php echo $cntrow; ?>.appendChild(newtd_c3);
@@ -496,5 +622,5 @@
 
 			var newtd_c6 = document.createElement("td");
-				newtd_c6.appendChild(newInnertable);
+                        newtd_c6.appendChild(newInnertable);
 
 			var newtd_c7 = document.createElement("td");
@@ -502,10 +628,20 @@
                                 newtd_c7.setAttribute("align","center");
                                 newtd_c7.setAttribute("valign", "top");
-				newtd_c7.appendChild(
+                                <?php if ($pastdate == 'true') { ?>
+                                newtd_c7.appendChild(
+					input_data = document.createElement("input"),
+					input_data.setAttribute("type","button"),
+                                        input_data.setAttribute("value","Delete Main"),
+                                        input_data.setAttribute("disabled"),
+					input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); }
+                                );
+                                <?php } else { ?>
+                                newtd_c7.appendChild(
 					input_data = document.createElement("input"),
 					input_data.setAttribute("type","button"),
 					input_data.setAttribute("value","Delete Main"),
 					input_data.onclick = function(){ return clearNode(newdiv<?php echo $cnt; ?>); }
-				);
+                                );
+                                <?php } ?>
 
 			var newOutertr = document.createElement("tr");
@@ -537,4 +673,8 @@
 			
 }
- </script>
+
+$('#LoadPrev').click(function() {
+
+});
+</script>
 	
