Phase 5, ,ash tab is a vieuwer.

Wed, 03 Aug 2022 17:37:30 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 03 Aug 2022 17:37:30 +0200
changeset 808
f6dcde592a7b
parent 807
ffb16dafbc93
child 809
8b30068497a9

Phase 5, ,ash tab is a vieuwer.

www/js/rec_edit.js file | annotate | diff | comparison | revisions
www/rec_edit.php file | annotate | diff | comparison | revisions
--- a/www/js/rec_edit.js	Wed Aug 03 17:24:05 2022 +0200
+++ b/www/js/rec_edit.js	Wed Aug 03 17:37:30 2022 +0200
@@ -103,17 +103,6 @@
   w100 = 90;
   w80 = 60;
  }
- $('#miscGrid').jqxGrid({ editable: rw });
- $('#maddrowbutton').jqxDropDownList({ disabled: ro });
- $('#minstockbutton').jqxCheckBox({ disabled: ro });
- $('#mdeleterowbutton').jqxButton({ disabled: ro });
- $('#yeastGrid').jqxGrid({ editable: rw });
- $('#yaddrowbutton').jqxDropDownList({ disabled: ro });
- $('#yinstockbutton').jqxCheckBox({ disabled: ro });
- $('#ydeleterowbutton').jqxButton({ disabled: ro });
- $('#mashGrid').jqxGrid({ editable: rw });
- $('#saddrowbutton').jqxButton({ disabled: ro });
- $('#sdeleterowbutton').jqxButton({ disabled: ro });
  $('#w1_name').jqxDropDownList({ disabled: ro });
  $('#w2_name').jqxDropDownList({ disabled: ro });
  $('#pr_name').jqxDropDownList({ disabled: ro });
@@ -307,22 +296,6 @@
 }
 
 
-function swapMash(r1, r2) {
-
- console.log('swap mash rows ' + r1 + ' ' + r2);
- var row1 = $('#mashGrid').jqxGrid('getrowdata', r1);
- var row2 = $('#mashGrid').jqxGrid('getrowdata', r2);
- var obj1 = { step_name: row1.step_name, step_type: row1.step_type, step_volume: row1.step_volume, step_infuse_amount: row1.step_infuse_amount,
-              step_infuse_temp: row1.step_infuse_temp, step_temp: row1.step_temp, step_time: row1.step_time,
-              ramp_time: row1.ramp_time, end_temp: row1.end_temp, step_wg_ratio: row1.step_wg_ratio };
- var obj2 = { step_name: row2.step_name, step_type: row2.step_type, step_volume: row2.step_volume, step_infuse_amount: row2.step_infuse_amount,
-              step_infuse_temp: row2.step_infuse_temp, step_temp: row2.step_temp, step_time: row2.step_time,
-              ramp_time: row2.ramp_time, end_temp: row2.end_temp, step_wg_ratio: row2.step_wg_ratio };
- $("#mashGrid").jqxGrid('updaterow', r1, obj2);
- $("#mashGrid").jqxGrid('updaterow', r2, obj1);
-}
-
-
 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) {
  var a = last_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
  var b = step_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
@@ -1244,9 +1217,6 @@
     { name: 'y_sg_hi', type: 'float' },
     { name: 'y_avail', type: 'int' }
    ],
-//   addrow: function(rowid, rowdata, position, commit) { commit(true); },
-  // deleterow: function(rowid, commit) { commit(true); },
-  // updaterow: function(rowid, rowdata, commit) { commit(true); }
   },
   yeastAdapter = new $.jqx.dataAdapter(yeastSource);
 
@@ -1318,8 +1288,8 @@
     { name: 'ramp_time', type: 'float' },
     { name: 'end_temp', type: 'float' }
    ],
