'use strict'; /*** controller***/ app.controller('FeeCollected_reportCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage" ,"$http", "$state","$modal","$log", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http,ipCookie ,$state,$modal,$log){ //function ($scope, apiPoint, $http, SweetAlert, $state,$modal, md5, ipCookie, $window, dateListDescService) { // DataTables configurable options $scope.filters = { "from_date": "", "to_date": "", }; var localDetails = JSON.parse(localStorage.getItem('localObj')); //var localDetails = ipCookie('cookiechk'); //console.log(localDetails); // $scope.initHead = function() { //console.log('rfd'); var logcheck = JSON.parse(localStorage.getItem('localObj')); const LOCALTYPE = logcheck.localType; if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE == 'R005')) { console.log("if"); }else { if(logcheck != null && LOCALTYPE !='R001') { console.log("else if"); $state.go('app.dashboard'); } else { console.log("else else"); //ipCookie.remove('cookiechk'); window.localStorage.clear(); $state.go('login.signin'); } } // } $scope.universitySearchData = ''; $scope.init = function() { // alert() var getuniv = { method: 'POST', url: apiPoint.url + 'AllgetUniversity/', headers: { 'Content-Type': 'application/json' }, data: { branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID, } }; $http(getuniv).then(function (response) { if(response.status == 200) { $scope.universitySearchData=response.data.details; } }); }; //$scope.opinctotal=''; $scope.newreglist=''; $scope.isLoaderShow =''; $scope.load = ''; $scope.isShow= ''; $scope.fromd=''; $scope.tod=''; $scope.universityId=''; $scope.getDetails = function (form,myModel) { var firstError = null; if (form.$invalid) { var field = null, firstError = null; $scope.show = true; for (field in form) { if (field[0] != '$') { if (firstError === null && !form[field].$valid) { firstError = form[field].$batch; } if (form[field].$pristine) { form[field].$dirty = true; } } } angular.element('.ng-invalid[batch=' + firstError + ']').focus(); } else { var from = $scope.filters.from_date; var to = $scope.filters.to_date; if(myModel === undefined) { $scope.universityId=''; } else { $scope.universityId = myModel.myUnivSearch; } var f = new Date(from), month = '' + (f.getMonth() + 1), day = '' + f.getDate(), year = f.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var from_dt = [day, month ,year].join('-'); var t = new Date(to), month = '' + (t.getMonth() + 1), day = '' + t.getDate(), year = t.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var to_dt = [day, month ,year].join('-'); $scope.fromd = from_dt; $scope.tod = to_dt; var getstudentdetails = { method: 'POST', url: apiPoint.url + 'feepaidDetails/', headers: { 'Content-Type': 'application/json' }, data: { university: $scope.universityId, from : $scope.filters.from_date , to : $scope.filters.to_date } } $http(getstudentdetails).then(function (response) { if(response.data.status == 200 && response.data.searchst==true) { //console.log(response.data); $scope.newreglist = response.data.details; $scope.isShow=true; $scope.isLoaderShow=false; $scope.Totalfee =0; console.log($scope.newreglist); angular.forEach(($scope.newreglist),function(newreglist,key) { console.log(newreglist) $scope.Totalfee= parseFloat($scope.Totalfee)+parseFloat(newreglist.Total); }); } else { $scope.isLoaderShow=true; $scope.isShow=false; } }); } } $scope.exportData = function () { //alert() $scope.sam = 'Fee Paid list from '+$scope.fromd+' to '+$scope.tod; var mystyle = { sheetid:$scope.sam, headers: true, caption: { title: $scope.sam, width: '1000px', style:'font-size:50px;bold:true' }, // style:'background:#00FF00', column: { style:'font-size:12px' }, }; console.log(mystyle); alasql('SELECT UniversityName,Cash,Cheque,Referal,Onlinec as OnlineTransaction,WAIVER as Waiver,Card as CardTransaction,Total INTO XLS("Fee Paid List report.xls",?) FROM ?',[mystyle,$scope.newreglist]); }; $scope.OpenWindowStatus = false; $scope.editId = -1; $scope.setEditId = function (P) { //alert(P); $scope.editId = P; } $scope.close = function () { $scope.editId = -1; } $scope.fdate =''; $scope.tdate =''; //$scope.Subtypes = ''; }]);