# HG changeset patch # User Michiel Broek # Date 1551814124 -3600 # Node ID 4116e618460921479d082b048f581fdf639caf0f # Parent f71bb110437548ed90f9ed977c77cb31dd83baf9 The products in production list now shows carbonation and mature period. Also the planned brewdate. diff -r f71bb1104375 -r 4116e6184609 www/includes/db_product.php --- a/www/includes/db_product.php Mon Mar 04 20:54:22 2019 +0100 +++ b/www/includes/db_product.php Tue Mar 05 20:28:44 2019 +0100 @@ -421,7 +421,7 @@ * SELECT, produce a list of products that are not yet Closed. */ if (isset($_GET['select']) && ($_GET['select'] == "inprod")) { - $query = "SELECT record,name,code,birth,stage FROM products WHERE stage != '11' ORDER BY birth,code;"; + $query = "SELECT record,name,code,birth,stage,brew_date_start,package_date FROM products WHERE stage != '11' ORDER BY birth,code;"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $brews[] = array( @@ -429,7 +429,9 @@ 'name' => $row['name'], 'code' => $row['code'], 'birth' => $row['birth'], - 'stage' => $row['stage'] + 'stage' => $row['stage'], + 'brew_date' => substr($row['brew_date_start'], 0, 10), + 'package_date' => $row['package_date'] ); } header("Content-type: application/json"); diff -r f71bb1104375 -r 4116e6184609 www/js/prod_inprod.js --- a/www/js/prod_inprod.js Mon Mar 04 20:54:22 2019 +0100 +++ b/www/js/prod_inprod.js Tue Mar 05 20:28:44 2019 +0100 @@ -31,6 +31,8 @@ { 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" @@ -59,9 +61,32 @@ { text: 'Datum', datafield: 'birth', width: 120 }, { text: 'Code', datafield: 'code', width: 120 }, { text: 'Naam', datafield: 'name' }, - { text: 'Fase', datafield: 'stage', width: 130, + { text: 'Fase', datafield: 'stage', width: 200, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { - return "" + StageData[value].nl + ""; + // 2 = brew, 6 = package, 7 = carbonation, 8 = mature, 9 = taste + var fase = StageData[value].nl; + if (value == 2) { + fase = StageData[value].nl + " op " + rowdata.brew_date; + } + if (value >= 6 && value < 9) { + var d = new Date(); + var 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 + var timeDifference = date1_unixtime - date2_unixtime; + var timeDifferenceInDays = timeDifference / 60 / 60 / 24; + if (timeDifferenceInDays >= 14) + fase = StageData[value].nl + " dag " + (timeDifferenceInDays - 14) + " van 42"; + else + fase = StageData[value].nl + " dag " + timeDifferenceInDays + " van 14"; + } + return "" + fase + ""; } }, { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () {