'use strict'; /*** controller***/ app.controller('report_examfeeCtrl', ["$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(sessionStorage.getItem('localObj')).localType; $scope.isTblShow = false; $scope.isLoader = false; $scope.isLoaderShow = false; $scope.isLoaderShow1 =false; $scope.isLoaderTxt = "Loading..."; $scope.generateButtonTxt = "GENERATE"; $scope.generateButtonStatus = false; $scope.currentPage = 1; $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 */ // DataTables configurable options $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(sessionStorage.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); } } }); $scope.show = false; $scope.onSubmit = function (form) { $scope.isLoaderShow1 =true; if($scope.univModel.university !== null && $scope.univModel.university !== '' ){ $scope.filterUniv = angular.fromJson($scope.univModel.university); }else { $scope.filterUniv = ''; } //alert($scope.batch.name); $scope.examfee_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_examfee/', headers: { 'Content-Type': 'application/json' }, data: { branch: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, university: $scope.filterUniv.universityID, batch: $scope.univModel.batch } }; $http(response_data).then(function (response) { if (response.data.examfeeList == true) { $scope.isLoaderShow1 =false; $scope.examfee_data = response.data.examfee_data; for(var i=0;i<$scope.examfee_data.length;i++) $scope.examfee_data[i].SL_NO = i+1; } else { $scope.isLoaderShow1 =false; $scope.message = response.data.message; } }); $scope.getstf = function(){ var totalf = 0; for(var i = 0; i < $scope.examfee_data.length; i++){ var item = $scope.examfee_data[i]; totalf += parseFloat(item.Amount); } return totalf; } } var mystyle = { sheetid: 'EXAM WRITING FEE REPORT', headers: true, caption: { title:'EXAM WRITING FEE REPORT', }, // style:'background:#00FF00', column: { style:'font-size:12px' }, // column: {style:{Font:{Bold:"1"}}}, // rows: {1:{style:{Font:{Color:"#FF0077"}}}}, // cells: {1:{1:{ // style: {Font:{Color:"#00FFFF"}} // }}} }; $scope.exportData = function () { alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Enrollment_id as EnrollmentID,Student_name as StudentName,Father_name as FatherName,Course_name as Course,Sem_year as SemYear,University as University,Stafname as Admitted_By,CAST(Amount AS NUMBER) as SumofExamWritingFee,Comments as Comments INTO XLS("Exam_writing_fee_report.xls",?) FROM ?',[mystyle,$scope.examfee_data]); }; $scope.$watch(function () { $scope.filteredItems = $scope.$eval(" examfee_data | filter: search "); }); /** * Auto Call Tracking Sriram */ $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