Index: /schedule/Module/Scheduling.php
===================================================================
--- /schedule/Module/Scheduling.php	(revision 17421)
+++ /schedule/Module/Scheduling.php	(revision 17422)
@@ -1,5 +1,5 @@
 <?php
 	include '../include/factdb.php';
-	include '../function/SplitDelete.php';
+	include 'control.php';
 ?>
 <table width="100%" id="TableHolder" >
@@ -13,14 +13,6 @@
 		<td width="141" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center" >Transaction</td>
 	</tr>
-
 </table>
 	<div id="Data">
+		<script>addRowClone();</script>
 	</div>
-<table width="100%">
-	<tr>
-	
-	
-		<td style="border:0px solid white; color:#37DFB1; font-size:14px;"  width="80%" align="center">&nbsp;</td>
-	
-	</tr>
-</table>
Index: /schedule/Module/calendar.php
===================================================================
--- /schedule/Module/calendar.php	(revision 17421)
+++ /schedule/Module/calendar.php	(revision 17422)
@@ -58,45 +58,27 @@
             var CAL = Calendar.setup({
                     cont: "cont",
-                   // weekNumbers: true,
                     selectionType: Calendar.SEL_MULTIPLE,
                     showTime: 24,
-					//fdow     : 1,
 					dateInfo:getDateInfo
-                    // titleFormat: "%B %Y"
             })
           </script>
 		  </td>
-
             <tr>
               <td>
 				<script type="text/javascript">
-					$(document).ready(function(){
-						Graph();
-					});
-					</script>
-                <script type="text/javascript">
+				$(document).ready(function(){
+					Graph();
+				});
 				var day;
 				var year;
 				var month;
                  CAL.addEventListener("onSelect", function(){
-							day =this.selection.print("%d").join("\n");
-							month =this.selection.print("%m").join("\n");
-							year =this.selection.print("%Y").join("\n");	
-                             GetData();
-							GetDate();
-						$('#Scheduling').load('Module/Scheduling.php?days='+year+'-'+month+'-'+day);
-							//$.get("function/function.php", {days:year+'-'+month+'-'+day});
-							//$load("function/function.php?days:year+-'+month+'-'+day);
-						//$.get("function/SplitDelete.php", {days:year+'-'+month+'-'+day});
-						 
-
-							 //GetDate();
-							
-
-                        	
-                });
-						
-						
-							
+						day =this.selection.print("%d").join("\n");
+						month =this.selection.print("%m").join("\n");
+						year =this.selection.print("%Y").join("\n");	
+						GetData();
+						GetDate(day,month,year);
+						$('#Scheduling').load('Module/Scheduling.php?days='+year+'-'+month+'-'+day);   	
+                });							
                </script>
               </td>
@@ -107,5 +89,4 @@
       </tr>
     </table>
-
   </body>
 </html>
Index: /schedule/Module/link.php
===================================================================
--- /schedule/Module/link.php	(revision 17421)
+++ /schedule/Module/link.php	(revision 17422)
@@ -1,10 +1,3 @@
-
-
-
-
-
-
-
-<script src="js/jquery-1.9.1.js"></script>
+<script src="js/jquery-1.7.1.js"></script>
 <script src="js/jquery-ui-1.10.1.custom.js"></script>
 <link href="css/jquery-ui-1.10.1.custom.css" rel="stylesheet">
Index: /schedule/Transaction/insert.php
===================================================================
--- /schedule/Transaction/insert.php	(revision 17421)
+++ /schedule/Transaction/insert.php	(revision 17422)
@@ -1,33 +1,22 @@
-<?php
-//Build by: khristofer Usman
-//Modified by: Jaypee Tanio
-// June 14,2013
+ <?php
+//connect to the mysql
+$db = mysql_connect('localhost', 'root', '') or die("Could not connect database");
+mysql_select_db('sandboxschedule', $db) or die("Could not select database");
 
