Sat, 19 Jan 2019 12:12:12 +0100
Changed buttons colors.
14 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2014-2018 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of BrewCloud | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * BrewCloud is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
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 | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | ||
24 | function createDelElements() { | |
25 | $('#eventWindow').jqxWindow({ | |
26 | theme: theme, | |
27 | position: { x: 490, y: 210 }, | |
28 | width: 300, | |
34 | 29 | height: 175, |
14 | 30 | resizable: false, |
31 | isModal: true, | |
32 | modalOpacity: 0.4, | |
33 | okButton: $('#delOk'), | |
34 | cancelButton: $('#delCancel'), | |
35 | initContent: function () { | |
36 | $('#delOk').jqxButton({ width: '65px', theme: theme }); | |
37 | $('#delCancel').jqxButton({ width: '65px', theme: theme }); | |
38 | $('#delCancel').focus(); | |
39 | } | |
40 | }); | |
41 | $('#eventWindow').jqxWindow('hide'); | |
42 | } | |
43 | ||
44 | ||
45 | $(document).ready(function () { | |
46 | var url = "includes/db_inventory_yeasts.php"; | |
47 | // prepare the data | |
48 | var source = { | |
49 | datatype: "json", | |
50 | cache: false, | |
51 | datafields: [ | |
52 | { name: 'record', type: 'number' }, | |
53 | { name: 'name', type: 'string' }, | |
54 | { name: 'type', type: 'string' }, | |
55 | { name: 'form', type: 'string' }, | |
56 | { name: 'laboratory', type: 'string' }, | |
57 | { name: 'product_id', type: 'string' }, | |
58 | { name: 'min_temperature', type: 'number' }, | |
59 | { name: 'max_temperature', type: 'number' }, | |
60 | { name: 'flocculation', type: 'string' }, | |
61 | { name: 'attenuation', type: 'float' }, | |
62 | { name: 'notes', type: 'string' }, | |
63 | { name: 'best_for', type: 'string' }, | |
64 | { name: 'max_reuse', type: 'number' }, | |
65 | { name: 'inventory', type: 'float' }, | |
66 | { name: 'cost', type: 'float' }, | |
67 | { name: 'production_date', type: 'string' }, | |
68 | { name: 'tht_date', type: 'string' } | |
69 | ], | |
70 | id: 'record', | |
71 | url: url, | |
72 | deleterow: function (rowid, commit) { | |
73 | // synchronize with the server - send delete command | |
74 | var data = "delete=true&" + $.param({ record: rowid }); | |
75 | $.ajax({ | |
76 | dataType: 'json', | |
77 | url: url, | |
78 | cache: false, | |
79 | data: data, | |
80 | success: function (data, status, xhr) { | |
81 | // delete command is executed. | |
82 | commit(true); | |
83 | }, | |
84 | error: function (jqXHR, textStatus, errorThrown) { | |
85 | commit(false); | |
86 | } | |
87 | }); | |
88 | }, | |
89 | addrow: function (rowid, rowdata, position, commit) { | |
90 | var data = "insert=true&" + $.param(rowdata); | |
91 | $.ajax({ | |
92 | dataType: 'json', | |
93 | url: url, | |
94 | cache: false, | |
95 | data: data, | |
96 | success: function (data, status, xhr) { | |
97 | commit(true); | |
98 | }, | |
99 | error: function(jqXHR, textStatus, errorThrown) { | |
100 | commit(false); | |
101 | } | |
102 | }); | |
103 | }, | |
104 | updaterow: function (rowid, rowdata, commit) { | |
105 | var data = "update=true&" + $.param(rowdata); | |
106 | $.ajax({ | |
107 | dataType: 'json', | |
108 | url: url, | |
109 | cache: false, | |
110 | data: data, | |
111 | success: function (data, status, xhr) { | |
112 | // update command is executed. | |
113 | commit(true); | |
114 | }, | |
115 | error: function(jqXHR, textStatus, errorThrown) { | |
116 | commit(false); | |
117 | } | |
118 | }); | |
119 | } | |
120 | }; | |
121 | var srcType = [ "Ale", "Lager", "Wheat", "Wine", "Champagne" ]; | |
122 | var srcForm = [ "Liquid", "Dry", "Slant", "Culture", "Bottle", "Frozen" ]; | |
123 | var srcFlocculation = [ "Low", "Medium", "High", "Very High" ]; | |
124 | // initialize the input fields. | |
125 | $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); | |
126 | $("#laboratory").jqxInput({ theme: theme, width: 150, height: 23 }); | |
127 | $("#product_id").jqxInput({ theme: theme, width: 120, height: 23 }); | |
128 | $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 90, height: 23, dropDownHeight: 170 }); | |
129 | $("#form").jqxDropDownList({ theme: theme, source: srcForm, selectedIndex: 0, width: 90, height: 23, dropDownHeight: 195 }); | |
130 | $("#notes").jqxInput({ theme: theme, width: 640, height: 120 }); | |
131 | $("#best_for").jqxInput({ theme: theme, width: 640, height: 23 }); | |
33
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
132 | $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); |
14 | 133 | $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); |
134 | ||
135 | $("#min_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 35, decimalDigits: 0, spinButtons: true }); | |
136 | $("#max_temperature").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 35, decimalDigits: 0, spinButtons: true }); | |
137 | $("#flocculation").jqxDropDownList({ theme: theme, source: srcFlocculation, width: 90, height: 23, dropDownHeight: 130 }); | |
138 | $("#attenuation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 50, max: 100, decimalDigits: 1, spinButtons: true }); | |
139 | ||
140 | $("#max_reuse").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 10, decimalDigits: 0, spinButtons: true }); | |
33
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
141 | $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); |
14 | 142 | $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); |
143 | ||
144 | var dataAdapter = new $.jqx.dataAdapter(source); | |
145 | var editrow = -1; | |
146 | // initialize jqxGrid | |
147 | $("#jqxgrid").jqxGrid({ | |
148 | width: 1280, | |
149 | height: 630, | |
150 | source: dataAdapter, | |
151 | theme: theme, | |
152 | showstatusbar: true, | |
153 | localization: getLocalization(), | |
154 | renderstatusbar: function (statusbar) { | |
155 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
34 | 156 | var 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>"); |
14 | 157 | container.append(addButton); |
158 | statusbar.append(container); | |
34 | 159 | addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
14 | 160 | // add new row. |
161 | addButton.click(function (event) { | |
162 | editrow = -1; | |
163 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); | |
164 | $("#name").val(''); | |
165 | $("#laboratory").val(''); | |
166 | $("#product_id").val(''); | |
167 | $("#type").val('Ale'); | |
168 | $("#form").val('Liquid'); | |
169 | $("#min_temperature").val(''); | |
170 | $("#max_temperature").val(''); | |
171 | $("#flocculation").val('Low'); | |
172 | $("#attenuation").val('75.0'); | |
173 | $("#notes").val(''); | |
174 | $("#best_for").val(''); | |
175 | $("#max_reuse").val(''); | |
176 | $("#inventory").val(''); | |
177 | $("#cost").val(''); | |
178 | $("#production_date").val(''); | |
179 | $("#tht_date").val(''); | |
180 | $("#popupWindow").jqxWindow('open'); | |
181 | }); | |
182 | }, | |
183 | filterable: true, | |
184 | filtermode: 'excel', | |
185 | columns: [ | |
186 | { text: 'Laboratorium', datafield: 'laboratory', width: 150 }, | |
187 | { text: 'Product ID', datafield: 'product_id', width: 120 }, | |
37
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
188 | { text: 'Gist naam', datafield: 'name' }, |
33
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
189 | { text: 'Type', datafield: 'type', align: 'center', cellsalign: 'center', width: 90 }, |
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
190 | { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 90 }, |
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
191 | { text: 'Vergistingsgraad', datafield: 'attenuation', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'p0' }, |
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
192 | { text: 'Voor. gr/ml', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
2ee6ad5d6f14
More weight/volmes standards in the database.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
193 | { text: 'Prijs kg/l', datafield: 'cost', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'c2' }, |
37
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
194 | { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 120, align: 'center', cellsrenderer: function () { |
34 | 195 | return "Wijzig"; |
14 | 196 | }, buttonclick: function (row) { |
197 | // open the popup window when the user clicks a button. | |
198 | editrow = row; | |
199 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); | |
200 | // get the clicked row's data and initialize the input fields. | |
201 | var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); | |
202 | $("#name").val(dataRecord.name); | |
203 | $("#laboratory").val(dataRecord.laboratory); | |
204 | $("#product_id").val(dataRecord.product_id); | |
205 | $("#type").val(dataRecord.type); | |
206 | $("#form").val(dataRecord.form); | |
207 | $("#min_temperature").val(dataRecord.min_temperature); | |
208 | $("#max_temperature").val(dataRecord.max_temperature); | |
209 | $("#flocculation").val(dataRecord.flocculation); | |
210 | $("#attenuation").val(dataRecord.attenuation); | |
211 | $("#notes").val(dataRecord.notes); | |
212 | $("#best_for").val(dataRecord.best_for); | |
213 | $("#max_reuse").val(dataRecord.max_reuse); | |
214 | $("#inventory").val(dataRecord.inventory); | |
215 | $("#cost").val(dataRecord.cost); | |
216 | $("#production_date").val(dataRecord.production_date); | |
217 | $("#tht_date").val(dataRecord.tht_date); | |
218 | // show the popup window. | |
219 | $("#popupWindow").jqxWindow('open'); | |
220 | } | |
221 | } | |
222 | ] | |
223 | }); | |
224 | // initialize the popup window and buttons. | |
225 | $("#popupWindow").jqxWindow({ | |
226 | width: 860, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 | |
227 | }); | |
228 | $("#popupWindow").on('open', function () { | |
229 | $("#name").jqxInput('selectAll'); | |
230 | }); | |
231 | $("#Delete").jqxButton({ theme: theme }); | |
232 | $("#Delete").click(function () { | |
233 | if (editrow >= 0) { | |
234 | // Open a popup to confirm this action. | |
235 | $('#eventWindow').jqxWindow('open'); | |
236 | $("#delOk").click(function () { | |
237 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
238 | $("#jqxgrid").jqxGrid('deleterow', rowID); | |
239 | }); | |
240 | } | |
241 | $("#popupWindow").jqxWindow('hide'); | |
242 | }); | |
243 | $("#Cancel").jqxButton({ theme: theme }); | |
244 | $("#Save").jqxButton({ theme: theme }); | |
245 | // update the edited row when the user clicks the 'Save' button. | |
246 | $("#Save").click(function () { | |
247 | if (editrow >= 0) { | |
248 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
249 | var row = { | |
250 | record: rowID, | |
251 | name: $("#name").val(), | |
252 | type: $("#type").val(), | |
253 | form: $("#form").val(), | |
254 | laboratory: $("#laboratory").val(), | |
255 | product_id: $("#product_id").val(), | |
256 | min_temperature: parseInt($("#min_temperature").jqxNumberInput('decimal')), | |
257 | max_temperature: parseInt($("#max_temperature").jqxNumberInput('decimal')), | |
258 | flocculation: $("#flocculation").val(), | |
259 | attenuation: parseFloat($("#attenuation").jqxNumberInput('decimal')), | |
260 | notes: $("#notes").val(), | |
261 | best_for: $("#best_for").val(), | |
262 | max_reuse: parseInt($("#max_reuse").jqxNumberInput('decimal')), | |
263 | inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), | |
264 | cost: parseFloat($("#cost").jqxNumberInput('decimal')), | |
265 | production_date: $("#production_date").val(), | |
266 | tht_date: $("#tht_date").val() | |
267 | }; | |
268 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); | |
269 | $("#popupWindow").jqxWindow('hide'); | |
270 | } else { | |
271 | // Insert a record | |
272 | var newrow = { | |
273 | record: -1, | |
274 | name: $("#name").val(), | |
275 | type: $("#type").val(), | |
276 | form: $("#form").val(), | |
277 | laboratory: $("#laboratory").val(), | |
278 | product_id: $("#product_id").val(), | |
279 | min_temperature: parseInt($("#min_temperature").jqxNumberInput('decimal')), | |
280 | max_temperature: parseInt($("#max_temperature").jqxNumberInput('decimal')), | |
281 | flocculation: $("#flocculation").val(), | |
282 | attenuation: parseFloat($("#attenuation").jqxNumberInput('decimal')), | |
283 | notes: $("#notes").val(), | |
284 | best_for: $("#best_for").val(), | |
285 | max_reuse: parseInt($("#max_reuse").jqxNumberInput('decimal')), | |
286 | inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), | |
287 | cost: parseFloat($("#cost").jqxNumberInput('decimal')), | |
288 | production_date: $("#production_date").val(), | |
289 | tht_date: $("#tht_date").val() | |
290 | }; | |
291 | $('#jqxgrid').jqxGrid('addrow', null, newrow); | |
292 | $("#popupWindow").jqxWindow('hide'); | |
293 | } | |
294 | }); | |
295 | createDelElements(); | |
296 | }); | |
297 |