dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32406
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16544: tracker capture - reports WIP
------------------------------------------------------------
revno: 16544
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-08-27 17:40:36 +0200
message:
tracker capture - reports WIP
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-details.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html 2014-08-27 15:40:36 +0000
@@ -20,4 +20,53 @@
<div id="mainPage" class="bordered-div">
<h2>{{'overdue_events' | translate}}</h2>
+ <form name="outerForm" novalidate>
+ <div class="row">
+ <div class="col-sm-12 col-md-8">
+ <table class="table table-borderless table-striped">
+ <tr>
+ <td class='col-sm-6 col-md-4 vertical-center'>
+ {{'program' | translate}}
+ </td>
+ <td class='col-sm-6 col-md-4'>
+ <select ng-model="selectedProgram"
+ class="form-control"
+ ng-options="program as program.name for program in programs | orderBy: 'name'"
+ ng-disabled="programs.length < 1">
+ <option value="">{{programs.length > 0 ? 'please_select_a_program' : 'no_program_exists' | translate}}</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td class='col-sm-6 col-md-4 vertical-center'>{{'org_unit'| translate}}</td>
+ <td class='col-sm-6 col-md-4'>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="accessible" value="ACCESSIBLE"> {{'ACCESSIBLE'| translate}}</label>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-8 col-md-6">
+ <table class="table-borderless">
+ <tr>
+ <td>
+ <input type="text" name="reportStartDate" placeholder="{{'start_date'| translate}} (yyyy-mm-dd)" class="form-control" ng-date ng-model="report.startDate" max="today" ng-required="true"/>
+ <span ng-show="outerForm.submitted && outerForm.reportStartDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} (yyyy-mm-dd)</span>
+ </td>
+ <td>
+ <input type="text" name="reportEndDate" placeholder="{{'end_date'| translate}} (yyyy-mm-dd)" class="form-control" ng-date ng-model="report.endDate" max="today" ng-required="true"/>
+ <span ng-show="outerForm.submitted && outerForm.reportEndDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} (yyyy-mm-dd)</span>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="col-md-6 trim">
+ <button type="button" class="btn btn-primary" ng-click="generateReport()" ng-disabled="!selectedProgram">{{'go'| translate}}</button>
+ </div>
+ </div>
+ </form>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-details.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-details.html 2014-08-18 10:01:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-details.html 2014-08-27 15:40:36 +0000
@@ -1,103 +1,42 @@
-<div class="modal-header">
- <h1>{{selectedProgram.name}} {{'report'| translate}}</h1>
- <span class="pull-right">
- {{'date'| translate}}: {{today}}
- </span>
-</div>
-<div class="modal-body">
- <div class='row'>
- <div class="col-sm-6">
- <h2>{{selectedProgram.trackedEntity.name}} {{'_details'| translate}}</h2>
- <table class="table table-bordered table-compact">
- <tr ng-repeat="attribute in tei.attributes" ng-show="attribute.show">
- <td class="bold">
- {{attribute.displayName}}
- </td>
- <td>
- {{attribute.value}}<!--<input type="text" class="form-control" ng-model="attribute.value" ng-disabled='true'/> -->
- </td>
- </tr>
- </table>
- </div>
+<div id='printSection'>
+ <div class="modal-header">
+ <h1>{{selectedProgram.name}} {{'report'| translate}}</h1>
+ <span class="pull-right bold">
+ {{'date'| translate}}: {{today}}
+ </span>
</div>
- <div class="row" ng-repeat="enrollment in enrollments">
- <h2 class='col-sm-12'>{{'enrollment'| translate}} {{'_details'| translate}}</h2>
- <div class="col-sm-4">
- <span class="bold">{{selectedProgram.dateOfEnrollmentDescription}}:</span> {{enrollment.dateOfEnrollment}}
- </div>
- <div class="col-sm-4">
- <span class="bold">{{selectedProgram.dateOfIncidentDescription}}:</span> {{enrollment.dateOfIncident}}
- </div>
- <div class="col-sm-4">
- <span class="bold">{{'status'| translate}}:</span> {{enrollment.status}}
- </div>
- <div class='row vertical-spacing'></div>
- <div ng-if="enrollment.notes">
- <h3 class='col-sm-12'>{{'notes'| translate}}</h3>
- <table class="table-borderless table-striped">
- <tr class="col-sm-12" ng-repeat="note in enrollment.notes">
- <td class="col-sm-12">
- <p>
- {{note.value}}<br>
- ({{note.storedBy}}, {{note.storedDate}})
- </p>
- </td>
- </tr>
- </table>
- </div>
-
- <h2 class='col-sm-12'>{{'visits'| translate}}</h2>
- <div class='vertical-spacing' ng-repeat="dhis2Event in selectedReport.enrollments[enrollment.enrollment] | orderBy:'sortingDate':reverse">
- <!--<h3 class='col-sm-12'>{{'visits'| translate}}</h3>-->
- <div class="col-sm-2">
- <span class="bold">{{'name'| translate}}:</span> {{dhis2Event.name}}
- </div>
- <div class="col-sm-2">
- <span class="bold">{{'org_unit'| translate}}:</span> {{dhis2Event.orgUnitName}}
- </div>
- <div class="col-sm-2">
- <span class="bold">{{'due_date'| translate}}:</span> {{dhis2Event.dueDate}}
- </div>
- <div class="col-sm-2">
- <span class="bold">{{'visit'| translate}} {{'_date'| translate}}:</span> {{dhis2Event.eventDate ? dhis2Event.eventDate:'no_visit_made' | translate}}
- </div>
- <div class="col-sm-2">
- <span class="bold">{{'status'| translate}}:</span> {{dhis2Event.status}}
- </div>
- <div class='row vertical-spacing'></div>
- <div class='col-sm-6'>
- <table class="table table-bordered table-compact" ng-if="dhis2Event.visited && dhis2Event.dataValues">
- <tr class="col-sm-12">
- <th class="col-md-5">
- {{'data_element'| translate}}
- </th>
- <th class="col-sm-5">
- {{'value'| translate}}
- </th>
- <th class="col-sm-2" ng-if="allowProvidedElsewhereExists[dhis2Event.programStage]">
- {{'provided_elsewhere'| translate}}
- </th>
- </tr>
- <tr class="col-sm-12" ng-repeat="prStDe in programStages[dhis2Event.programStage].programStageDataElements">
- <td>
- {{prStDe.dataElement.formName ? prStDe.dataElement.formName : prStDe.dataElement.name}}
- </td>
- <td>
- {{dhis2Event[prStDe.dataElement.id].value}}
- </td>
- <td ng-if="allowProvidedElsewhereExists[dhis2Event.programStage]">
- {{dhis2Event[prStDe.dataElement.id].providedElsewhere ? 'provided_elsewhere' : ''| translate}}
- </td>
+ <div class="modal-body">
+ <div class='row'>
+ <div class="col-sm-6">
+ <h2>{{selectedProgram.trackedEntity.name}} {{'_details'| translate}}</h2>
+ <table class="table table-bordered table-compact">
+ <tr ng-repeat="attribute in selectedTei.attributes" ng-show="attribute.show">
+ <td class="bold">
+ {{attribute.displayName}}
+ </td>
+ <td>
+ {{attribute.value}}<!--<input type="text" class="form-control" ng-model="attribute.value" ng-disabled='true'/> -->
+ </td>
</tr>
</table>
</div>
- <div class="alert alert-warning visit-details col-sm-6" ng-if="!dhis2Event.visited">{{'visit_not_made'| translate}}</div>
- <div class="alert alert-warning visit-details col-sm-6" ng-if="!dhis2Event.dataValues && dhis2Event.visited">{{'no_data'| translate}}</div>
+ </div>
+ <div class="row" ng-repeat="enrollment in enrollments">
+ <h2 class='col-sm-12'>{{'enrollment'| translate}} {{'_details'| translate}}</h2>
+ <div class="col-sm-4">
+ <span class="bold">{{selectedProgram.dateOfEnrollmentDescription}}:</span> {{enrollment.dateOfEnrollment}}
+ </div>
+ <div class="col-sm-4">
+ <span class="bold">{{selectedProgram.dateOfIncidentDescription}}:</span> {{enrollment.dateOfIncident}}
+ </div>
+ <div class="col-sm-4">
+ <span class="bold">{{'status'| translate}}:</span> {{enrollment.status}}
+ </div>
<div class='row vertical-spacing'></div>
- <div ng-if="dhis2Event.notes">
- <h4 class='col-sm-12'>{{'notes'| translate}}</h4>
+ <div ng-if="enrollment.notes">
+ <h3 class='col-sm-12'>{{'notes'| translate}}</h3>
<table class="table-borderless table-striped">
- <tr class="col-sm-12" ng-repeat="note in dhis2Event.notes">
+ <tr class="col-sm-12" ng-repeat="note in enrollment.notes">
<td class="col-sm-12">
<p>
{{note.value}}<br>
@@ -107,12 +46,75 @@
</tr>
</table>
</div>
- <hr class="visit-details" ng-show="$index < selectedReport.enrollments[enrollment.enrollment].length - 1">
+
+ <h2 class='col-sm-12'>{{'visits'| translate}}</h2>
+ <div class='vertical-spacing' ng-repeat="dhis2Event in report.enrollments[enrollment.enrollment]| orderBy:'sortingDate':reverse">
+ <!--<h3 class='col-sm-12'>{{'visits'| translate}}</h3>-->
+ <div class="col-sm-2">
+ <span class="bold">{{'name'| translate}}:</span> {{dhis2Event.name}}
+ </div>
+ <div class="col-sm-2">
+ <span class="bold">{{'org_unit'| translate}}:</span> {{dhis2Event.orgUnitName}}
+ </div>
+ <div class="col-sm-2">
+ <span class="bold">{{'due_date'| translate}}:</span> {{dhis2Event.dueDate}}
+ </div>
+ <div class="col-sm-2">
+ <span class="bold">{{'visit'| translate}} {{'_date'| translate}}:</span> {{dhis2Event.eventDate ? dhis2Event.eventDate : 'no_visit_made'| translate}}
+ </div>
+ <div class="col-sm-2">
+ <span class="bold">{{'status'| translate}}:</span> {{dhis2Event.status}}
+ </div>
+ <div class='row vertical-spacing'></div>
+ <div class='col-sm-6'>
+ <table class="table table-bordered table-compact" ng-if="dhis2Event.visited && dhis2Event.dataValues">
+ <tr class="col-sm-12">
+ <th class="col-md-5">
+ {{'data_element'| translate}}
+ </th>
+ <th class="col-sm-5">
+ {{'value'| translate}}
+ </th>
+ <th class="col-sm-2" ng-if="allowProvidedElsewhereExists[dhis2Event.programStage]">
+ {{'provided_elsewhere'| translate}}
+ </th>
+ </tr>
+ <tr class="col-sm-12" ng-repeat="prStDe in programStages[dhis2Event.programStage].programStageDataElements">
+ <td>
+ {{prStDe.dataElement.formName ? prStDe.dataElement.formName : prStDe.dataElement.name}}
+ </td>
+ <td>
+ {{dhis2Event[prStDe.dataElement.id].value}}
+ </td>
+ <td ng-if="allowProvidedElsewhereExists[dhis2Event.programStage]">
+ {{dhis2Event[prStDe.dataElement.id].providedElsewhere ? 'provided_elsewhere' : ''| translate}}
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="alert alert-warning visit-details col-sm-6" ng-if="!dhis2Event.visited">{{'visit_not_made'| translate}}</div>
+ <div class="alert alert-warning visit-details col-sm-6" ng-if="!dhis2Event.dataValues">{{'no_data'| translate}}</div>
+ <div class='row vertical-spacing'></div>
+ <div ng-if="dhis2Event.notes">
+ <h4 class='col-sm-12'>{{'notes'| translate}}</h4>
+ <table class="table-borderless table-striped">
+ <tr class="col-sm-12" ng-repeat="note in dhis2Event.notes">
+ <td class="col-sm-12">
+ <p>
+ {{note.value}}<br>
+ ({{note.storedBy}}, {{note.storedDate}})
+ </p>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <hr class="visit-details" ng-show="$index < report.enrollments[enrollment.enrollment].length - 1">
+ </div>
+
</div>
-
</div>
</div>
-<div class="modal-footer not-printable">
- <button class="btn btn-default" data-ng-click="close()">{{'close'| translate}}</button>
- <button class="btn btn-primary" data-ng-click="print()" onclick="javascript:window.print()">{{'print'| translate}}</button>
+<div class="modal-footer">
+ <button class="btn btn-default" data-ng-click="close()">{{'close'| translate}}</button>
+ <button class="btn btn-primary" d2-print print-element-id="printSection">{{'print'| translate}}</button>
</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2014-08-27 15:40:36 +0000
@@ -63,15 +63,17 @@
}
};
- //watch for selection of org unit from tree
+ //watch for selection of program
$scope.$watch('selectedProgram', function() {
if( angular.isObject($scope.selectedProgram)){
+ $scope.reportStarted = false;
$scope.dataReady = false;
}
});
$scope.generateReport = function(){
+ $scope.reportStarted = true;
$scope.dataReady = false;
//check for form validity
@@ -98,8 +100,7 @@
$scope.pager,
false).then(function(data){
if(data.rows){
- $scope.teiCount = data.rows.length;
- $scope.dataReady = true;
+ $scope.teiCount = data.rows.length;
}
@@ -124,7 +125,8 @@
ev = EventUtils.setEventOrgUnitName(ev);
}
});
-
+ $scope.reportStarted = false;
+ $scope.dataReady = true;
});
});
};
@@ -212,178 +214,4 @@
$scope.close = function () {
$modalInstance.close();
};
-})
-
-
-//conroller for tei report
-.controller('TeiReportController',
- function($scope,
- $filter,
- CurrentSelection,
- storage,
- DateUtils,
- EventUtils,
- TEIService,
- TranslationService,
- ProgramFactory,
- ProgramStageFactory,
- EnrollmentService,
- DHIS2EventFactory) {
-
- TranslationService.translate();
- $scope.showProgramReportDetailsDiv = false;
- $scope.programs = [];
- $scope.programNames = [];
- $scope.programStageNames = [];
- ProgramFactory.getAll().then(function(programs){
- $scope.programs = programs;
- angular.forEach($scope.programs, function(pr){
- delete pr.organisationUnits;
- $scope.programNames[pr.id] = {id: pr.id, name: pr.name};
- angular.forEach(pr.programStages, function(stage){
- $scope.programStageNames[stage.id] = {id: stage.id, name: stage.name};
- });
- });
- });
-
- $scope.$on('dashboardWidgets', function(event, args) {
- $scope.showProgramReportDetailsDiv = false;
- var selections = CurrentSelection.get();
- $scope.selectedOrgUnit = storage.get('SELECTED_OU');
- $scope.selectedTei = selections.tei;
- $scope.selectedEntity = selections.te;
- $scope.selectedProgram = selections.pr;
- $scope.selectedEnrollment = selections.enrollment;
-
- if($scope.selectedTei){
- $scope.getEvents();
- }
- });
-
- $scope.getEvents = function(){
-
- $scope.dataFetched = false;
- $scope.dataExists = false;
- var programId = null, orgUnitId = null;
-
- if($scope.selectedProgram){
- programId = $scope.selectedProgram.id;
- }
-
- $scope.report = [];
- angular.forEach($scope.programs, function(pr){
- $scope.report[pr.id] = {};
- });
-
- DHIS2EventFactory.getEventsByProgram($scope.selectedTei.trackedEntityInstance, orgUnitId, programId).then(function(eventList){
- angular.forEach(eventList, function(ev){
- if(ev.program){
- ev.visited = true;
- ev.dueDate = DateUtils.format(ev.dueDate);
- ev.sortingDate = ev.dueDate;
- ev.name = $scope.programStageNames[ev.programStage].name;
- ev.programName = $scope.programNames[ev.program].name;
- if(angular.isUndefined($scope.report[ev.program].enrollments)){
- $scope.report[ev.program] = {enrollments: {}};
- }
- ev.statusColor = EventUtils.getEventStatusColor(ev);
-
- if(ev.eventDate){
- ev.eventDate = DateUtils.format(ev.eventDate);
- ev.sortingDate = ev.eventDate;
- }
- else{
- ev.visited = false;
- }
-
- if(ev.enrollment){
- if($scope.report[ev.program].enrollments[ev.enrollment]){
- $scope.report[ev.program].enrollments[ev.enrollment].push(ev);
- }
- else{
- $scope.report[ev.program].enrollments[ev.enrollment]= [ev];
- }
- }
- ev = EventUtils.setEventOrgUnitName(ev);
- }
- });
-
- if(eventList){
- $scope.dataExists = true;
- }
- $scope.dataFetched = true;
- });
- };
-
- $scope.showProgramReportDetails = function(pr){
-
- $scope.showProgramReportDetailsDiv = !$scope.showProgramReportDetailsDiv;
- $scope.selectedProgram = pr;
- $scope.selectedReport = $scope.report[pr.id];
-
- //today as report date
- $scope.today = moment();
- $scope.today = Date.parse($scope.today);
- $scope.today = $filter('date')($scope.today, 'yyyy-MM-dd');
-
- //process tei attributes, this is to have consistent display so that the tei
- //contains program attributes whether it has value or not
- TEIService.processAttributes($scope.selectedTei, $scope.selectedProgram, null).then(function(tei){
- $scope.tei = tei;
- });
-
- //get program stage for the selected program
- //they are needed assign data element names for event data values
- $scope.programStages = [];
- $scope.allowProvidedElsewhereExists = [];
- angular.forEach($scope.selectedProgram.programStages, function(st){
- ProgramStageFactory.get(st.id).then(function(stage){
- $scope.programStages[stage.id] = stage;
- var providedElsewhereExists = false;
- for(var i=0; i<stage.programStageDataElements.length && !providedElsewhereExists; i++){
- if(stage.programStageDataElements[i].allowProvidedElsewhere){
- providedElsewhereExists = true;
- $scope.allowProvidedElsewhereExists[st.id] = true;
- }
- }
- });
- });
-
- //program reports come grouped in enrollment, process for each enrollment
- $scope.enrollments = [];
- angular.forEach(Object.keys($scope.selectedReport.enrollments), function(enr){
- //format report data values
- angular.forEach($scope.selectedReport.enrollments[enr], function(ev){
- angular.forEach(ev.notes, function(note){
- note.storedDate = moment(note.storedDate).format('DD.MM.YYYY @ hh:mm A');
- });
-
- if(ev.dataValues){
- angular.forEach(ev.dataValues, function(dv){
- if(dv.dataElement){
- ev[dv.dataElement] = dv;
- }
- });
- }
- });
-
- //get enrollment details
- EnrollmentService.get(enr).then(function(enrollment){
- enrollment.dateOfEnrollment = DateUtils.format(enrollment.dateOfEnrollment);
- enrollment.dateOfIncident = DateUtils.format(enrollment.dateOfIncident);
- angular.forEach(enrollment.notes, function(note){
- note.storedDate = moment(note.storedDate).format('DD.MM.YYYY @ hh:mm A');
- });
- $scope.enrollments.push(enrollment);
- });
- });
- };
-
- $scope.close = function(){
- $scope.showProgramReportDetailsDiv = false;
- };
-
- $scope.print = function(){
- $scope.showProgramReportDetailsDiv = false;
- };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html 2014-08-27 15:40:36 +0000
@@ -79,6 +79,7 @@
<div class="alert alert-warning">{{'please_select_program_report'| translate}}</div>
</div>
</div>
+ <img src="../images/ajax-loader-bar.gif" ng-if="!dataReady && reportStarted"/>
<div ng-if="dataReady">
<div ng-switch="teiCount">
<div ng-switch-when="undefined">
@@ -139,4 +140,4 @@
</div>
</div>
</div>
-</div>
+</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js 2014-08-27 15:40:36 +0000
@@ -1,6 +1,134 @@
trackerCapture.controller('UpcomingEventsController',
- function(TranslationService) {
-
- TranslationService.translate();
+ function($scope,
+ $modal,
+ DateUtils,
+ EventUtils,
+ TEIService,
+ TEIGridService,
+ TranslationService,
+ AttributesFactory,
+ ProgramFactory,
+ DHIS2EventFactory,
+ storage) {
+
+ TranslationService.translate();
+
+ $scope.today = DateUtils.format(moment());
+
+ $scope.ouModes = [{name: 'SELECTED'}, {name: 'CHILDREN'}, {name: 'DESCENDANTS'}, {name: 'ACCESSIBLE'}];
+ $scope.selectedOuMode = $scope.ouModes[0];
+ $scope.report = {};
+
+ //watch for selection of org unit from tree
+ $scope.$watch('selectedOrgUnit', function() {
+ if( angular.isObject($scope.selectedOrgUnit)){
+ storage.set('SELECTED_OU', $scope.selectedOrgUnit);
+ $scope.loadPrograms($scope.selectedOrgUnit);
+ }
+ });
+
+ //load programs associated with the selected org unit.
+ $scope.loadPrograms = function(orgUnit) {
+
+ $scope.selectedOrgUnit = orgUnit;
+
+ if (angular.isObject($scope.selectedOrgUnit)) {
+
+ ProgramFactory.getAll().then(function(programs){
+ $scope.programs = [];
+ angular.forEach(programs, function(program){
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
+ $scope.programs.push(program);
+ }
+ });
+
+ if($scope.programs.length === 0){
+ $scope.selectedProgram = null;
+ }
+ else{
+ if($scope.selectedProgram){
+ angular.forEach($scope.programs, function(program){
+ if(program.id === $scope.selectedProgram.id){
+ $scope.selectedProgram = program;
+ }
+ });
+ }
+ else{
+ if($scope.programs.length === 1){
+ $scope.selectedProgram = $scope.programs[0];
+ }
+ }
+ }
+ });
+ }
+ };
+
+ //watch for selection of program
+ $scope.$watch('selectedProgram', function() {
+ if( angular.isObject($scope.selectedProgram)){
+ $scope.reportStarted = false;
+ $scope.dataReady = false;
+ }
+ });
+
+ $scope.generateReport = function(){
+
+ $scope.reportStarted = true;
+ $scope.dataReady = false;
+
+ //check for form validity
+ $scope.outerForm.submitted = true;
+ if( $scope.outerForm.$invalid || !$scope.selectedProgram){
+ return false;
+ }
+
+ $scope.programStages = [];
+ angular.forEach($scope.selectedProgram.programStages, function(stage){
+ $scope.programStages[stage.id] = stage;
+ });
+
+ AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
+ $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
+ });
+
+ //fetch TEIs for the selected program and orgunit/mode
+ TEIService.search($scope.selectedOrgUnit.id,
+ $scope.selectedOuMode.name,
+ null,
+ 'program=' + $scope.selectedProgram.id,
+ null,
+ $scope.pager,
+ false).then(function(data){
+ if(data.rows){
+ $scope.teiCount = data.rows.length;
+ }
+
+
+ //process tei grid
+ $scope.teiList = TEIGridService.format(data);
+
+ DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedOuMode.name, $scope.selectedProgram.id).then(function(eventList){
+ $scope.dhis2Events = [];
+ angular.forEach(eventList, function(ev){
+ if(ev.trackedEntityInstance){
+ ev.name = $scope.programStages[ev.programStage].name;
+ ev.programName = $scope.selectedProgram.name;
+ ev.statusColor = EventUtils.getEventStatusColor(ev);
+ ev.eventDate = DateUtils.format(ev.eventDate);
+
+ if($scope.dhis2Events[ev.trackedEntityInstance]){
+ $scope.dhis2Events[ev.trackedEntityInstance].push(ev);
+ }
+ else{
+ $scope.dhis2Events[ev.trackedEntityInstance] = [ev];
+ }
+ ev = EventUtils.setEventOrgUnitName(ev);
+ }
+ });
+ $scope.reportStarted = false;
+ $scope.dataReady = true;
+ });
+ });
+ };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html 2014-08-27 15:40:36 +0000
@@ -20,4 +20,124 @@
<div id="mainPage" class="bordered-div">
<h2>{{'upcoming_events' | translate}}</h2>
+ <form name="outerForm" novalidate>
+ <div class="row">
+ <div class="col-sm-12 col-md-8">
+ <table class="table table-borderless table-striped">
+ <tr>
+ <td class='col-sm-6 col-md-4 vertical-center'>
+ {{'program' | translate}}
+ </td>
+ <td class='col-sm-6 col-md-4'>
+ <select ng-model="selectedProgram"
+ class="form-control"
+ ng-options="program as program.name for program in programs | orderBy: 'name'"
+ ng-disabled="programs.length < 1">
+ <option value="">{{programs.length > 0 ? 'please_select_a_program' : 'no_program_exists' | translate}}</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td class='col-sm-6 col-md-4 vertical-center'>{{'org_unit'| translate}}</td>
+ <td class='col-sm-6 col-md-4'>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
+ <label><input type="radio" ng-model="selectedOuMode.name" name="accessible" value="ACCESSIBLE"> {{'ACCESSIBLE'| translate}}</label>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-8 col-md-6">
+ <table class="table-borderless">
+ <tr>
+ <td>
+ <input type="text" name="reportStartDate" placeholder="{{'start_date'| translate}} (yyyy-mm-dd)" class="form-control" ng-date ng-model="report.startDate" max="today" ng-required="true"/>
+ <span ng-show="outerForm.submitted && outerForm.reportStartDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} (yyyy-mm-dd)</span>
+ </td>
+ <td>
+ <input type="text" name="reportEndDate" placeholder="{{'end_date'| translate}} (yyyy-mm-dd)" class="form-control" ng-date ng-model="report.endDate" max="today" ng-required="true"/>
+ <span ng-show="outerForm.submitted && outerForm.reportEndDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} (yyyy-mm-dd)</span>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="col-md-6 trim">
+ <button type="button" class="btn btn-primary" ng-click="generateReport()" ng-disabled="!selectedProgram">{{'go'| translate}}</button>
+ </div>
+ </div>
+ </form>
+ <div class="row" ng-if="programs.length < 1">
+ <div class="col-sm-8 col-md-6 vertical-spacing">
+ <div class="alert alert-warning">{{'no_program_exists_report'| translate}}</div>
+ </div>
+ </div>
+ <div class="row" ng-if="programs.length > 0 && !selectedProgram">
+ <div class="col-sm-8 col-md-6 vertical-spacing">
+ <div class="alert alert-warning">{{'please_select_program_report'| translate}}</div>
+ </div>
+ </div>
+ <img src="../images/ajax-loader-bar.gif" ng-if="!dataReady && reportStarted"/>
+ <div ng-if="dataReady">
+ <div ng-switch="teiCount">
+ <div ng-switch-when="undefined">
+ <div class="alert alert-warning vertical-spacing">
+ {{'no'| translate}} {{selectedProgram.trackedEntity.name|| 'records' | translate}} {{'found'| translate}}
+ </div>
+ </div>
+ <div ng-switch-when="0">
+ <div class="alert alert-warning vertical-spacing">
+ {{'no'| translate}} {{selectedProgram.trackedEntity.name|| 'records' | translate}} {{'found'| translate}}
+ </div>
+ </div>
+ <div ng-switch-default>
+
+ <!-- report begins -->
+ <div class="vertical-spacing">
+ <table class="table table-compact table-striped">
+ <thead>
+ <tr>
+ <th>{{selectedProgram.trackedEntity.name}}</th>
+ <th>{{selectedProgram.name}} {{'visit' | translate}}</th>
+ </tr>
+ </thead>
+ <tr ng-repeat="tei in teiList.rows">
+ <td>
+ <span ng-repeat="gridColumn in gridColumns">
+ <span class="bold">{{gridColumn.name}}:</span> {{tei[gridColumn.id]}}<br>
+ </span>
+ </td>
+ <td class='vertical-center'>
+ <div class='bold inline-block' ng-if='!dhis2Events[tei.id]'>{{'no_visit_made' | translate}}</div>
+ <div class="inline-block" ng-repeat="ev in dhis2Events[tei.id] | orderBy: 'eventDate'">
+ <div class="block align-center">{{ev.orgUnitName}}</div>
+ <div class="empty-stage-container"
+ title="{{'no_data' | translate}}"
+ ng-class="{'{{ev.statusColor}}': true}"
+ ng-if='!ev.dataValues'>
+ {{ev.name}}<br/>
+ {{ev.eventDate}}<br>
+ {{'no_data' | translate}}
+ </div>
+ <div class="stage-container"
+ title="{{'details' | translate}}"
+ ng-class="{'{{ev.statusColor}}': true}"
+ ng-if='ev.dataValues'
+ ng-click="showEventDetails(ev, tei)">
+ {{ev.name}}<br/>
+ {{ev.eventDate}}<br>
+ {{'data_exists' | translate}}
+ </div>
+ <span><i class="fa fa-arrow-right" ng-show="$index < dhis2Events[tei.id].length - 1"></i></span>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <!-- report ends -->
+ </div>
+ </div>
+ </div>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-08-27 15:40:36 +0000
@@ -74,6 +74,7 @@
<script type="text/javascript" src="components/registration/registration-controller.js"></script>
<script type="text/javascript" src="components/enrollment/enrollment-controller.js"></script>
<script type="text/javascript" src="components/dataentry/dataentry-controller.js"></script>
+ <script type="text/javascript" src="components/report/tei-report-controller.js"></script>
<script type="text/javascript" src="components/report/program-summary-controller.js"></script>
<script type="text/javascript" src="components/report/overdue-events-controller.js"></script>
<script type="text/javascript" src="components/report/upcoming-events-controller.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html 2014-08-27 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html 2014-08-27 15:40:36 +0000
@@ -18,7 +18,7 @@
{{'upcoming_events_description' | translate}}
</div>
<div class="col-md-6 report-type-container" ng-click="overdueEvents()">
- <h2><i class="fa fa-exclamation-circle"></i> <span class="horizonal-spacing">{{'overdue_events' | translate}}</span></h2>
+ <h2><i class="fa fa-bell-o"></i> <span class="horizonal-spacing">{{'overdue_events' | translate}}</span></h2>
{{'overdue_events_description' | translate}}
</div>
</div>