19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
19 * along with ThermFerm; see the file COPYING. If not, write to the Free |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
21 *****************************************************************************/ |
21 *****************************************************************************/ |
22 |
22 |
23 |
23 |
24 $(document).ready(function () { |
24 $(document).ready(function() { |
25 var source = { |
25 var source = { |
26 datatype: "json", |
26 datatype: 'json', |
27 cache: false, |
27 cache: false, |
28 datafields: [ |
28 datafields: [ |
29 { name: 'record', type: 'number' }, |
29 { name: 'record', type: 'number' }, |
30 { name: 'name', type: 'string' }, |
30 { name: 'name', type: 'string' }, |
31 { name: 'code', type: 'string' }, |
31 { name: 'code', type: 'string' }, |
32 { name: 'birth', type: 'string' }, |
32 { name: 'birth', type: 'string' }, |
33 { name: 'stage', type: 'int' }, |
33 { name: 'stage', type: 'int' }, |
34 { name: 'brew_date', type: 'string' }, |
34 { name: 'brew_date', type: 'string' }, |
35 { name: 'package_date', type: 'string' }, |
35 { name: 'package_date', type: 'string' }, |
36 ], |
36 ], |
37 id: 'record', |
37 id: 'record', |
38 url: "includes/db_product.php?select=inprod" |
38 url: 'includes/db_product.php?select=inprod' |
39 }, |
39 }, |
40 dataAdapter = new $.jqx.dataAdapter(source); |
40 dataAdapter = new $.jqx.dataAdapter(source); |
41 |
41 |
42 // initialize jqxGrid |
42 // initialize jqxGrid |
43 $("#jqxgrid").jqxGrid({ |
43 $('#jqxgrid').jqxGrid({ |
44 width: 1280, |
44 width: 1280, |
45 height: 630, |
45 height: 630, |
46 source: dataAdapter, |
46 source: dataAdapter, |
47 theme: theme, |
47 theme: theme, |
48 showstatusbar: true, |
48 showstatusbar: true, |
49 renderstatusbar: function (statusbar) { |
49 renderstatusbar: function(statusbar) { |
50 var container, addButton; |
50 var container, addButton; |
51 container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
51 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); |
52 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>"); |
52 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + |
53 container.append(addButton); |
53 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Add</span></div>'); |
54 statusbar.append(container); |
54 container.append(addButton); |
55 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
55 statusbar.append(container); |
56 // add new recipe. |
56 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
57 addButton.click(function (event) { |
57 // add new recipe. |
58 window.location.href = "prod_new.php?return=prod_inprod.php"; |
58 addButton.click(function(event) { |
59 }); |
59 window.location.href = 'prod_new.php?return=prod_inprod.php'; |
60 }, |
60 }); |
61 columns: [ |
61 }, |
62 { text: 'Datum', datafield: 'birth', width: 120 }, |
62 columns: [ |
63 { text: 'Code', datafield: 'code', width: 120 }, |
63 { text: 'Datum', datafield: 'birth', width: 120 }, |
64 { text: 'Naam', datafield: 'name' }, |
64 { text: 'Code', datafield: 'code', width: 120 }, |
65 { text: 'Fase', datafield: 'stage', width: 200, |
65 { text: 'Naam', datafield: 'name' }, |
66 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
66 { text: 'Fase', datafield: 'stage', width: 200, |
67 var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays; |
67 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
68 // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste |
68 var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays; |
69 fase = StageData[value].nl; |
69 // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste |
70 if (value == 2) { |
70 fase = StageData[value].nl; |
71 fase = StageData[value].nl + " op " + rowdata.brew_date; |
71 if (value == 2) { |
72 } |
72 fase = StageData[value].nl + ' op ' + rowdata.brew_date; |
73 if (value == 7 || value == 8) { |
73 } |
74 d = new Date(); |
74 if (value == 7 || value == 8) { |
75 date2 = rowdata.package_date; |
75 d = new Date(); |
76 date2 = date2.split('-'); |
76 date2 = rowdata.package_date; |
77 // Now we convert the array to a Date object |
77 date2 = date2.split('-'); |
78 date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); |
78 // Now we convert the array to a Date object |
79 date2 = new Date(date2[0], date2[1]-1, date2[2]); |
79 date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); |
80 // We use the getTime() method and get the unixtime |
80 date2 = new Date(date2[0], date2[1] - 1, date2[2]); |
81 date1_unixtime = parseInt(date1.getTime() / 1000); |
81 // We use the getTime() method and get the unixtime |
82 date2_unixtime = parseInt(date2.getTime() / 1000); |
82 date1_unixtime = parseInt(date1.getTime() / 1000); |
83 // This is the calculated difference in seconds |
83 date2_unixtime = parseInt(date2.getTime() / 1000); |
84 timeDifference = date1_unixtime - date2_unixtime; |
84 // This is the calculated difference in seconds |
85 // Round the result for brews that overlap summer/wintertime changes. |
85 timeDifference = date1_unixtime - date2_unixtime; |
86 timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24); |
86 // Round the result for brews that overlap summer/wintertime changes. |
87 if (timeDifferenceInDays >= 14) |
87 timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24); |
88 fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 28"; |
88 if (timeDifferenceInDays >= 14) |
89 else |
89 fase = StageData[value].nl + ' dag ' + (timeDifferenceInDays - 14) + ' van 28'; |
90 fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14"; |
90 else |
91 } |
91 fase = StageData[value].nl + ' dag ' + timeDifferenceInDays + ' van 14'; |
92 return "<span style='margin: 3px; margin-top: 6px; float: left;'>" + fase + "</span>"; |
92 } |
93 } |
93 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + fase + '</span>'; |
94 }, |
94 } |
95 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { |
95 }, |
96 return "Wijzig"; |
96 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() { |
97 }, buttonclick: function (row) { |
97 return 'Wijzig'; |
98 var datarecord = dataAdapter.records[row]; |
98 }, buttonclick: function(row) { |
99 window.location.href = "prod_edit.php?record=" + datarecord.record + "&select=inprod&return=prod_inprod.php"; |
99 var datarecord = dataAdapter.records[row]; |
100 } |
100 window.location.href = 'prod_edit.php?record=' + datarecord.record + '&select=inprod&return=prod_inprod.php'; |
101 } |
101 } |
102 ], |
102 } |
103 }); |
103 ], |
|
104 }); |
104 }); |
105 }); |