-   addrow: function(rowid, rowdata, position, commit) { commit(true); },
-   deleterow: function(rowid, commit) { commit(true); }
+//   addrow: function(rowid, rowdata, position, commit) { commit(true); },
+//   deleterow: function(rowid, commit) { commit(true); }
   },
   mashAdapter = new $.jqx.dataAdapter(mashSource, {
    beforeLoadComplete: function(records) {
@@ -1339,48 +1309,7 @@
    height: 400,
    source: mashAdapter,
    theme: theme,
-   selectionmode: 'singlerow',
-   showtoolbar: true,
-   rendertoolbar: function(toolbar) {
-    //var me = this;
-    var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
-    toolbar.append(container);
-    container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />');
-    container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />');
-    $('#saddrowbutton').jqxButton({ template: 'primary', theme: theme, height: 27, width: 150 });
-    $('#saddrowbutton').on('click', function() {
-     var row = {}, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount;
-     row['step_name'] = 'Stap ' + (rowscount + 1);
-     if (rowscount > 0) {
-      row['step_type'] = 1;
-      row['step_infuse_amount'] = 0;
-      row['step_volume'] = mash_infuse;
-     } else {
-      row['step_type'] = 0;
-      row['step_infuse_amount'] = 15;
-      row['step_volume'] = 15;
-     }
-     row['step_infuse_temp'] = 0;
-     row['step_temp'] = 62.0;
-     row['step_time'] = 20.0;
-     row['step_wg_ratio'] = 0;
-     row['ramp_time'] = 1.0;
-     row['end_temp'] = 62.0;
-     $('#mashGrid').jqxGrid('addrow', null, datarow);
-     calcMash();
-    });
-    // delete selected yeast.
-    $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 });
-    $('#sdeleterowbutton').on('click', function() {
-     var id, rowscount, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex');
-     rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount;
-     if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
-      id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex);
-      $('#mashGrid').jqxGrid('deleterow', id);
-      calcMash();
-     }
-    });
-   },
+   editable: false,
    ready: function() {
     calcFermentables();
     calcInit();
@@ -1420,73 +1349,12 @@
         color = '#ff4040';
        return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f2') + '</span>';
       }
-    },
-    { text: '', columntype: 'button', width: 15, align: 'center',
-     cellsrenderer: function(row) {
-      if (row < 2)
-       return ' ';
-      return '▴';
-     }, buttonclick: function(row) {
-      if (row >= 2) {
-       swapMash(row, row-1);
-      }
-     }
-    },
-    { text: '', columntype: 'button', width: 15, align: 'center',
-     cellsrenderer: function(row) {
-      rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount;
-      if (row < 1 || row > (rowscount -2))
-       return ' ';
-      return '▾';
-     }, buttonclick: function(row) {
-      rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount;
-      if (row >= 1 && row <= (rowscount -2)) {
-       swapMash(row, row+1);
-      }
-     }
-    },
-    { text: '', datafield: 'Edit', columntype: 'button', width: 80, align: 'center',
-     cellsrenderer: function() {
-      return 'Wijzig';
-     }, buttonclick: function(row) {
-      mashRow = row;
-      mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-      if (mashRow == 0)
-       $("#wstep_type").jqxDropDownList('disableAt', 2);
-      else
-       $("#wstep_type").jqxDropDownList('enableAt', 2);
-      $('#wstep_name').val(mashData.step_name);
-      $('#wstep_type').val(mashData.step_type);
-      $('#wstep_infuse_amount').val(mashData.step_infuse_amount);
-      $('#wstep_infuse_temp').val(mashData.step_infuse_temp);
-      $('#wstep_temp').val(mashData.step_temp);
-      $('#wend_temp').val(mashData.end_temp);
-      $('#wstep_time').val(mashData.step_time);
-      $('#wramp_time').val(mashData.ramp_time);
-      $('#wstep_infuse_amount').hide(); // Hide all untile we need it.
-      $('#wstep_infuse_temp').hide();
-      $('#wstep_pmpt_amount').hide();
-      $('#wstep_pmpt_temp').hide();
-      if (mashData.step_type == 0) {
-       if (mashRow == 0) {
-        $('#wstep_infuse_amount').show();
-        $('#wstep_pmpt_amount').show();
-       } else {
-        $('#wstep_infuse_temp').show();
-        $('#wstep_pmpt_temp').show();
-       }
-      }
-      // show the popup window.
-      $('#popupMash').jqxWindow('open');
-     }
     }
    ]
   });
  };
 
 
