'use strict'; /*** controller***/ app.controller('report_markcard_certificateCtrl', ["$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 */ // DataTables configurable options $scope.univModel = { "branch": "", "university": "", "batch": "", "from_date": "", "to_date": "", }; $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 { } }); } /* watch university model for bind batch objects*/ $scope.$watchCollection('univModel.university', function (newValue,oldValue) { if(newValue==undefined || newValue==''){ $scope.filterBatchDetails=""; $scope.disableSubmit=true; } else{ if(angular.isString(newValue)){ $scope.filterBatchDetails=angular.fromJson(newValue); $scope.disableSubmit=false; } } }); // disable submit $scope.$watchCollection('univModel.from_date', function (newValue,oldValue) { if(newValue==undefined || newValue=='' || newValue==null){ $scope.disableSubmit=true; } else{ $scope.disableSubmit=false; } }); $scope.onSubmit = function () { //alert($scope.univModel.from_date); // if(angular.isString($scope.univModel.university) && $scope.univModel.university !== null){ // $scope.filterUniv = angular.fromJson($scope.univModel.university); // } // else{ // $scope.filterUniv =''; // } //alert($scope.univModel.university); if($scope.univModel.university !== null && $scope.univModel.university !== '' ){ $scope.filterUniv = angular.fromJson($scope.univModel.university); }else { $scope.filterUniv = ''; } $scope.mark_cert_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_markcard_certificate/', headers: { 'Content-Type': 'application/json' }, data: { branch: JSON.parse(localStorage.getItem('localObj')).localBranchID, university: $scope.filterUniv.universityID, batch: $scope.univModel.batch, from : $scope.univModel.from_date, to : $scope.univModel.to_date } }; $http(response_data).then(function (response) { if (response.data.mark_certList == true) { $scope.mark_cert_data = response.data.mark_cert_data; for(var i=0;i<$scope.mark_cert_data.length;i++) $scope.mark_cert_data[i].SL_NO = i+1; } else { $scope.message = response.data.message; } }); } var mystyle = { sheetid: 'MARKCARD/CERTIFICATE STATUS REPORT', headers: true, caption: { title:'MARKCARD/CERTIFICATE 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,Student_name as StudentName,Father_name as FatherName,CAST(Phone_number AS NUMBER) as PhoneNumber,University as University,course_name as CourseName,Sem_year as SemYear,Certificate_name as CertificateName,rstatus as ReceivedStatus,rdate as ReceivedDate,istatus as IssuedStatus,issuedate as IssuedDate,acmts as CertificateIssuedComments,CAST(Balance_fee AS NUMBER) as BalanceFee INTO XLS("Markcard/Certificate_status.xls",?) FROM ?',[mystyle,$scope.mark_cert_data]); }; /** * 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.mark_cert_data.length; var i = 0; for(i=0;i