Thu, 22 Nov 2018 22:27:42 +0100
Basic screens for brew products.
/***************************************************************************** * Copyright (C) 2018 * * Michiel Broek <mbroek at mbse dot eu> * * This file is part of BMS * * 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. *****************************************************************************/ $(document).ready(function () { console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); var dataReecord = {}; var url = "includes/db_product.php"; // tooltips $("#name").jqxTooltip({ content: 'De naam voor dit product.' }); $("#code").jqxTooltip({ content: 'Product code nummer.' }); $("#birth").jqxTooltip({ content: 'De ontwerp datum van dit product.' }); $("#stage").jqxTooltip({ content: 'De productie fase van dit product.' }); $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit product.' }); $("#eq_name").jqxTooltip({ content: 'The unique name of this brew equipment.' }); $("#eq_notes").jqxTooltip({ content: 'Some notes about the equipment.' }); $("#eq_tun_volume").jqxTooltip({ content: 'Mash TUN volume.' }); $("#eq_tun_height").jqxTooltip({ content: 'Mash TUN height in cm.' }); $("#eq_tun_weight").jqxTooltip({ content: 'Mash TUN weight in Kg.' }); $("#eq_tun_material").jqxTooltip({ content: 'Mash TUN material. Needed to calculate the right strike temperature.' }); $("#eq_mash_volume").jqxTooltip({ content: 'Mash water for the first step.' }); $("#eq_lauter_volume").jqxTooltip({ content: 'Total lauter volume.' }); $("#eq_lauter_height").jqxTooltip({ content: 'Height of the lauter TUN in cm.' }); $("#eq_lauter_deadspace").jqxTooltip({ content: 'Volume loss in the lauter TUN.' }); $("#eq_efficiency").jqxTooltip({ content: 'Average efficiency.' }); $("#eq_kettle_volume").jqxTooltip({ content: 'Boil kettle volume in liters.' }); $("#eq_kettle_height").jqxTooltip({ content: 'Boil kettle height in cm.' }); $("#eq_boil_size").jqxTooltip({ content: 'Normal boil volume in liters' }); $("#eq_evap_rate").jqxTooltip({ content: 'Evaporation in liters per hour.' }); $("#eq_boil_time").jqxTooltip({ content: 'Normal boil time in minutes.' }); $("#eq_top_up_kettle").jqxTooltip({ content: 'Extra water added to the boil.' }); $("#eq_hop_utilization").jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' }); $("#eq_batch_size").jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' }); $("#eq_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: 'uuid', type: 'string' }, { name: 'name', type: 'string' }, { name: 'code', type: 'string' }, { name: 'birth', type: 'string' }, { name: 'stage', type: 'string' }, { name: 'notes', type: 'string' }, { name: 'eq_name', type: 'string' }, { name: 'eq_boil_size', type: 'float' }, { name: 'eq_batch_size', type: 'float' }, { name: 'eq_tun_volume', type: 'float' }, { name: 'eq_tun_weight', type: 'float' }, { name: 'eq_trub_chiller_loss', type: 'float' }, { name: 'eq_evap_rate', type: 'float' }, { name: 'eq_boil_time', type: 'float' }, { name: 'eq_lauter_deadspace', type: 'float' }, { name: 'eq_top_up_kettle', type: 'float' }, { name: 'eq_hop_utilization', type: 'float' }, { name: 'eq_notes', type: 'string' }, { name: 'eq_lauter_volume', type: 'float' }, { name: 'eq_kettle_volume', type: 'float' }, { name: 'eq_tun_material', type: 'string' }, { name: 'eq_tun_height', type: 'float' }, { name: 'eq_kettle_height', type: 'float' }, { name: 'eq_lauter_height', type: 'float' }, { name: 'eq_mash_volume', type: 'float' }, { name: 'eq_efficiency', type: 'float' } ], id: 'record', url: url }; // Load data and select one record. var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function () { var records = dataAdapter.records; dataRecord = records[0]; // Hidden record uuid $("#name").val(dataRecord.name); $("#code").val(dataRecord.code); $("#birth").val(dataRecord.birth); $("#stage").val(dataRecord.stage); $("#notes").val(dataRecord.notes); $("#eq_name").val(dataRecord.eq_name); $("#eq_boil_size").val(dataRecord.eq_boil_size); $("#eq_batch_size").val(dataRecord.eq_batch_size); $("#eq_tun_volume").val(dataRecord.eq_tun_volume); $("#eq_tun_weight").val(dataRecord.eq_tun_weight); $("#eq_trub_chiller_loss").val(dataRecord.eq_trub_chiller_loss); $("#eq_evap_rate").val(dataRecord.eq_evap_rate); $("#eq_boil_time").val(dataRecord.eq_boil_time); $("#eq_lauter_deadspace").val(dataRecord.eq_lauter_deadspace); $("#eq_top_up_kettle").val(dataRecord.eq_top_up_kettle); $("#eq_hop_utilization").val(dataRecord.eq_hop_utilization); $("#eq_notes").val(dataRecord.eq_notes); $("#eq_lauter_volume").val(dataRecord.eq_lauter_volume); $("#eq_kettle_volume").val(dataRecord.eq_kettle_volume); $("#eq_tun_material").val(dataRecord.eq_tun_material); $("#eq_tun_height").val(dataRecord.eq_tun_height); $("#eq_kettle_height").val(dataRecord.eq_kettle_height); $("#eq_lauter_height").val(dataRecord.eq_lauter_height); $("#eq_mash_volume").val(dataRecord.eq_mash_volume); $("#eq_efficiency").val(dataRecord.eq_efficiency); }, loadError: function (jqXHR, status, error) { }, beforeLoadComplete: function (records) { var filteredRecords = []; for (var i = 0; i < records.length; i++) { if (records[i].record == my_record) { filteredRecords.push(records[i]); } } return filteredRecords; } }); dataAdapter.dataBind(); // initialize the input fields. var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); $("#code").jqxInput({ theme: theme, width: 100, height: 23 }); $("#birth").jqxDateTimeInput({ theme: theme, width: 150, height: 23, formatString: 'yyyy-MM-dd' }); $("#stage").jqxInput({ theme: theme, width: 100, height: 23, disabled: true }); $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); $("#eq_name").jqxInput({ theme: theme, width: 250, height: 23 }); $("#eq_boil_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#eq_batch_size").jqxNumberInput({ inputMode: 'simple', readOnly: 'true', theme: theme, width: 50, height: 23, min: 0, decimalDigits: 1 }); $("#eq_tun_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#eq_tun_weight").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); $("#eq_trub_chiller_loss").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#eq_evap_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); $("#eq_boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); $("#eq_lauter_deadspace").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#eq_top_up_kettle").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#eq_hop_utilization").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); $("#eq_notes").jqxInput({ theme: theme, width: 640, height: 100 }); $("#eq_lauter_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#eq_kettle_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#eq_tun_material").jqxDropDownList({ theme: theme, source: srcMaterial, selectedIndex: 0, width: 110, height: 23, dropDownHeight: 130 }); $("#eq_tun_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#eq_kettle_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#eq_lauter_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#eq_mash_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $('#jqxTabs').jqxTabs({ theme: theme, width: 1280, height: 630, autoHeight: false, position: 'top' }); /* //Creating wizard module var wizard = (function () { //Adding event listeners var _addHandlers = function () { $('#name').on('change', function (event) { wizard.validate(true); }); $('#nextButtonCompleted').click(function () { console.log("insert start"); var newrow = { record: -1, name: $("#name").val(), notes: $("#notes").val(), st_name: $('#st_name').val(), st_letter: $('#st_style_letter').val(), mash_ph: 5.4, mash_sparge_temp: 78.0 }; var data = "insert=true&return=" + my_return + "&" + $.param(newrow); $.ajax({ dataType: 'json', url: "includes/db_recipes.php", cache: false, data: data, type: "POST", success: function (data, status, xhr) { // update command is executed. window.location.href = my_return; }, error: function(jqXHR, textStatus, errorThrown) { } }); }); $('.nextButton').click(function () { wizard.validate(true); $('#jqxTabs').jqxTabs('next'); }); $('.backButton').click(function () { wizard.validate(true); $('#jqxTabs').jqxTabs('previous'); }); }; return { //Initializing the wizzard - creating all elements, adding event handlers and starting the validation init: function () { $('#jqxTabs').jqxTabs({ theme: theme, height: 630, width: 1280, autoHeight: false, position: 'top', keyboardNavigation: false }); $('#nextButtonBase').jqxButton({ theme: theme, width: 150 }); $('#nextButtonStyle').jqxButton({ theme: theme, width: 150}); $('#backButtonStyle').jqxButton({ theme: theme, width: 150}); $('#nextButtonCompleted').jqxButton({ theme: theme, width: 150}); $('#backButtonCompleted').jqxButton({ theme: theme, width: 150}); _addHandlers(); this.validate(); this.showHint('Validation hints.'); }, //Validating all wizard tabs validate: function (notify) { if (!this.firstTab(notify)) { $('#jqxTabs').jqxTabs('disableAt', 1); $('#jqxTabs').jqxTabs('disableAt', 2); return; } else { $('#jqxTabs').jqxTabs('enableAt', 1); } if (!this.secondTab(notify)) { $('#jqxTabs').jqxTabs('disableAt', 2); return; } else { $('#jqxTabs').jqxTabs('enableAt', 2); } }, //Displaying message to the user showHint: function (message, selector) { if (typeof selector === 'undefined') { selector = '.hint'; } if (message === '') { message = 'Ok, je mag doorgaan.'; } $(selector).html('<strong>' + message + '</strong>'); }, //Validating the first tab firstTab: function (notify) { var name = $('#name').val(), type = $('#type').val(), boil_time = parseFloat($("#boil_time").jqxNumberInput('decimal')), est_og = parseFloat($("#est_og").jqxNumberInput('decimal')), efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')), message = ''; if (name.length < 3) { message += 'Je moet een recept naam invullen. <br />'; } // Check if name already exists. if (type.length < 1) { message += 'Je moet een brouw type kiezen. <br />'; } if ((boil_time < 4) || (boil_time > 360)) { message += 'De kooktijd moet tussen 4 en 360 minuten zijn. <br />'; } if ((est_og < 1.010) || (est_og > 1.200)) { message += 'Het OG moet tussen 1.010 en 1.500 zijn. <br />'; } if ((efficiency < 35) || (efficiency > 95)) { message += 'Het brouwzaal rendement moet tussen 35 en 95 zijn. <br />'; } if (message !== '') { if (notify) { this.showHint(message, '#hintBase'); } return false; } this.showHint('Ok, je mag doorgaan.', '#hintBase'); return true; }, //Validating the second tab secondTab: function (notify) { var stylesel = $('#styleSelect').val(), message = ''; if (stylesel.length < 3) { message += 'Je moet een bierstijl kiezen. <br />'; } if (message !== '') { if (notify) { this.showHint(message, '#hintStyle'); } return false; } this.showHint('Ok, je mag doorgaan.', '#hintStyle'); return true; } } } ()); */ //Initializing the wizard // wizard.init(); });