www/js/inv_equipments.js

changeset 488
77f1617b6994
parent 286
124af734af68
child 494
af28ebe4a779
equal deleted inserted replaced
487:06df1320327c 488:77f1617b6994
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function () {
46 46
47 var dataRecord = {};
48
49 function calcBatchVolume() { 47 function calcBatchVolume() {
50 var calc = $("#calc_boil_volume").val(); 48 var calc = $("#calc_boil_volume").val(),
51 var boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal')); 49 boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal')),
52 var evap_rate = parseFloat($("#evap_rate").jqxNumberInput('decimal')); 50 evap_rate = parseFloat($("#evap_rate").jqxNumberInput('decimal')),
53 var boil_time = parseFloat($("#boil_time").jqxNumberInput('decimal')); 51 boil_time = parseFloat($("#boil_time").jqxNumberInput('decimal')),
54 var top_up = parseFloat($("#top_up_kettle").jqxNumberInput('decimal')); 52 top_up = parseFloat($("#top_up_kettle").jqxNumberInput('decimal')),
53 batch;
55 54
56 if (calc) { // If checked, calculate the batch size. 55 if (calc) { // If checked, calculate the batch size.
57 var batch = boil_size - (evap_rate * boil_time / 60) + top_up; 56 batch = boil_size - (evap_rate * boil_time / 60) + top_up;
58 $("#batch_size").val(batch); 57 $("#batch_size").val(batch);
59 } 58 }
60 } 59 }
61 60
62 var url = "includes/db_inventory_equipments.php";
63 // tooltips 61 // tooltips
64 $("#name").jqxTooltip({ content: 'The unique name of this brew equipment.' }); 62 $("#name").jqxTooltip({ content: 'The unique name of this brew equipment.' });
65 $("#notes").jqxTooltip({ content: 'Some notes about the equipment.' }); 63 $("#notes").jqxTooltip({ content: 'Some notes about the equipment.' });
66 $("#tun_volume").jqxTooltip({ content: 'Mash TUN volume.' }); 64 $("#tun_volume").jqxTooltip({ content: 'Mash TUN volume.' });
67 $("#tun_height").jqxTooltip({ content: 'Mash TUN height in cm.' }); 65 $("#tun_height").jqxTooltip({ content: 'Mash TUN height in cm.' });
80 $("#boil_time").jqxTooltip({ content: 'Normal boil time in minutes.' }); 78 $("#boil_time").jqxTooltip({ content: 'Normal boil time in minutes.' });
81 $("#top_up_kettle").jqxTooltip({ content: 'Extra water added to the boil.' }); 79 $("#top_up_kettle").jqxTooltip({ content: 'Extra water added to the boil.' });
82 $("#hop_utilization").jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' }); 80 $("#hop_utilization").jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' });
83 $("#batch_size").jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' }); 81 $("#batch_size").jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' });
84 $("#trub_chiller_loss").jqxTooltip({ content: 'Standard loss in liters during transfer to the fermenter.' }); 82 $("#trub_chiller_loss").jqxTooltip({ content: 'Standard loss in liters during transfer to the fermenter.' });
85 83
84 var dataRecord = {},
85 url = 'includes/db_inventory_equipments.php',
86 // prepare the data 86 // prepare the data
87 var source = { 87 source = {
88 datatype: "json", 88 datatype: "json",
89 cache: false, 89 cache: false,
90 datafields: [ 90 datafields: [
91 { name: 'record', type: 'number' }, 91 { name: 'record', type: 'number' },
92 { name: 'name', type: 'string' }, 92 { name: 'name', type: 'string' },
124 url: url, 124 url: url,
125 cache: false, 125 cache: false,
126 data: data, 126 data: data,
127 type: "POST", 127 type: "POST",
128 success: function (data, status, xhr) { 128 success: function (data, status, xhr) {
129 // delete command is executed.
130 commit(true); 129 commit(true);
130 location.reload( true );
131 }, 131 },
132 error: function (jqXHR, textStatus, errorThrown) { 132 error: function (jqXHR, textStatus, errorThrown) {
133 commit(false); 133 commit(false);
134 } 134 }
135 }); 135 });
142 cache: false, 142 cache: false,
143 data: data, 143 data: data,
144 type: "POST", 144 type: "POST",
145 success: function (data, status, xhr) { 145 success: function (data, status, xhr) {
146 commit(true); 146 commit(true);
147 location.reload( true );
147 }, 148 },
148 error: function(jqXHR, textStatus, errorThrown) { 149 error: function(jqXHR, textStatus, errorThrown) {
149 commit(false); 150 commit(false);
150 } 151 }
151 }); 152 });
157 url: url, 158 url: url,
158 cache: false, 159 cache: false,
159 data: data, 160 data: data,
160 type: "POST", 161 type: "POST",
161 success: function (data, status, xhr) { 162 success: function (data, status, xhr) {
162 // update command is executed.
163 commit(true); 163 commit(true);
164 location.reload( true );
164 }, 165 },
165 error: function(jqXHR, textStatus, errorThrown) { 166 error: function(jqXHR, textStatus, errorThrown) {
166 commit(false); 167 commit(false);
167 } 168 }
168 }); 169 });
181 $("#tun_material").jqxDropDownList({ 182 $("#tun_material").jqxDropDownList({
182 theme: theme, 183 theme: theme,
183 source: MaterialAdapter, 184 source: MaterialAdapter,
184 valueMember: 'id', 185 valueMember: 'id',
185 displayMember: 'nl', 186 displayMember: 'nl',
186 // selectedIndex: 0,
187 width: 180, 187 width: 180,
188 height: 23, 188 height: 23,
189 autoDropDownHeight: true 189 autoDropDownHeight: true
190 }); 190 });
191 $("#tun_height").jqxNumberInput( Spin1dec ); 191 $("#tun_height").jqxNumberInput( Spin1dec );
221 height: 630, 221 height: 630,
222 source: dataAdapter, 222 source: dataAdapter,
223 theme: theme, 223 theme: theme,
224 showstatusbar: true, 224 showstatusbar: true,
225 renderstatusbar: function (statusbar) { 225 renderstatusbar: function (statusbar) {
226 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 226 var addButton, container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
227 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>"); 227 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>");
228 container.append(addButton); 228 container.append(addButton);
229 statusbar.append(container); 229 statusbar.append(container);
230 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 230 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
231 // add new row. 231 // add new row.
232 addButton.click(function (event) { 232 addButton.click(function (event) {
342 }); 342 });
343 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 343 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme });
344 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 344 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
345 // update the edited row when the user clicks the 'Save' button. 345 // update the edited row when the user clicks the 'Save' button.
346 $("#Save").click(function () { 346 $("#Save").click(function () {
347 var rowID = -1; 347 var row, rowID = -1;
348 if (editrow >= 0) { 348 if (editrow >= 0) {
349 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 349 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
350 } 350 }
351 var row = { 351 row = {
352 record: rowID, 352 record: rowID,
353 name: $("#name").val(), 353 name: $("#name").val(),
354 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), 354 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
355 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), 355 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
356 tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')), 356 tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')),
379 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 379 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
380 } else { 380 } else {
381 $('#jqxgrid').jqxGrid('addrow', null, row); 381 $('#jqxgrid').jqxGrid('addrow', null, row);
382 } 382 }
383 $("#popupWindow").jqxWindow('hide'); 383 $("#popupWindow").jqxWindow('hide');
384 location.reload( true ); // reload ourself.
385 }); 384 });
386 createDelElements(); 385 createDelElements();
387 }); 386 });
388 387

mercurial