Sat, 18 Aug 2018 21:29:54 +0200
Added inventory equipments
--- a/README.design Sat Aug 18 19:41:31 2018 +0200 +++ b/README.design Sat Aug 18 21:29:54 2018 +0200 @@ -29,7 +29,7 @@ Database inventaris: Werking Maten ---------------------------- ------- ------- -inventory_equipments +inventory_equipments Ok. inventory_fermentables Ok. inventory_hops Ok. inventory_mash_profiles Ok zonder de steps.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/includes/db_inventory_equipments.php Sat Aug 18 21:29:54 2018 +0200 @@ -0,0 +1,142 @@ +<?php +require($_SERVER['DOCUMENT_ROOT']."/config.php"); +require($_SERVER['DOCUMENT_ROOT']."/version.php"); + +#Connect to the database +$connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); +if (! $connect) { + die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); +} + +// get data and store in a json array +$query = "SELECT * FROM inventory_equipments"; +if (isset($_GET['insert'])) { + // INSERT COMMAND + $sql = "INSERT INTO `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); + $sql .= "', boil_size='" . $_GET['boil_size']; + $sql .= "', tun_volume='" . $_GET['tun_volume']; + $sql .= "', tun_weight='" . $_GET['tun_weight']; + $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; + $sql .= "', evap_rate='" . $_GET['evap_rate']; + $sql .= "', boil_time='" . $_GET['boil_time']; + $sql .= "', calc_boil_volume='Y"; + $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; + $sql .= "', batch_size='" . eval('return ' . $batch . ';'); + $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; + $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; + $sql .= "', hop_utilization='" . $_GET['hop_utilization']; + $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); + $sql .= "', lauter_volume='" . $_GET['lauter_volume']; + $sql .= "', kettle_volume='" . $_GET['kettle_volume']; + $material = mysqli_real_escape_string($connect, $_GET['tun_material']); + $sql .= "', tun_material='" . $material; + if ($material == "RVS") { + $sql .= "', tun_specific_heat='0.11"; + } else if ($material == "Aluminium") { + $sql .= "', tun_specific_heat='0.22"; + } else if ($material == "Kunststof") { + $sql .= "', tun_specific_heat='0.46"; + } else if ($material == "Koper") { + $sql .= "', tun_specific_heat='0.092"; + } + $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; + $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; + $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; + $sql .= "', mash_volume='" . $_GET['mash_volume']; + $sql .= "', efficiency='" . $_GET['efficiency']; + $sql .= "';"; + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_equipment: inserted ".$_GET['name']); + } + echo $result; + +} else if (isset($_GET['update'])) { + // UPDATE COMMAND + $sql = "UPDATE `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); + $sql .= "', boil_size='" . $_GET['boil_size']; + $sql .= "', tun_volume='" . $_GET['tun_volume']; + $sql .= "', tun_weight='" . $_GET['tun_weight']; + $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; + $sql .= "', evap_rate='" . $_GET['evap_rate']; + $sql .= "', boil_time='" . $_GET['boil_time']; + $sql .= "', calc_boil_volume='Y"; + $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; + $sql .= "', batch_size='" . eval('return ' . $batch . ';'); + $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; + $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; + $sql .= "', hop_utilization='" . $_GET['hop_utilization']; + $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); + $sql .= "', lauter_volume='" . $_GET['lauter_volume']; + $sql .= "', kettle_volume='" . $_GET['kettle_volume']; + $material = mysqli_real_escape_string($connect, $_GET['tun_material']); + $sql .= "', tun_material='" . $material; + if ($material == "RVS") { + $sql .= "', tun_specific_heat='0.11"; + } else if ($material == "Aluminium") { + $sql .= "', tun_specific_heat='0.22"; + } else if ($material == "Kunststof") { + $sql .= "', tun_specific_heat='0.46"; + } else if ($material == "Koper") { + $sql .= "', tun_specific_heat='0.092"; + } + $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; + $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; + $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; + $sql .= "', mash_volume='" . $_GET['mash_volume']; + $sql .= "', efficiency='" . $_GET['efficiency']; + $sql .= "' WHERE record='" . $_GET['record'] . "';"; + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_GET['record']); + } + echo $result; + +} else if (isset($_GET['delete'])) { + // DELETE COMMAND + // FIXME: need to check if the record is in use + $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_GET['record']."';"; + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_equipment: deleted record ".$_GET['record']); + } + echo $result; + +} else { + // SELECT COMMAND + $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); + while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + $equipments[] = array( + 'record' => $row['record'], + 'name' => $row['name'], + 'boil_size' => $row['boil_size'], + 'batch_size' => $row['batch_size'], + 'tun_volume' => $row['tun_volume'], + 'tun_weight' => $row['tun_weight'], + 'top_up_water' => $row['top_up_water'], + 'trub_chiller_loss' => $row['trub_chiller_loss'], + 'evap_rate' => $row['evap_rate'], + 'boil_time' => $row['boil_time'], + 'lauter_deadspace' => $row['lauter_deadspace'], + 'top_up_kettle' => $row['top_up_kettle'], + 'hop_utilization' => $row['hop_utilization'], + 'notes' => $row['notes'], + 'lauter_volume' => $row['lauter_volume'], + 'kettle_volume' => $row['kettle_volume'], + 'tun_material' => $row['tun_material'], + 'tun_height' => $row['tun_height'] * 100.0, + 'kettle_height' => $row['kettle_height'] * 100.0, + 'lauter_height' => $row['lauter_height'] * 100.0, + 'mash_volume' => $row['mash_volume'], + 'efficiency' => $row['efficiency'] + ); + } + echo json_encode($equipments); +} +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/inv_equipments.php Sat Aug 18 21:29:54 2018 +0200 @@ -0,0 +1,99 @@ +<?php +require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); +page_header('Brouw apparatuur', 'inv_equipments'); +?> + + <div id="jqxgrid"></div> + <div style="margin-top: 30px;"> + <div id="cellbegineditevent"></div> + <div style="margin-top: 10px;" id="cellendeditevent"></div> + </div> + + <!-- Popup editor window. --> + <div id="popupWindow"> + <div>Wijzig brouw apparatuur.</div> + <div style="overflow: hidden;"> + <table> + <tr> + <td style="vertical-align: top; float: right;">Installatie naam:</td> + <td colspan="3" style="vertical-align: top;"><input id="name" /></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Opmerkingen:</td> + <td colspan="3"><textarea id="notes"></textarea></td> + </tr> + <tr> + <th style="text-align: center;" colspan="2">Maischen</th> + <th style="text-align: center;" colspan="2">Koken</th> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Maischkuip volume l:</td> + <td><div id="tun_volume"></div></td> + <td style="vertical-align: top; float: right;">Kookketel volume l:</td> + <td><div id="kettle_volume"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Maischkuip hoogte cm:</td> + <td><div id="tun_height"></div></td> + <td style="vertical-align: top; float: right;">Kookketel hoogte cm:</td> + <td><div id="kettle_height"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Maischkuip gewicht kg:</td> + <td><div id="tun_weight"></div></td> + <td style="vertical-align: top; float: right;">Kook volume l:</td> + <td><div id="boil_size"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Maischkuip materiaal:</td> + <td><div id="tun_material"></div></td> + <td style="vertical-align: top; float: right;">Verdamping per uur l:</td> + <td><div id="evap_rate"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Maischwater l:</td> + <td><div id="mash_volume"></div></td> + <td style="vertical-align: top; float: right;">Kooktijd in minuten:</td> + <td><div id="boil_time"></div></td> + </tr> + <tr> + <th style="text-align: center;" colspan="2">Filteren</th> + <td style="vertical-align: top; float: right;">Extra water bij koken l:</td> + <td><div id="top_up_kettle"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Filter volume l:</td> + <td><div id="lauter_volume"></div></td> + <td style="vertical-align: top; float: right;">Hopfactor %:</td> + <td><div id="hop_utilization"></div></td> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Filterkuip hoogte cm:</td> + <td><div id="lauter_height"></div></td> + <td style="vertical-align: top; float: right;">Volume eind koken l:</td> + <td><div id="batch_size"></div></td> + <tr> + <td style="vertical-align: top; float: right;">Filterkuip verlies l:</td> + <td><div id="lauter_deadspace"></div></td> + <th style="text-align: center;" colspan="2">Koelen</th> + </tr> + <tr> + <td style="vertical-align: top; float: right;">Brouwzaalrendement %:</td> + <td><div id="efficiency"></div></td> + <td style="vertical-align: top; float: right;">Trub verlies kookketel l:</td> + <td><div id="trub_chiller_loss"></div></td> + </tr> + <tr> + <td style="padding-top: 10px; float: right;"><input type="button" id="Delete" value="Delete" /></td> + <td></td> + <td></td> + <td style="padding-top: 10px;"><input style="margin-right: 5px;" type="button" id="Save" value="Save" /><input id="Cancel" type="button" value="Cancel" /></td> + </tr> + </table> + </div> + </div> + +<?php +confirm_delete(); +page_footer(); +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/inv_equipments.js Sat Aug 18 21:29:54 2018 +0200 @@ -0,0 +1,335 @@ +/***************************************************************************** + * Copyright (C) 2014-2018 + * + * Michiel Broek <mbroek at mbse dot eu> + * + * This file is part of BrewCloud + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * BrewCloud is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ThermFerm; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + + +function createDelElements() { + $('#eventWindow').jqxWindow({ + theme: theme, + position: { x: 490, y: 210 }, + width: 300, + height: 145, + resizable: false, + isModal: true, + modalOpacity: 0.4, + okButton: $('#delOk'), + cancelButton: $('#delCancel'), + initContent: function () { + $('#delOk').jqxButton({ width: '65px', theme: theme }); + $('#delCancel').jqxButton({ width: '65px', theme: theme }); + $('#delCancel').focus(); + } + }); + $('#eventWindow').jqxWindow('hide'); +} + + +$(document).ready(function () { + var url = "includes/db_inventory_equipments.php"; + // tooltips + $("#name").jqxTooltip({ content: 'The unique name of this brew equipment.' }); + $("#notes").jqxTooltip({ content: 'Some notes about the equipment.' }); + $("#tun_volume").jqxTooltip({ content: 'Mash TUN volume.' }); + $("#tun_height").jqxTooltip({ content: 'Mash TUN height in cm.' }); + $("#tun_weight").jqxTooltip({ content: 'Mash TUN weight in Kg.' }); + $("#tun_material").jqxTooltip({ content: 'Mash TUN material. Needed to calculate the right strike temperature.' }); + $("#mash_volume").jqxTooltip({ content: 'Mash water for the first step.' }); + $("#lauter_volume").jqxTooltip({ content: 'Total lauter volume.' }); + $("#lauter_height").jqxTooltip({ content: 'Height of the lauter TUN in cm.' }); + $("#lauter_deadspace").jqxTooltip({ content: 'Volume loss in the lauter TUN.' }); + $("#efficiency").jqxTooltip({ content: 'Average efficiency.' }); + $("#kettle_volume").jqxTooltip({ content: 'Boil kettle volume in liters.' }); + $("#kettle_height").jqxTooltip({ content: 'Boil kettle height in cm.' }); + $("#boil_size").jqxTooltip({ content: 'Normal boil volume in liters' }); + $("#evap_rate").jqxTooltip({ content: 'Evaporation in liters per hour.' }); + $("#boil_time").jqxTooltip({ content: 'Normal boil time in minutes.' }); + $("#top_up_kettle").jqxTooltip({ content: 'Extra water added to the boil.' }); + $("#hop_utilization").jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' }); + $("#batch_size").jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' }); + $("#trub_chiller_loss").jqxTooltip({ content: 'Standard loss in liters during transfer to the fermenter.' }); + + // prepare the data + var source = { + datatype: "json", + cache: false, + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'boil_size', type: 'float' }, + { name: 'batch_size', type: 'float' }, + { name: 'tun_volume', type: 'float' }, + { name: 'tun_weight', type: 'float' }, + { name: 'trub_chiller_loss', type: 'float' }, + { name: 'evap_rate', type: 'float' }, + { name: 'boil_time', type: 'float' }, + { name: 'lauter_deadspace', type: 'float' }, + { name: 'top_up_kettle', type: 'float' }, + { name: 'hop_utilization', type: 'float' }, + { name: 'notes', type: 'string' }, + { name: 'lauter_volume', type: 'float' }, + { name: 'kettle_volume', type: 'float' }, + { name: 'tun_material', type: 'string' }, + { name: 'tun_height', type: 'float' }, + { name: 'kettle_height', type: 'float' }, + { name: 'lauter_height', type: 'float' }, + { name: 'mash_volume', type: 'float' }, + { name: 'efficiency', type: 'float' } + ], + id: 'record', + url: url, + deleterow: function (rowid, commit) { + // synchronize with the server - send delete command + var data = "delete=true&" + $.param({ record: rowid }); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + success: function (data, status, xhr) { + // delete command is executed. + commit(true); + }, + error: function (jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + }, + addrow: function (rowid, rowdata, position, commit) { + var data = "insert=true&" + $.param(rowdata); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + success: function (data, status, xhr) { + commit(true); + }, + error: function(jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + }, + updaterow: function (rowid, rowdata, commit) { + var data = "update=true&" + $.param(rowdata); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + success: function (data, status, xhr) { + // update command is executed. + commit(true); + }, + error: function(jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + } + }; + // initialize the input fields. + var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; + + $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#boil_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#batch_size").jqxNumberInput({ inputMode: 'simple', readOnly: 'true', theme: theme, width: 50, height: 23, min: 0, decimalDigits: 1 }); + $("#tun_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#tun_weight").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); + $("#trub_chiller_loss").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#evap_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); + $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); + $("#lauter_deadspace").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#top_up_kettle").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#hop_utilization").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); + $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); + $("#lauter_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#kettle_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#tun_material").jqxDropDownList({ theme: theme, source: srcMaterial, selectedIndex: 0, width: 110, height: 23, dropDownHeight: 130 }); + $("#tun_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#kettle_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#lauter_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#mash_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + var dataAdapter = new $.jqx.dataAdapter(source); + var editrow = -1; + // initialize jqxGrid + $("#jqxgrid").jqxGrid({ + width: 1280, + height: 630, + source: dataAdapter, + theme: theme, + showstatusbar: true, + localization: getLocalization(), + renderstatusbar: function (statusbar) { + var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); + 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;'>Add</span></div>"); + container.append(addButton); + statusbar.append(container); + addButton.jqxButton({ width: 60, height: 20 }); + // add new row. + addButton.click(function (event) { + editrow = -1; + $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); + $("#name").val(''); + $("#boil_size").val('18'); + $("#batch_size").val('15.3'); + $("#tun_volume").val('20'); + $("#tun_weight").val('2'); + $("#trub_chiller_loss").val('0.5'); + $("#evap_rate").val('1.8'); + $("#boil_time").val('90'); + $("#lauter_deadspace").val('0.5'); + $("#top_up_kettle").val('0'); + $("#hop_utilization").val('100'); + $("#notes").val(''); + $("#lauter_volume").val('20'); + $("#kettle_volume").val('20'); + $("#tun_material").val('RVS'); + $("#tun_height").val('20'); + $("#kettle_height").val('20'); + $("#lauter_height").val('20'); + $("#mash_volume").val('18'); + $("#efficiency").val('75'); + $("#popupWindow").jqxWindow('open'); + }); + }, + filterable: true, + filtermode: 'excel', + columns: [ + { text: 'Equipment Name', datafield: 'name', width: 250 }, + { text: 'Boil Size', datafield: 'boil_size', width: 90, cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Batch Size', datafield: 'batch_size', width: 90, cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Notes', datafield: 'notes' }, + { text: 'Edit', datafield: 'Edit', width: 80, columntype: 'button', cellsrenderer: function () { + return "Edit"; + }, buttonclick: function (row) { + // open the popup window when the user clicks a button. + editrow = row; + $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); + // get the clicked row's data and initialize the input fields. + var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); + $("#name").val(dataRecord.name); + $("#boil_size").val(dataRecord.boil_size); + $("#batch_size").val(dataRecord.batch_size); + $("#tun_volume").val(dataRecord.tun_volume); + $("#tun_weight").val(dataRecord.tun_weight); + $("#trub_chiller_loss").val(dataRecord.trub_chiller_loss); + $("#evap_rate").val(dataRecord.evap_rate); + $("#boil_time").val(dataRecord.boil_time); + $("#lauter_deadspace").val(dataRecord.lauter_deadspace); + $("#top_up_kettle").val(dataRecord.top_up_kettle); + $("#hop_utilization").val(dataRecord.hop_utilization); + $("#notes").val(dataRecord.notes); + $("#lauter_volume").val(dataRecord.lauter_volume); + $("#kettle_volume").val(dataRecord.kettle_volume); + $("#tun_material").val(dataRecord.tun_material); + $("#tun_height").val(dataRecord.tun_height); + $("#kettle_height").val(dataRecord.kettle_height); + $("#lauter_height").val(dataRecord.lauter_height); + $("#mash_volume").val(dataRecord.mash_volume); + $("#efficiency").val(dataRecord.efficiency); + // show the popup window. + $("#popupWindow").jqxWindow('open'); + } + } + ] + }); + // initialize the popup window and buttons. + $("#popupWindow").jqxWindow({ + width: 800, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 + }); + $("#popupWindow").on('open', function () { + $("#name").jqxInput('selectAll'); + }); + $("#Delete").jqxButton({ theme: theme }); + $("#Delete").click(function () { + if (editrow >= 0) { + // Open a popup to confirm this action. + $('#eventWindow').jqxWindow('open'); + $("#delOk").click(function () { + var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); + $("#jqxgrid").jqxGrid('deleterow', rowID); + }); + } + $("#popupWindow").jqxWindow('hide'); + }); + $("#Cancel").jqxButton({ theme: theme }); + $("#Save").jqxButton({ theme: theme }); + // update the edited row when the user clicks the 'Save' button. + $("#Save").click(function () { + if (editrow >= 0) { + var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); + var row = { + record: rowID, + name: $("#name").val(), + boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), + batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), + tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')), + tun_weight: parseFloat($("#tun_weight").jqxNumberInput('decimal')), + trub_chiller_loss: parseFloat($("#trub_chiller_loss").jqxNumberInput('decimal')), + evap_rate: parseFloat($("#evap_rate").jqxNumberInput('decimal')), + boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), + lauter_deadspace: parseFloat($("#lauter_deadspace").jqxNumberInput('decimal')), + top_up_kettle: parseFloat($("#top_up_kettle").jqxNumberInput('decimal')), + hop_utilization: parseFloat($("#hop_utilization").jqxNumberInput('decimal')), + notes: $("#notes").val(), + lauter_volume: parseFloat($("#lauter_volume").jqxNumberInput('decimal')), + kettle_volume: parseFloat($("#kettle_volume").jqxNumberInput('decimal')), + tun_material: $("#tun_material").val(), + tun_height: parseFloat($("#tun_height").jqxNumberInput('decimal')), + kettle_height: parseFloat($("#kettle_height").jqxNumberInput('decimal')), + lauter_height: parseFloat($("#lauter_height").jqxNumberInput('decimal')), + mash_volume: parseFloat($("#mash_volume").jqxNumberInput('decimal')), + efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')) + }; + $('#jqxgrid').jqxGrid('updaterow', rowID, row); + $("#popupWindow").jqxWindow('hide'); + } else { + // Insert a record + var newrow = { + record: -1, + name: $("#name").val(), + boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), + batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), + tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')), + tun_weight: parseFloat($("#tun_weight").jqxNumberInput('decimal')), + trub_chiller_loss: parseFloat($("#trub_chiller_loss").jqxNumberInput('decimal')), + evap_rate: parseFloat($("#evap_rate").jqxNumberInput('decimal')), + boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), + lauter_deadspace: parseFloat($("#lauter_deadspace").jqxNumberInput('decimal')), + top_up_kettle: parseFloat($("#top_up_kettle").jqxNumberInput('decimal')), + hop_utilization: parseFloat($("#hop_utilization").jqxNumberInput('decimal')), + notes: $("#notes").val(), + lauter_volume: parseFloat($("#lauter_volume").jqxNumberInput('decimal')), + kettle_volume: parseFloat($("#kettle_volume").jqxNumberInput('decimal')), + tun_material: $("#tun_material").val(), + tun_height: parseFloat($("#tun_height").jqxNumberInput('decimal')), + kettle_height: parseFloat($("#kettle_height").jqxNumberInput('decimal')), + lauter_height: parseFloat($("#lauter_height").jqxNumberInput('decimal')), + mash_volume: parseFloat($("#mash_volume").jqxNumberInput('decimal')), + efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')) + }; + $('#jqxgrid').jqxGrid('addrow', null, newrow); + $("#popupWindow").jqxWindow('hide'); + } + }); + createDelElements(); +}); +