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