12 * |
12 * |
13 * BrewCloud is distributed in the hope that it will be useful, but |
13 * BrewCloud is distributed in the hope that it will be useful, but |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * General Public License for more details. |
16 * General Public License for more details. |
17 * |
17 * |
18 * You should have received a copy of the GNU General Public License |
18 * You should have received a copy of the GNU General Public License |
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
21 *****************************************************************************/ |
21 *****************************************************************************/ |
22 |
22 |
23 |
23 |
24 |
24 |
25 function createDelElements() { |
25 function createDelElements() { |
26 $('#eventWindow').jqxWindow({ |
26 $('#eventWindow').jqxWindow({ |
27 theme: theme, |
27 theme: theme, |
28 position: { x: 490, y: 210 }, |
28 position: { x: 490, y: 210 }, |
29 width: 300, |
29 width: 300, |
30 height: 175, |
30 height: 175, |
31 resizable: false, |
31 resizable: false, |
32 isModal: true, |
32 isModal: true, |
33 modalOpacity: 0.4, |
33 modalOpacity: 0.4, |
34 okButton: $('#delOk'), |
34 okButton: $('#delOk'), |
35 cancelButton: $('#delCancel'), |
35 cancelButton: $('#delCancel'), |
36 initContent: function () { |
36 initContent: function() { |
37 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); |
37 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme }); |
38 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); |
38 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme }); |
39 $('#delCancel').focus(); |
39 $('#delCancel').focus(); |
40 } |
40 } |
41 }); |
41 }); |
42 $('#eventWindow').jqxWindow('hide'); |
42 $('#eventWindow').jqxWindow('hide'); |
43 } |
43 } |
44 |
44 |
45 |
45 |
46 |
46 |
47 $(document).ready(function () { |
47 $(document).ready(function() { |
48 |
48 |
49 // tooltips |
49 // tooltips |
50 $("#name").jqxTooltip({ content: 'De naam van de leverancier.' }); |
50 $('#name').jqxTooltip({ content: 'De naam van de leverancier.' }); |
51 $("#address").jqxTooltip({ content: 'Het adres en huisnummer.' }); |
51 $('#address').jqxTooltip({ content: 'Het adres en huisnummer.' }); |
52 $("#city").jqxTooltip({ content: 'De woonplaats of gemeente.' }); |
52 $('#city').jqxTooltip({ content: 'De woonplaats of gemeente.' }); |
53 $("#zip").jqxTooltip({ content: 'De postcode.' }); |
53 $('#zip').jqxTooltip({ content: 'De postcode.' }); |
54 $("#country").jqxTooltip({ content: 'Het land.' }); |
54 $('#country').jqxTooltip({ content: 'Het land.' }); |
55 $("#website").jqxTooltip({ content: 'Het website adres.' }); |
55 $('#website').jqxTooltip({ content: 'Het website adres.' }); |
56 $("#email").jqxTooltip({ content: 'Het email adres.' }); |
56 $('#email').jqxTooltip({ content: 'Het email adres.' }); |
57 $("#phone").jqxTooltip({ content: 'Het telefoon nummer.' }); |
57 $('#phone').jqxTooltip({ content: 'Het telefoon nummer.' }); |
58 $("#notes").jqxTooltip({ content: 'Opmerkingen over deze leverancier.' }); |
58 $('#notes').jqxTooltip({ content: 'Opmerkingen over deze leverancier.' }); |
59 |
59 |
60 var url = 'includes/db_inventory_suppliers.php', |
60 var url = 'includes/db_inventory_suppliers.php', |
61 // prepare the data |
61 source = { |
62 source = { |
62 datatype: 'json', |
63 datatype: "json", |
63 cache: false, |
64 cache: false, |
64 datafields: [ |
65 datafields: [ |
65 { name: 'record', type: 'number' }, |
66 { name: 'record', type: 'number' }, |
66 { name: 'name', type: 'string' }, |
67 { name: 'name', type: 'string' }, |
67 { name: 'address', type: 'string' }, |
68 { name: 'address', type: 'string' }, |
68 { name: 'city', type: 'string' }, |
69 { name: 'city', type: 'string' }, |
69 { name: 'zip', type: 'string' }, |
70 { name: 'zip', type: 'string' }, |
70 { name: 'country', type: 'string' }, |
71 { name: 'country', type: 'string' }, |
71 { name: 'website', type: 'string' }, |
72 { name: 'website', type: 'string' }, |
72 { name: 'email', type: 'string' }, |
73 { name: 'email', type: 'string' }, |
73 { name: 'phone', type: 'string' }, |
74 { name: 'phone', type: 'string' }, |
74 { name: 'notes', type: 'string' } |
75 { name: 'notes', type: 'string' } |
75 ], |
76 ], |
76 id: 'record', |
77 id: 'record', |
77 url: url, |
78 url: url, |
78 deleterow: function(rowid, commit) { |
79 deleterow: function (rowid, commit) { |
79 // synchronize with the server - send delete command |
80 // synchronize with the server - send delete command |
80 var data = 'delete=true&' + $.param({ record: rowid }); |
81 var data = "delete=true&" + $.param({ record: rowid }); |
81 $.ajax({ |
82 $.ajax({ |
82 dataType: 'json', |
83 dataType: 'json', |
83 url: url, |
84 url: url, |
84 cache: false, |
85 cache: false, |
85 data: data, |
86 data: data, |
86 type: 'POST', |
87 type: "POST", |
87 success: function(data, status, xhr) { |
88 success: function (data, status, xhr) { |
88 commit(true); |
89 commit(true); |
89 location.reload(true); |
90 location.reload( true ); |
90 }, |
91 }, |
91 error: function(jqXHR, textStatus, errorThrown) { |
92 error: function (jqXHR, textStatus, errorThrown) { |
92 commit(false); |
93 commit(false); |
93 } |
94 } |
94 }); |
95 }); |
95 }, |
96 }, |
96 addrow: function(rowid, rowdata, position, commit) { |
97 addrow: function (rowid, rowdata, position, commit) { |
97 var data = 'insert=true&' + $.param(rowdata); |
98 var data = "insert=true&" + $.param(rowdata); |
98 $.ajax({ |
99 $.ajax({ |
99 dataType: 'json', |
100 dataType: 'json', |
100 url: url, |
101 url: url, |
101 cache: false, |
102 cache: false, |
102 data: data, |
103 data: data, |
103 type: 'POST', |
104 type: "POST", |
104 success: function(data, status, xhr) { |
105 success: function (data, status, xhr) { |
105 commit(true); |
106 commit(true); |
106 location.reload(true); |
107 location.reload( true ); |
107 }, |
108 }, |
108 error: function(jqXHR, textStatus, errorThrown) { |
109 error: function(jqXHR, textStatus, errorThrown) { |
109 commit(false); |
110 commit(false); |
110 } |
111 } |
111 }); |
112 }); |
112 }, |
113 }, |
113 updaterow: function(rowid, rowdata, commit) { |
114 updaterow: function (rowid, rowdata, commit) { |
114 var data = 'update=true&' + $.param(rowdata); |
115 var data = "update=true&" + $.param(rowdata); |
115 $.ajax({ |
116 $.ajax({ |
116 dataType: 'json', |
117 dataType: 'json', |
117 url: url, |
118 url: url, |
118 cache: false, |
119 cache: false, |
119 data: data, |
120 data: data, |
120 type: 'POST', |
121 type: "POST", |
121 success: function(data, status, xhr) { |
122 success: function (data, status, xhr) { |
122 commit(true); |
123 commit(true); |
123 location.reload(true); |
124 location.reload( true ); |
124 }, |
125 }, |
125 error: function(jqXHR, textStatus, errorThrown) { |
126 error: function(jqXHR, textStatus, errorThrown) { |
126 commit(false); |
127 commit(false); |
127 } |
128 } |
128 }); |
129 }); |
129 } |
130 } |
130 }, |
131 }, |
131 dataAdapter = new $.jqx.dataAdapter(source), |
132 dataAdapter = new $.jqx.dataAdapter(source), |
|
133 editrow = -1; |
132 editrow = -1; |
134 |
133 |
135 // initialize the input fields. |
134 // initialize the input fields. |
136 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
135 $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); |
137 $("#address").jqxInput({ theme: theme, width: 350, height: 23 }); |
136 $('#address').jqxInput({ theme: theme, width: 350, height: 23 }); |
138 $("#zip").jqxInput({ theme: theme, width: 120, height: 23 }); |
137 $('#zip').jqxInput({ theme: theme, width: 120, height: 23 }); |
139 $("#city").jqxInput({ theme: theme, width: 350, height: 23 }); |
138 $('#city').jqxInput({ theme: theme, width: 350, height: 23 }); |
140 $("#country").jqxInput({ theme: theme, width: 250, height: 23 }); |
139 $('#country').jqxInput({ theme: theme, width: 250, height: 23 }); |
141 $("#website").jqxInput({ theme: theme, width: 640, height: 23 }); |
140 $('#website').jqxInput({ theme: theme, width: 640, height: 23 }); |
142 $("#email").jqxInput({ theme: theme, width: 640, height: 23 }); |
141 $('#email').jqxInput({ theme: theme, width: 640, height: 23 }); |
143 $("#phone").jqxInput({ theme: theme, width: 175, height: 23 }); |
142 $('#phone').jqxInput({ theme: theme, width: 175, height: 23 }); |
144 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); |
143 $('#notes').jqxInput({ theme: theme, width: 800, height: 100 }); |
145 |
144 |
146 // initialize jqxGrid |
145 // initialize jqxGrid |
147 $("#jqxgrid").jqxGrid({ |
146 $('#jqxgrid').jqxGrid({ |
148 width: 1280, |
147 width: 1280, |
149 height: 630, |
148 height: 630, |
150 source: dataAdapter, |
149 source: dataAdapter, |
151 theme: theme, |
150 theme: theme, |
152 showstatusbar: true, |
151 showstatusbar: true, |
153 renderstatusbar: function (statusbar) { |
152 renderstatusbar: function(statusbar) { |
154 var addButton, container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
153 var addButton, container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
155 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); |
154 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
156 container.append(addButton); |
155 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); |
157 statusbar.append(container); |
156 container.append(addButton); |
158 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
157 statusbar.append(container); |
159 // add new row. |
158 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
160 addButton.click(function (event) { |
159 // add new row. |
161 editrow = -1; |
160 addButton.click(function(event) { |
162 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
161 editrow = -1; |
163 $("#name").val('Nieuwe leverancier'); |
162 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
164 $("#address").val(''); |
163 $('#name').val('Nieuwe leverancier'); |
165 $("#city").val(''); |
164 $('#address').val(''); |
166 $("#zip").val(''); |
165 $('#city').val(''); |
167 $("#country").val('Nederland'); |
166 $('#zip').val(''); |
168 $("#website").val(''); |
167 $('#country').val('Nederland'); |
169 $("#email").val(''); |
168 $('#website').val(''); |
170 $("#phone").val(''); |
169 $('#email').val(''); |
171 $("#notes").val(''); |
170 $('#phone').val(''); |
172 $("#popupWindow").jqxWindow('open'); |
171 $('#notes').val(''); |
173 }); |
172 $('#popupWindow').jqxWindow('open'); |
174 }, |
173 }); |
175 filterable: false, |
174 }, |
176 columns: [ |
175 filterable: false, |
177 { text: 'Leverancier naam', datafield: 'name' }, |
176 columns: [ |
178 { text: 'Adres', datafield: 'address', width: 300 }, |
177 { text: 'Leverancier naam', datafield: 'name' }, |
179 { text: 'Plaats', datafield: 'city', width: 250 }, |
178 { text: 'Adres', datafield: 'address', width: 300 }, |
180 { text: 'Land', datafield: 'country', width: 200 }, |
179 { text: 'Plaats', datafield: 'city', width: 250 }, |
181 { text: 'Telefoon', datafield: 'phone', width: 175 }, |
180 { text: 'Land', datafield: 'country', width: 200 }, |
182 { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', |
181 { text: 'Telefoon', datafield: 'phone', width: 175 }, |
183 cellsrenderer: function () { |
182 { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', |
184 return "Wijzig"; |
183 cellsrenderer: function() { |
185 }, buttonclick: function (row) { |
184 return 'Wijzig'; |
186 // open the popup window when the user clicks a button. |
185 }, buttonclick: function(row) { |
187 editrow = row; |
186 // open the popup window when the user clicks a button. |
188 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
187 editrow = row; |
189 // get the clicked row's data and initialize the input fields. |
188 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
190 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
189 // get the clicked row's data and initialize the input fields. |
191 $("#name").val(dataRecord.name); |
190 var dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); |
192 $("#address").val(dataRecord.address); |
191 $('#name').val(dataRecord.name); |
193 $("#city").val(dataRecord.city); |
192 $('#address').val(dataRecord.address); |
194 $("#zip").val(dataRecord.zip); |
193 $('#city').val(dataRecord.city); |
195 $("#country").val(dataRecord.country); |
194 $('#zip').val(dataRecord.zip); |
196 $("#website").val(dataRecord.website); |
195 $('#country').val(dataRecord.country); |
197 $("#email").val(dataRecord.email); |
196 $('#website').val(dataRecord.website); |
198 $("#phone").val(dataRecord.phone); |
197 $('#email').val(dataRecord.email); |
199 $("#notes").val(dataRecord.notes); |
198 $('#phone').val(dataRecord.phone); |
200 // show the popup window. |
199 $('#notes').val(dataRecord.notes); |
201 $("#popupWindow").jqxWindow('open'); |
200 // show the popup window. |
202 } |
201 $('#popupWindow').jqxWindow('open'); |
203 } |
202 } |
204 ] |
203 } |
205 }); |
204 ] |
206 // initialize the popup window and buttons. |
205 }); |
207 $("#popupWindow").jqxWindow({ |
206 // initialize the popup window and buttons. |
208 width: 1050, |
207 $('#popupWindow').jqxWindow({ |
209 height: 550, |
208 width: 1050, |
210 resizable: false, |
209 height: 550, |
211 theme: theme, |
210 resizable: false, |
212 isModal: true, |
211 theme: theme, |
213 autoOpen: false, |
212 isModal: true, |
214 cancelButton: $("#Cancel"), |
213 autoOpen: false, |
215 modalOpacity: 0.40 |
214 cancelButton: $('#Cancel'), |
216 }); |
215 modalOpacity: 0.40 |
217 $("#popupWindow").on('open', function () { |
216 }); |
218 $("#name").jqxInput('selectAll'); |
217 $('#popupWindow').on('open', function() { |
219 }); |
218 $('#name').jqxInput('selectAll'); |
220 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); |
219 }); |
221 $("#Delete").click(function () { |
220 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); |
222 if (editrow >= 0) { |
221 $('#Delete').click(function() { |
223 // Open a popup to confirm this action. |
222 if (editrow >= 0) { |
224 $('#eventWindow').jqxWindow('open'); |
223 // Open a popup to confirm this action. |
225 $("#delOk").click(function () { |
224 $('#eventWindow').jqxWindow('open'); |
226 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
225 $('#delOk').click(function() { |
227 $("#jqxgrid").jqxGrid('deleterow', rowID); |
226 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
228 }); |
227 $('#jqxgrid').jqxGrid('deleterow', rowID); |
229 } |
228 }); |
230 $("#popupWindow").jqxWindow('hide'); |
229 } |
231 }); |
230 $('#popupWindow').jqxWindow('hide'); |
232 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); |
231 }); |
233 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
232 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); |
234 // update the edited row when the user clicks the 'Save' button. |
233 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
235 $("#Save").click(function () { |
234 // update the edited row when the user clicks the 'Save' button. |
236 var row, rowID = -1; |
235 $('#Save').click(function() { |
237 if (editrow >= 0) { |
236 var row, rowID = -1; |
238 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
237 if (editrow >= 0) { |
239 } |
238 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
240 row = { |
239 } |
241 record: rowID, |
240 row = { |
242 name: $("#name").val(), |
241 record: rowID, |
243 address: $("#address").val(), |
242 name: $('#name').val(), |
244 city: $("#city").val(), |
243 address: $('#address').val(), |
245 zip: $("#zip").val(), |
244 city: $('#city').val(), |
246 country: $("#country").val(), |
245 zip: $('#zip').val(), |
247 website: $("#website").val(), |
246 country: $('#country').val(), |
248 email: $("#email").val(), |
247 website: $('#website').val(), |
249 phone: $("#phone").val(), |
248 email: $('#email').val(), |
250 notes: $("#notes").val() |
249 phone: $('#phone').val(), |
251 }; |
250 notes: $('#notes').val() |
252 if (editrow >= 0) { |
251 }; |
253 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
252 if (editrow >= 0) { |
254 } else { |
253 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
255 $('#jqxgrid').jqxGrid('addrow', null, row); |
254 } else { |
256 } |
255 $('#jqxgrid').jqxGrid('addrow', null, row); |
257 $("#popupWindow").jqxWindow('hide'); |
256 } |
258 }); |
257 $('#popupWindow').jqxWindow('hide'); |
259 createDelElements(); |
258 }); |
|
259 createDelElements(); |
260 }); |
260 }); |
261 |
261 |