|
1 /***************************************************************************** |
|
2 * Copyright (C) 2018 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of BMS |
|
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 $(document).ready(function () { |
|
25 |
|
26 var dataRecord = {}; |
|
27 |
|
28 // dropdownlist datasource from inventory_waters, must load sync |
|
29 var waterUrl = "getwatersources.php"; |
|
30 var waterInvSource = { |
|
31 datatype: "json", |
|
32 datafields: [ |
|
33 { name: 'name', type: 'string' }, |
|
34 ], |
|
35 url: waterUrl, |
|
36 async: false |
|
37 }; |
|
38 var waterlist = new $.jqx.dataAdapter(waterInvSource); |
|
39 |
|
40 var url = "includes/db_setup.php"; |
|
41 |
|
42 // Tooltips |
|
43 $("#brewery_name").jqxTooltip({ content: 'De naam voor deze brouwerij.' }); |
|
44 $("#factor_mashhop").jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' }); |
|
45 $("#factor_fwh").jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' }); |
|
46 $("#factor_pellet").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' }); |
|
47 $("#factor_plug").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' }); |
|
48 $("#brix_correction").jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' }); |
|
49 $("#grain_absorbtion").jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' }); |
|
50 |
|
51 // Prepare the data |
|
52 var source = { |
|
53 datatype: "json", |
|
54 cache: false, |
|
55 datafields: [ |
|
56 { name: 'brewery_name', type: 'string' }, |
|
57 /* { name: 'brewery_logo', type: 'array' }, */ |
|
58 { name: 'factor_mashhop', type: 'number' }, |
|
59 { name: 'factor_fwh', type: 'number' }, |
|
60 { name: 'factor_pellet', type: 'number' }, |
|
61 { name: 'factor_plug', type: 'number' }, |
|
62 { name: 'ibu_method', type: 'string' }, |
|
63 { name: 'color_method', type: 'string' }, |
|
64 { name: 'brix_correction', type: 'float' }, |
|
65 { name: 'grain_absorbtion', type: 'float' }, |
|
66 { name: 'default_water', type: 'string' } |
|
67 ], |
|
68 url: url |
|
69 }; |
|
70 |
|
71 // Load data and select one record. |
|
72 var dataAdapter = new $.jqx.dataAdapter(source, { |
|
73 loadComplete: function () { |
|
74 var records = dataAdapter.records; |
|
75 dataRecord = records[0]; |
|
76 $("#brewery_name").val(dataRecord.brewery_name); |
|
77 $("#factor_mashhop").val(dataRecord.factor_mashhop); |
|
78 $("#factor_fwh").val(dataRecord.factor_fwh); |
|
79 $("#factor_pellet").val(dataRecord.factor_pellet); |
|
80 $("#factor_plug").val(dataRecord.factor_plug); |
|
81 $("#color_method").val(dataRecord.color_method); |
|
82 $("#ibu_method").val(dataRecord.ibu_method); |
|
83 $("#brix_correction").val(dataRecord.brix_correction); |
|
84 $("#grain_absorbtion").val(dataRecord.grain_absorbtion); |
|
85 $("#default_water").val(dataRecord.default_water); |
|
86 }, |
|
87 loadError: function (jqXHR, status, error) { |
|
88 }, |
|
89 }); |
|
90 dataAdapter.dataBind(); |
|
91 |
|
92 // Editers |
|
93 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
|
94 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. |
|
95 $("#brewery_name").jqxInput({ theme: theme, width: 640, height: 23 }); |
|
96 $("#factor_fwh").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
97 $("#factor_mashhop").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
98 $("#factor_pellet").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
99 $("#factor_plug").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
100 $("#brix_correction").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.00, max: 1.08, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 }); |
|
101 $("#grain_absorbtion").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.00, max: 1.25, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 }); |
|
102 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
|
103 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95 }); |
|
104 $('#default_water').jqxDropDownList({ |
|
105 placeHolder: "Kies water:", |
|
106 theme: theme, |
|
107 source: waterlist, |
|
108 valueMember: "name", |
|
109 displayMember: "name", |
|
110 width: 250, |
|
111 height: 27, |
|
112 dropDownHorizontalAlignment: 'right', |
|
113 dropDownWidth: 300 |
|
114 }); |
|
115 $('#default_water').jqxDropDownList( 'selectItem', dataRecord.default_water ); |
|
116 |
|
117 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
|
118 $("#Save").click(function () { |
|
119 var row = { |
|
120 record: 1, |
|
121 brewery_name: $("#brewery_name").val(), |
|
122 factor_mashhop: $("#factor_mashhop").val(), |
|
123 factor_fwh: $("#factor_fwh").val(), |
|
124 factor_pellet: $("#factor_pellet").val(), |
|
125 factor_plug: $("#factor_plug").val(), |
|
126 color_method: $("#color_method").val(), |
|
127 ibu_method: $("#ibu_method").val(), |
|
128 brix_correction: parseFloat($("#brix_correction").jqxNumberInput('decimal')), |
|
129 grain_absorbtion: parseFloat($("#grain_absorbtion").jqxNumberInput('decimal')), |
|
130 default_water: $("#default_water").val() |
|
131 }; |
|
132 var data = "update=true&" + $.param(row); |
|
133 $.ajax({ |
|
134 dataType: 'json', |
|
135 url: url, |
|
136 cache: false, |
|
137 data: data, |
|
138 type: "POST", |
|
139 success: function (data, status, xhr) { |
|
140 // update command is executed. |
|
141 //window.location.href = my_return; |
|
142 }, |
|
143 error: function(jqXHR, textStatus, errorThrown) { |
|
144 } |
|
145 }); |
|
146 }); |
|
147 }); |