source: schedule/js/function.js@ 17485

Last change on this file since 17485 was 17485, checked in by tose, 12 years ago
File size: 2.8 KB
Line 
1// This module prepare by : Jaypee Tanio
2// June 16, 2013
3
4var currentDate;
5var transCount;
6
7function GetDate(d,m,y)
8{
9 currentDate = y+'-'+m+'-'+d;
10 transCount = 1;
11 $('document').ready(function(){
12 $('#save').click(function(){
13 if(($('#save').val()=='SAVE') && transCount==1)
14 {
15 transCount = 0;
16 Gdate = currentDate;
17 alert("Save: " + Gdate);
18 $('.datalisting').each(function(){
19 var get_seq = 0;
20 get_time = $(this).find(".time").val();
21 countchild = $(this).find(".tr").length;
22 $(this).find(".tr").each(function(){
23 get_measure = $(this).find(".measure").val();
24 get_source = $(this).find(".source").val();
25 get_selected = $(this).find(".selected").val();
26 GetSaveData(get_time, get_selected, get_source, get_measure, Gdate,get_seq);
27 get_seq++;
28 });
29 });
30 }
31 else if(($('#save').val()=='UPDATE') && transCount==1)
32 {
33 transCount = 0;
34 Gdate = currentDate;
35 alert("Update: " + Gdate);
36 GetDelete(Gdate);
37 $('.datalisting').each(function(){
38 var get_seq = 0;
39 get_time = $(this).find(".time").val();
40 countchild = $(this).find(".tr").length;
41 $(this).find(".tr").each(function(){
42
43 get_measure = $(this).find(".measure").val();
44 get_source = $(this).find(".source").val();
45 get_selected = $(this).find(".selected").val();
46 GetUpdateData(get_time, get_selected, get_source, get_measure, Gdate, get_seq);
47 get_seq++;
48 });
49 });
50 }
51 });
52
53 function GetSaveData(Time,Data,Source,Measure,date,seq){
54 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
55 $.ajax({
56 type: "POST",
57 cache: false,
58 url: "Transaction/insert.php",
59 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
60 success: function(data) {
61 alert('Successfully added ! '+date);
62 //$("#Data").append("Ok"+date);
63
64 }
65 });
66 };
67 function GetDelete(date){
68 //alert('del');
69 $.ajax({
70 type:"POST",
71 cache:false,
72 url:"Transaction/delete.php",
73 data:"Gdate="+date,
74 success:function(data){
75
76 }
77 });
78 };
79 function GetUpdateData(Time,Data,Source,Measure,date,seq){
80 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
81 $.ajax({
82 type: "POST",
83 cache: false,
84 url: "Transaction/update.php",
85 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
86 success: function(data) {
87 alert('Successfully added ! '+date);
88 //$("#Data").append("Ok"+date);
89
90 }
91 });
92 };
93 });
94};
Note: See TracBrowser for help on using the repository browser.