diff --git a/freppledb/input/static/operationplandetail/operationplandetail.html b/freppledb/input/static/operationplandetail/operationplandetail.html index f63c63a3b..29fdf4d15 100644 --- a/freppledb/input/static/operationplandetail/operationplandetail.html +++ b/freppledb/input/static/operationplandetail/operationplandetail.html @@ -6,6 +6,9 @@
+
+
+
diff --git a/freppledb/input/static/operationplandetail/src/inventorygraphDrv.js b/freppledb/input/static/operationplandetail/src/inventorygraphDrv.js new file mode 100644 index 000000000..66379ea2e --- /dev/null +++ b/freppledb/input/static/operationplandetail/src/inventorygraphDrv.js @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 by frePPLe bv + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE + * + */ + +'use strict'; + +angular.module('operationplandetailapp').directive('showinventorygraphDrv', showinventorygraphDrv); + +showinventorygraphDrv.$inject = ['$window', '$filter', 'gettextCatalog']; + +function showinventorygraphDrv($window, $filter, gettextCatalog) { + + var directive = { + restrict: 'EA', + scope: { operationplan: '=data' }, + link: linkfunc + }; + return directive; + + function linkfunc(scope, elem, attrs) { + var template = '
' + + gettextCatalog.getString("inventory") + '
' + + '
'; + + scope.$watchGroup(['operationplan.id', 'operationplan.inventoryreport.length'], function (newValue, oldValue) { + // console.log(46, scope.operationplan); + angular.element(document).find('#attributes-inventorygraph').empty().append(template); + var rows = ['' + gettextCatalog.getString('no inventory information') + '']; + var columnHeaders = ['']; + + if (typeof scope.operationplan !== 'undefined') { + if (scope.operationplan.hasOwnProperty('inventoryreport')) { + columnHeaders = ['' ]; + rows = [ + // '' + gettextCatalog.getString("bucket") + '', + '' + gettextCatalog.getString("start on-hand") + '', + '' + gettextCatalog.getString("safety stock") + '', + '' + gettextCatalog.getString("total consumed") + '', + '' + gettextCatalog.getString("consumed proposed") + '', + '' + gettextCatalog.getString("consumed confirmed") + '', + '' + gettextCatalog.getString("total produced") + '', + '' + gettextCatalog.getString("produced proposed") + '', + '' + gettextCatalog.getString("produced confirmed") + '', + '' + gettextCatalog.getString("end on-hand") + '', + ]; + angular.forEach(scope.operationplan.inventoryreport, function (inventoryData) { + // console.log(68, inventoryData); + columnHeaders.push('' + + '' + inventoryData[0] + '' + ); + + for (const i in inventoryData.slice(4)) { + // console.log(72, rows[i], inventoryData.slice(4)[i]); + rows[i] += '' + $filter('number')(inventoryData.slice(4)[i]) + ''; + } + }); + columnHeaders.push(''); + rows = rows.map(x => x + ''); + } + } + + angular.element(document).find('#attributes-inventorygraph thead').append(columnHeaders.join("")); + angular.element(document).find('#attributes-inventorygraph tbody').append(rows.join("")); + window.tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); + window.tooltipList = [...window.tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)); + }); //watch end + + } //link end +} //directive end diff --git a/freppledb/input/templates/input/operationplanreport.html b/freppledb/input/templates/input/operationplanreport.html index 0d7528d0f..34fd1e731 100644 --- a/freppledb/input/templates/input/operationplanreport.html +++ b/freppledb/input/templates/input/operationplanreport.html @@ -62,6 +62,7 @@ + {% else %}