www/js/prod_inprod.js

changeset 467
f8d16480a6a7
parent 339
da1f4525169d
child 525
8bbc5730aaa8
equal deleted inserted replaced
466:dcfb78cd37ab 467:f8d16480a6a7
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 var dataAdapter = new $.jqx.dataAdapter(source); 40 dataAdapter = new $.jqx.dataAdapter(source);
41
41 // initialize jqxGrid 42 // initialize jqxGrid
42 $("#jqxgrid").jqxGrid({ 43 $("#jqxgrid").jqxGrid({
43 width: 1280, 44 width: 1280,
44 height: 630, 45 height: 630,
45 source: dataAdapter, 46 source: dataAdapter,
46 theme: theme, 47 theme: theme,
47 showstatusbar: true, 48 showstatusbar: true,
48 renderstatusbar: function (statusbar) { 49 renderstatusbar: function (statusbar) {
49 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 50 var container, addButton;
50 var 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>"); 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>");
51 container.append(addButton); 53 container.append(addButton);
52 statusbar.append(container); 54 statusbar.append(container);
53 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 55 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
54 // add new recipe. 56 // add new recipe.
55 addButton.click(function (event) { 57 addButton.click(function (event) {
56 var url= "prod_new.php?return=prod_inprod.php"; 58 window.location.href = "prod_new.php?return=prod_inprod.php";
57 window.location.href = url;
58 }); 59 });
59 }, 60 },
60 columns: [ 61 columns: [
61 { text: 'Datum', datafield: 'birth', width: 120 }, 62 { text: 'Datum', datafield: 'birth', width: 120 },
62 { text: 'Code', datafield: 'code', width: 120 }, 63 { text: 'Code', datafield: 'code', width: 120 },
63 { text: 'Naam', datafield: 'name' }, 64 { text: 'Naam', datafield: 'name' },
64 { text: 'Fase', datafield: 'stage', width: 200, 65 { text: 'Fase', datafield: 'stage', width: 200,
65 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 66 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
67 var fase, d, date1, date2, date1_unixtime, date2_unixtime, timeDifference, timeDifferenceInDays;
66 // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste 68 // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste
67 var fase = StageData[value].nl; 69 fase = StageData[value].nl;
68 if (value == 2) { 70 if (value == 2) {
69 fase = StageData[value].nl + " op " + rowdata.brew_date; 71 fase = StageData[value].nl + " op " + rowdata.brew_date;
70 } 72 }
71 if (value == 7 || value == 8) { 73 if (value == 7 || value == 8) {
72 var d = new Date(); 74 d = new Date();
73 var date2 = rowdata.package_date; 75 date2 = rowdata.package_date;
74 date2 = date2.split('-'); 76 date2 = date2.split('-');
75 // Now we convert the array to a Date object 77 // Now we convert the array to a Date object
76 date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); 78 date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate());
77 date2 = new Date(date2[0], date2[1]-1, date2[2]); 79 date2 = new Date(date2[0], date2[1]-1, date2[2]);
78 // We use the getTime() method and get the unixtime 80 // We use the getTime() method and get the unixtime
79 date1_unixtime = parseInt(date1.getTime() / 1000); 81 date1_unixtime = parseInt(date1.getTime() / 1000);
80 date2_unixtime = parseInt(date2.getTime() / 1000); 82 date2_unixtime = parseInt(date2.getTime() / 1000);
81 // This is the calculated difference in seconds 83 // This is the calculated difference in seconds
82 var timeDifference = date1_unixtime - date2_unixtime; 84 timeDifference = date1_unixtime - date2_unixtime;
83 // Round the result for brews that overlap summer/wintertime changes. 85 // Round the result for brews that overlap summer/wintertime changes.
84 var timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24); 86 timeDifferenceInDays = Math.round(timeDifference / 60 / 60 / 24);
85 if (timeDifferenceInDays >= 14) 87 if (timeDifferenceInDays >= 14)
86 fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 28"; 88 fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 28";
87 else 89 else
88 fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14"; 90 fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14";
89 } 91 }
92 }, 94 },
93 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { 95 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () {
94 return "Wijzig"; 96 return "Wijzig";
95 }, buttonclick: function (row) { 97 }, buttonclick: function (row) {
96 var datarecord = dataAdapter.records[row]; 98 var datarecord = dataAdapter.records[row];
97 var url= "prod_edit.php?record=" + datarecord.record + "&select=inprod&return=prod_inprod.php"; 99 window.location.href = "prod_edit.php?record=" + datarecord.record + "&select=inprod&return=prod_inprod.php";
98 window.location.href = url;
99 } 100 }
100 } 101 }
101 ], 102 ],
102 }); 103 });
103 }); 104 });

mercurial