www/js/prod_edit.js

changeset 273
19606adfea42
parent 271
af0270694d1e
child 278
dc22dd5d77fd
--- a/www/js/prod_edit.js	Mon Feb 11 22:56:58 2019 +0100
+++ b/www/js/prod_edit.js	Wed Feb 13 20:28:54 2019 +0100
@@ -1385,6 +1385,37 @@
 			$('#jqxTabs').jqxTabs('disableAt', 9);	// Fermentation tab
 		} else {
 			$('#jqxTabs').jqxTabs('enableAt', 9);
+			$("#batch_size").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#boil_size").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#boil_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#efficiency").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#est_og").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#type").jqxDropDownList({ disabled: true });
+			$("#styleSelect").jqxDropDownList({ disabled: true });
+			$("#color_method").jqxDropDownList({ disabled: true });
+			$("#ibu_method").jqxDropDownList({ disabled: true });
+			$("#mash_select").jqxDropDownList({ disabled: true });
+			$("#w1_name").jqxDropDownList({ disabled: true });
+			$("#w2_name").jqxDropDownList({ disabled: true });
+			$("#w2_amount").jqxNumberInput({ readOnly: true });
+			$("#pr_name").jqxDropDownList({ disabled: true });
+			$("#wa_cacl2").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#wa_caso4").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#wa_mgso4").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#wa_nacl").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#mash_ph").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#calc_acid").jqxCheckBox({ disabled: true });
+			$("#wa_base_name").jqxDropDownList({ disabled: true });
+			$("#wa_base").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#wa_acid_name").jqxDropDownList({ disabled: true });
+			$("#wa_acid").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#wa_acid_perc").jqxNumberInput({ spinButtons: false, readOnly: true, width: 70 });
+			$("#sparge_temp").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#sparge_volume").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#sparge_ph").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
+			$("#sparge_source").jqxDropDownList({ disabled: true });
+			$("#sparge_acid_type").jqxDropDownList({ disabled: true });
+			$("#sparge_acid_perc").jqxNumberInput({ spinButtons: false, readOnly: true, width: false });
 		}
 		if (dataRecord.stage < 5) { // At least secondary
 			$('#jqxTabs').jqxTabs('disableAt', 10);	// Packaging tab
@@ -2392,6 +2423,7 @@
 					template: "primary",
                                         source: fermentablelist,
                                         displayMember: "name",
+					disabled: (dataRecord.stage > 3),
                                         width: 150,
                                         height: 27,
                                         dropDownWidth: 500,
@@ -2446,14 +2478,14 @@
                                         }
                                 });
 
-                                $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 });
+                                $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
                                 $("#finstockbutton").on('change', function (event) {
                                         fermentableinstock = event.args.checked;
                                         fermentablelist.dataBind();
                                 });
 
                                 // delete selected fermentable.
-                                $("#fdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
+                                $("#fdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#fdeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
@@ -2522,15 +2554,17 @@
 				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
 					return "Wijzig";
 					}, buttonclick: function (row) {
-						fermentableRow = row;
-						fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
-						$("#wf_name").val(fermentableData.f_name);
-						$("#wf_amount").val(fermentableData.f_amount);
-						$("#wf_percentage").val(fermentableData.f_percentage);
-						$("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100);
-						$("#wf_added").val(fermentableData.f_added);
-						// show the popup window.
-						$("#popupFermentable").jqxWindow('open');
+						if (dataRecord.stage <= 3) {
+							fermentableRow = row;
+							fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
+							$("#wf_name").val(fermentableData.f_name);
+							$("#wf_amount").val(fermentableData.f_amount);
+							$("#wf_percentage").val(fermentableData.f_percentage);
+							$("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100);
+							$("#wf_added").val(fermentableData.f_added);
+							// show the popup window.
+							$("#popupFermentable").jqxWindow('open');
+						}
 					}
 				}
                         ]
@@ -2594,6 +2628,7 @@
                                         theme: theme,
 					template: "primary",
                                         source: hoplist,
+					disabled: (dataRecord.stage > 3),
                                         displayMember: "name",
                                         width: 150,
                                         height: 27,
@@ -2631,14 +2666,14 @@
 					$("#haddrowbutton").jqxDropDownList('clearSelection');
                                 });
 
-                                $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
+                                $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
                                 $("#hinstockbutton").on('change', function (event) {
                                         hopinstock = event.args.checked;
                                         hoplist.dataBind();
                                 });
 
                                 // delete selected hop.
