source: schedule/js/function.js@ 17517

Last change on this file since 17517 was 17517, checked in by tose, 11 years ago
Implemented strict mode
File size: 2.9 KB
Line 
1'use strict';
2// This module prepare by : Jaypee Tanio
3// June 16, 2013
4
5var currentDate;
6var transCount;
7var transLoadPrev;
8var Gdate;
9
10function GetDate(d,m,y)
11{
12 currentDate = y+'-'+m+'-'+d;
13 transCount = 1;
14 transLoadPrev = 1;
15 $('document').ready(function(){
16 $('#save').click(function(){
17 if(($('#save').val()=='SAVE') && transCount==1)
18 {
19 transCount = 0;
20 Gdate = currentDate;
21 alert("Save: " + Gdate);
22 $('.datalisting').each(function(){
23 var get_seq = 0;
24 var get_time = $(this).find(".time").val();
25 var countchild = $(this).find(".tr").length;
26 $(this).find(".tr").each(function(){
27 var get_measure = $(this).find(".measure").val();
28 var get_source = $(this).find(".source").val();
29 var get_selected = $(this).find(".selected").val();
30 GetSaveData(get_time, get_selected, get_source, get_measure, Gdate,get_seq);
31 get_seq++;
32 });
33 });
34 }
35 else if(($('#save').val()=='UPDATE') && transCount==1)
36 {
37 transCount = 0;
38 Gdate = currentDate;
39 alert("Update: " + Gdate);
40 GetDelete(Gdate);
41 $('.datalisting').each(function(){
42 var get_seq = 0;
43 var get_time = $(this).find(".time").val();
44 var countchild = $(this).find(".tr").length;
45 $(this).find(".tr").each(function(){
46
47 var get_measure = $(this).find(".measure").val();
48 var get_source = $(this).find(".source").val();
49 var get_selected = $(this).find(".selected").val();
50 GetUpdateData(get_time, get_selected, get_source, get_measure, Gdate, get_seq);
51 get_seq++;
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.