Index: schedule/js/function.js
===================================================================
--- schedule/js/function.js	(revision 16982)
+++ 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);
+						
+					}
+				});
+			};
+	});
 };