-                                $("#hdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
+                                $("#hdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#hdeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount;
@@ -2720,23 +2755,25 @@
 				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
 					return "Wijzig";
 					}, buttonclick: function (row) {
-						hopRow = row;
-						hopData = $("#hopGrid").jqxGrid('getrowdata', hopRow);
-						$("#wh_name").val(hopData.h_name);
-						$("#wh_amount").val(hopData.h_amount * 1000);
-						var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg,
-							parseFloat($("#batch_size").jqxNumberInput('decimal')),
-							parseFloat(hopData.h_amount), parseFloat(hopData.h_time),
-							parseFloat(hopData.h_alpha), $("#ibu_method").val()
-						);
-						$("#wh_ibu").val(ibu);
-						if (hopData.h_useat == 5)       // Dry hop
-							$("#wh_time").val(hopData.h_time / 1440);
-						else
-							$("#wh_time").val(hopData.h_time);
-						$("#wh_useat").val(hopData.h_useat);
-						// show the popup window.
-						$("#popupHop").jqxWindow('open');
+						if (dataRecord.stage <= 3) {
+							hopRow = row;
+							hopData = $("#hopGrid").jqxGrid('getrowdata', hopRow);
+							$("#wh_name").val(hopData.h_name);
+							$("#wh_amount").val(hopData.h_amount * 1000);
+							var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg,
+								parseFloat($("#batch_size").jqxNumberInput('decimal')),
+								parseFloat(hopData.h_amount), parseFloat(hopData.h_time),
+								parseFloat(hopData.h_alpha), $("#ibu_method").val()
+							);
+							$("#wh_ibu").val(ibu);
+							if (hopData.h_useat == 5)       // Dry hop
+								$("#wh_time").val(hopData.h_time / 1440);
+							else
+								$("#wh_time").val(hopData.h_time);
+							$("#wh_useat").val(hopData.h_useat);
+							// show the popup window.
+							$("#popupHop").jqxWindow('open');
+						}
 					}
 				}
                         ]
@@ -2850,6 +2887,7 @@
                                         theme: theme,
 					template: "primary",
                                         source: misclist,
+					disabled: (dataRecord.stage > 3),
                                         displayMember: "name",
                                         width: 150,
                                         height: 27,
@@ -2872,13 +2910,13 @@
                                                 var commit = $("#miscGrid").jqxGrid('addrow', null, row);
                                         }
                                 });
-                                $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 });
+                                $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
                                 $("#minstockbutton").on('change', function (event) {
                                         miscinstock = event.args.checked;
                                         misclist.dataBind();
                                 });
                                 // delete selected misc.
-                                $("#mdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
+                                $("#mdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#mdeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
@@ -2931,22 +2969,24 @@
 				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
 					return "Wijzig";
 					}, buttonclick: function (row) {
-						miscRow = row;
-						miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow);
-						if (miscData.m_amount_is_weight)
-							$("#wm_pmpt_amount").html("Gewicht gram:");
-						else
-							$("#wm_pmpt_amount").html("Volume ml:");
-						$("#wm_name").val(miscData.m_name);
-						$("#wm_amount").val(miscData.m_amount * 1000);
-						if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4))     // Primary or Secondary
-							$("#wm_time").val(miscData.m_time / 1440);
-						else
-							$("#wm_time").val(miscData.m_time);
-						$("#wm_use_use").val(miscData.m_use_use);
-						// show the popup window.
-						if (miscData.m_type != 4)
-							$("#popupMisc").jqxWindow('open');
+						if (dataRecord.stage <= 3) {
+							miscRow = row;
+							miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow);
+							if (miscData.m_amount_is_weight)
+								$("#wm_pmpt_amount").html("Gewicht gram:");
+							else
+								$("#wm_pmpt_amount").html("Volume ml:");
+							$("#wm_name").val(miscData.m_name);
+							$("#wm_amount").val(miscData.m_amount * 1000);
+							if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4))     // Primary or Secondary
+								$("#wm_time").val(miscData.m_time / 1440);
+							else
+								$("#wm_time").val(miscData.m_time);
+							$("#wm_use_use").val(miscData.m_use_use);
+							// show the popup window.
+							if (miscData.m_type != 4)
+								$("#popupMisc").jqxWindow('open');
+						}
 					}
 				}
                         ]
@@ -3006,6 +3046,7 @@
                                         placeHolder: "Kies gist:",
                                         theme: theme,
                                         source: yeastlist,
+					disabled: (dataRecord.stage > 3),
 					template: "primary",
                                         displayMember: "name",
                                         width: 150,
@@ -3040,13 +3081,13 @@
                                         }
 					$("#yaddrowbutton").jqxDropDownList('clearSelection');
                                 });
-                                $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 });
+                                $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
                                 $("#yinstockbutton").on('change', function (event) {
                                         yeastinstock = event.args.checked;
                                         yeastlist.dataBind();
                                 });
                                 // delete selected yeast.
