source: schedule/js/function.js@ 17480

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