community-app/app/scripts/controllers/client/ClientScreenReportController.js
2014-03-02 04:09:27 -08:00

33 lines
1.6 KiB
JavaScript

(function (module) {
mifosX.controllers = _.extend(module, {
ClientScreenReportController: function (scope, resourceFactory, location, $http, API_VERSION, routeParams, $rootScope) {
resourceFactory.templateResource.get({entityId: 0, typeId: 0}, function (data) {
scope.clientTemplateData = data;
});
scope.print = function (template) {
var templateWindow = window.open('', 'Screen Report', 'height=400,width=600');
templateWindow.document.write('<html><head>');
templateWindow.document.write('</head><body>');
templateWindow.document.write(template);
templateWindow.document.write('</body></html>');
templateWindow.print();
templateWindow.close();
};
scope.getClientTemplate = function (templateId) {
scope.selectedTemplate = templateId;
$http({
method: 'POST',
url: $rootScope.hostUrl + API_VERSION + '/templates/' + templateId + '?clientId=' + routeParams.clientId,
data: {}
}).then(function (data) {
scope.template = data.data;
});
};
}
});
mifosX.ng.application.controller('ClientScreenReportController', ['$scope', 'ResourceFactory', '$location', '$http', 'API_VERSION', '$routeParams', '$rootScope', mifosX.controllers.ClientScreenReportController]).run(function ($log) {
$log.info("ClientScreenReportController initialized");
});
}(mifosX.controllers || {}));