source: schedule/js/function.js@ 17509

Last change on this file since 17509 was 17509, checked in by tose, 11 years ago
Corrected bug: missing end of function expression
File size: 2.8 KB
Line 
1'use strict';
2// This module prepare by : Jaypee Tanio
3// June 16, 2013
4
5var currentDate;
6var transCount;
7
8function GetDate(d,m,y)
9{
10 currentDate = y+'-'+m+'-'+d;
11 transCount = 1;
12 $('document').ready(function(){
13 $('#save').click(function(){
14 if(($('#save').val()=='SAVE') && transCount==1)
15 {
16 transCount = 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()=='UPDATE') && transCount==1)
33 {
34 transCount = 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
55});
56
57 function GetSaveData(Time,Data,Source,Measure,date,seq){
58 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
59 $.ajax({
60 type: "POST",
61 cache: false,
62 url: "Transaction/insert.php",
63 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
64 success: function(data) {
65 alert('Successfully added ! '+date);
66 //$("#Data").append("Ok"+date);
67
68 }
69 });
70 };
71 function GetDelete(date){
72 //alert('del');
73 $.ajax({
74 type:"POST",
75 cache:false,
76 url:"Transaction/delete.php",
77 data:"Gdate="+date,
78 success:function(data){
79
80 }
81 });
82 };
83 function GetUpdateData(Time,Data,Source,Measure,date,seq){
84 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data);
85 $.ajax({
86 type: "POST",
87 cache: false,
88 url: "Transaction/update.php",
89 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save
90 success: function(data) {
91 alert('Successfully added ! '+date);
92 //$("#Data").append("Ok"+date);
93
94 }
95 });
96 };
97 });
98};
Note: See TracBrowser for help on using the repository browser.