-include '../include/factdb.php';
- $Time =$_POST['Time'];
- $SelectedSource = $_POST['Source'];
- $Date = $_POST['Date'];
- echo $Date;
- $SelectedMeasure = $_POST['measure'];
-$value = $_POST['Data'];
-$date = $_POST['Date'];
-echo "<br />";
-$n_value = explode(",",$value);
-$Times = explode(",",$Time);
-$select = explode(",",$SelectedSource);
-$measure = explode(",",$SelectedMeasure);
-$limtex = count(explode(",",$SelectedMeasure));
-echo "<br />";
-for($i=0;$i<=$limtex-1;$i++)
-{
-	$n1 = $n_value[$i];		
-	$selectf = $select[$i];	
-	$measuref = $measure[$i];
-	$dateTime=new DateTime($date." ".$Times[$i]);
-	$parsed_date =  $dateTime->format('Y-m-d H:i:s');
+
+	$GTimes=$_POST['GTime'];
+	$Source=$_POST['Source'];
+	$measure=$_POST['measure'];
+	$data=$_POST['Data'];
+	$Gdates = $_POST['GDate'];
+	$seq = $_POST['seq'];
 	
-		mysql_query("INSERT INTO schedule VALUES('null','".$parsed_date."','".$UpdateDate."','".$measuref."','','".$n1."','".$selectf."','".$measuref."')");	
-			
-}
+	$date = new DateTime($Gdates.$GTimes);
+	$par=$date->format('Y-m-d H:i:s');
+	$Timez = new DateTime($GTimes);
+	$part = $Timez->format('H:i:s');	
+			//database query
+			mysql_query("INSERT INTO schedule VALUES('null','".$par."','".$part."','".$seq."','','".$data."','".$Source."','".$measure."')");
+	
 	
 ?>
Index: /schedule/Transaction/update.php
===================================================================
--- /schedule/Transaction/update.php	(revision 17421)
+++ /schedule/Transaction/update.php	(revision 17422)
@@ -1,54 +1,33 @@
-
-<?php
-//Build by: khristofer Usman
-//Modified by: Jaypee Tanio
-// June 22,2013
-include '../include/factdb.php';
-$Time =$_POST['Time'];
-$SelectedSource = $_POST['Source'];
-$SelectedMeasure = $_POST['measure'];
-$limtex = count(explode(",",$SelectedSource));
-$Upd=$_POST['upd'];
-$Upt=$_POST['upt'];
-$value = $_POST['Data'];
-$date = $_POST['Date'];
-$n_value = explode(",",$value);
-$Times = explode(",",$Time);
-$select = explode(",",$SelectedSource);
-$measure = explode(",",$SelectedMeasure);
-//date_default_timezone_set('Asia/Manila'); // Setting up the localTimeZone in asia
-$UpdateDate=(date('Y-m-d H:i:s'));
+ <?php
+//connect to the mysql
+$db = mysql_connect('localhost', 'root', '') or die("Could not connect database");
+mysql_select_db('sandboxschedule', $db) or die("Could not select database");
 
 
-						$days = Date('Y-m-d',strtotime($date));
+	$GTimes=$_POST['GTime'];
+	$Source=$_POST['Source'];
+	$measure=$_POST['measure'];
+	$data=$_POST['Data'];
+	$Gdates = $_POST['GDate'];
+	$seq = $_POST['seq'];
+	
+	$date = new DateTime($Gdates.$GTimes);
+	$par=$date->format('Y-m-d H:i:s');
+	$UpdateDate=(date('Y-m-d H:i:s'));
 
-			$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)
-						{
-
-						$delete = mysql_query("DELETE FROM `schedule` WHERE `fStart`='{$rows['fStart']}'");
+			$days = Date('Y-m-d',strtotime($Gdates));
+			$cnt = 0;
+			//QUERY TO DELETE THE TABLE INSIDE THE DATABASE
+			//$fetch = mysql_query("SELECT * FROM schedule WHERE date(fStart)='$days'") or die(mysql_error());			
+			//while($rows = mysql_fetch_array($fetch)){
+				//$update=mysql_query("UPDATE schedule SET `fStart`='$par',`fLastUpdate`='$UpdateDate',`fMeasurementID`='$seq',`fData`='$data',`fSourceKey`='$Source',`fMeasurementTypeKey`='$measure' WHERE fScheduleID = '".$rows['fSchecduleID']."' ");
+				
+				//mysql_query("DELETE FROM schedule WHERE date(fStart)='".$rows['fStart']."'");
+				mysql_query("INSERT INTO schedule VALUES('null','".$par."','".$UpdateDate."','".$seq."','','".$data."','".$Source."','".$measure."')");
+			//}	
 			
-						}
-					}
-					
-
-for($i=0;$i<=$limtex-1;$i++)
-{
-$select = explode(",",$SelectedSource);
-	$n1 = $n_value[$i];		
-	$selectf = $select[$i];	
-	$measuref = $measure[$i];
-	$dateTime=new DateTime($date." ".$Times[$i]);
-	$parsed_date =  $dateTime->format('Y-m-d H:i:s');
+			
+				//$delete = mysql_query("DELETE FROM `schedule` WHERE `fStart`='{$rows['fStart']}'");
+			//database query
 	
-		mysql_query("INSERT INTO schedule VALUES('null','".$parsed_date."','".$UpdateDate."','".$measuref."','','".$n1."','".$selectf."','".$measuref."')");	
-			
-}	
 ?>
