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