diff --git a/cor_custom/report/project_hours_report_view.xml b/cor_custom/report/project_hours_report_view.xml index 1e35e2e..cc6cc0c 100755 --- a/cor_custom/report/project_hours_report_view.xml +++ b/cor_custom/report/project_hours_report_view.xml @@ -75,6 +75,7 @@ 'search_default_project': 1, 'search_default_consultant': 1, 'search_default_group_by_hours_type': 1, + 'default_res_model': 'project.consultant.hrs.report' } diff --git a/cor_custom/views/project_view.xml b/cor_custom/views/project_view.xml index 0d48f0a..8a27226 100755 --- a/cor_custom/views/project_view.xml +++ b/cor_custom/views/project_view.xml @@ -208,6 +208,10 @@ project.task + + 1 + + diff --git a/project_report/report/project_budget_amt_analysis_views.xml b/project_report/report/project_budget_amt_analysis_views.xml index 7c6c197..61f6338 100755 --- a/project_report/report/project_budget_amt_analysis_views.xml +++ b/project_report/report/project_budget_amt_analysis_views.xml @@ -79,7 +79,7 @@ project.budget.amt.report graph,tree,pivot - {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1} + {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report'} =1)) { + //var res = dataset[referenceColor].filter(item => item != 'red'); + var res = r.filter(item => item != 'red'); + if (res.length>=1) { + r = res[0] + } + /* else{ + dataset[referenceColor] = dataset[referenceColor][0] + } */ + } return { text: self._shortenLabel(dataset.label), fullText: dataset.label, - fillStyle: dataset[referenceColor], + fillStyle: r, hidden: !chart.isDatasetVisible(i), lineCap: dataset.borderCapStyle, lineDash: dataset.borderDash, lineDashOffset: dataset.borderDashOffset, lineJoin: dataset.borderJoinStyle, lineWidth: dataset.borderWidth, - strokeStyle: dataset[referenceColor], + strokeStyle: r, pointStyle: dataset.pointStyle, datasetIndex: i, }; @@ -521,16 +541,110 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); // prepare data var data = this._prepareData(dataPoints); + // this.title = 'Time Line'; + + if (self.resModel == 'project.budget.hrs.report') { + var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', '')); + _.map(groupedData, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + //var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); + /*var maxB = zipped_2.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return self._getColor(1); + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return 'red'; + } + else { + return self._getColor(1); + } + }); + y[1].backgroundColor = maxB;*/ + } + }); + } + if (self.resModel == 'project.budget.amt.report') { + var groupedData2 = _.groupBy(data.datasets, x => x.label.replace('Actual Cost', '').replace('Budgeted Revenue', '')); + _.map(groupedData2, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + } + }); + } + if (self.resModel == 'project.consultant.hrs.report') { + var groupedData3 = _.groupBy(data.datasets, x => x.label.replace('Actual Hours for period', '').replace('Budgeted Hours for period', '')); + _.map(groupedData3, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + } + }); + } data.datasets.forEach(function (dataset, index) { // used when stacked dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined; // set dataset color - var color = self._getColor(index); - dataset.backgroundColor = color; + if (self.resModel == 'project.budget.hrs.report') { + if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else if (self.resModel == 'project.budget.amt.report') { + if (dataset.label.indexOf("Actual Cost") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Revenue") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else if (self.resModel == 'project.consultant.hrs.report') { + if (dataset.label.indexOf("Actual Hours for period") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours for period") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else { + var color = self._getColor(index); + dataset.backgroundColor = color; + } }); // prepare options - var options = this._prepareOptions(data.datasets.length); + var options = this._prepareOptions(data.datasets.length); // create chart var ctx = document.getElementById(this.chartId); this.chart = new Chart(ctx, { @@ -562,12 +676,97 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); // prepare data var data = this._prepareData(dataPoints); + if (self.resModel == 'project.budget.hrs.report') { + var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', '')); + _.map(groupedData, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); + } + }); + } + + if (self.resModel == 'project.budget.amt.report') { + var groupedData2 = _.groupBy(data.datasets, x => x.label.replace('Actual Cost', '').replace('Budgeted Revenue', '')); + _.map(groupedData2, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + //var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); + } + }); + } + + if (self.resModel == 'project.consultant.hrs.report') { + var groupedData3 = _.groupBy(data.datasets, x => x.label.replace('Actual Hours for period', '').replace('Budgeted Hours for period', '')); + _.map(groupedData3, (y) => { + if (y.length > 1) { + var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); + var maxA = zipped_1.map((a) => { + if ((!!a[0] && !!a[1]) && a[0] > a[1]) { + return 'red'; + } else if ((!!a[0] && !!a[1]) && a[0] < a[1]) { + return self._getColor(0); + } + else { + return self._getColor(0); + } + }); + y[0].backgroundColor = maxA; + y[1].backgroundColor = self._getColor(1); + } + }); + } + data.datasets.forEach(function (dataset, index) { // used when stacked dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined; // set dataset color + if (self.resModel == 'project.budget.hrs.report') { + if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else if (self.resModel == 'project.budget.amt.report') { + if (dataset.label.indexOf("Actual Cost") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Revenue") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else if (self.resModel == 'project.consultant.hrs.report') { + if (dataset.label.indexOf("Actual Hours for period") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours for period") === -1) { + var color = self._getColor(index); + dataset.backgroundColor = color; + } + } + else { var color = self._getColor(index); dataset.backgroundColor = color; + } }); // prepare options