'use strict'; /*** controller***/ app.controller('report_study_material_statusCtrl', ["$scope", "$filter","$rootScope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService","$modal","$timeout", function ($scope, $filter,$rootScope,apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService,$modal,$timeout,$log) { /** * 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.university = response.data.university; //Desc order Batchlist // call service for make a list in desc order based on date // console.log(response.data.batch); // console.log($scope.batch); } else { } }); } /* watch university model for bind batch objects*/ $scope.$watch('univModel.university', function (newValue,oldValue) { if(newValue==undefined || newValue==''){ $scope.filterBatchDetails=""; } else{ if(angular.isString(newValue)){ $scope.filterBatchDetails=angular.fromJson(newValue); } } }); $scope.show = false; $scope.onSubmit = function (form) { $scope.isLoaderShow1 =true; if(angular.isString($scope.univModel.university)) { $scope.filterUniv = angular.fromJson($scope.univModel.university); } else{ $scope.filterUniv=$scope.univModel.university; } 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 { //alert($scope.batch.name); $scope.study_mat_data = ''; $scope.message = ''; $scope.message1 =''; var response_data = { method: 'POST', url: apiPoint.url + 'report_status/', 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.statusList == true) { $scope.study_mat_data = response.data.statusr; $scope.isLoaderShow1 =false; for(var i=0;i<$scope.study_mat_data.length;i++) $scope.study_mat_data[i].SL_NO = i+1; } else { $scope.message = response.data.message; $scope.isLoaderShow1 =false; } }); } } //Export to excel var mystyle = { sheetid: 'STUDY MATERIAL STATUS REPORT', headers: true, caption: { title:'STUDY MATERIAL STATUS 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,Initial_paid_date as InitialPaymentPaidDate,Enrollment_id as EnrollmentId,Student_name as StudentName,Father_name as FatherName,Course_name as Course,Sem as SemYear,University,CAST(Balance_fee AS NUMBER) as BalanceFee,appdate as ApplicationSendtoUnivDate,Status as StudyMaterialStatus,Date as Date INTO XLS("Study_material_status.xls",?) FROM ?',[mystyle,$scope.study_mat_data]); }; $scope.$watch(function () { $scope.filteredItems = $scope.$eval(" study_mat_data | filter: search "); }); /** * Auto Call Tracking Status */ $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