source: schedule/js/function.js@ 17486

Last change on this file since 17486 was 17486, checked in by tose, 11 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 }
54 );
55
56 function GetSaveData(Time,Data,Source,Measure,date,seq){
57 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
58 $.ajax({
59 type: "POST",
60 cache: false,
61 url: "Transaction/insert.php",
62 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
63 success: function(data) {
64 alert('Successfully added ! '+date);
65 //$("#Data").append("Ok"+date);
66
67 }
68 });
69 };
70 function GetDelete(date){
71 //alert('del');
72 $.ajax({
73 type:"POST",
74 cache:false,
75 url:"Transaction/delete.php",
76 data:"Gdate="+date,
77 success:function(data){
78
79 }
80 });
81 };
82 function GetUpdateData(Time,Data,Source,Measure,date,seq){
83 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
84 $.ajax({
85 type: "POST",
86 cache: false,
87 url: "Transaction/update.php",
88 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
89 success: function(data) {
90 alert('Successfully added ! '+date);
91 //$("#Data").append("Ok"+date);
92
93 }
94 });
95 };
96 });
97};
Note: See TracBrowser for help on using the repository browser.