'use strict'; /*** controller***/ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window', function ($scope, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window) { // DataTables configurable options $scope.filters = { "from_date": "", "to_date": "", }; $scope.filters = function () { var filterlist = { method: 'POST', url: apiPoint.url + 'report_filters/', headers: { 'Content-Type': 'application/json' } }; $http(filterlist).then(function (response) { if (response.data) { $scope.batch = response.data.batch; $scope.branch = response.data.branch; $scope.university = response.data.university; //console.log($scope.branch); } else { } }); } $scope.onSubmit = function () { //alert($scope.batch.name); $scope.expense_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_expense/', headers: { 'Content-Type': 'application/json' }, data: { from : $scope.filters.from_date, to : $scope.filters.to_date } }; $http(response_data).then(function (response) { if (response.data.expenseList == true) { $scope.expense_data = response.data.expense_data; } else { $scope.message = response.data.message; } }); } var mystyle = { sheetid: 'EXPENSE REPORT', headers: true, caption: { title:'EXPENSE REPORT', width: '300px', style:'font-size:50px;' }, // style:'background:#00FF00', column: { style:'font-size:10px' }, }; $scope.exportData = function () { alasql('SELECT * INTO XLS("Expense_report.xls",?) FROM ?',[mystyle,$scope.expense_data]); }; }]);