Sat, 26 Jan 2019 15:03:09 +0100
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
22 | 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, |
22 | 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 () { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
46 | var url = "includes/db_profile_water.php"; |
22 | 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: 'calcium', type: 'float' }, | |
55 | { name: 'bicarbonate', type: 'float' }, | |
56 | { name: 'sulfate', type: 'float' }, | |
57 | { name: 'chloride', type: 'float' }, | |
58 | { name: 'sodium', type: 'float' }, | |
59 | { name: 'magnesium', type: 'float' }, | |
60 | { name: 'ph', type: 'float' }, | |
61 | { name: 'notes', type: 'string' }, | |
62 | { name: 'total_alkalinity', type: 'float' } | |
63 | ], | |
64 | id: 'record', | |
65 | url: url, | |
66 | deleterow: function (rowid, commit) { | |
67 | // synchronize with the server - send delete command | |
68 | var data = "delete=true&" + $.param({ record: rowid }); | |
69 | $.ajax({ | |
70 | dataType: 'json', | |
71 | url: url, | |
72 | cache: false, | |
73 | data: data, | |
74 | success: function (data, status, xhr) { | |
75 | // delete command is executed. | |
76 | commit(true); | |
77 | }, | |
78 | error: function (jqXHR, textStatus, errorThrown) { | |
79 | commit(false); | |
80 | } | |
81 | }); | |
82 | }, | |
83 | addrow: function (rowid, rowdata, position, commit) { | |
84 | var data = "insert=true&" + $.param(rowdata); | |
85 | $.ajax({ | |
86 | dataType: 'json', | |
87 | url: url, | |
88 | cache: false, | |
89 | data: data, | |
90 | success: function (data, status, xhr) { | |
91 | commit(true); | |
92 | }, | |
93 | error: function(jqXHR, textStatus, errorThrown) { | |
94 | commit(false); | |
95 | } | |
96 | }); | |
97 | }, | |
98 | updaterow: function (rowid, rowdata, commit) { | |
99 | var data = "update=true&" + $.param(rowdata); | |
100 | $.ajax({ | |
101 | dataType: 'json', | |
102 | url: url, | |
103 | cache: false, | |
104 | data: data, | |
105 | success: function (data, status, xhr) { | |
106 | // update command is executed. | |
107 | commit(true); | |
108 | }, | |
109 | error: function(jqXHR, textStatus, errorThrown) { | |
110 | commit(false); | |
111 | } | |
112 | }); | |
113 | } | |
114 | }; | |
115 | // initialize the input fields. | |
116 | $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); | |
117 | $("#calcium").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
118 | $("#bicarbonate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
119 | $("#sulfate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
120 | $("#chloride").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
121 | $("#sodium").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
122 | $("#magnesium").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
123 | $("#ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
124 | ||
125 | $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); | |
126 | $("#total_alkalinity").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
127 | var dataAdapter = new $.jqx.dataAdapter(source); | |
128 | var editrow = -1; | |
129 | // initialize jqxGrid | |
130 | $("#jqxgrid").jqxGrid({ | |
131 | width: 1280, | |
132 | height: 630, | |
133 | source: dataAdapter, | |
134 | theme: theme, | |
135 | showstatusbar: true, | |
136 | localization: getLocalization(), | |
137 | renderstatusbar: function (statusbar) { | |
138 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
34 | 139 | 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>"); |
22 | 140 | container.append(addButton); |
141 | statusbar.append(container); | |
34 | 142 | addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
22 | 143 | // add new row. |
144 | addButton.click(function (event) { | |
145 | editrow = -1; | |
146 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); | |
147 | $("#name").val(''); | |
148 | $("#calcium").val(''); | |
149 | $("#bicarbonate").val(''); | |
150 | $("#sulfate").val(''); | |
151 | $("#chloride").val(''); | |
152 | $("#sodium").val(''); | |
153 | $("#magnesium").val(''); | |
154 | $("#ph").val(''); | |
155 | $("#notes").val(''); | |
156 | $("#total_alkalinity").val(''); | |
157 | $("#popupWindow").jqxWindow('open'); | |
158 | }); | |
159 | }, | |
160 | filterable: true, | |
161 | filtermode: 'excel', | |
162 | columns: [ | |
34 | 163 | { text: 'Water Profiel', datafield: 'name', width: 250 }, |
164 | { text: 'Opmerkingen', datafield: 'notes', width: 475 }, | |
165 | { text: 'Natrium', datafield: 'sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
166 | { text: 'Chloride', datafield: 'chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
167 | { text: 'Sulfaat', datafield: 'sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
168 | { text: 'Zuurgraad', datafield: 'ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
169 | { text: 'Alkaliteit', datafield: 'total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
170 | { text: 'Wijzig', datafield: 'Edit', columntype: 'button', cellsrenderer: function () { | |
171 | return "Wijzig"; | |
22 | 172 | }, buttonclick: function (row) { |
173 | // open the popup window when the user clicks a button. | |
174 | editrow = row; | |
175 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); | |
176 | // get the clicked row's data and initialize the input fields. | |
177 | var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); | |
178 | $("#name").val(dataRecord.name); | |
179 | $("#calcium").val(dataRecord.calcium); | |
180 | $("#bicarbonate").val(dataRecord.bicarbonate); | |
181 | $("#sulfate").val(dataRecord.sulfate); | |
182 | $("#chloride").val(dataRecord.chloride); | |
183 | $("#sodium").val(dataRecord.sodium); | |
184 | $("#magnesium").val(dataRecord.magnesium); | |
185 | $("#ph").val(dataRecord.ph); | |
186 | $("#notes").val(dataRecord.notes); | |
187 | $("#total_alkalinity").val(dataRecord.total_alkalinity); | |
188 | // show the popup window. | |
189 | $("#popupWindow").jqxWindow('open'); | |
190 | } | |
191 | } | |
192 | ] | |
193 | }); | |
194 | // initialize the popup window and buttons. | |
195 | $("#popupWindow").jqxWindow({ | |
196 | width: 860, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 | |
197 | }); | |
198 | $("#popupWindow").on('open', function () { | |
199 | $("#name").jqxInput('selectAll'); | |
200 | }); | |
201 | $("#Delete").jqxButton({ theme: theme }); | |
202 | $("#Delete").click(function () { | |
203 | if (editrow >= 0) { | |
204 | // Open a popup to confirm this action. | |
205 | $('#eventWindow').jqxWindow('open'); | |
206 | $("#delOk").click(function () { | |
207 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
208 | $("#jqxgrid").jqxGrid('deleterow', rowID); | |
209 | }); | |
210 | } | |
211 | $("#popupWindow").jqxWindow('hide'); | |
212 | }); | |
213 | $("#Cancel").jqxButton({ theme: theme }); | |
214 | $("#Save").jqxButton({ theme: theme }); | |
215 | // update the edited row when the user clicks the 'Save' button. | |
216 | $("#Save").click(function () { | |
217 | if (editrow >= 0) { | |
218 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
219 | var row = { | |
220 | record: rowID, | |
221 | name: $("#name").val(), | |
222 | calcium: parseFloat($("#calcium").jqxNumberInput('decimal')), | |
223 | bicarbonate: parseFloat($("#bicarbonate").jqxNumberInput('decimal')), | |
224 | sulfate: parseFloat($("#sulfate").jqxNumberInput('decimal')), | |
225 | chloride: parseFloat($("#chloride").jqxNumberInput('decimal')), | |
226 | sodium: parseFloat($("#sodium").jqxNumberInput('decimal')), | |
227 | magnesium: parseFloat($("#magnesium").jqxNumberInput('decimal')), | |
228 | ph: parseFloat($("#ph").jqxNumberInput('decimal')), | |
229 | notes: $("#notes").val(), | |
230 | total_alkalinity: parseFloat($("#total_alkalinity").jqxNumberInput('decimal')) | |
231 | }; | |
232 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); | |
233 | $("#popupWindow").jqxWindow('hide'); | |
234 | } else { | |
235 | // Insert a record | |
236 | var newrow = { | |
237 | record: -1, | |
238 | name: $("#name").val(), | |
239 | calcium: parseFloat($("#calcium").jqxNumberInput('decimal')), | |
240 | bicarbonate: parseFloat($("#bicarbonate").jqxNumberInput('decimal')), | |
241 | sulfate: parseFloat($("#sulfate").jqxNumberInput('decimal')), | |
242 | chloride: parseFloat($("#chloride").jqxNumberInput('decimal')), | |
243 | sodium: parseFloat($("#sodium").jqxNumberInput('decimal')), | |
244 | magnesium: parseFloat($("#magnesium").jqxNumberInput('decimal')), | |
245 | ph: parseFloat($("#ph").jqxNumberInput('decimal')), | |
246 | notes: $("#notes").val(), | |
247 | total_alkalinity: parseFloat($("#total_alkalinity").jqxNumberInput('decimal')) | |
248 | }; | |
249 | $('#jqxgrid').jqxGrid('addrow', null, newrow); | |
250 | $("#popupWindow").jqxWindow('hide'); | |
251 | } | |
252 | }); | |
253 | createDelElements(); | |
254 | }); | |
255 |