1890 loadError: function(jqXHR, status, error) { |
1890 loadError: function(jqXHR, status, error) { |
1891 $('#err').text(status + ' ' + error); |
1891 $('#err').text(status + ' ' + error); |
1892 }, |
1892 }, |
1893 }); |
1893 }); |
1894 $("#miscGrid").jqxGrid({ |
1894 $("#miscGrid").jqxGrid({ |
1895 width: 960, |
1895 width: 1240, |
1896 height: 400, |
1896 height: 525, |
1897 source: miscAdapter, |
1897 source: miscAdapter, |
1898 theme: theme, |
1898 theme: theme, |
1899 selectionmode: 'singlerow', |
1899 selectionmode: 'singlerow', |
1900 editmode: 'selectedcell', |
|
1901 editable: true, |
|
1902 localization: getLocalization(), |
1900 localization: getLocalization(), |
1903 showtoolbar: true, |
1901 showtoolbar: true, |
1904 rendertoolbar: function (toolbar) { |
1902 rendertoolbar: function (toolbar) { |
1905 var me = this; |
1903 var me = this; |
1906 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
1904 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
1907 toolbar.append(container); |
1905 toolbar.append(container); |
1908 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
1906 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
1909 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1907 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
1910 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); |
1908 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); |
1911 container.append('<input style="float: left; margin-left: 200px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); |
1909 container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingrediënt" />'); |
1912 // add misc from dropdownlist. |
1910 // add misc from dropdownlist. |
1913 $("#maddrowbutton").jqxDropDownList({ |
1911 $("#maddrowbutton").jqxDropDownList({ |
1914 placeHolder: "Kies ingredient:", |
1912 placeHolder: "Kies ingrediënt:", |
1915 theme: theme, |
1913 theme: theme, |
|
1914 template: "primary", |
1916 source: misclist, |
1915 source: misclist, |
1917 displayMember: "name", |
1916 displayMember: "name", |
1918 width: 150, |
1917 width: 150, |
1919 height: 27, |
1918 height: 27, |
1920 dropDownWidth: 500, |
1919 dropDownWidth: 500, |
1929 row["m_amount"] = 0; |
1928 row["m_amount"] = 0; |
1930 row["m_cost"] = datarecord.cost; |
1929 row["m_cost"] = datarecord.cost; |
1931 row["m_type"] = datarecord.type; |
1930 row["m_type"] = datarecord.type; |
1932 row["m_use_use"] = datarecord.use_use; |
1931 row["m_use_use"] = datarecord.use_use; |
1933 row["m_time"] = 0; |
1932 row["m_time"] = 0; |
1934 row["m_weight"] = 0; |
|
1935 row["m_amount_is_weight"] = datarecord.amount_is_weight; |
1933 row["m_amount_is_weight"] = datarecord.amount_is_weight; |
|
1934 row["m_inventory"] = datarecord.inventory; |
1936 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
1935 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
1937 } |
1936 } |
1938 }); |
1937 }); |
1939 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
1938 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
1940 $("#minstockbutton").on('change', function (event) { |
1939 $("#minstockbutton").on('change', function (event) { |
1941 miscinstock = event.args.checked; |
1940 miscinstock = event.args.checked; |
1942 misclist.dataBind(); |
1941 misclist.dataBind(); |
1943 }); |
1942 }); |
1944 // delete selected misc. |
1943 // delete selected misc. |
1945 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
1944 $("#mdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
1946 $("#mdeleterowbutton").on('click', function () { |
1945 $("#mdeleterowbutton").on('click', function () { |
1947 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
1946 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
1948 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
1947 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
1949 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type"); |
1948 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type"); |
1950 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent") { |
1949 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent |
1951 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
1950 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
1952 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
1951 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
1953 } |
1952 } |
1954 }); |
1953 }); |
1955 }, |
1954 }, |
1956 ready: function() { |
1955 ready: function() { |
1957 $('#jqxTabs').jqxTabs('next'); |
1956 $('#jqxTabs').jqxTabs('next'); |
1958 }, |
1957 }, |
1959 columns: [ |
1958 columns: [ |
1960 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
1959 { text: 'Ingredient', datafield: 'm_name' }, |
1961 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
1960 { text: 'Type', width: 140, datafield: 'm_type', |
1962 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist', |
1961 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1963 createeditor: function (row, column, editor) { |
1962 return "<div style='margin: 4px;'>" + MiscTypeData[value].nl + "</div>"; |
1964 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ]; |
|
1965 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); |
|
1966 }, |
|
1967 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1968 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); |
|
1969 if (type == "Water agent") |
|
1970 return oldvalue; |
|
1971 } |
1963 } |
1972 }, |
1964 }, |
1973 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column |
1965 { text: 'Gebruik', width: 140, datafield: 'm_use_use', |
1974 { datafield: 'm_amount', hidden: true }, // We need to declare this column |
1966 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1975 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', |
1967 return "<div style='margin: 4px;'>" + MiscUseData[value].nl + "</div>"; |
1976 columntype: 'numberinput', |
1968 } |
|
1969 }, |
|
1970 { text: 'Tijd', datafield: 'm_time', width: 90, align: 'right', |
|
1971 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1972 if (rowdata.m_use_use == 2) { // Boil |
|
1973 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" min.</div>"; |
|
1974 } else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) { // Primary or Secondary |
|
1975 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value/1440, "f0")+" dagen</div>"; |
|
1976 } else { |
|
1977 var tijd = 0; |
|
1978 return "<div style='margin: 4px;'> </div>"; |
|
1979 } |
|
1980 }, |
|
1981 }, |
|
1982 { text: 'Hoeveel', datafield: 'm_amount', width: 110, align: 'right', |
1977 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1983 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1978 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
1984 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
1979 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>"; |
1985 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr+"</div>"; |
1980 }, |
1986 }, |
1981 validation: function (cell, value) { |
1987 }, |
1982 var high = parseFloat(dataRecord.boil_size) * 1000; |
1988 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1983 if (value < 0 || value > high) { |
1989 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1984 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; |
1990 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
1985 } |
1991 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value * 1000,"f2")+" "+vstr+"</div>"; |
1986 return true; |
|
1987 }, |
|
1988 initeditor: function (row, cellvalue, editor) { |
|
1989 editor.jqxNumberInput({ |
|
1990 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000, |
|
1991 decimalDigits: 2, spinButtons: false |
|
1992 }); |
|
1993 }, |
1992 }, |
1994 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
1993 }, |
1995 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); |
1994 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
1996 if (type == "Water agent") |
1995 return "Wijzig"; |
1997 return oldvalue; |
1996 }, buttonclick: function (row) { |
1998 } |
1997 miscRow = row; |
1999 }, |
1998 miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
2000 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
1999 if (miscData.m_amount_is_weight) |
2001 columntype: 'numberinput', |
2000 $("#wm_pmpt_amount").html("Gewicht gram:"); |
2002 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2001 else |
2003 if (rowdata.m_use_use == 'Boil') { |
2002 $("#wm_pmpt_amount").html("Volume ml:"); |
2004 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>"; |
2003 $("#wm_name").val(miscData.m_name); |
2005 } else if (rowdata.m_use_use == 'Secondary') { |
2004 $("#wm_amount").val(miscData.m_amount * 1000); |
2006 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>"; |
2005 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary |
2007 } else { |
2006 $("#wm_time").val(miscData.m_time / 1440); |
2008 var tijd = 0; |
2007 else |
2009 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
2008 $("#wm_time").val(miscData.m_time); |
|
2009 $("#wm_use_use").val(miscData.m_use_use); |
|
2010 // show the popup window. |
|
2011 if (miscData.m_type != 4) |
|
2012 $("#popupMisc").jqxWindow('open'); |
2010 } |
2013 } |
2011 }, |
2014 } |
2012 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
2013 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
|
2014 }, |
|
2015 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
2016 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use"); |
|
2017 if ((use != "Boil") && (use != "Secondary")) |
|
2018 return oldvalue; |
|
2019 }, |
|
2020 validation: function (cell, value) { |
|
2021 var high = parseFloat(dataRecord.boil_time); |
|
2022 if (value < 0 || value > high ) { |
|
2023 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
|
2024 } |
|
2025 return true; |
|
2026 } |
|
2027 } |
|
2028 ] |
2015 ] |
2029 }); |
2016 }); |
2030 $("#miscGrid").on('cellendedit', function (event) { |
|
2031 var args = event.args; |
|
2032 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
2033 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
2034 if (args.datafield == 'm_weight') { |
|
2035 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000); |
|
2036 } |
|
2037 }); |
|
2038 }; |
2017 }; |
2039 |
2018 |
2040 // Inline yeasts editor |
2019 // Inline yeasts editor |
2041 var editYeast = function (data) { |
2020 var editYeast = function (data) { |
2042 var yeastSource = { |
2021 var yeastSource = { |
2801 $("#wh_pmpt_time").html("Tijd in minuten"); |
2779 $("#wh_pmpt_time").html("Tijd in minuten"); |
2802 } |
2780 } |
2803 }); |
2781 }); |
2804 |
2782 |
2805 // Tab 4, Diversen |
2783 // Tab 4, Diversen |
|
2784 $("#popupMisc").jqxWindow({ |
|
2785 width: 800, |
|
2786 height: 275, |
|
2787 position: { x: 230, y: 100 }, |
|
2788 resizable: false, |
|
2789 theme: theme, |
|
2790 isModal: true, |
|
2791 autoOpen: false, |
|
2792 cancelButton: $("#MiscReady"), |
|
2793 modalOpacity: 0.40 |
|
2794 }); |
|
2795 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
|
2796 $("#MiscReady").click(function () { |
|
2797 $("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc'); |
|
2798 }); |
|
2799 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
2800 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 }); |
|
2801 $("#wm_instock").on('change', function (event) { |
|
2802 miscinstock = event.args.checked; |
|
2803 misclist.dataBind(); |
|
2804 }); |
|
2805 $("#wm_select").jqxDropDownList({ |
|
2806 placeHolder: "Kies ingrediënt:", |
|
2807 theme: theme, |
|
2808 source: misclist, |
|
2809 displayMember: "name", |
|
2810 width: 150, |
|
2811 height: 23, |
|
2812 dropDownWidth: 500, |
|
2813 dropDownHeight: 500 |
|
2814 }); |
|
2815 $("#wm_select").on('select', function (event) { |
|
2816 if (event.args) { |
|
2817 var index = event.args.index; |
|
2818 var datarecord = misclist.records[index]; |
|
2819 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
|
2820 $("#wm_name").val(datarecord.name); |
|
2821 rowdata.m_name = datarecord.name; |
|
2822 rowdata.m_cost = datarecord.cost; |
|
2823 rowdata.m_type = datarecord.type; |
|
2824 rowdata.m_use_use = datarecord.use_use; |
|
2825 rowdata.m_amount_is_weight = datarecord.amount_is_weight; |
|
2826 rowdata.m_inventory = datarecord.inventory; |
|
2827 } |
|
2828 }); |
|
2829 $("#wm_amount").jqxNumberInput( Spin1dec1 ); |
|
2830 $('#wm_amount').on('change', function (event) { |
|
2831 console.log("amount changed: "+event.args.value); |
|
2832 var amount = parseFloat(event.args.value) / 1000; |
|
2833 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
|
2834 rowdata.m_amount = amount; |
|
2835 }); |
|
2836 $("#wm_time").jqxNumberInput( PosInt ); |
|
2837 $("#wm_time").on('change', function (event) { |
|
2838 console.log("time changed: "+event.args.value); |
|
2839 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
|
2840 var newtime = parseFloat(event.args.value); |
|
2841 |
|
2842 if (rowdata.m_use_use == 2) { // Boil |
|
2843 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) { |
|
2844 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
|
2845 $("#wm_time").val(newtime); |
|
2846 } |
|
2847 rowdata.m_time = newtime; |
|
2848 } else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) { // Primary or Secondary |
|
2849 if (newtime > 21) { |
|
2850 newtime = 21; |
|
2851 $("#wm_time").val(newtime); |
|
2852 } |
|
2853 rowdata.m_time = newtime * 1440; |
|
2854 } |
|
2855 }); |
|
2856 $("#wm_use_use").jqxDropDownList({ |
|
2857 theme: theme, |
|
2858 source: MiscUseAdapter, |
|
2859 valueMember: 'id', |
|
2860 displayMember: 'nl', |
|
2861 width: 180, |
|
2862 height: 23, |
|
2863 autoDropDownHeight: true, |
|
2864 dropDownVerticalAlignment: 'top' |
|
2865 }); |
|
2866 $("#wm_use_use").on('select', function (event) { |
|
2867 if (event.args) { |
|
2868 var index = event.args.index; |
|
2869 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow); |
|
2870 rowdata.m_use_use = index; |
|
2871 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary |
|
2872 $("#wm_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); |
|
2873 } else { |
|
2874 rowdata.m_time = 0; |
|
2875 $("#wm_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); |
|
2876 $("#wm_time").val(0); |
|
2877 } |
|
2878 } |
|
2879 }); |
2806 |
2880 |
2807 // Tab 5, Gist |
2881 // Tab 5, Gist |
2808 |
2882 |
2809 // Tab 6, Maischen |
2883 // Tab 6, Maischen |
2810 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
2884 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |