source: schedule/js/function.js@ 16918

Last change on this file since 16918 was 16918, checked in by tanio, 11 years ago
File size: 3.6 KB
Line 
1// This module prepare by : Jaypee Tanio
2// June 16, 2013
3
4function GetDate()
5{
6 $('#save').click(function(){
7 Time = [];
8 Data = [];
9 Source = [];
10 Measure = [];
11 Table = [];
12 $('div#TableHolder table').each(function(){ // call all the id of the table inside div#TableHolder
13 id=$(this).attr('id'); //Getting all id's
14 Time.push('#'+id+' input#Time'); // Storing id's of each element
15 Data.push('#'+id+' input#txtData');
16 Source.push('#'+id+' select#source :selected');
17 Measure.push('#'+id+' select#measurement :selected');
18 Table.push(id);
19 });
20 alert(Table);
21 GetSaveData(Time,Data,Source,Measure); // Function call of saving the data
22 });
23
24 /*$('#update').click(function(){
25 Time = [];
26 Data = [];
27 Source = [];
28 Measure = [];
29 Table = [];
30 $('div#TableHolder table').each(function(){
31 id=$(this).attr('id');
32 Table.push(id);
33 Time.push('#'+id+' input#Time');
34 Data.push('#'+id+' input#txtData');
35 Source.push('#'+id+' select#source :selected');
36 Measure.push('#'+id+' select#measurement :selected');
37 Table.push(id);
38 });
39 alert(Table);
40 GetUpdatedData(Time,Data,Source,Measure);
41 });*/
42
43
44};
45
46
47function GetSaveData(Time,Data,Source,Measure){
48 var checks=0;
49 TimeSave = [];
50 DataSave = [];
51 SourceSave = [];
52 MeasureSave = [];
53 for(i=0;i<$('div#TableHolder table').length;i++)
54 {
55 //Table[i].val();
56 $(Time[i]).each(function(){
57 TimeSave.push($(this).val()); // extracting each data into a value
58 });
59 $(Data[i]).each(function(){
60 DataSave.push($(this).val()); // extracting each data into a value
61 });
62 $(Source[i]).each(function(){
63 SourceSave.push($(this).val()); // extracting each data into a value
64 });
65 $(Measure[i]).each(function(){
66 MeasureSave.push($(this).val()); // extracting each data into a value
67 });
68 alert(DataSave);
69 }
70 if($('#save').val()=='UPDATE')
71 {
72 if(checks == 0)
73 {
74 $.ajax({
75 type: "POST",
76 cache: false,
77 url: "Transaction/update.php",
78 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
79 success: function(data) {
80
81 alert('Successfully Updated ! '+year+'-'+month+'-'+day);
82
83 }
84 });
85 }
86 else
87 {
88
89 alert("Please fill all the details!");
90 }
91 }
92 else
93 {
94 if(checks == 0)
95 {
96 $.ajax({
97 type: "POST",
98 cache: false,
99 url: "Transaction/insert.php",
100 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
101 success: function(data) {
102
103 alert('Successfully added ! '+year+'-'+month+'-'+day);
104
105 }
106 });
107 }
108 else
109 {
110
111 alert("Please fill all the details!");
112 }
113
114 }
115
116};
117/*
118function GetUpdatedData(Time,Data,Source,Measure){
119 var checks=0;
120 TimeSave = [];
121 DataSave = [];
122 SourceSave = [];
123 MeasureSave = [];
124 for(i=0;i<Time.length;i++)
125 {
126 $(Time[i]).each(function(){
127 TimeSave.push($(this).val());
128 });
129 $(Data[i]).each(function(){
130 DataSave.push($(this).val());
131 });
132 $(Source[i]).each(function(){
133 SourceSave.push($(this).val());
134 });
135 $(Measure[i]).each(function(){
136 MeasureSave.push($(this).val());
137 });
138 }
139 if(checks == 0)
140 {
141 $.ajax({
142 type: "POST",
143 cache: false,
144 url: "Transaction/update.php",
145 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day,
146 success: function(data) {
147 alert('Successfully updated ! '+year+'-'+month+'-'+day);
148 }
149 });
150 }
151 else
152 {
153
154 alert("Please fill all the details!");
155 }
156}*/
Note: See TracBrowser for help on using the repository browser.