-
-
  /*
   * Remove the top menu so that we MUST use the buttons to leave the editor.
   */
@@ -2407,206 +2275,6 @@
 
  // Tab 6, Maischen
  $('#mash_name').jqxInput({ theme: theme, width: 320, height: 23 });
- $('#mash_select').jqxDropDownList({
-  placeHolder: 'Kies schema:',
-  theme: theme,
-  source: mashlist,
-  displayMember: 'name',
-  width: 250,
-  height: 23,
-  dropDownWidth: 500,
-  dropDownHeight: 500,
-  dropDownHorizontalAlignment: 'right'
- });
- $('#mash_select').on('select', function(event) {
-  if (event.args) {
-   var infused = 0, data, datarecord, i, row, rows, rowIDs, index = event.args.index;
-   // First delete all current steps
-   rowIDs = new Array();
-   rows = $('#mashGrid').jqxGrid('getdisplayrows');
-   for (i = 0; i < rows.length; i++) {
-    row = rows[i];
-    rowIDs.push(row.uid);
-   }
-   $('#mashGrid').jqxGrid('deleterow', rowIDs);
-   // Then add the new steps
-   datarecord = mashlist.records[index];
-   $('#mash_name').val(datarecord.name);
-   for (i = 0; i < datarecord.steps.length; i++) {
-    data = datarecord.steps[i];
-    row = {};
-    row['step_name'] = data.step_name;
-    row['step_type'] = parseInt(data.step_type);
-    row['step_temp'] = parseFloat(data.step_temp);
-    row['end_temp'] = parseFloat(data.end_temp);
-    row['step_time'] = parseFloat(data.step_time);
-    row['ramp_time'] = parseFloat(data.ramp_time);
-    row['step_infuse_temp'] = 0.0;
-    row['step_infuse_amount'] = 0.0;
-    if (mash_infuse == 0 && dataRecord.wg_amount > 0)
-     mash_infuse = dataRecord.wg_amount;
-    if (data.step_type == 0) { // Infusion
-     if (i == 0) {
-      row['step_infuse_amount'] = parseFloat(mash_infuse);
-     } else {
-      row['step_infuse_temp'] = 99.0;
-     }
-    }
-    //console.log(i + ' type: ' + row['step_type'] + ' start infusion: ' + parseFloat(row['step_infuse_amount']) + ' mash_infuse: ' + mash_infuse);
-    infused += parseFloat(row['step_infuse_amount']);
-    row['step_volume'] = infused;
-    if (mashkg > 0)
-     row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2);
-    else
-     row['step_wg_ratio'] = 0;
-    $('#mashGrid').jqxGrid('addrow', null, row);
-   }
-   calcMash();
-  }
- });
- $('#popupMash').jqxWindow({
-  width: 800,
-  height: 375,
-  position: { x: 230, y: 100 },
-  resizable: false,
-  theme: theme,
-  isModal: true,
-  autoOpen: false,
-  cancelButton: $('#MashReady'),
-  modalOpacity: 0.40
- });
- $('#MashReady').jqxButton({ template: 'success', width: '90px', theme: theme });
- $('#MashReady').click(function() {
-  calcMash();
- });
- $('#wstep_name').jqxInput({ theme: theme, width: 320, height: 23 });
- $('#wstep_name').on('change', function(event) {
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.step_name = $('#wstep_name').val();
- });
- $('#wstep_type').jqxDropDownList({
-  theme: theme,
-  source: MashStepTypeAdapter,
-  valueMember: 'id',
-  displayMember: 'nl',
-  width: 180,
-  height: 23,
-  autoDropDownHeight: true
- });
- $('#wstep_type').on('select', function(event) {
-  if (event.args) {
-   var rowdata, rows, i, row, index = event.args.index;
-   rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-   if (rowdata.step_type != index) {
-    rowdata.step_type = index;
-    $('#wstep_infuse_amount').hide();
-    $('#wstep_infuse_temp').hide();
-    $('#wstep_pmpt_amount').hide();
-    $('#wstep_pmpt_temp').hide();
-    if (index == 0) { // Infusion
-     if (mashRow == 0) {
-      $('#wstep_infuse_amount').show();
-      $('#wstep_pmpt_amount').show();
-     } else {
-      $('#wstep_infuse_temp').show();
-      $('#wstep_pmpt_temp').show();
-     }
-    }
-    if (index == 1) { // Temperature
-     if (mashRow > 0)
-      rowdata.step_infuse_amount = 0;
-     rowdata.step_infuse_temp = 0;
-    }
-    if (index == 2) { // Decoction
-     var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1);
-     rowdata.step_infuse_temp = 99;
-     rowdata.step_infuse_amount = decoctionVol(rowdata.step_volume, rowdata.step_temp, rowprev.end_temp);
-     console.log('decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp);
-    }
-    $('#mashGrid').jqxGrid('updaterow', mashRow, rowdata);
-    mash_infuse = 0;
-    rows = $('#mashGrid').jqxGrid('getrows');
-    for (i = 0; i < rows.length; i++) {
-     row = rows[i];
-     if (row.step_type == 0) // Infusion
-      mash_infuse += parseFloat(row.step_infuse_amount);
-    }
-    calcMash();
-   }
-  }
- });
- $('#wstep_temp').jqxNumberInput(Spin1dec);
- $('#wstep_temp').on('change', function(event) {
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  if (rowdata.step_type == 2) { // Decoction
-   var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1);
-   var a = (eq_tun_weight * eq_tun_specific_heat + rowdata.step_volume * SpecificHeatWater) *
-           (parseFloat(event.args.value) - rowprev.end_temp);
-   var b = SpecificHeatWater * (99 - parseFloat(event.args.value));
-   if (b > 0) {
-    rowdata.step_temp = parseFloat(event.args.value);
-    rowdata.step_infuse_amount = Round(a / b, 2);
-   } else
-    rowdata.step_infuse_amount = 0;
-   console.log('change temp ' + rowdata.step_temp + ' decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp);
-  } else {
-   rowdata.step_temp = parseFloat(event.args.value);
-  }
- });
- $('#wend_temp').jqxNumberInput(Spin1dec);
- $('#wend_temp').on('change', function(event) {
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.end_temp = parseFloat(event.args.value);
- });
- $('#wstep_time').jqxNumberInput(PosInt);
- $('#wstep_time').on('change', function(event) {
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.step_time = parseFloat(event.args.value);
- });
- $('#wramp_time').jqxNumberInput(PosInt);
- $('#wramp_time').on('change', function(event) {
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.ramp_time = parseFloat(event.args.value);
- });
- $('#wstep_infuse_amount').jqxNumberInput(Spin1dec);
- $('#wstep_infuse_amount').on('change', function(event) {
-  var i, rows, row, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.step_infuse_amount = parseFloat(event.args.value);
-  if (mashRow == 0) {
-   rowdata.step_infuse_amount = parseFloat(event.args.value);
-   mash_infuse = 0;
-   rows = $('#mashGrid').jqxGrid('getrows');
-   for (i = 0; i < rows.length; i++) {
-    row = rows[i];
-    if (row.step_type == 0) // Infusion
-     mash_infuse += parseFloat(row.step_infuse_amount);
-   }
-   if (dataRecord.w2_amount == 0) {
-    dataRecord.w1_amount = mash_infuse;
-    $('#w1_amount').val(mash_infuse);
-   } else {
-    var w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse;
-    var w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse;
-    dataRecord.w1_amount = Round(w1_amount, 3);
-    dataRecord.w2_amount = Round(w2_amount, 3);
-    $('#w1_amount').val(dataRecord.w1_amount);
-    $('#w2_amount').val(dataRecord.w2_amount);
-   }
-   $('#wg_amount').val(mash_infuse);
-   console.log('new infuse amount: ' + mash_infuse);
-   calcWater();
-  }
- });
- $('#wstep_infuse_temp').jqxNumberInput(Spin1dec);
- $('#wstep_infuse_temp').on('change', function(event) {
-  var prevdata = $('#mashGrid').jqxGrid('getrowdata', mashRow-1);
-  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-  rowdata.step_infuse_temp = parseFloat(event.args.value);
-  var vol = infusionVol(prevdata.step_volume, mashkg, rowdata.step_infuse_temp, rowdata.step_temp, prevdata.end_temp);
-  console.log('new vol: ' + vol);
-  rowdata.step_infuse_amount = vol;
-  $('#wstep_infuse_amount').val(vol);
- });
 
  // Tab 7, Water
  $('#tgt_bu').jqxNumberInput(Show2wat);