-                                $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
+                                $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#ydeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount;
@@ -3102,27 +3143,29 @@
 				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
 					return "Wijzig";
 					}, buttonclick: function (row) {
-						yeastRow = row;
-						yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
-						if (yeastData.y_form == 0) {
-							$("#wy_pmpt_amount").html("Pak(ken):");
-							$("#wy_amount").val(yeastData.y_amount);
-							$("#wy_amount").jqxNumberInput({ decimalDigits: 0 });
-						} else if (yeastData.y_form == 1) {
-							$("#wy_pmpt_amount").html("Gewicht gram:");
-							$("#wy_amount").val(yeastData.y_amount * 1000);
-							$("#wy_amount").jqxNumberInput({ decimalDigits: 1 });
-						} else {
-							$("#wy_pmpt_amount").html("Volume ml:");
-							$("#wy_amount").val(yeastData.y_amount * 1000);
-							$("#wy_amount").jqxNumberInput({ decimalDigits: 0 });
+						if (dataRecord.stage <= 3) {
+							yeastRow = row;
+							yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
+							if (yeastData.y_form == 0) {
+								$("#wy_pmpt_amount").html("Pak(ken):");
+								$("#wy_amount").val(yeastData.y_amount);
+								$("#wy_amount").jqxNumberInput({ decimalDigits: 0 });
+							} else if (yeastData.y_form == 1) {
+								$("#wy_pmpt_amount").html("Gewicht gram:");
+								$("#wy_amount").val(yeastData.y_amount * 1000);
+								$("#wy_amount").jqxNumberInput({ decimalDigits: 1 });
+							} else {
+								$("#wy_pmpt_amount").html("Volume ml:");
+								$("#wy_amount").val(yeastData.y_amount * 1000);
+								$("#wy_amount").jqxNumberInput({ decimalDigits: 0 });
+							}
+							$("#wy_name").val(yeastData.y_name);
+							$("#wy_laboratory").val(yeastData.y_laboratory);
+							$("#wy_product_id").val(yeastData.y_product_id);
+							$("#wy_use").val(yeastData.y_use);
+							// show the popup window.
+							$("#popupYeast").jqxWindow('open');
 						}
-						$("#wy_name").val(yeastData.y_name);
-						$("#wy_laboratory").val(yeastData.y_laboratory);
-						$("#wy_product_id").val(yeastData.y_product_id);
-						$("#wy_use").val(yeastData.y_use);
-						// show the popup window.
-						$("#popupYeast").jqxWindow('open');
 					}
 				}
                         ]
@@ -3188,13 +3231,13 @@
                                 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").jqxButton({ template: "primary", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#saddrowbutton").on('click', function () {
                                         var datarow = generaterow();
                                         var commit = $("#mashGrid").jqxGrid('addrow', null, datarow);
                                 });
                                 // delete selected step.
-                                $("#sdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
+                                $("#sdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
                                 $("#sdeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount;
@@ -3224,24 +3267,26 @@
 				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
 					return "Wijzig";
 					}, buttonclick: function (row) {
-						mashRow = row;
-						mashData = $("#mashGrid").jqxGrid('getrowdata', mashRow);
-						$("#wstep_name").val(mashData.step_name);
-						$("#wstep_type").val(mashData.step_type);
-						$("#wstep_infuse_amount").val(mashData.step_infuse_amount);
-						$("#wstep_temp").val(mashData.step_temp);
-						$("#wend_temp").val(mashData.end_temp);
-						$("#wstep_time").val(mashData.step_time);
-						$("#wramp_time").val(mashData.ramp_time);
-						if (mashData.step_type == 0) {
-							$("#wstep_infuse_amount").show();
-							$("#wstep_pmpt").show();
-						} else {
-							$("#wstep_infuse_amount").hide();
-							$("#wstep_pmpt").hide();
+						if (dataRecord.stage <= 3) {
+							mashRow = row;
+							mashData = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+							$("#wstep_name").val(mashData.step_name);
+							$("#wstep_type").val(mashData.step_type);
+							$("#wstep_infuse_amount").val(mashData.step_infuse_amount);
+							$("#wstep_temp").val(mashData.step_temp);
+							$("#wend_temp").val(mashData.end_temp);
+							$("#wstep_time").val(mashData.step_time);
+							$("#wramp_time").val(mashData.ramp_time);
+							if (mashData.step_type == 0) {
+								$("#wstep_infuse_amount").show();
+								$("#wstep_pmpt").show();
+							} else {
+								$("#wstep_infuse_amount").hide();
+								$("#wstep_pmpt").hide();
+							}
+							// show the popup window.
+							$("#popupMash").jqxWindow('open');
 						}
-						// show the popup window.
-						$("#popupMash").jqxWindow('open');
 					}
 				}
                         ]
@@ -3260,11 +3305,26 @@
 	$("#stage").jqxInput({ theme: theme, width: 100, height: 23 });
 	$("#inventory_reduced").jqxCheckBox({ theme: theme, width: 120, height: 23 });
 	$('#inventory_reduced').on('checked', function (event) {
-		// Call a script to do the work and block this.
-		// Note that this script must set this flag too, so if the user doesn't Save it is still set.
-		// Call the script with the uuid.
-		// set dataRecord.inventory_reduced to 1
-		$("#inventory_reduced").jqxCheckBox({ disabled : true });
+		if (dataRecord.inventory_reduced == 0) {
+			saveRecord();
+			var data = "reduce=1&uuid="+dataRecord.uuid+"&record="+my_record;
+			var url = "prod_reduce.php";
+			$.ajax({
+				dataType: 'json',
+				url: url,
+				cache: false,
+				data: data,
+				type: "POST",
+				success: function (data, status, xhr) {
+					console.log("success");
+					window.location.href = my_return;
+				},
+				error: function(jqXHR, textStatus, errorThrown) {
+					console.log("error");
+					window.location.href = my_return;
+				}
+			});
+		}
 	});
 	$("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true });
 	$('#locked').on('checked', function (event) {

mercurial