www/js/prod_inprod.js

changeset 525
8bbc5730aaa8
parent 467
f8d16480a6a7
child 816
d76f623d487c
--- a/www/js/prod_inprod.js	Fri Oct 18 20:04:40 2019 +0200
+++ b/www/js/prod_inprod.js	Fri Oct 18 20:49:07 2019 +0200
@@ -21,84 +21,85 @@
  *****************************************************************************/
 
 
-$(document).ready(function () {
-	var source = {
-		datatype: "json",
-		cache: false,
-		datafields: [
-			{ name: 'record', type: 'number' },
-			{ name: 'name', type: 'string' },
-			{ name: 'code', type: 'string' },
-			{ name: 'birth', type: 'string' },
-			{ name: 'stage', type: 'int' },
-			{ name: 'brew_date', type: 'string' },
-			{ name: 'package_date', type: 'string' },
-		],
-		id: 'record',
-		url: "includes/db_product.php?select=inprod"
-	},
-	dataAdapter = new $.jqx.dataAdapter(source);
+$(document).ready(function() {
+ var source = {
+  datatype: 'json',
+  cache: false,
+  datafields: [
+   { name: 'record', type: 'number' },
+   { name: 'name', type: 'string' },
+   { name: 'code', type: 'string' },
+   { name: 'birth', type: 'string' },
+   { name: 'stage', type: 'int' },
+   { name: 'brew_date', type: 'string' },
+   { name: 'package_date', type: 'string' },
+  ],
+  id: 'record',
+  url: 'includes/db_product.php?select=inprod'
+ },
+ dataAdapter = new $.jqx.dataAdapter(source);
 
-	// initialize jqxGrid
-	$("#jqxgrid").jqxGrid({
-		width: 1280,
-		height: 630,
-		source: dataAdapter,
-		theme: theme,
-		showstatusbar: true,
-		renderstatusbar: function (statusbar) {
-			var container, addButton;
-			container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
-			addButton = $("<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;'>Add</span></div>");
-			container.append(addButton);
-			statusbar.append(container);
-			addButton.jqxButton({ theme: theme, width: 90, height: 20 });
-			// add new recipe.
-			addButton.click(function (event) {
-				window.location.href = "prod_new.php?return=prod_inprod.php";
-			});
-		},
-		columns: [
-			{ text: 'Datum', datafield: 'birth', width: 120 },
-			{ text: 'Code', datafield: 'code', width: 120 },
-			{ text: 'Naam', datafield: 'name' },
-			{ text: 'Fase', datafield: 'stage', width: 200,
-			  cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
-				var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays;
-				// 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste
-				fase = StageData[value].nl;
-				if (value == 2) {
-					fase = StageData[value].nl + " op " + rowdata.brew_date;
-				}
-				if (value == 7 || value == 8) {
-					d = new Date();
-					date2 = rowdata.package_date;
-					date2 = date2.split('-');
-					// Now we convert the array to a Date object
-					date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate());
-					date2 = new Date(date2[0], date2[1]-1, date2[2]);
-					// We use the getTime() method and get the unixtime
-					date1_unixtime = parseInt(date1.getTime() / 1000);
-					date2_unixtime = parseInt(date2.getTime() / 1000);
-					// This is the calculated difference in seconds
-					timeDifference = date1_unixtime - date2_unixtime;
-					// Round the result for brews that overlap summer/wintertime changes.
-					timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24);
-					if (timeDifferenceInDays >= 14)
-						fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 28";
-					else
-						fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14";
-				}
-				return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + fase + "</span>";
-			  }
-		       	},
-			{ text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () {
-				return "Wijzig";
-				}, buttonclick: function (row) {
-					var datarecord = dataAdapter.records[row];
-					window.location.href = "prod_edit.php?record=" + datarecord.record + "&select=inprod&return=prod_inprod.php";
-				}
-			}
-		],
-	});
+ // initialize jqxGrid
+ $('#jqxgrid').jqxGrid({
+  width: 1280,
+  height: 630,
+  source: dataAdapter,
+  theme: theme,
+  showstatusbar: true,
+  renderstatusbar: function(statusbar) {
+   var container, addButton;
+   container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
+   addButton = $('<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;">Add</span></div>');
+   container.append(addButton);
+   statusbar.append(container);
+   addButton.jqxButton({ theme: theme, width: 90, height: 20 });
+   // add new recipe.
+   addButton.click(function(event) {
+    window.location.href = 'prod_new.php?return=prod_inprod.php';
+   });
+  },
+  columns: [
+   { text: 'Datum', datafield: 'birth', width: 120 },
+   { text: 'Code', datafield: 'code', width: 120 },
+   { text: 'Naam', datafield: 'name' },
+   { text: 'Fase', datafield: 'stage', width: 200,
+    cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
+     var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays;
+     // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste
+     fase = StageData[value].nl;
+     if (value == 2) {
+      fase = StageData[value].nl + ' op ' + rowdata.brew_date;
+     }
+     if (value == 7 || value == 8) {
+      d = new Date();
+      date2 = rowdata.package_date;
+      date2 = date2.split('-');
+      // Now we convert the array to a Date object
+      date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate());
+      date2 = new Date(date2[0], date2[1] - 1, date2[2]);
+      // We use the getTime() method and get the unixtime
+      date1_unixtime = parseInt(date1.getTime() / 1000);
+      date2_unixtime = parseInt(date2.getTime() / 1000);
+      // This is the calculated difference in seconds
+      timeDifference = date1_unixtime - date2_unixtime;
+      // Round the result for brews that overlap summer/wintertime changes.
+      timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24);
+      if (timeDifferenceInDays >= 14)
+       fase = StageData[value].nl + ' dag ' + (timeDifferenceInDays - 14) + ' van 28';
+      else
+       fase = StageData[value].nl + ' dag ' + timeDifferenceInDays + ' van 14';
+     }
+     return '<span style="margin: 3px; margin-top: 6px; float: left;">' + fase + '</span>';
+    }
+   },
+   { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() {
+    return 'Wijzig';
+    }, buttonclick: function(row) {
+     var datarecord = dataAdapter.records[row];
+     window.location.href = 'prod_edit.php?record=' + datarecord.record + '&select=inprod&return=prod_inprod.php';
+    }
+   }
+  ],
+ });
 });

mercurial