Index: /schedule/authenticate/body.php
===================================================================
--- /schedule/authenticate/body.php	(revision 17421)
+++ /schedule/authenticate/body.php	(revision 17422)
@@ -1,13 +1,2 @@
- <?php
-
-ini_set('error_reporting', E_ALL | E_STRICT);
-ini_set('display_errors', 'Off');
-include 'function/sourcelist.php';
-
-//include 'function/function.php';
- ?>
-
-
-
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -17,6 +6,7 @@
         <meta name="keywords" content="" />
         <meta name="description" content="" />
-			<script src="js/function.js"></script>
-        <link href="css/styles.css" rel="stylesheet" type="text/css" media="screen" />
+		<script src="js/function.js"></script>
+		<?php include 'Module/control.php';		?>
+		<link href="css/styles.css" rel="stylesheet" type="text/css" media="screen" />
     </head>
     <body style="background-color: #000;">
@@ -24,77 +14,44 @@
 			<div id="wrapper1">
 					<div id="header2">
-						<ul>
-						<li><a href="http://www.fact-project.org">FACT <li2>OBSERVATION SCHEDULING</li2></a></li>
-						</ul>
+						<ul><li><a href="http://www.fact-project.org">FACT <li2>OBSERVATION SCHEDULING</li2></a></li></ul>
 						<div class="clear"></div>
 					</div>	
 					<div id="content_bg_top"></div>
-				<div id="content_box">
-					
-					<br />
+					<div id="content_box">
 					<div id="column_box">
 						<div id="column1">
-								
-								<div id="calendar" align="center"> 	
-									
-									<?php require_once 'Module/calendar.php'; ?>
-								</div>
-								<br/>
-									<div width="100px">
-										<!-- AKI -->
-										<?php
-                                        include 'search.php';
-										?>
-										
-										<br />
-									</div>		
-					</div>
+							<div id="calendar" align="center"><?php require_once 'Module/calendar.php'; ?></div>
+							<div><?php include 'search/search.php'; ?></div>		
+						</div>
 					<div id="column3">
 						<div id="Graph" style="height: 400px"></div>
-						
 					</div>
 					<div class="clear">
 					</div>
 					</div>
-					
 					<div style="width:100%;" align="right" id='btn'>
-						<?php include 'function/button.php';  ?>
+						<input type="button" id="save" value="SAVE" class="button" title="Click to save">&nbsp;&nbsp;&nbsp;
+						<input type="button" id="LoadPrev" value="Load Previous Night" class="button" title="Click to load previous night">
 					</div>
-						<div style="border:2px solid white; width:100%;" id="Scheduling">
-						
+					<div style="border:2px solid white; width:100%;" id="Scheduling">
 						<table width="100%" id="TableHolder" >
-
 								<tr>
 									<td width="184" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Time</td>
-									
 									<td width="170" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Measurement</td>
-									<td width="185" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Source list</td>
-									<td width="290" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Value</td>
+									<td width="145" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Source list</td>
+									<td width="316" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center"  >Value</td>
 									<td width="141" style="border:1px solid white; color:#37DFB1; font-size:14px;" align="center" >Transaction</td>
 								</tr>
-								
-
-							</table>
-		<?php
-						include 'function/SplitDelete.php';
-						?>
-	
-							<div id="Data">
-	</div>
-	
-						</div>
-						
-				
-			<div id="footer_bot">
-				<p>&copy; 2012 FACT Project Design by i-SoftTech</p>
-				<p>Western Mindanao State University (<strong><a href="http://www.wmsu.edu.ph">WMSU</a>,Philippines</strong>)</p>
+						</table>
+						<div id="Data"><script>addRowClone();</script></div>
+					</div>
+				<div id="footer_bot">
+					<p>&copy; 2012 FACT Project Design by i-SoftTech</p>
+					<p>Western Mindanao State University (<strong><a href="http://www.wmsu.edu.ph">WMSU</a>,Philippines</strong>)</p>
 				</div>