--- a/www/rec_edit.php	Wed Aug 03 17:24:05 2022 +0200
+++ b/www/rec_edit.php	Wed Aug 03 17:37:30 2022 +0200
@@ -178,9 +178,8 @@
        <table style="width: 100%;">
         <tr>
          <td style="vertical-align: top; float: right; padding: 3px;">Maischchema:</td>
-	 <td align="left" style="vertical-align: top; padding: 3px;"><input id="mash_name" /></td>
-         <td style="vertical-align: top; float: right; padding: 3px;">Kies ander schema:</td>
-         <td style="padding: 3px;" colspan="2"><div id="mash_select"></div></td>
+	 <td align="left" style="vertical-align: top; padding: 3px;"><input readonly="1" id="mash_name" /></td>
+         <td colspan="2"></td>
 	</tr>
         <tr><td colspan="4">&nbsp;</td></tr>
         <tr><td align="center" colspan="4" style="padding: 3px;"><div id="mashGrid"></div></td></tr>
@@ -359,51 +358,6 @@
 
    </div> <!-- jqxTabs -->
 
-   <div id="popupMash">
-    <div>Wijzig maisch stap detail.</div>
-    <div style="overflow: hidden;">
-     <table style="width: 100%;">
-      <tr>
-       <td align="right" style="vertical-align: top;">Stap naam:</td>
-       <td style="padding: 3px;"><input id="wstep_name" /></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;">Stap type:</td>
-       <td style="padding: 3px;"><div id="wstep_type" /></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;">Start temperatuur &deg;C:</td>
-       <td style="padding: 3px;"><div id="wstep_temp" /></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;">Eind temperatuur &deg;C:</td>
-       <td style="padding: 3px;"><div id="wend_temp"></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;">Stap tijd minuten:</td>
-       <td style="padding: 3px;"><div id="wstep_time"></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;">Opwarm tijd minuten:</td>
-       <td style="padding: 3px;"><div id="wramp_time"></div></td>
-      </tr>
-      <tr>
-       <td align="right" style="vertical-align: top;"><div id="wstep_pmpt_amount">Infusie liters:</div></td>
-       <td style="padding: 3px;"><div id="wstep_infuse_amount"></div></td>
-      </tr>
-       <tr>
-       <td align="right" style="vertical-align: top;"><div id="wstep_pmpt_temp">Infusie temperatuur:</div></td>
-       <td style="padding: 3px;"><div id="wstep_infuse_temp"></div></td>
-      </tr>
-      <tr>
-       <td style="padding-top: 30px;" colspan="2" align="center">
-        <input id="MashReady" type="button" value="Sla op" />
-       </td>
-      </tr>
-     </table>
-    </div>
-   </div>
-
 <?php
 confirm_delete();
 page_footer();

mercurial