www/js/inv_waters-min.js

Wed, 16 Oct 2019 21:05:03 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 16 Oct 2019 21:05:03 +0200
changeset 514
3c680d1dea35
parent 488
77f1617b6994
permissions
-rw-r--r--

Added dutch array strings to a global php script. Changed fermentables, hops, yeast and misc inventory scripts to use these strings between the database scripts and javascript scripts. This makes filtering on types strings useable. Added these changes to the product/recipe forum and print exports too.

488
77f1617b6994 Fixed inventory databases race conditions
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1 function createDelElements(){$("#eventWindow").jqxWindow({theme:theme,position:{x:490,y:210},width:300,height:175,resizable:false,isModal:true,modalOpacity:0.4,okButton:$("#delOk"),cancelButton:$("#delCancel"),initContent:function(){$("#delOk").jqxButton({template:"danger",width:"65px",theme:theme});$("#delCancel").jqxButton({template:"success",width:"65px",theme:theme});$("#delCancel").focus()}});$("#eventWindow").jqxWindow("hide")}$(document).ready(function(){$("#name").jqxTooltip({content:"De unieke naam van dit brouwwater."});$("#notes").jqxTooltip({content:"Extra opmerkingen over dit water."});$("#unlimited_stock").jqxTooltip({content:"Onbeperkte voorraad zoals kraanwater en bronnen."});$("#calcium").jqxTooltip({content:"Calcium (Ca)."});$("#bicarbonate").jqxTooltip({content:"Bicarbonaat (HCO3). Berekend meteen de Totale alkaliteit."});$("#sulfate").jqxTooltip({content:"Calcium Sulfaat (CaSO4)."});$("#chloride").jqxTooltip({content:"Chloride (Cl)."});$("#sodium").jqxTooltip({content:"Natrium, oftewel keukenzout (Na). In berekeningen ook vaak als Sodium."});$("#magnesium").jqxTooltip({content:"Magnesium (Mg)."});$("#ph").jqxTooltip({content:"De zuurgraad (pH)."});$("#total_alkalinity").jqxTooltip({content:"Totale alkaliniteit. Berekend meteen de Bicarbonaat."});$("#inventory").jqxTooltip({content:"Voorraad in liters."});$("#cost").jqxTooltip({content:"Kostprijs per liter. 5 cijfers achter de comma zodat het kraanwater er ook in kan."});var b={},a="includes/db_inventory_water.php",d={datatype:"json",cache:false,datafields:[{name:"record",type:"number"},{name:"name",type:"string"},{name:"unlimited_stock",type:"int"},{name:"calcium",type:"float"},{name:"bicarbonate",type:"float"},{name:"sulfate",type:"float"},{name:"chloride",type:"float"},{name:"sodium",type:"float"},{name:"magnesium",type:"float"},{name:"ph",type:"float"},{name:"notes",type:"string"},{name:"total_alkalinity",type:"float"},{name:"inventory",type:"float"},{name:"cost",type:"float"}],id:"record",url:a,deleterow:function(f,h){var g="delete=true&"+$.param({record:f});$.ajax({dataType:"json",url:a,cache:false,data:g,type:"POST",success:function(j,i,k){h(true);location.reload(true)},error:function(i,k,j){h(false)}})},addrow:function(g,j,f,i){var h="insert=true&"+$.param(j);$.ajax({dataType:"json",url:a,cache:false,data:h,type:"POST",success:function(l,k,m){i(true);location.reload(true)},error:function(k,m,l){i(false)}})},updaterow:function(f,i,h){var g="update=true&"+$.param(i);$.ajax({dataType:"json",url:a,cache:false,data:g,type:"POST",success:function(k,j,l){h(true);location.reload(true)},error:function(j,l,k){h(false)}})}},e=new $.jqx.dataAdapter(d),c=-1;$("#name").jqxInput({theme:theme,width:640,height:23});$("#notes").jqxInput({theme:theme,width:640,height:100});$("#unlimited_stock").jqxCheckBox({theme:theme,width:120,height:23});$("#calcium").jqxNumberInput(Spin1dec);$("#bicarbonate").jqxNumberInput(Spin1dec);$("#sulfate").jqxNumberInput(Spin1dec);$("#chloride").jqxNumberInput(Spin1dec);$("#sodium").jqxNumberInput(Spin1dec);$("#magnesium").jqxNumberInput(Spin1dec);$("#ph").jqxNumberInput(Spin2pH);$("#total_alkalinity").jqxNumberInput(Spin1dec);$("#inventory").jqxNumberInput(Spin1dec);$("#cost").jqxNumberInput({inputMode:"simple",theme:theme,width:110,height:23,min:0,decimalDigits:5,spinButtons:true});$("#jqxgrid").jqxGrid({width:1280,height:630,source:e,theme:theme,showstatusbar:true,renderstatusbar:function(h){var g,f=$("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");g=$("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>");f.append(g);h.append(f);g.jqxButton({theme:theme,width:90,height:20});g.click(function(i){c=-1;$("#popupWindow").jqxWindow({position:{x:110,y:30}});$("#name").val("Nieuw brouwwater");$("#unlimited_stock").val(0);$("#calcium").val(0);$("#bicarbonate").val(0);$("#sulfate").val(0);$("#chloride").val(0);$("#sodium").val(0);$("#magnesium").val(0);$("#ph").val(7);$("#notes").val("");$("#total_alkalinity").val(0);$("#inventory").val(0);$("#cost").val(0);$("#popupWindow").jqxWindow("open")})},filterable:false,columns:[{text:"Water leverancier",datafield:"name",width:225},{text:"Opmerkingen",datafield:"notes"},{text:"Onbeperkt",datafield:"unlimited_stock",columntype:"checkbox",width:80},{text:"Voorraad",datafield:"inventory",width:100,align:"right",cellsalign:"right",cellsformat:"f1",cellsrenderer:function(g,f,k,j,i,l){var h="";if(k>0&&l.unlimited_stock==0){h=e.formatNumber(k,"f1")+" L"}return"<span style='margin: 3px; margin-top: 6px; float: right;'>"+h+"</span>"}},{text:"",datafield:"Edit",width:100,align:"center",columntype:"button",cellsrenderer:function(){return"Wijzig"},buttonclick:function(f){c=f;$("#popupWindow").jqxWindow({position:{x:110,y:30}});b=$("#jqxgrid").jqxGrid("getrowdata",c);$("#name").val(b.name);$("#unlimited_stock").val(b.unlimited_stock);$("#calcium").val(b.calcium);$("#bicarbonate").val(b.bicarbonate);$("#sulfate").val(b.sulfate);$("#chloride").val(b.chloride);$("#sodium").val(b.sodium);$("#magnesium").val(b.magnesium);$("#ph").val(b.ph);$("#notes").val(b.notes);$("#total_alkalinity").val(b.total_alkalinity);$("#inventory").val(b.inventory);$("#cost").val(b.cost);$("#popupWindow").jqxWindow("open")}}]});$("#total_alkalinity").on("change",function(f){b.bicarbonate=parseFloat(f.args.value)*1.22;$("#bicarbonate").val(b.bicarbonate)});$("#bicarbonate").on("change",function(f){b.total_alkalinity=parseFloat(f.args.value)*50/61;$("#total_alkalinity").val(b.total_alkalinity)});$("#popupWindow").jqxWindow({width:1050,height:550,resizable:false,theme:theme,isModal:true,autoOpen:false,cancelButton:$("#Cancel"),modalOpacity:0.4});$("#popupWindow").on("open",function(){$("#name").jqxInput("selectAll")});$("#Delete").jqxButton({template:"danger",width:"90px",theme:theme});$("#Delete").click(function(){if(c>=0){$("#eventWindow").jqxWindow("open");$("#delOk").click(function(){var f=$("#jqxgrid").jqxGrid("getrowid",c);$("#jqxgrid").jqxGrid("deleterow",f)})}$("#popupWindow").jqxWindow("hide")});$("#Cancel").jqxButton({template:"primary",width:"90px",theme:theme});$("#Save").jqxButton({template:"success",width:"90px",theme:theme});$("#Save").click(function(){var g,f=-1;if(c>=0){f=$("#jqxgrid").jqxGrid("getrowid",c)}g={record:f,name:$("#name").val(),unlimited_stock:$("#unlimited_stock").val(),calcium:parseFloat($("#calcium").jqxNumberInput("decimal")),bicarbonate:parseFloat($("#bicarbonate").jqxNumberInput("decimal")),sulfate:parseFloat($("#sulfate").jqxNumberInput("decimal")),chloride:parseFloat($("#chloride").jqxNumberInput("decimal")),sodium:parseFloat($("#sodium").jqxNumberInput("decimal")),magnesium:parseFloat($("#magnesium").jqxNumberInput("decimal")),ph:parseFloat($("#ph").jqxNumberInput("decimal")),notes:$("#notes").val(),total_alkalinity:parseFloat($("#total_alkalinity").jqxNumberInput("decimal")),inventory:parseFloat($("#inventory").jqxNumberInput("decimal")),cost:parseFloat($("#cost").jqxNumberInput("decimal"))};if(c>=0){$("#jqxgrid").jqxGrid("updaterow",f,g)}else{$("#jqxgrid").jqxGrid("addrow",null,g)}$("#popupWindow").jqxWindow("hide")});createDelElements()});

mercurial