-			</div>
-			<div id="data"></div>
-			<div id="day"></div>
-			
-			
+				</div>
+				<div id="data"></div>
+				<div id="day"></div>
 		</div>
-
     </body>
 </html>
Index: /schedule/css/styles.css
===================================================================
--- /schedule/css/styles.css	(revision 17421)
+++ /schedule/css/styles.css	(revision 17422)
@@ -46,8 +46,8 @@
 	font-weight: normal;
 	color: #0870d7;
-		padding: 30px 0px 10px 40px;
-}
-
-h3{
+	padding: 30px 0px 10px 40px;
+}
+
+/*h3{
 	background: url(../images/title.png) no-repeat top left;
 	font: 18px Arial, Helvetica, sans-serif;
@@ -59,5 +59,5 @@
 	font-weight: normal;
 	
-}
+}*/
 
 body{	
@@ -345,69 +345,4 @@
 }
 
-
-/*=================================*/
-/* Nivo Slider Demo
-/* November 2010
-/* By: Gilbert Pellegrom
-/* http://dev7studios.com
-/*=================================*/
-
-
-#slider-wrapper {
-    width: 876px;
-    height: 326px;
-}
-
-#slider {
-	position:relative;
-    width: 876px;
-    height: 326px;
-	background:url(../images/loading.gif) no-repeat 50% 50%;
-}
-#slider img {
-	position:absolute;
-	top:0px;
-	left:0px;
-	display:none;
-}
-#slider a {
-	border:0;
-	display:block;
-}
-
-.nivo-controlNav {
-	position:absolute;
-	left:260px;
-	bottom:-42px;
-	display: none;
-}
-.nivo-controlNav a.active {
-	background-position:0 -22px;
-}
-
-.nivo-directionNav a {
-	display:block;
-	width:30px;
-	height:30px;
-	background:url(../images/arrows.png) no-repeat;
-	text-indent:-9999px;
-	border:0;
-}
-a.nivo-nextNav {
-	background-position:-30px 0;
-	right:15px;
-}
-a.nivo-prevNav {
-	left:15px;
-}
-
-.nivo-caption {
-    text-shadow:none;
-    font-family: Helvetica, Arial, sans-serif;
-}
-.nivo-caption a { 
-    color:#efe9d1;
-    text-decoration:underline;
-}
 .button {
 	cursor:pointer;
Index: /schedule/include/factdb.php
===================================================================
--- /schedule/include/factdb.php	(revision 17421)
+++ /schedule/include/factdb.php	(revision 17422)
@@ -2,6 +2,6 @@
 
 	
-	//$con=mysql_connect("localhost","root","");
-	$con=mysql_connect("localhost","scheduletest","t3stsched");
+	$con=mysql_connect("localhost","root","");
+	//$con=mysql_connect("localhost","scheduletest","t3stsched");
 	mysql_select_db("sandboxschedule",$con);
  ?>
Index: /schedule/index.php
===================================================================
--- /schedule/index.php	(revision 17421)
+++ /schedule/index.php	(revision 17422)
@@ -1,4 +1,3 @@
 <?php
-	
 	include 'Module/link.php';
 	include 'include/factdb.php';
Index: /schedule/js/function.js
===================================================================
--- /schedule/js/function.js	(revision 17421)
+++ /schedule/js/function.js	(revision 17422)
@@ -2,91 +2,92 @@
 // June 16, 2013
 
-function GetDate()
+function GetDate(d,m,y)
 {
-	$('#save').click(function(){
-		var Time = [];
-		var Data = [];
-		var Source = [];
-		var Measure = [];
-		var Table = [];
-		$('#TableHolder table').each(function(){ // call all the id of the table inside div#TableHolder
-			id=$(this).attr('id'); //Getting all id's
-			Time.push('#'+id+' input#Time'); // Storing id's of each element
-			Data.push('#'+id+' input#txtData'); 
-			Source.push('#'+id+' select#source :selected');
-			Measure.push('#'+id+' select#measurement :selected');
-			Table.push(id);
-		});
-		GetSaveData(Time,Data,Source,Measure,Table); // Function call of saving the data
-	});	
-};
+	$('document').ready(function(){
+			/*var currentdate = new Date();
+			var datetime = currentdate.getFullYear()+ "-"+(currentdate.getMonth()+1) 
+			+ "-" + (currentdate.getDay()+1); /* + " @ " 
+			+ currentdate.getHours() + ":" 
+			+ currentdate.getMinutes() + ":" + currentdate.getSeconds(); */
+			var Gdate = y+'-'+m+'-'+d;
+			//alert(Gdate);
+			$('#save').click(function(){
+				if($('#save').val()=='SAVE')
+				{
+					$('.datalisting').each(function(){
+						var get_seq = 0;
+						get_time = $(this).find(".time").val();
+						countchild = $(this).find(".tr").length;
+							$(this).find(".tr").each(function(){
+								
+								get_measure   = $(this).find(".measure").val();		
+								get_source    = $(this).find(".source").val();		
+								get_selected  = $(this).find(".selected").val();
+								GetSaveData(get_time, get_selected, get_source, get_measure, Gdate,get_seq);
+								get_seq++;
+							});
+					});
+				}
+				else
+				{
+					GetDelete(Gdate);
+					$('.datalisting').each(function(){
+						var get_seq = 0;
+						get_time = $(this).find(".time").val();
+						countchild = $(this).find(".tr").length;
+							$(this).find(".tr").each(function(){
+								
+								get_measure   = $(this).find(".measure").val();		
+								get_source    = $(this).find(".source").val();		
+								get_selected  = $(this).find(".selected").val();
+								GetUpdateData(get_time, get_selected, get_source, get_measure, Gdate,get_seq);
+								get_seq++;
+							});
+					});
+				}
+		});	
 
 
-function GetSaveData(Time,Data,Source,Measure,Table){
-	var checks=0;
-	TimeSave = [];
-	DataSave = [];
-	SourceSave = [];
-	MeasureSave = [];
-	for(i=0;i<Table.length;i++)
-	{
-		$(Time[i]).each(function(){
-			TimeSave.push($(this).val()); // extracting each data into a value
-		});
-		$(Data[i]).each(function(){
-			DataSave.push($(this).val()); // extracting each data into a value
-		});
-		$(Source[i]).each(function(){
-			SourceSave.push($(this).val()); // extracting each data into a value 
-		});
-		$(Measure[i]).each(function(){
-			MeasureSave.push($(this).val()); // extracting each data into a value
-		});
-	}
-	if($('#save').val()=='UPDATE')
-	{
-		if(checks == 0)
-		{
-			$.ajax({
-				type: "POST",
-				cache: false,
-				url: "Transaction/update.php",
-				data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
-				success: function(data) {
-					
-						alert('Successfully Updated ! '+year+'-'+month+'-'+day);
-					
-				}
-			});
-		}
-		else
-		{
 
-		alert("Please fill all the details!");
-		}
-	}
-	else
-	{
-		if(checks == 0)
-		{
+	function GetSaveData(Time,Data,Source,Measure,date,seq){
+		//alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
 			$.ajax({
 				type: "POST",
 				cache: false,
 				url: "Transaction/insert.php",
-				data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
+				data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
 				success: function(data) {
-					
-						alert('Successfully added ! '+year+'-'+month+'-'+day);
+						alert('Successfully added ! '+date);
+						//$("#Data").append("Ok"+date);
 					
 				}
 			});
-		}
-		else
-		{
-
-		alert("Please fill all the details!");
-		}
-	
-	}
-	
+		};
+		function GetDelete(date){
+			//alert('del');
+			$.ajax({
+				type:"POST",
+				cache:false,
+				url:"Transaction/delete.php",
+				data:"Gdate="+date,
+				success:function(data){
+				
+				}
+			});
+		};
+		function GetUpdateData(Time,Data,Source,Measure,date,seq){
+			//alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
+				$.ajax({
+					type: "POST",
+					cache: false,
+					url: "Transaction/update.php",
+					data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
+					success: function(data) {
+							alert('Successfully added ! '+date);
+							//$("#Data").append("Ok"+date);
+						
+					}
+				});
+			};
+	});
 };
