Wed, 30 Jan 2019 16:40:23 +0100
Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
--- a/www/getfermentablesources.php Tue Jan 29 21:52:08 2019 +0100 +++ b/www/getfermentablesources.php Wed Jan 30 16:40:23 2019 +0100 @@ -22,12 +22,14 @@ 'moisture' => $row['moisture'], 'diastatic_power' => $row['diastatic_power'], 'protein' => $row['protein'], + 'dissolved_protein' => $row['dissolved_protein'], 'max_in_batch' => $row['max_in_batch'], 'recommend_mash' => $row['recommend_mash'], 'graintype' => $row['graintype'], 'di_ph' => $row['di_ph'], + 'acid_to_ph_57' => $row['acid_to_ph_57'], 'inventory' => $row['inventory'], 'cost' => $row['cost'] ); } -echo json_encode($fermentables); +echo json_encode($fermentables, JSON_UNESCAPED_UNICODE);
--- a/www/includes/db_recipes.php Tue Jan 29 21:52:08 2019 +0100 +++ b/www/includes/db_recipes.php Wed Jan 30 16:40:23 2019 +0100 @@ -328,10 +328,34 @@ $recipes .= ',"wa_acid_name":' . $row['wa_acid_name']; $recipes .= ',"wa_acid_perc":' . $row['wa_acid_perc']; $recipes .= ',"wa_base_name":' . $row['wa_base_name']; - $recipes .= ',"fermentables":' . $row['json_fermentables']; - $recipes .= ',"hops":' . $row['json_hops']; - $recipes .= ',"miscs":' . $row['json_miscs']; - $recipes .= ',"yeasts":' . $row['json_yeasts']; + if (isset($_GET['record'])) { + // Append stock information. + $fermentables = json_decode($row['json_fermentables'], true); + for ($i = 0; $i < count($fermentables); $i++) { + $fermentables[$i]['f_inventory'] = 0; // Not in stock + $fermentables[$i]['f_avail'] = 0; // Ingredient not in db + $sql2 = "SELECT inventory FROM inventory_fermentables "; + $sql2 .= "WHERE name='".$fermentables[$i]['f_name']."' AND supplier='".$fermentables[$i]['f_supplier']."'"; + if ($result2 = mysqli_query($connect, $sql2)) { + if ($obj = mysqli_fetch_object($result2)) { + $fermentables[$i]['f_inventory'] = $obj->inventory; + $fermentables[$i]['f_avail'] = 1; + } + mysqli_free_result($result2); + } + } + syslog(LOG_NOTICE, json_encode($fermentables, JSON_UNESCAPED_UNICODE)); + $recipes .= ',"fermentables":' . json_encode($fermentables, JSON_UNESCAPED_UNICODE); + $recipes .= ',"hops":' . $row['json_hops']; + $recipes .= ',"miscs":' . $row['json_miscs']; + $recipes .= ',"yeasts":' . $row['json_yeasts']; + } else { + // Just leave it. + $recipes .= ',"fermentables":' . $row['json_fermentables']; + $recipes .= ',"hops":' . $row['json_hops']; + $recipes .= ',"miscs":' . $row['json_miscs']; + $recipes .= ',"yeasts":' . $row['json_yeasts']; + } $recipes .= ',"mashs":' . $row['json_mashs']; $recipes .= '}'; }
--- a/www/js/global.js Tue Jan 29 21:52:08 2019 +0100 +++ b/www/js/global.js Wed Jan 30 16:40:23 2019 +0100 @@ -455,8 +455,7 @@ { name: 'ingredients', type: 'string' }, { name: 'examples', type: 'string' } ], - url: stylesUrl, - async: true + url: stylesUrl }; var styleslist = new $.jqx.dataAdapter(stylesSource); @@ -490,8 +489,7 @@ { name: 'mash_max', type: 'float' }, { name: 'efficiency', type: 'float' } ], - url: equipmentUrl, - async: true + url: equipmentUrl }; var equipmentlist = new $.jqx.dataAdapter(equipmentSource); @@ -511,15 +509,16 @@ { name: 'moisture', type: 'float' }, { name: 'diastatic_power', type: 'float' }, { name: 'protein', type: 'float' }, + { name: 'dissolved_protein', type: 'float' }, { name: 'max_in_batch', type: 'float' }, { name: 'recommend_mash', type: 'int' }, { name: 'graintype', type: 'int' }, { name: 'di_ph', type: 'float' }, + { name: 'acid_to_ph_57', type: 'float' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: "getfermentablesources.php", - async: true + url: "getfermentablesources.php" }; var fermentableinstock = false; var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource, { @@ -558,8 +557,7 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: "gethopsources.php", - async: true + url: "gethopsources.php" }; var hopinstock = false; var hoplist = new $.jqx.dataAdapter(hopInvSource, { @@ -590,8 +588,7 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: "getmiscsources.php", - async: true + url: "getmiscsources.php" }; var miscinstock = false; var misclist = new $.jqx.dataAdapter(miscInvSource, { @@ -625,8 +622,7 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], - url: "getyeastsources.php", - async: true + url: "getyeastsources.php" }; var yeastinstock = false; var yeastlist = new $.jqx.dataAdapter(yeastInvSource, { @@ -661,8 +657,7 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' }, ], - url: "getwatersources.php", - async: true + url: "getwatersources.php" }; var waterinstock = false; var waterlist = new $.jqx.dataAdapter(waterInvSource, { @@ -695,8 +690,7 @@ { name: 'ph', type: 'float' }, { name: 'total_alkalinity', type: 'float' }, ], - url: "includes/db_profile_water.php", - async: true + url: "includes/db_profile_water.php" }; var waterprofiles = new $.jqx.dataAdapter(waterProfileSource); @@ -708,8 +702,7 @@ { name: 'name', type: 'string' }, { name: 'steps', type: 'array' } ], - url: "include/db_profile_mash.php", - async: true + url: "include/db_profile_mash.php" }; var mashlist = new $.jqx.dataAdapter(mashInvSource);
--- a/www/js/rec_edit.js Tue Jan 29 21:52:08 2019 +0100 +++ b/www/js/rec_edit.js Wed Jan 30 16:40:23 2019 +0100 @@ -1420,7 +1420,8 @@ { name: 'f_percentage', type: 'float' }, { name: 'f_di_ph', type: 'float' }, { name: 'f_acid_to_ph_57', type: 'float' }, - { name: 'f_stock', type: 'float' }, + { name: 'f_inventory', type: 'float' }, + { name: 'f_avail', type: 'int' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -1450,6 +1451,7 @@ $("#faddrowbutton").jqxDropDownList({ placeHolder: "Kies mout:", theme: theme, + template: "primary", source: fermentablelist, displayMember: "name", width: 150, @@ -1501,6 +1503,7 @@ } row["f_di_ph"] = datarecord.di_ph; row["f_acid_to_ph_57"] = datarecord.acid_to_ph_57; + row["f_inventory"] = datarecord.inventory; var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); } }); @@ -1512,7 +1515,7 @@ }); // delete selected fermentable. - $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); + $("#fdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); $("#fdeleterowbutton").on('click', function () { var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; @@ -1577,7 +1580,7 @@ }, { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'Voorr. Kg', datafield: 'f_stock', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'Voorr. Kg', datafield: 'f_inventory', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, { text: 'Percent', datafield: 'f_percentage', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 }, { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { @@ -2501,17 +2504,61 @@ }); $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme }); $("#FermentableReady").click(function () { - $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_name', $("#wf_name").val()); - - // $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc'); + $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc'); // Recalc percentages - // calcFermentables(); - // calcSVG(); - // calcABV(); - // calcIBUs(); + calcFermentables(); + calcSVG(); + calcABV(); + calcIBUs(); // Waters: yes there is impact. }); $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#wf_instock").jqxCheckBox({ theme: theme, height: 23 }); + $("#wf_instock").on('change', function (event) { + fermentableinstock = event.args.checked; + fermentablelist.dataBind(); + }); + $("#wf_select").jqxDropDownList({ + placeHolder: "Kies mout:", + theme: theme, + source: fermentablelist, + displayMember: "name", + width: 150, + height: 23, + dropDownWidth: 500, + dropDownHeight: 500, + renderer: function (index, label, value) { + var datarecord = fermentablelist.records[index]; + return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; + } + }); + $("#wf_select").on('select', function (event) { + if (event.args) { + var index = event.args.index; + var datarecord = fermentablelist.records[index]; + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); + $("#wf_name").val(datarecord.name); + rowdata.f_name = datarecord.name; + rowdata.f_origin = datarecord.origin; + rowdata.f_supplier = datarecord.supplier; + rowdata.f_type = datarecord.type; + rowdata.f_cost = datarecord.cost; + rowdata.f_yield = datarecord.yield; + rowdata.f_color = datarecord.color; + rowdata.f_coarse_fine_diff = datarecord.coarse_fine_diff; + rowdata.f_moisture = datarecord.moisture; + rowdata.f_diastatic_power = datarecord.diastatic_power; + rowdata.f_protein = datarecord.protein; + rowdata.f_max_in_batch = datarecord.max_in_batch; + rowdata.f_graintype = datarecord.graintype; + rowdata.f_dissolved_protein = datarecord.dissolved_protein; + rowdata.f_recommend_mash = datarecord.recommend_mash; + rowdata.f_add_after_boil = datarecord.add_after_boil; + rowdata.f_di_ph = datarecord.di_ph; + rowdata.f_acid_to_ph_57 = datarecord.acid_to_ph_57; + rowdata.f_inventory = datarecord.inventory; + } + }); $("#wf_amount").jqxNumberInput( Spin3dec5 ); $('#wf_amount').on('change', function (event) { console.log("amount changed: "+event.args.value);
--- a/www/profile_mash.php Tue Jan 29 21:52:08 2019 +0100 +++ b/www/profile_mash.php Wed Jan 30 16:40:23 2019 +0100 @@ -48,7 +48,7 @@ <table style="width: 100%;"> <tr> <td align="right" style="vertical-align: top;">Stap naam:</td> - <td align="left" colspan="2" style="vertical-align: top;"><input id="m_step_name" /></td> + <td align="left" style="vertical-align: top;"><input id="m_step_name" /></td> </tr> <tr> <td align="right" style="vertical-align: top;">Stap type:</td>
--- a/www/rec_edit.php Tue Jan 29 21:52:08 2019 +0100 +++ b/www/rec_edit.php Wed Jan 30 16:40:23 2019 +0100 @@ -341,7 +341,15 @@ <table style="width: 100%;"> <tr> <td align="right" style="vertical-align: top;">Ingrediënt naam:</td> - <td align="left" colspan="2" style="vertical-align: top;"><input readonly="1" id="wf_name" /></td> + <td style="padding: 3px;"><input readonly="1" id="wf_name" /></div></td> + </tr> + <tr> + <td align="right" style="vertical-align: top;">Ander ingrediënt:</td> + <td style="padding: 3px;"><div style='overflow: hidden;'> + <div style="float: left;" id="wf_select"></div> + <div style="float: left; margin-left: 10px;">In voorraad:</div> + <div style="float: left; margin-left: 10px;" id="wf_instock"></div></div> + </td> </tr> <tr> <td align="right" style="vertical-align: top;">Hoeveelheid kg:</td> @@ -360,7 +368,7 @@ <td style="padding: 3px;"><div id="wf_added"></div></td> </tr> <tr> - <td style="padding-top: 50px;" colspan="2" align="center"> + <td style="padding-top: 30px;" colspan="2" align="center"> <input id="FermentableReady" type="button" value="Sla op" /> </td> </tr>