'use strict'; /*** controller***/ app.controller('report_balfeeCtrl', ["$scope", "$filter","$rootScope","$modal", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService", function ($scope, $filter,$rootScope,$modal, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService) { /* * auto call tracking */ $scope.userType=JSON.parse(localStorage.getItem('localObj')).localType; $scope.myModel = { "date": new Date(), "activity": "", "assignedTo": "", "status": "", "referedBy": '', "comments":'', "enquiryStatus":'', "important":false, "branch":"", }; //get current date $scope.hideDateSearch=true; $scope.modifyMinDate = moment(); //$scope.minDate = $filter('date')($scope.modifyMinDate, 'MM-dd-yyyy'); $scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy'); // get 30 plus date for follwup details $scope.modifyDate = moment(); $scope.modifyDate.add(30, 'days'); $scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy'); $scope.myModel.date=$scope.currentDate; // console.log($scope.currentDate); /** * End of the call tracking */ // to generate serial number $scope.currentPage=1; $scope.itemsPerPage=10; // $scope.serial = 1; // $scope.itemPerPage=10 // $scope.indexCount = function(newPageNumber){ // $scope.serial = newPageNumber * $scope.itemPerPage - ($scope.itemPerPage-1); // } //to filter labels $scope.univModel = { "branch": "", "university": "", "batch": "", }; $scope.filters = function () { var filterlist = { method: 'POST', url: apiPoint.url + 'report_filters/', headers: { 'Content-Type': 'application/json' }, data: { branch : JSON.parse(localStorage.getItem('localObj')).localBranchID } }; $http(filterlist).then(function (response) { if (response.data) { $scope.batch=[]; $scope.batchlist = response.data.batch; $scope.university = response.data.university; //Desc order Batchlist angular.forEach($scope.batchlist,function (values,key) { var parts = values.BatchDate.split("-"); $scope.batch.push({ "batchcode":values.batchcode, "batch":values.batch + '('+ values.batchcode + ')', "BatchDate":values.BatchDate, "givenDateObject":new Date(parts[2], parts[1] - 1, parts[0]) }) }); // call service for make a list in desc order based on date $scope.batch=dateListDescService.getOrderByList($scope.batch); //console.log($scope.branch); } else { } }); } //For batch dropdown $scope.$watch('univModel.university', function (newValue,oldValue) { if(newValue==undefined || newValue==''){ $scope.filterBatchDetails=""; console.log($scope.filterBatchDetails); } else{ if(angular.isString(newValue)){ $scope.filterBatchDetails=angular.fromJson(newValue); } } }); // response data $scope.show = false; $scope.returnResultData = []; $scope.onSubmit = function (form) { $scope.returnResultData.length=0; 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 { $scope.filterUniv = angular.fromJson($scope.univModel.university); $scope.balfee_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_balfee/', headers: { 'Content-Type': 'application/json' }, data: { branch: JSON.parse(localStorage.getItem('localObj')).localBranchID, university: $scope.filterUniv.universityID, batch: $scope.univModel.batch } }; $http(response_data).then(function (response) { var j =0; if (response.data.balfeeList == true) { $scope.balfee_data = response.data.balfee_data; for(var i=0;i<$scope.balfee_data.length;i++) if($scope.balfee_data[i].bal !=0){ $scope.balfee_data[i].SL_NO = j+1; $scope.returnResultData.push($scope.balfee_data[i]); j++; } } else { $scope.message = response.data.message; } }); $scope.gettotal = function(){ var length = $scope.returnResultData.length; var totalfee = 0; for(var i = 0; i < length; i++){ var item = $scope.returnResultData[i]; totalfee += parseFloat(item.Total); } return totalfee; } $scope.getpaid = function(){ var totalpaid = 0; for(var i = 0; i < $scope.returnResultData.length; i++){ var item = $scope.returnResultData[i]; totalpaid += parseFloat(item.Paid_fee); } return totalpaid; } $scope.getbalance = function(){ var totalbalance=0; for(var i = 0; i < $scope.returnResultData.length; i++){ var item = $scope.returnResultData[i]; totalbalance += parseFloat(item.bal); } return totalbalance; } } } $scope.$watch(function () { $scope.filteredItems = $scope.$eval(" returnResultData | filter: search "); }); //Export to excel var mystyle = { sheetid: 'FEE BALANCE REPORT', headers: true, caption: { title:'FEE BALANCE REPORT', width: '300px', style:'font-size:50px;' }, // style:'background:#00FF00', column: { style:'font-size:10px' }, }; $scope.exportData = function () { alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,eid as EnrollmentID,Student_name as StudentName,Father_name as FatherName,Course_name as CourseName,Sem_year as SemYear,University as University,regdate as InitialPaymentDate,CAST(Total AS NUMBER) as TotalFee,CAST(Paid_fee AS NUMBER) as FeesPaid,CAST(bal AS NUMBER) as Balance,billno1 as BillNO1,CAST(billamt1 AS NUMBER) as BillAmount1,billno2 as BillNO2,CAST(billamt2 AS NUMBER) as BillAmount2, billno3 as BillNO3, CAST(billamt3 AS NUMBER) as BillAmount3, billno4 as BillNO4, CAST(billamt4 AS NUMBER) as BillAmount4, billno5 as BillNO5,CAST(billamt5 AS NUMBER) as BillAmount5,billno6 as BillNO6,CAST(billamt6 AS NUMBER) as BillAmount6,billno7 as BillNo7,CAST(billamt7 AS NUMBER)as BillAmount7,billno8 as BillNO8,CAST(billamt8 AS NUMBER) as BillAmount8,billno9 as BillNO9,CAST(billamt9 AS NUMBER) as BillAmount9,billno10 as BillNO10,CAST(billamt10 AS NUMBER) as BillAmount10 INTO XLS("Balancefee_status.xls",?) FROM ?',[mystyle,$scope.returnResultData]); }; /** * Auto Call Tracking Sriram */ $rootScope.selectedStudentbalfeesMN = []; $scope.selectedStudentsID = []; $scope.isCheckAll = function(e){ var val = (e.target.checked ? true : false); if(val) { // $scope.disable = false; var len = $scope.filteredItems.length; var i = 0; for(i=0;i