www/js/prod_edit.js

changeset 617
f962f1e5936e
parent 616
2cbf21bb9bdc
child 618
2712082437b0
equal deleted inserted replaced
616:2cbf21bb9bdc 617:f962f1e5936e
298 { name: 'wa_base_name', type: 'int' }, 298 { name: 'wa_base_name', type: 'int' },
299 { name: 'starter_enable', type: 'int' }, 299 { name: 'starter_enable', type: 'int' },
300 { name: 'starter_type', type: 'int' }, 300 { name: 'starter_type', type: 'int' },
301 { name: 'starter_sg', type: 'float' }, 301 { name: 'starter_sg', type: 'float' },
302 { name: 'starter_viability', type: 'int' }, 302 { name: 'starter_viability', type: 'int' },
303 { name: 'yeast_prod_date', type: 'string' },
303 { name: 'prop1_type', type: 'int' }, 304 { name: 'prop1_type', type: 'int' },
304 { name: 'prop1_volume', type: 'float' }, 305 { name: 'prop1_volume', type: 'float' },
305 { name: 'prop2_type', type: 'int' }, 306 { name: 'prop2_type', type: 'int' },
306 { name: 'prop2_volume', type: 'float' }, 307 { name: 'prop2_volume', type: 'float' },
307 { name: 'prop3_type', type: 'int' }, 308 { name: 'prop3_type', type: 'int' },
528 $('#wa_base_name').val(dataRecord.wa_base_name); 529 $('#wa_base_name').val(dataRecord.wa_base_name);
529 $('#starter_enable').val(dataRecord.starter_enable); 530 $('#starter_enable').val(dataRecord.starter_enable);
530 $('#starter_type').val(dataRecord.starter_type); 531 $('#starter_type').val(dataRecord.starter_type);
531 $('#starter_sg').val(dataRecord.starter_sg); 532 $('#starter_sg').val(dataRecord.starter_sg);
532 $('#starter_viability').val(dataRecord.starter_viability); 533 $('#starter_viability').val(dataRecord.starter_viability);
534 $('#yeast_prod_date').val(dataRecord.yeast_prod_date);
533 $('#prop1_type').val(dataRecord.prop1_type); 535 $('#prop1_type').val(dataRecord.prop1_type);
534 $('#prop1_volume').val(dataRecord.prop1_volume); 536 $('#prop1_volume').val(dataRecord.prop1_volume);
535 $('#prop2_type').val(dataRecord.prop2_type); 537 $('#prop2_type').val(dataRecord.prop2_type);
536 $('#prop2_volume').val(dataRecord.prop2_volume); 538 $('#prop2_volume').val(dataRecord.prop2_volume);
537 $('#prop3_type').val(dataRecord.prop3_type); 539 $('#prop3_type').val(dataRecord.prop3_type);
1308 }, 1310 },
1309 yeastAdapter = new $.jqx.dataAdapter(yeastSource); 1311 yeastAdapter = new $.jqx.dataAdapter(yeastSource);
1310 1312
1311 $('#yeastGrid').jqxGrid({ 1313 $('#yeastGrid').jqxGrid({
1312 width: 1240, 1314 width: 1240,
1313 height: 350, 1315 height: 325,
1314 source: yeastAdapter, 1316 source: yeastAdapter,
1315 theme: theme, 1317 theme: theme,
1316 selectionmode: 'singlerow', 1318 selectionmode: 'singlerow',
1317 showtoolbar: true, 1319 showtoolbar: true,
1318 rendertoolbar: function(toolbar) { 1320 rendertoolbar: function(toolbar) {
1365 row['y_pitch_temperature'] = datarecord.pitch_temperature; 1367 row['y_pitch_temperature'] = datarecord.pitch_temperature;
1366 row['y_pofpos'] = datarecord.pofpos; 1368 row['y_pofpos'] = datarecord.pofpos;
1367 row['y_zymocide'] = datarecord.zymocide; 1369 row['y_zymocide'] = datarecord.zymocide;
1368 $('#yeastGrid').jqxGrid('addrow', null, row); 1370 $('#yeastGrid').jqxGrid('addrow', null, row);
1369 } 1371 }
1372 calcViability();
1370 calcYeast(); 1373 calcYeast();
1371 $('#yaddrowbutton').jqxDropDownList('clearSelection'); 1374 $('#yaddrowbutton').jqxDropDownList('clearSelection');
1372 }); 1375 });
1373 $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); 1376 $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
1374 $('#yinstockbutton').on('change', function(event) { 1377 $('#yinstockbutton').on('change', function(event) {
1381 var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex'); 1384 var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex');
1382 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; 1385 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount;
1383 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 1386 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1384 id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex); 1387 id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex);
1385 $('#yeastGrid').jqxGrid('deleterow', id); 1388 $('#yeastGrid').jqxGrid('deleterow', id);
1389 calcViability();
1386 calcYeast(); 1390 calcYeast();
1387 } 1391 }
1388 }); 1392 });
1389 }, 1393 },
1390 ready: function() { 1394 ready: function() {
1625 $('#jqxLoader').jqxLoader({ width: 250, height: 150, isModal: true, text: 'Laden product ...', theme: theme }); 1629 $('#jqxLoader').jqxLoader({ width: 250, height: 150, isModal: true, text: 'Laden product ...', theme: theme });
1626 1630
1627 /* 1631 /*
1628 * Generic functions 1632 * Generic functions
1629 */ 1633 */
1634 function calcViability() {
1635 var vpm = 1.00;
1636 var max = 100;
1637 var rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount;
1638 if (rowscount) {
1639 for (i = 0; i < rowscount; i++) {
1640 row = $('#yeastGrid').jqxGrid('getrowdata', i);
1641 if (row.y_use == 0) {
1642 if (row.y_form == 0) { // Liquid
1643 vpm = 0.80;
1644 max = 97;
1645 if (row.y_laboratory == 'White Labs')
1646 vpm = 0.95;
1647 } else if (row.y_form == 1) { // dry yeast
1648 vpm = 0.98;
1649 max = 100;
1650 } else if (row.y_form == 6) { // Dried kveik
1651 vpm = 1.00;
1652 max = 100;
1653 } else { // Slant, Culture, Frozen, Bottle
1654 vpm = 0.99;
1655 max = 97;
1656 }
1657 }
1658 }
1659 }
1660 var base = max;
1661 var days = 0;
1662
1663 if (parseFloat($('#yeast_prod_date').val()) > 2000) {
1664 console.log('calculate viability');
1665 var d = new Date();
1666 var date2 = $('#yeast_prod_date').val();
1667 date2 = date2.split('-');
1668 // Now we convert the array to a Date object
1669 var date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate());
1670 date2 = new Date(date2[0], date2[1] - 1, date2[2]);
1671 var diff = parseInt(date1.getTime()) - parseInt(date2.getTime());
1672 days = Math.floor(diff/1000/60/60/24);
1673
1674 var degrade = 1 - ((1 - vpm) / 30.41); // viability degradation per day.
1675 for (i = 0; i < days; i++) {
1676 base = base * degrade;
1677 }
1678 if (base > max) {
1679 base = max;
1680 }
1681 base = Math.round(base);
1682 }
1683 console.log('age:' + days + ' max:' + max + ' vpm:' + vpm + ' base:' + base);
1684
1685 if (dataRecord.starter_viability != base) {
1686 dataRecord.starter_viability = base;
1687 $('#starter_viability').val(dataRecord.starter_viability);
1688 }
1689 }
1690
1630 function calcSupplies() { 1691 function calcSupplies() {
1631 if (dataRecord.inventory_reduced > 6) { 1692 if (dataRecord.inventory_reduced > 6) {
1632 $('#ok_pmpt').hide(); 1693 $('#ok_pmpt').hide();
1633 return; 1694 return;
1634 } 1695 }
1882 if (parseFloat(row.y_attenuation) > svg) 1943 if (parseFloat(row.y_attenuation) > svg)
1883 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. 1944 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts.
1884 if (row.y_form == 0) 1945 if (row.y_form == 0)
1885 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100); 1946 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100);
1886 else 1947 else
1887 initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount); 1948 initcells += (parseFloat(row.y_cells) / 1000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100);
1888 } 1949 }
1889 // TODO: brett in secondary ?? 1950 // TODO: brett in secondary ??
1890 if ((((dataRecord.inventory_reduced <= 3) && (row.y_use == 0)) || // Primary 1951 if ((((dataRecord.inventory_reduced <= 3) && (row.y_use == 0)) || // Primary
1891 ((dataRecord.inventory_reduced <= 4) && (row.y_use == 1)) || // Secondary 1952 ((dataRecord.inventory_reduced <= 4) && (row.y_use == 1)) || // Secondary
1892 ((dataRecord.inventory_reduced <= 5) && (row.y_use == 2)) || // Tertiary 1953 ((dataRecord.inventory_reduced <= 5) && (row.y_use == 2)) || // Tertiary
2366 for (i = 0; i < rowscount; i++) { 2427 for (i = 0; i < rowscount; i++) {
2367 row = $('#yeastGrid').jqxGrid('getrowdata', i); 2428 row = $('#yeastGrid').jqxGrid('getrowdata', i);
2368 if (row.y_use == 0) { // primary 2429 if (row.y_use == 0) { // primary
2369 // pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ 2430 // pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
2370 // and http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ 2431 // and http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
2371 pitchrate = 0.75; 2432 if (row.y_type == 0) { // lager yeast
2372 if (dataRecord.est_og > 1.060) 2433 pitchrate = 1.5;
2373 pitchrate = 1.0; 2434 if (dataRecord.est_og > 1.060)
2374 // if (dataRecord.est_og > 1.076) 2435 pitchrate = 2.0;
2375 // pitchrate = 1.25; // Wyeast labs. http://www.wyeastlab.com/hb_pitchrates.cfm 2436 } else if (row.y_type == 6) { // Kveik
2376 if (row.y_type == 0) // lager yeast 2437 pitchrate = 0.075;
2377 pitchrate *= 2; 2438 } else {
2378 if (row.y_type == 6) // Kveik 2439 pitchrate = 0.75;
2379 pitchrate /= 10; // http://suigenerisbrewing.com/index.php/2019/08/28/drying-kveik-the-grand-finale/ 2440 if (dataRecord.est_og > 1.060)
2380 // pitchrate = 0.25; // Who knows. 2441 pitchrate = 1.0;
2381 2442 if (dataRecord.est_og > 1.076)
2443 pitchrate = 1.25; // Wyeast labs. http://www.wyeastlab.com/hb_pitchrates.cfm
2444 }
2382 // if (row.y_form == 1) { // dry yeast 2445 // if (row.y_form == 1) { // dry yeast
2383 // } else { // possible starter needed 2446 // } else { // possible starter needed
2384 // } 2447 // }
2385 } 2448 }
2386 } 2449 }
3556 $('#sparge_acid_perc').jqxNumberInput({ spinButtons: false, readOnly: true, width: false }); 3619 $('#sparge_acid_perc').jqxNumberInput({ spinButtons: false, readOnly: true, width: false });
3557 $('#starter_enable').jqxCheckBox({ disabled: true }); 3620 $('#starter_enable').jqxCheckBox({ disabled: true });
3558 $('#starter_type').jqxDropDownList({ disabled: true }); 3621 $('#starter_type').jqxDropDownList({ disabled: true });
3559 $('#starter_try').jqxButton({ disabled: true }); 3622 $('#starter_try').jqxButton({ disabled: true });
3560 $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3623 $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3561 $('#starter_viability').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3624 $('#yeast_prod_date').jqxDateTimeInput({ disabled: true });
3562 } 3625 }
3563 if (dataRecord.stage > 3) { // Primary fermentation done 3626 if (dataRecord.stage > 3) { // Primary fermentation done
3564 $('#brew_date_start').jqxDateTimeInput({ disabled: true }); 3627 $('#brew_date_start').jqxDateTimeInput({ disabled: true });
3565 $('#brew_date_end').jqxDateTimeInput({ disabled: true }); 3628 $('#brew_date_end').jqxDateTimeInput({ disabled: true });
3566 $('#brew_mash_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3629 $('#brew_mash_ph').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3650 if (dataRecord.starter_enable) { 3713 if (dataRecord.starter_enable) {
3651 $('#propagator').show(); 3714 $('#propagator').show();
3652 $('#starter_type').jqxDropDownList({ disabled: false }); 3715 $('#starter_type').jqxDropDownList({ disabled: false });
3653 $('#starter_try').jqxButton({ disabled: false }); 3716 $('#starter_try').jqxButton({ disabled: false });
3654 $('#starter_sg').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); 3717 $('#starter_sg').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3655 $('#starter_viability').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3656 } else { 3718 } else {
3657 $('#propagator').hide(); 3719 $('#propagator').hide();
3658 $('#starter_type').jqxDropDownList({ disabled: true }); 3720 $('#starter_type').jqxDropDownList({ disabled: true });
3659 $('#starter_try').jqxButton({ disabled: true }); 3721 $('#starter_try').jqxButton({ disabled: true });
3660 $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3722 $('#starter_sg').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3661 $('#starter_viability').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3662 } 3723 }
3663 } 3724 }
3664 3725
3665 function calcInit() { 3726 function calcInit() {
3666 console.log('calcInit()'); 3727 console.log('calcInit()');
3693 } 3754 }
3694 }); 3755 });
3695 $('#starter_sg').on('change', function(event) { 3756 $('#starter_sg').on('change', function(event) {
3696 if (event.args) { 3757 if (event.args) {
3697 dataRecord.starter_sg = event.args.value; 3758 dataRecord.starter_sg = event.args.value;
3698 calcYeast();
3699 }
3700 });
3701 $('#starter_viability').on('change', function(event) {
3702 if (event.args) {
3703 dataRecord.starter_viability = event.args.value;
3704 calcFermentables();
3705 calcYeast(); 3759 calcYeast();
3706 } 3760 }
3707 }); 3761 });
3708 $('#prop1_type').on('change', function(event) { 3762 $('#prop1_type').on('change', function(event) {
3709 if (event.args) { 3763 if (event.args) {
4434 wa_base_name: $('#wa_base_name').val(), 4488 wa_base_name: $('#wa_base_name').val(),
4435 starter_enable: dataRecord.starter_enable, 4489 starter_enable: dataRecord.starter_enable,
4436 starter_type: $('#starter_type').val(), 4490 starter_type: $('#starter_type').val(),
4437 starter_sg: parseFloat($('#starter_sg').jqxNumberInput('decimal')), 4491 starter_sg: parseFloat($('#starter_sg').jqxNumberInput('decimal')),
4438 starter_viability: parseFloat($('#starter_viability').jqxNumberInput('decimal')), 4492 starter_viability: parseFloat($('#starter_viability').jqxNumberInput('decimal')),
4493 yeast_prod_date: $('#yeast_prod_date').val(),
4439 prop1_type: $('#prop1_type').val(), 4494 prop1_type: $('#prop1_type').val(),
4440 prop1_volume: parseFloat($('#prop1_volume').jqxNumberInput('decimal')), 4495 prop1_volume: parseFloat($('#prop1_volume').jqxNumberInput('decimal')),
4441 prop2_type: $('#prop2_type').val(), 4496 prop2_type: $('#prop2_type').val(),
4442 prop2_volume: parseFloat($('#prop2_volume').jqxNumberInput('decimal')), 4497 prop2_volume: parseFloat($('#prop2_volume').jqxNumberInput('decimal')),
4443 prop3_type: $('#prop3_type').val(), 4498 prop3_type: $('#prop3_type').val(),
5222 $('#yeast_cells').jqxNumberInput(Show1dec); 5277 $('#yeast_cells').jqxNumberInput(Show1dec);
5223 $('#need_cells').jqxTooltip({ content: 'Het aantal nodige cellen is afhankelijk van het biertype.' }); 5278 $('#need_cells').jqxTooltip({ content: 'Het aantal nodige cellen is afhankelijk van het biertype.' });
5224 $('#need_cells').jqxNumberInput(Show1dec); 5279 $('#need_cells').jqxNumberInput(Show1dec);
5225 $('#plato_cells').jqxTooltip({ content: 'De berekende hoeveelheid gistcellen in miljard per ml per graad Plato. Dit is de zogenaamde pitchrate.' }); 5280 $('#plato_cells').jqxTooltip({ content: 'De berekende hoeveelheid gistcellen in miljard per ml per graad Plato. Dit is de zogenaamde pitchrate.' });
5226 $('#plato_cells').jqxNumberInput(Show2dec); 5281 $('#plato_cells').jqxNumberInput(Show2dec);
5282 $('#yeast_prod_date').jqxTooltip({ content: 'Bij korrelgisten is meestal "best voor" datum op het zakje gedrukt.<br>Gebruik die datum maar dan twee jaar eerder als productie datum.<br>Bij White Labs is de productie datum vier maanden voor de "Best by" datum die geprint op het buisje.<br>Bij Wyeast is dit de "manufacture date" die op het pak geprint is.<br>Voor schuine buis, slurry, opkweek en gedroogd is dit de datum dat je de gist geoogst hebt.' });
5283 $('#yeast_prod_date').jqxDateTimeInput(Dateopts);
5284 $('#yeast_prod_date').on('close', function(event) {
5285 calcViability();
5286 calcFermentables();
5287 calcYeast();
5288 });
5227 $('#popupYeast').jqxWindow({ 5289 $('#popupYeast').jqxWindow({
5228 width: 800, 5290 width: 800,
5229 height: 300, 5291 height: 300,
5230 position: { x: 230, y: 100 }, 5292 position: { x: 230, y: 100 },
5231 resizable: false, 5293 resizable: false,
5263 y_pofpos: yeastData.y_pofpos, 5325 y_pofpos: yeastData.y_pofpos,
5264 y_zymocide: yeastData.y_zymocide, 5326 y_zymocide: yeastData.y_zymocide,
5265 y_avail: yeastData.y_avail 5327 y_avail: yeastData.y_avail
5266 }; 5328 };
5267 $('#yeastGrid').jqxGrid('updaterow', rowID, row); 5329 $('#yeastGrid').jqxGrid('updaterow', rowID, row);
5330 calcViability();
5268 calcFermentables(); 5331 calcFermentables();
5269 calcYeast(); 5332 calcYeast();
5270 }); 5333 });
5271 $('#wy_name,#wy_laboratory,#wy_product_id').jqxInput({ theme: theme, width: 320, height: 23 }); 5334 $('#wy_name,#wy_laboratory,#wy_product_id').jqxInput({ theme: theme, width: 320, height: 23 });
5272 $('#wy_instock').jqxCheckBox({ theme: theme, height: 23 }); 5335 $('#wy_instock').jqxCheckBox({ theme: theme, height: 23 });
5319 } else if (yeastData.y_form == 1 || yeastData.y_form == 6) { 5382 } else if (yeastData.y_form == 1 || yeastData.y_form == 6) {
5320 $('#wy_pmpt_amount').html('Gewicht gram:'); 5383 $('#wy_pmpt_amount').html('Gewicht gram:');
5321 } else { 5384 } else {
5322 $('#wy_pmpt_amount').html('Volume ml:'); 5385 $('#wy_pmpt_amount').html('Volume ml:');
5323 } 5386 }
5387 calcViability();
5324 calcFermentables(); 5388 calcFermentables();
5325 calcYeast(); 5389 calcYeast();
5326 } 5390 }
5327 }); 5391 });
5328 $('#wy_amount').jqxNumberInput(Spin1dec); 5392 $('#wy_amount').jqxNumberInput(Spin1dec);
5346 }); 5410 });
5347 $('#wy_use').on('select', function(event) { 5411 $('#wy_use').on('select', function(event) {
5348 if (event.args) { 5412 if (event.args) {
5349 var index = event.args.index; 5413 var index = event.args.index;
5350 yeastData.y_use = index; 5414 yeastData.y_use = index;
5415 calcViability();
5351 calcFermentables(); 5416 calcFermentables();
5352 calcYeast(); 5417 calcYeast();
5353 } 5418 }
5354 }); 5419 });
5355 for (i = 1; i < 5; i++) { 5420 for (i = 1; i < 5; i++) {
5387 height: 23, 5452 height: 23,
5388 autoDropDownHeight: true 5453 autoDropDownHeight: true
5389 }); 5454 });
5390 $('#starter_sg').jqxTooltip({ content: 'Het ideale starter SG moet tussen de 1.030 en 1.040 zijn. Optimaal is 1.037.' }); 5455 $('#starter_sg').jqxTooltip({ content: 'Het ideale starter SG moet tussen de 1.030 en 1.040 zijn. Optimaal is 1.037.' });
5391 $('#starter_sg').jqxNumberInput(SGopts); 5456 $('#starter_sg').jqxNumberInput(SGopts);
5392 $('#starter_viability').jqxTooltip({ 5457 $('#starter_viability').jqxTooltip({ content: 'De gist conditie.' });
5393 content: 'De gist conditie te berekenen vanaf de productie datum. Vloeibare gist verlist iedere maand ongeveer 20% active cellen.' 5458 $('#starter_viability').jqxNumberInput(Smal0dec);
5394 });
5395 $('#starter_viability').jqxNumberInput(Perc0);
5396 $('#starter_try').jqxButton({ template: 'primary', width: '100px', height: 23, theme: theme }); 5459 $('#starter_try').jqxButton({ template: 'primary', width: '100px', height: 23, theme: theme });
5460
5397 5461
5398 // Tab 7, Mashing 5462 // Tab 7, Mashing
5399 $('#mash_name').jqxTooltip({ content: 'De omschrijving van dit maisch profiel.' }); 5463 $('#mash_name').jqxTooltip({ content: 'De omschrijving van dit maisch profiel.' });
5400 $('#mash_name').jqxInput({ theme: theme, width: 320, height: 23 }); 5464 $('#mash_name').jqxInput({ theme: theme, width: 320, height: 23 });
5401 $('#mash_select').jqxDropDownList({ 5465 $('#mash_select').jqxDropDownList({

mercurial