diff --git a/ui/app/i18n/reports/locale_en.json b/ui/app/i18n/reports/locale_en.json index 2d123cfb6c..3c1dd130c6 100644 --- a/ui/app/i18n/reports/locale_en.json +++ b/ui/app/i18n/reports/locale_en.json @@ -44,5 +44,6 @@ "CHOOSE_ANSWER_FROM_DROPDOWN_LABEL": "Choose Answer", "DELETE_LABEL": "Delete", "EDIT_LABEL": "Edit", - "REPORT_DATE_RANGE": "Select Date Range" + "REPORT_DATE_RANGE": "Select Date Range", + "START_DATE_CANNOT_LATER_THAN_STOP_DATE": "start date can not be later than stop date" } \ No newline at end of file diff --git a/ui/app/reports/controllers/reportsController.js b/ui/app/reports/controllers/reportsController.js index e862fe9454..81f2882bd2 100644 --- a/ui/app/reports/controllers/reportsController.js +++ b/ui/app/reports/controllers/reportsController.js @@ -1,9 +1,12 @@ 'use strict'; angular.module('bahmni.reports') - .controller('ReportsController', ['$scope', 'appService', 'reportService', 'FileUploader', 'messagingService', 'spinner', '$rootScope', 'auditLogService', function ($scope, appService, reportService, FileUploader, messagingService, spinner, $rootScope, auditLogService) { + .controller('ReportsController', ['$scope', 'appService', 'reportService', 'FileUploader', 'messagingService', 'spinner', '$rootScope', '$translate', 'auditLogService', function ($scope, appService, reportService, FileUploader, messagingService, spinner, $rootScope, $translate, auditLogService) { const format = _.values(reportService.getAvailableFormats()); const dateRange = _.values(reportService.getAvailableDateRange()); + var getTranslatedMessage = function (key) { + return $translate.instant(key); + }; $scope.uploader = new FileUploader({ url: Bahmni.Common.Constants.uploadReportTemplateUrl, @@ -38,6 +41,7 @@ angular.module('bahmni.reports') report['stopDate'] = dateRange[0]; } else if ($rootScope.default[header][item] === undefined) { + $rootScope.default.reportsRequiringDateRange.startDate = dateRange[0]; $rootScope.reportsRequiringDateRange.forEach(function (report) { report.startDate = dateRange[0]; report.stopDate = dateRange[0]; @@ -76,6 +80,9 @@ angular.module('bahmni.reports') if (!report.stopDate) { msg.push("end date"); } + if ((report.startDate > report.stopDate)) { + msg.push(getTranslatedMessage("START_DATE_CANNOT_LATER_THAN_STOP_DATE")); + } messagingService.showMessage("error", "Please select the " + msg.join(" and ")); return false; } diff --git a/ui/app/reports/views/reports.html b/ui/app/reports/views/reports.html index ccb5cb9828..767460b8c2 100644 --- a/ui/app/reports/views/reports.html +++ b/ui/app/reports/views/reports.html @@ -25,7 +25,7 @@

{{::'REPORTS_TITLE_KEY' | translate}}

{{::'REPORTS_END_DATE_HEADER_KEY' |translate}} * @@ -45,12 +45,10 @@

{{::'REPORTS_TITLE_KEY' | translate}}

{{:: report.name |translate }} - + - +