www/js/profile_setup.js

Wed, 30 Jan 2019 23:08:05 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 30 Jan 2019 23:08:05 +0100
changeset 223
0de4455bd2a1
parent 218
38499e3859fa
child 270
cf4b4b63eb36
permissions
-rw-r--r--

Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.

/*****************************************************************************
 * Copyright (C) 2019
 *
 * 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 () {

	var dataRecord = {};

	// dropdownlist datasource from inventory_waters, must load sync
	var waterUrl = "getwatersources.php";
	var waterInvSource = {
		datatype: "json",
		datafields: [
			{ name: 'name', type: 'string' },
		],
		url: waterUrl,
		async: false
	};
	var waterlist = new $.jqx.dataAdapter(waterInvSource);

	var url = "includes/db_setup.php";

	// Tooltips
	$("#brewery_name").jqxTooltip({ content: 'De naam voor deze brouwerij.' });
	$("#factor_mashhop").jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' });
	$("#factor_fwh").jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' });
	$("#factor_pellet").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' });
	$("#factor_plug").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' });
	$("#brix_correction").jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' });
	$("#grain_absorbtion").jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' });

	// Prepare the data
	var source = {
		datatype: "json",
		cache: false,
		datafields: [
			{ name: 'brewery_name', type: 'string' },
		/*	{ name: 'brewery_logo', type: 'array' },  */
			{ name: 'factor_mashhop', type: 'number' },
			{ name: 'factor_fwh', type: 'number' },
			{ name: 'factor_pellet', type: 'number' },
			{ name: 'factor_plug', type: 'number' },
			{ name: 'ibu_method', type: 'int' },
			{ name: 'color_method', type: 'int' },
			{ name: 'brix_correction', type: 'float' },
			{ name: 'grain_absorbtion', type: 'float' },
			{ name: 'default_water', type: 'string' }
		],
		url: url
	};

	// Load data and select one record.
	var dataAdapter = new $.jqx.dataAdapter(source, {
		loadComplete: function () {
			var records = dataAdapter.records;
			dataRecord = records[0];
			$("#brewery_name").val(dataRecord.brewery_name);
			$("#factor_mashhop").val(dataRecord.factor_mashhop);
			$("#factor_fwh").val(dataRecord.factor_fwh);
			$("#factor_pellet").val(dataRecord.factor_pellet);
			$("#factor_plug").val(dataRecord.factor_plug);
			$("#color_method").val(dataRecord.color_method);
			$("#ibu_method").val(dataRecord.ibu_method);
			$("#brix_correction").val(dataRecord.brix_correction);
			$("#grain_absorbtion").val(dataRecord.grain_absorbtion);
			$("#default_water").val(dataRecord.default_water);
		},
		loadError: function (jqXHR, status, error) {
		},
	});
	dataAdapter.dataBind();

	// Editers
	$("#brewery_name").jqxInput({ theme: theme, width: 640, height: 23 });
	$("#factor_fwh").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right'  });
	$("#factor_mashhop").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right'  });
	$("#factor_pellet").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right'  });
	$("#factor_plug").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right'  });
	$("#brix_correction").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 1.00, max: 1.05, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 });
	$("#grain_absorbtion").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0.5, max: 1.1, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 });
	$("#color_method").jqxDropDownList({
		theme: theme,
		source: ColorMethodAdapter,
		valueMember: 'id',
		displayMember: 'nl',
		width: 180,
		autoDropDownHeight: true
	});
	$("#ibu_method").jqxDropDownList({
		theme: theme,
		source: IBUmethodAdapter,
		valueMember: 'id',
		displayMember: 'nl',
		width: 180,
		autoDropDownHeight: true
	});
	$('#default_water').jqxDropDownList({
		placeHolder: "Kies water:",
		theme: theme,
		source: waterlist,
		valueMember: "name",
		displayMember: "name",
		width: 250,
		dropDownHorizontalAlignment: 'right',
		dropDownWidth: 300,
		autoDropDownHeight: true
	});
	$('#default_water').jqxDropDownList( 'selectItem', dataRecord.default_water );

	$("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
	$("#Save").click(function () {
		var row = {
			record: 1,
			brewery_name: $("#brewery_name").val(),
			factor_mashhop: $("#factor_mashhop").val(),
			factor_fwh: $("#factor_fwh").val(),
			factor_pellet: $("#factor_pellet").val(),
			factor_plug: $("#factor_plug").val(),
			color_method: $("#color_method").val(),
			ibu_method: $("#ibu_method").val(),
			brix_correction: parseFloat($("#brix_correction").jqxNumberInput('decimal')),
			grain_absorbtion: parseFloat($("#grain_absorbtion").jqxNumberInput('decimal')),
			default_water: $("#default_water").val()
		};
		var data = "update=true&" + $.param(row);
		$.ajax({
			dataType: 'json',
			url: url,
			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) {
			}
		});
	});
});

mercurial