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 function createDelElements() { |
24 function createDelElements() { |
25 $('#eventWindow').jqxWindow({ |
25 $('#eventWindow').jqxWindow({ |
26 theme: theme, |
26 theme: theme, |
27 position: { x: 490, y: 210 }, |
27 position: { x: 490, y: 210 }, |
28 width: 300, |
28 width: 300, |
29 height: 175, |
29 height: 175, |
30 resizable: false, |
30 resizable: false, |
31 isModal: true, |
31 isModal: true, |
32 modalOpacity: 0.4, |
32 modalOpacity: 0.4, |
33 okButton: $('#delOk'), |
33 okButton: $('#delOk'), |
34 cancelButton: $('#delCancel'), |
34 cancelButton: $('#delCancel'), |
35 initContent: function () { |
35 initContent: function() { |
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); |
36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme }); |
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); |
37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme }); |
38 $('#delCancel').focus(); |
38 $('#delCancel').focus(); |
39 } |
39 } |
40 }); |
40 }); |
41 $('#eventWindow').jqxWindow('hide'); |
41 $('#eventWindow').jqxWindow('hide'); |
42 } |
42 } |
43 |
43 |
44 |
44 |
45 $(document).ready(function () { |
45 $(document).ready(function() { |
46 |
46 |
47 function calcTotal(cost, inventory) { |
47 function calcTotal(cost, inventory) { |
48 |
48 $('#totval').val(cost * (inventory / 1000)); |
49 $('#totval').val(cost * (inventory / 1000)); |
49 } |
50 } |
50 |
51 |
51 var dataRecord = {}, |
52 var dataRecord = {}, |
52 url = 'includes/db_inventory_hops.php', |
53 url = 'includes/db_inventory_hops.php', |
53 source = { |
54 // prepare the data |
54 datatype: 'json', |
55 source = { |
55 cache: false, |
56 datatype: "json", |
56 datafields: [ |
57 cache: false, |
57 { name: 'record', type: 'number' }, |
58 datafields: [ |
58 { name: 'name', type: 'string' }, |
59 { name: 'record', type: 'number' }, |
59 { name: 'alpha', type: 'float' }, |
60 { name: 'name', type: 'string' }, |
60 { name: 'beta', type: 'float' }, |
61 { name: 'alpha', type: 'float' }, |
61 { name: 'humulene', type: 'float' }, |
62 { name: 'beta', type: 'float' }, |
62 { name: 'caryophyllene', type: 'float' }, |
63 { name: 'humulene', type: 'float' }, |
63 { name: 'cohumulone', type: 'float' }, |
64 { name: 'caryophyllene', type: 'float' }, |
64 { name: 'myrcene', type: 'float' }, |
65 { name: 'cohumulone', type: 'float' }, |
65 { name: 'hsi', type: 'float' }, |
66 { name: 'myrcene', type: 'float' }, |
66 { name: 'type', type: 'string' }, |
67 { name: 'hsi', type: 'float' }, |
67 { name: 'form', type: 'string' }, |
68 { name: 'type', type: 'string' }, |
68 { name: 'notes', type: 'string' }, |
69 { name: 'form', type: 'string' }, |
69 { name: 'origin', type: 'string' }, |
70 { name: 'notes', type: 'string' }, |
70 { name: 'substitutes', type: 'string' }, |
71 { name: 'origin', type: 'string' }, |
71 { name: 'always_on_stock', type: 'int' }, |
72 { name: 'substitutes', type: 'string' }, |
72 { name: 'inventory', type: 'float' }, |
73 { name: 'always_on_stock', type: 'int' }, |
73 { name: 'cost', type: 'float' }, |
74 { name: 'inventory', type: 'float' }, |
74 { name: 'production_date', type: 'string' }, |
75 { name: 'cost', type: 'float' }, |
75 { name: 'tht_date', type: 'string' }, |
76 { name: 'production_date', type: 'string' }, |
76 { name: 'total_oil', type: 'float' } |
77 { name: 'tht_date', type: 'string' }, |
77 ], |
78 { name: 'total_oil', type: 'float' } |
78 id: 'record', |
79 ], |
79 url: url, |
80 id: 'record', |
80 deleterow: function(rowid, commit) { |
81 url: url, |
81 var data = 'delete=true&' + $.param({ record: rowid }); |
82 deleterow: function (rowid, commit) { |
82 $.ajax({ |
83 // synchronize with the server - send delete command |
83 dataType: 'json', |
84 var data = "delete=true&" + $.param({ record: rowid }); |
84 url: url, |
85 $.ajax({ |
85 cache: false, |
86 dataType: 'json', |
86 data: data, |
87 url: url, |
87 type: 'POST', |
88 cache: false, |
88 success: function(data, status, xhr) { |
89 data: data, |
89 commit(true); |
90 type: "POST", |
90 location.reload(true); |
91 success: function (data, status, xhr) { |
91 }, |
92 commit(true); |
92 error: function(jqXHR, textStatus, errorThrown) { |
93 location.reload( true ); |
93 commit(false); |
94 }, |
94 } |
95 error: function (jqXHR, textStatus, errorThrown) { |
95 }); |
96 commit(false); |
96 }, |
97 } |
97 addrow: function(rowid, rowdata, position, commit) { |
98 }); |
98 var data = 'insert=true&' + $.param(rowdata); |
99 }, |
99 $.ajax({ |
100 addrow: function (rowid, rowdata, position, commit) { |
100 dataType: 'json', |
101 var data = "insert=true&" + $.param(rowdata); |
101 url: url, |
102 $.ajax({ |
102 cache: false, |
103 dataType: 'json', |
103 data: data, |
104 url: url, |
104 type: 'POST', |
105 cache: false, |
105 success: function(data, status, xhr) { |
106 data: data, |
106 commit(true); |
107 type: "POST", |
107 location.reload(true); |
108 success: function (data, status, xhr) { |
108 }, |
109 commit(true); |
109 error: function(jqXHR, textStatus, errorThrown) { |
110 location.reload( true ); |
110 commit(false); |
111 }, |
111 } |
112 error: function(jqXHR, textStatus, errorThrown) { |
112 }); |
113 commit(false); |
113 }, |
114 } |
114 updaterow: function(rowid, rowdata, commit) { |
115 }); |
115 var data = 'update=true&' + $.param(rowdata); |
116 }, |
116 $.ajax({ |
117 updaterow: function (rowid, rowdata, commit) { |
117 dataType: 'json', |
118 var data = "update=true&" + $.param(rowdata); |
118 url: url, |
119 $.ajax({ |
119 cache: false, |
120 dataType: 'json', |
120 data: data, |
121 url: url, |
121 type: 'POST', |
122 cache: false, |
122 success: function(data, status, xhr) { |
123 data: data, |
123 commit(true); |
124 type: "POST", |
124 location.reload(true); |
125 success: function (data, status, xhr) { |
125 }, |
126 commit(true); |
126 error: function(jqXHR, textStatus, errorThrown) { |
127 location.reload( true ); |
127 commit(false); |
128 }, |
128 } |
129 error: function(jqXHR, textStatus, errorThrown) { |
129 }); |
130 commit(false); |
130 } |
131 } |
131 }, |
132 }); |
132 dataAdapter = new $.jqx.dataAdapter(source), |
133 } |
133 editrow = -1; |
134 }, |
134 |
135 dataAdapter = new $.jqx.dataAdapter(source), |
135 // initialize the input fields. |
136 editrow = -1; |
136 $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); |
137 |
137 $('#alpha').jqxNumberInput(Perc1dec); |
138 // initialize the input fields. |
138 $('#beta').jqxNumberInput(Perc1dec); |
139 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
139 $('#humulene').jqxNumberInput(Perc1dec); |
140 $("#alpha").jqxNumberInput( Perc1dec ); |
140 $('#caryophyllene').jqxNumberInput(Perc1dec); |
141 $("#beta").jqxNumberInput( Perc1dec ); |
141 $('#cohumulone').jqxNumberInput(Perc1dec); |
142 $("#humulene").jqxNumberInput( Perc1dec ); |
142 $('#myrcene').jqxNumberInput(Perc1dec); |
143 $("#caryophyllene").jqxNumberInput( Perc1dec ); |
143 $('#hsi').jqxNumberInput(Perc1dec); |
144 $("#cohumulone").jqxNumberInput( Perc1dec ); |
144 |
145 $("#myrcene").jqxNumberInput( Perc1dec ); |
145 $('#type').jqxDropDownList({ |
146 $("#hsi").jqxNumberInput( Perc1dec ); |
146 theme: theme, |
147 |
147 source: HopTypeAdapter, |
148 $("#type").jqxDropDownList({ |
148 valueMember: 'nl', |
149 theme: theme, |
149 displayMember: 'nl', |
150 source: HopTypeAdapter, |
150 width: 150, |
151 valueMember: 'nl', |
151 height: 23, |
152 displayMember: 'nl', |
152 autoDropDownHeight: true |
153 width: 150, |
153 }); |
154 height: 23, |
154 $('#form').jqxDropDownList({ |
155 autoDropDownHeight: true |
155 theme: theme, |
156 }); |
156 source: HopFormAdapter, |
157 $("#form").jqxDropDownList({ |
157 valueMember: 'nl', |
158 theme: theme, |
158 displayMember: 'nl', |
159 source: HopFormAdapter, |
159 width: 150, |
160 valueMember: 'nl', |
160 height: 23, |
161 displayMember: 'nl', |
161 autoDropDownHeight: true |
162 width: 150, |
162 }); |
163 height: 23, |
163 $('#notes').jqxInput({ theme: theme, width: 640, height: 100 }); |
164 autoDropDownHeight: true |
164 $('#origin').jqxInput({ theme: theme, width: 320, height: 23 }); |
165 }); |
165 $('#substitutes').jqxInput({ theme: theme, width: 320, height: 23 }); |
166 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); |
166 $('#always_on_stock').jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
167 $("#origin").jqxInput({ theme: theme, width: 320, height: 23 }); |
167 $('#inventory').jqxNumberInput(Spin1dec); |
168 $("#substitutes").jqxInput({ theme: theme, width: 320, height: 23 }); |
168 $('#production_date').jqxDateTimeInput(Dateopts); |
169 $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
169 $('#cost').jqxNumberInput(Spin2dec); |
170 $("#inventory").jqxNumberInput( Spin1dec ); |
170 $('#tht_date').jqxDateTimeInput(Dateopts); |
171 $("#production_date").jqxDateTimeInput( Dateopts ); |
171 $('#total_oil').jqxNumberInput(Perc1dec); |
172 $("#cost").jqxNumberInput( Spin2dec ); |
172 $('#totval').jqxNumberInput(Show2dec); |
173 $("#tht_date").jqxDateTimeInput( Dateopts ); |
173 |
174 $("#total_oil").jqxNumberInput( Perc1dec ); |
174 // initialize jqxGrid |
175 $("#totval").jqxNumberInput( Show2dec ); |
175 $('#jqxgrid').jqxGrid({ |
176 |
176 width: 1280, |
177 // initialize jqxGrid |
177 height: 630, |
178 $("#jqxgrid").jqxGrid({ |
178 source: dataAdapter, |
179 width: 1280, |
179 theme: theme, |
180 height: 630, |
180 showstatusbar: true, |
181 source: dataAdapter, |
181 renderstatusbar: function(statusbar) { |
182 theme: theme, |
182 var container, addButton, impButton; |
183 showstatusbar: true, |
183 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
184 renderstatusbar: function (statusbar) { |
184 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
185 var container, addButton, impButton; |
185 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); |
186 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
186 impButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' + |
187 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>"); |
187 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Import</span></div>'); |
188 impButton = $("<div style='float: right; margin-right: 50px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Import</span></div>"); |
188 container.append(addButton); |
189 container.append(addButton); |
189 container.append(impButton); |
190 container.append(impButton); |
190 statusbar.append(container); |
191 statusbar.append(container); |
191 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
192 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
192 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
193 impButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
193 // add new row. |
194 // add new row. |
194 addButton.click(function(event) { |
195 addButton.click(function (event) { |
195 editrow = -1; |
196 editrow = -1; |
196 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
197 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
197 $('#name').val('Nieuwe hop'); |
198 $("#name").val('Nieuwe hop'); |
198 $('#alpha').val(0); |
199 $("#alpha").val(0); |
199 $('#beta').val(0); |
200 $("#beta").val(0); |
200 $('#humulene').val(0); |
201 $("#humulene").val(0); |
201 $('#caryophyllene').val(0); |
202 $("#caryophyllene").val(0); |
202 $('#cohumulone').val(0); |
203 $("#cohumulone").val(0); |
203 $('#myrcene').val(0); |
204 $("#myrcene").val(0); |
204 $('#hsi').val(0); |
205 $("#hsi").val(0); |
205 $('#type').val('Bitterhop'); |
206 $("#type").val('Bitterhop'); |
206 $('#form').val('Pellets'); |
207 $("#form").val('Pellets'); |
207 $('#notes').val(''); |
208 $("#notes").val(''); |
208 $('#origin').val(''); |
209 $("#origin").val(''); |
209 $('#substitutes').val(''); |
210 $("#substitutes").val(''); |
210 $('#always_on_stock').val(0); |
211 $("#always_on_stock").val(0); |
211 $('#inventory').val(0); |
212 $("#inventory").val(0); |
212 $('#cost').val(0); |
213 $("#cost").val(0); |
213 $('#production_date').val(''); |
214 $("#production_date").val(''); |
214 $('#tht_date').val(''); |
215 $("#tht_date").val(''); |
215 $('#total_oil').val(0); |
216 $("#total_oil").val(0); |
216 $('#popupWindow').jqxWindow('open'); |
217 $("#popupWindow").jqxWindow('open'); |
217 }); |
218 }); |
218 impButton.click(function(event) { |
219 impButton.click(function (event) { |
219 window.location.href = 'import_ingredients.php?select=hops'; |
220 window.location.href = 'import_ingredients.php?select=hops'; |
220 }); |
221 }); |
221 }, |
222 }, |
222 filterable: true, |
223 filterable: true, |
223 filtermode: 'excel', |
224 filtermode: 'excel', |
224 columns: [ |
225 columns: [ |
225 { text: 'Herkomst', datafield: 'origin', width: 150 }, |
226 { text: 'Herkomst', datafield: 'origin', width: 150 }, |
226 { text: 'Hop Naam', datafield: 'name', menu: false }, |
227 { text: 'Hop Naam', datafield: 'name', menu: false }, |
227 { text: 'Soort', datafield: 'type', align: 'left', width: 90 }, |
228 { text: 'Soort', datafield: 'type', align: 'left', width: 90 }, |
228 { text: 'Vorm', datafield: 'form', align: 'left', width: 90 }, |
229 { text: 'Vorm', datafield: 'form', align: 'left', width: 90 }, |
229 { text: 'Alpha %', datafield: 'alpha', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
230 { text: 'Alpha %', datafield: 'alpha', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
230 { text: 'Beta %', datafield: 'beta', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
231 { text: 'Beta %', datafield: 'beta', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
231 { text: 'Cohumuloon %%', datafield: 'cohumulone', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
232 { text: 'Cohumuloon %%', datafield: 'cohumulone', width: 80, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'p1' }, |
232 { text: 'HSI', datafield: 'hsi', width: 60, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1' }, |
233 { text: 'HSI', datafield: 'hsi', width: 60, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1' }, |
233 { text: 'Oogst datum', datafield: 'production_date', align: 'center', cellsalign: 'center', menu: false, width: 110 }, |
234 { text: 'Oogst datum', datafield: 'production_date', align: 'center', cellsalign: 'center', menu: false, width: 110 }, |
234 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1', |
235 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', menu: false, cellsformat: 'f1', |
235 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
236 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
236 var amount = ''; |
237 var amount = ""; |
237 if (value > 0) { |
238 if (value > 0) { |
238 if (value < 1000) |
239 if (value < 1000) |
239 amount = dataAdapter.formatNumber(value, 'f1') + ' gr'; |
240 amount = dataAdapter.formatNumber(value,"f1")+" gr"; |
240 else |
241 else |
241 amount = dataAdapter.formatNumber(value / 1000.0, 'f1') + ' kg'; |
242 amount = dataAdapter.formatNumber(value / 1000.0,"f1")+" kg"; |
242 } |
243 } |
243 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
244 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
244 } |
245 } |
245 }, |
246 }, |
246 { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', menu: false, |
247 { text: '', datafield: 'Wijzig', columntype: 'button', width: 100, align: 'center', menu: false, |
247 cellsrenderer: function() { |
248 cellsrenderer: function () { |
248 return 'Wijzig'; |
249 return "Wijzig"; |
249 }, buttonclick: function(row) { |
250 }, buttonclick: function (row) { |
250 // open the popup window when the user clicks a button. |
251 // open the popup window when the user clicks a button. |
251 editrow = row; |
252 editrow = row; |
252 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
253 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
253 // get the clicked row's data and initialize the input fields. |
254 // get the clicked row's data and initialize the input fields. |
254 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); |
255 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
255 $('#name').val(dataRecord.name); |
256 $("#name").val(dataRecord.name); |
256 $('#alpha').val(dataRecord.alpha); |
257 $("#alpha").val(dataRecord.alpha); |
257 $('#beta').val(dataRecord.beta); |
258 $("#beta").val(dataRecord.beta); |
258 $('#humulene').val(dataRecord.humulene); |
259 $("#humulene").val(dataRecord.humulene); |
259 $('#caryophyllene').val(dataRecord.caryophyllene); |
260 $("#caryophyllene").val(dataRecord.caryophyllene); |
260 $('#cohumulone').val(dataRecord.cohumulone); |
261 $("#cohumulone").val(dataRecord.cohumulone); |
261 $('#myrcene').val(dataRecord.myrcene); |
262 $("#myrcene").val(dataRecord.myrcene); |
262 $('#hsi').val(dataRecord.hsi); |
263 $("#hsi").val(dataRecord.hsi); |
263 $('#type').val(dataRecord.type); |
264 $("#type").val(dataRecord.type); |
264 $('#form').val(dataRecord.form); |
265 $("#form").val(dataRecord.form); |
265 $('#notes').val(dataRecord.notes); |
266 $("#notes").val(dataRecord.notes); |
266 $('#origin').val(dataRecord.origin); |
267 $("#origin").val(dataRecord.origin); |
267 $('#substitutes').val(dataRecord.substitutes); |
268 $("#substitutes").val(dataRecord.substitutes); |
268 $('#always_on_stock').val(dataRecord.always_on_stock); |
269 $("#always_on_stock").val(dataRecord.always_on_stock); |
269 $('#inventory').val(dataRecord.inventory); |
270 $("#inventory").val(dataRecord.inventory); |
270 $('#cost').val(dataRecord.cost); |
271 $("#cost").val(dataRecord.cost); |
271 $('#production_date').val(dataRecord.production_date); |
272 $("#production_date").val(dataRecord.production_date); |
272 $('#tht_date').val(dataRecord.tht_date); |
273 $("#tht_date").val(dataRecord.tht_date); |
273 $('#total_oil').val(dataRecord.total_oil); |
274 $("#total_oil").val(dataRecord.total_oil); |
274 calcTotal(dataRecord.cost, dataRecord.inventory); |
275 calcTotal(dataRecord.cost, dataRecord.inventory); |
275 // show the popup window. |
276 // show the popup window. |
276 $('#popupWindow').jqxWindow('open'); |
277 $("#popupWindow").jqxWindow('open'); |
277 } |
278 } |
278 } |
279 } |
279 ] |
280 ] |
280 }); |
281 }); |
281 |
282 |
282 $('#cost').on('change', function(event) { |
283 $("#cost").on('change', function (event) { |
283 dataRecord.cost = parseFloat(event.args.value); |
284 dataRecord.cost = parseFloat(event.args.value); |
284 calcTotal(dataRecord.cost, dataRecord.inventory); |
285 calcTotal(dataRecord.cost, dataRecord.inventory); |
285 }); |
286 }); |
286 $('#inventory').on('change', function(event) { |
287 $("#inventory").on('change', function (event) { |
287 dataRecord.inventory = parseFloat(event.args.value); |
288 dataRecord.inventory = parseFloat(event.args.value); |
288 calcTotal(dataRecord.cost, dataRecord.inventory); |
289 calcTotal(dataRecord.cost, dataRecord.inventory); |
289 }); |
290 }); |
290 |
291 |
291 // initialize the popup window and buttons. |
292 // initialize the popup window and buttons. |
292 $('#popupWindow').jqxWindow({ |
293 $("#popupWindow").jqxWindow({ |
293 width: 1050, |
294 width: 1050, |
294 height: 550, |
295 height: 550, |
295 resizable: false, |
296 resizable: false, |
296 theme: theme, |
297 theme: theme, |
297 isModal: true, |
298 isModal: true, |
298 autoOpen: false, |
299 autoOpen: false, |
299 cancelButton: $('#Cancel'), |
300 cancelButton: $("#Cancel"), |
300 modalOpacity: 0.40 |
301 modalOpacity: 0.40 |
301 }); |
302 }); |
302 $('#popupWindow').on('open', function() { |
303 $("#popupWindow").on('open', function () { |
303 $('#name').jqxInput('selectAll'); |
304 $("#name").jqxInput('selectAll'); |
304 }); |
305 }); |
305 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); |
306 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); |
306 $('#Delete').click(function() { |
307 $("#Delete").click(function () { |
307 if (editrow >= 0) { |
308 if (editrow >= 0) { |
308 // Open a popup to confirm this action. |
309 // Open a popup to confirm this action. |
309 $('#eventWindow').jqxWindow('open'); |
310 $('#eventWindow').jqxWindow('open'); |
310 $('#delOk').click(function() { |
311 $("#delOk").click(function () { |
311 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
312 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
312 $('#jqxgrid').jqxGrid('deleterow', rowID); |
313 $("#jqxgrid").jqxGrid('deleterow', rowID); |
313 }); |
314 }); |
314 } |
315 } |
315 $('#popupWindow').jqxWindow('hide'); |
316 $("#popupWindow").jqxWindow('hide'); |
316 }); |
317 }); |
317 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); |
318 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); |
318 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme }); |
319 $("#Clone").jqxButton({ template: "warning", width: '90px', theme: theme }); |
319 $('#Clone').click(function() { |
320 $("#Clone").click(function () { |
320 var row = { |
321 var row = { |
321 record: -1, |
322 record: -1, |
322 name: $('#name').val() + ' kopie', |
323 name: $("#name").val()+" kopie", |
323 alpha: parseFloat($('#alpha').jqxNumberInput('decimal')), |
324 alpha: parseFloat($("#alpha").jqxNumberInput('decimal')), |
324 beta: parseFloat($('#beta').jqxNumberInput('decimal')), |
325 beta: parseFloat($("#beta").jqxNumberInput('decimal')), |
325 humulene: parseFloat($('#humulene').jqxNumberInput('decimal')), |
326 humulene: parseFloat($("#humulene").jqxNumberInput('decimal')), |
326 caryophyllene: parseFloat($('#caryophyllene').jqxNumberInput('decimal')), |
327 caryophyllene: parseFloat($("#caryophyllene").jqxNumberInput('decimal')), |
327 cohumulone: parseFloat($('#cohumulone').jqxNumberInput('decimal')), |
328 cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), |
328 myrcene: parseFloat($('#myrcene').jqxNumberInput('decimal')), |
329 myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), |
329 hsi: parseFloat($('#hsi').jqxNumberInput('decimal')), |
330 hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), |
330 type: $('#type').val(), |
331 type: $("#type").val(), |
331 form: $('#form').val(), |
332 form: $("#form").val(), |
332 notes: $('#notes').val(), |
333 notes: $("#notes").val(), |
333 origin: $('#origin').val(), |
334 origin: $("#origin").val(), |
334 substitutes: $('#substitutes').val(), |
335 substitutes: $("#substitutes").val(), |
335 always_on_stock: $('#always_on_stock').val(), |
336 always_on_stock: $("#always_on_stock").val(), |
336 inventory: 0, |
337 inventory: 0, |
337 cost: parseFloat($('#cost').jqxNumberInput('decimal')), |
338 cost: parseFloat($("#cost").jqxNumberInput('decimal')), |
338 production_date: '', |
339 production_date: '', |
339 tht_date: '', |
340 tht_date: '', |
340 total_oil: parseFloat($('#total_oil').jqxNumberInput('decimal')) |
341 total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) |
341 }; |
342 }; |
342 $('#jqxgrid').jqxGrid('addrow', null, row); |
343 $('#jqxgrid').jqxGrid('addrow', null, row); |
343 $('#popupWindow').jqxWindow('hide'); |
344 $("#popupWindow").jqxWindow('hide'); |
344 }); |
345 }); |
345 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
346 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
346 // update the edited row when the user clicks the 'Save' button. |
347 // update the edited row when the user clicks the 'Save' button. |
347 $('#Save').click(function() { |
348 $("#Save").click(function () { |
348 var row, rowID = -1; |
349 var row, rowID = -1; |
349 if (editrow >= 0) { |
350 if (editrow >= 0) { |
350 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
351 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
351 } |
352 } |
352 row = { |
353 row = { |
353 record: rowID, |
354 record: rowID, |
354 name: $('#name').val(), |
355 name: $("#name").val(), |
355 alpha: parseFloat($('#alpha').jqxNumberInput('decimal')), |
356 alpha: parseFloat($("#alpha").jqxNumberInput('decimal')), |
356 beta: parseFloat($('#beta').jqxNumberInput('decimal')), |
357 beta: parseFloat($("#beta").jqxNumberInput('decimal')), |
357 humulene: parseFloat($('#humulene').jqxNumberInput('decimal')), |
358 humulene: parseFloat($("#humulene").jqxNumberInput('decimal')), |
358 caryophyllene: parseFloat($('#caryophyllene').jqxNumberInput('decimal')), |
359 caryophyllene: parseFloat($("#caryophyllene").jqxNumberInput('decimal')), |
359 cohumulone: parseFloat($('#cohumulone').jqxNumberInput('decimal')), |
360 cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), |
360 myrcene: parseFloat($('#myrcene').jqxNumberInput('decimal')), |
361 myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), |
361 hsi: parseFloat($('#hsi').jqxNumberInput('decimal')), |
362 hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), |
362 type: $('#type').val(), |
363 type: $("#type").val(), |
363 form: $('#form').val(), |
364 form: $("#form").val(), |
364 notes: $('#notes').val(), |
365 notes: $("#notes").val(), |
365 origin: $('#origin').val(), |
366 origin: $("#origin").val(), |
366 substitutes: $('#substitutes').val(), |
367 substitutes: $("#substitutes").val(), |
367 always_on_stock: $('#always_on_stock').val(), |
368 always_on_stock: $("#always_on_stock").val(), |
368 inventory: parseFloat($('#inventory').jqxNumberInput('decimal')), |
369 inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), |
369 cost: parseFloat($('#cost').jqxNumberInput('decimal')), |
370 cost: parseFloat($("#cost").jqxNumberInput('decimal')), |
370 production_date: $('#production_date').val(), |
371 production_date: $("#production_date").val(), |
371 tht_date: $('#tht_date').val(), |
372 tht_date: $("#tht_date").val(), |
372 total_oil: parseFloat($('#total_oil').jqxNumberInput('decimal')) |
373 total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) |
373 }; |
374 }; |
374 if (editrow >= 0) { |
375 if (editrow >= 0) { |
375 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
376 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
376 } else { |
377 } else { |
377 $('#jqxgrid').jqxGrid('addrow', null, row); |
378 $('#jqxgrid').jqxGrid('addrow', null, row); |
378 } |
379 } |
379 $('#popupWindow').jqxWindow('hide'); |
380 $("#popupWindow").jqxWindow('hide'); |
380 }); |
381 }); |
381 createDelElements(); |
382 createDelElements(); |
|
383 }); |
382 }); |
384 |
383 |