www/js/prod_edit.js

changeset 738
11e6bd8d8107
parent 726
872a3635e4ef
child 740
04c0e444e48e
equal deleted inserted replaced
737:3f823bc205ca 738:11e6bd8d8107
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2018-2020 2 * Copyright (C) 2018-2021
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of BMS 6 * This file is part of BMS
7 * 7 *
113 modalOpacity: 0.40 113 modalOpacity: 0.40
114 }); 114 });
115 115
116 $('#popupMash').jqxWindow({ 116 $('#popupMash').jqxWindow({
117 width: 800, 117 width: 800,
118 height: 375, 118 height: 400,
119 position: { x: 230, y: 100 }, 119 position: { x: 230, y: 100 },
120 resizable: false, 120 resizable: false,
121 theme: theme, 121 theme: theme,
122 isModal: true, 122 isModal: true,
123 autoOpen: false, 123 autoOpen: false,
1563 { name: 'step_infuse_temp', type: 'float' }, 1563 { name: 'step_infuse_temp', type: 'float' },
1564 { name: 'step_temp', type: 'float' }, 1564 { name: 'step_temp', type: 'float' },
1565 { name: 'step_time', type: 'float' }, 1565 { name: 'step_time', type: 'float' },
1566 { name: 'step_wg_ratio', type: 'float' }, 1566 { name: 'step_wg_ratio', type: 'float' },
1567 { name: 'ramp_time', type: 'float' }, 1567 { name: 'ramp_time', type: 'float' },
1568 { name: 'end_temp', type: 'float' } 1568 { name: 'end_temp', type: 'float' },
1569 { name: 'step_ph', type: 'float' },
1570 { name: 'step_sg', type: 'float' }
1569 ], 1571 ],
1570 addrow: function(rowid, rowdata, position, commit) { commit(true); }, 1572 addrow: function(rowid, rowdata, position, commit) { commit(true); },
1571 deleterow: function(rowid, commit) { commit(true); } 1573 deleterow: function(rowid, commit) { commit(true); }
1572 }, 1574 },
1573 mashAdapter = new $.jqx.dataAdapter(mashSource, { 1575 mashAdapter = new $.jqx.dataAdapter(mashSource, {
1612 row['step_temp'] = 62.0; 1614 row['step_temp'] = 62.0;
1613 row['step_time'] = 20.0; 1615 row['step_time'] = 20.0;
1614 row['step_wg_ratio'] = 0; 1616 row['step_wg_ratio'] = 0;
1615 row['ramp_time'] = 1.0; 1617 row['ramp_time'] = 1.0;
1616 row['end_temp'] = 62.0; 1618 row['end_temp'] = 62.0;
1619 row['step_ph'] = 0.0;
1620 row['step_sg'] = 0.0;
1617 $('#mashGrid').jqxGrid('addrow', null, row); 1621 $('#mashGrid').jqxGrid('addrow', null, row);
1618 calcMash(); 1622 calcMash();
1619 }); 1623 });
1620 // delete selected step. 1624 // delete selected step.
1621 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); 1625 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
1646 $('#jqxLoader').jqxLoader('close'); 1650 $('#jqxLoader').jqxLoader('close');
1647 $('#jqxTabs').jqxTabs('first'); 1651 $('#jqxTabs').jqxTabs('first');
1648 }, 1652 },
1649 columns: [ 1653 columns: [
1650 { text: 'Stap naam', datafield: 'step_name' }, 1654 { text: 'Stap naam', datafield: 'step_name' },
1651 { text: 'Stap type', datafield: 'step_type', width: 175, 1655 { text: 'Stap type', datafield: 'step_type', width: 150,
1652 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { 1656 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
1653 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + MashStepTypeData[value].nl + '</span>'; 1657 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + MashStepTypeData[value].nl + '</span>';
1654 } 1658 }
1655 }, 1659 },
1656 { text: 'Start &deg;C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 1660 { text: 'Start &deg;C', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
1657 { text: 'Eind &deg;C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 1661 { text: 'Eind &deg;C', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
1658 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, 1662 { text: 'Rust min.', datafield: 'step_time', width: 80, align: 'right', cellsalign: 'right' },
1659 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, 1663 { text: 'Stap min.', datafield: 'ramp_time', width: 80, align: 'right', cellsalign: 'right' },
1660 { text: 'Inf/dec L.', datafield: 'step_infuse_amount', width: 90, align: 'right', 1664 { text: 'Inf/dec L.', datafield: 'step_infuse_amount', width: 80, align: 'right',
1661 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { 1665 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) {
1662 if (rowdata.step_type == 1) 1666 if (rowdata.step_type == 1)
1663 return '<span></span>'; 1667 return '<span></span>';
1664 var color = '#ffffff'; 1668 var color = '#ffffff';
1665 var mvol = mashkg * MaltVolume; 1669 var mvol = mashkg * MaltVolume;
1673 if (rowdata.step_type == 1) 1677 if (rowdata.step_type == 1)
1674 return '<span></span>'; 1678 return '<span></span>';
1675 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; 1679 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value, 'f2') + '</span>';
1676 } 1680 }
1677 }, 1681 },
1678 { text: 'L/Kg.', datafield: 'step_wg_ratio', width: 90, align: 'right', 1682 { text: 'L/Kg.', datafield: 'step_wg_ratio', width: 80, align: 'right',
1679 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { 1683 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) {
1680 var color = '#ffffff'; 1684 var color = '#ffffff';
1681 if (value < 2.0 || value > 6.0) 1685 if (value < 2.0 || value > 6.0)
1682 color = '#ff4040'; 1686 color = '#ff4040';
1683 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; 1687 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f2') + '</span>';
1684 } 1688 }
1685 }, 1689 },
1690 { text: 'pH', datafield: 'step_ph', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f2' },
1691 { text: 'SG', datafield: 'step_sg', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
1686 { text: '', columntype: 'button', width: 15, align: 'center', 1692 { text: '', columntype: 'button', width: 15, align: 'center',
1687 cellsrenderer: function(row) { 1693 cellsrenderer: function(row) {
1688 if (row < 2) 1694 if (row < 2)
1689 return ' '; 1695 return ' ';
1690 return '▴'; 1696 return '▴';
1739 } else { 1745 } else {
1740 $('#wstep_infuse_temp').show(); 1746 $('#wstep_infuse_temp').show();
1741 $('#wstep_pmpt_temp').show(); 1747 $('#wstep_pmpt_temp').show();
1742 } 1748 }
1743 } 1749 }
1750 $('#wstep_ph').val(mashData.step_ph);
1751 $('#wstep_sg').val(mashData.step_sg);
1744 // show the popup window. 1752 // show the popup window.
1745 $('#popupMash').jqxWindow('open'); 1753 $('#popupMash').jqxWindow('open');
1746 } 1754 }
1747 } 1755 }
1748 } 1756 }
1777 console.log('swap mash rows ' + r1 + ' ' + r2); 1785 console.log('swap mash rows ' + r1 + ' ' + r2);
1778 var row1 = $('#mashGrid').jqxGrid('getrowdata', r1); 1786 var row1 = $('#mashGrid').jqxGrid('getrowdata', r1);
1779 var row2 = $('#mashGrid').jqxGrid('getrowdata', r2); 1787 var row2 = $('#mashGrid').jqxGrid('getrowdata', r2);
1780 var obj1 = { step_name: row1.step_name, step_type: row1.step_type, step_volume: row1.step_volume, step_infuse_amount: row1.step_infuse_amount, 1788 var obj1 = { step_name: row1.step_name, step_type: row1.step_type, step_volume: row1.step_volume, step_infuse_amount: row1.step_infuse_amount,
1781 step_infuse_temp: row1.step_infuse_temp, step_temp: row1.step_temp, step_time: row1.step_time, 1789 step_infuse_temp: row1.step_infuse_temp, step_temp: row1.step_temp, step_time: row1.step_time,
1782 ramp_time: row1.ramp_time, end_temp: row1.end_temp, step_wg_ratio: row1.step_wg_ratio }; 1790 ramp_time: row1.ramp_time, end_temp: row1.end_temp, step_wg_ratio: row1.step_wg_ratio, step_ph: row1.step_ph, step_sg: row1.step_sg };
1783 var obj2 = { step_name: row2.step_name, step_type: row2.step_type, step_volume: row2.step_volume, step_infuse_amount: row2.step_infuse_amount, 1791 var obj2 = { step_name: row2.step_name, step_type: row2.step_type, step_volume: row2.step_volume, step_infuse_amount: row2.step_infuse_amount,
1784 step_infuse_temp: row2.step_infuse_temp, step_temp: row2.step_temp, step_time: row2.step_time, 1792 step_infuse_temp: row2.step_infuse_temp, step_temp: row2.step_temp, step_time: row2.step_time,
1785 ramp_time: row2.ramp_time, end_temp: row2.end_temp, step_wg_ratio: row2.step_wg_ratio }; 1793 ramp_time: row2.ramp_time, end_temp: row2.end_temp, step_wg_ratio: row2.step_wg_ratio, step_ph: row2.step_ph, step_sg: row2.step_sg };
1786 $("#mashGrid").jqxGrid('updaterow', r1, obj2); 1794 $("#mashGrid").jqxGrid('updaterow', r1, obj2);
1787 $("#mashGrid").jqxGrid('updaterow', r2, obj1); 1795 $("#mashGrid").jqxGrid('updaterow', r2, obj1);
1788 } 1796 }
1789 1797
1790 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) { 1798 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) {
5691 row['step_infuse_amount'] = parseFloat(mash_infuse); 5699 row['step_infuse_amount'] = parseFloat(mash_infuse);
5692 } else { 5700 } else {
5693 row['step_infuse_temp'] = 99.0; 5701 row['step_infuse_temp'] = 99.0;
5694 } 5702 }
5695 } 5703 }
5704 row['step_ph'] = 0.0;
5705 row['step_sg'] = 0.0;
5696 //console.log(i + ' type: ' + row['step_type'] + ' start infusion: ' + parseFloat(row['step_infuse_amount']) + ' mash_infuse: ' + mash_infuse); 5706 //console.log(i + ' type: ' + row['step_type'] + ' start infusion: ' + parseFloat(row['step_infuse_amount']) + ' mash_infuse: ' + mash_infuse);
5697 infused += parseFloat(row['step_infuse_amount']); 5707 infused += parseFloat(row['step_infuse_amount']);
5698 row['step_volume'] = infused; 5708 row['step_volume'] = infused;
5699 if (mashkg > 0) 5709 if (mashkg > 0)
5700 row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2); 5710 row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2);
5798 $('#wstep_time').on('change', function(event) { 5808 $('#wstep_time').on('change', function(event) {
5799 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); 5809 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5800 rowdata.step_time = parseFloat(event.args.value); 5810 rowdata.step_time = parseFloat(event.args.value);
5801 calcMash(); 5811 calcMash();
5802 }); 5812 });
5813 $('#wstep_ph').jqxNumberInput(Spin2pH);
5814 $('#wstep_ph').on('change', function(event) {
5815 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5816 rowdata.step_ph = parseFloat(event.args.value);
5817 });
5818 $('#wstep_sg').jqxNumberInput(SGopts);
5819 $('#wstep_sg').on('change', function(event) {
5820 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5821 rowdata.step_sg = parseFloat(event.args.value);
5822 });
5823 $('#wstep_brix').jqxNumberInput(Spin1dec);
5824 $('#wstep_brix').on('change', function(event) {
5825 var sg = brix_to_sg(parseFloat(event.args.value));
5826 console.log('brix: ' + parseFloat(event.args.value) + ' sg: ' + sg);
5827 if (sg > 1.005) {
5828 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5829 rowdata.step_sg = sg;
5830 $('#wstep_sg').val(sg);
5831 }
5832 });
5803 $('#wramp_time').on('change', function(event) { 5833 $('#wramp_time').on('change', function(event) {
5804 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); 5834 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5805 rowdata.ramp_time = parseFloat(event.args.value); 5835 rowdata.ramp_time = parseFloat(event.args.value);
5806 calcMash(); 5836 calcMash();
5807 }); 5837 });
6050 $('#brew_sparge_temperature').jqxTooltip({ content: 'De spoelwater temperatuur, in te stellen in de Water tab.' }); 6080 $('#brew_sparge_temperature').jqxTooltip({ content: 'De spoelwater temperatuur, in te stellen in de Water tab.' });
6051 $('#brew_sparge_volume').jqxTooltip({ content: 'Het spoelwater voorraad volume, in te stellen in de Water tab.' }); 6081 $('#brew_sparge_volume').jqxTooltip({ content: 'Het spoelwater voorraad volume, in te stellen in de Water tab.' });
6052 $('#brew_date_start,#brew_date_end').jqxDateTimeInput(DateTimeopts); 6082 $('#brew_date_start,#brew_date_end').jqxDateTimeInput(DateTimeopts);
6053 $('#brew_date_start,#brew_date_end').on('close', function(event) { calcStage(); }); 6083 $('#brew_date_start,#brew_date_end').on('close', function(event) { calcStage(); });
6054 $('#est_mash_ph').jqxNumberInput(Show2wat); 6084 $('#est_mash_ph').jqxNumberInput(Show2wat);
6055 $('#brew_mash_ph,#brew_preboil_ph,#brew_aboil_ph').jqxNumberInput(SpinpH); 6085 $('#brew_mash_ph,#brew_preboil_ph,#brew_aboil_ph').jqxNumberInput(Spin2pH);
6056 $('#brew_mash_sg').on('valueChanged', function() { calcMashEfficiency(); }); 6086 $('#brew_mash_sg').on('valueChanged', function() { calcMashEfficiency(); });
6057 $('#brew_preboil_sg').on('valueChanged', function(event) { 6087 $('#brew_preboil_sg').on('valueChanged', function(event) {
6058 dataRecord.brew_preboil_sg = event.args.value; 6088 dataRecord.brew_preboil_sg = event.args.value;
6059 calcEfficiencyBeforeBoil(); 6089 calcEfficiencyBeforeBoil();
6060 }); 6090 });
6123 $('#volumeWindow').jqxWindow('open'); 6153 $('#volumeWindow').jqxWindow('open');
6124 }); 6154 });
6125 $('#est_pre_vol,#est_a_vol').jqxNumberInput(Show1wat); 6155 $('#est_pre_vol,#est_a_vol').jqxNumberInput(Show1wat);
6126 $('#brew_preboil_efficiency,#brew_aboil_efficiency,#brew_sparge_temperature,#brew_sparge_volume,#brew_sparge_est').jqxNumberInput(Show1dec); 6156 $('#brew_preboil_efficiency,#brew_aboil_efficiency,#brew_sparge_temperature,#brew_sparge_volume,#brew_sparge_est').jqxNumberInput(Show1dec);
6127 $('#brew_cooling_to').jqxNumberInput(Spin1dec); 6157 $('#brew_cooling_to').jqxNumberInput(Spin1dec);
6128 $('#brew_sparge_ph').jqxNumberInput(SpinpH); 6158 $('#brew_sparge_ph').jqxNumberInput(Spin2pH);
6129 $('#brew_cooling_method').jqxDropDownList({ 6159 $('#brew_cooling_method').jqxDropDownList({
6130 theme: theme, 6160 theme: theme,
6131 source: CoolingTypeAdapter, 6161 source: CoolingTypeAdapter,
6132 valueMember: 'id', 6162 valueMember: 'id',
6133 displayMember: 'nl', 6163 displayMember: 'nl',

mercurial