'use strict'; /*** controller***/ app.controller('report_study_material_statusCtrl', ["$scope", "$filter","$rootScope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService","$modal", function ($scope, $filter,$rootScope,apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService,$modal,$log) { /** * 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.filters = { "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(response.data.batch); // console.log($scope.batch); } else { } }); } $scope.onSubmit = function() { //alert($scope.batch.name); $scope.study_mat_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_status/', headers: { 'Content-Type': 'application/json' }, data: { branch : JSON.parse(localStorage.getItem('localObj')).localBranchID, university : $scope.filters.university, batch : $scope.filters.batch } }; $http(response_data).then(function (response) { if (response.data.statusList == true) { $scope.study_mat_data = response.data.statusr; 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; } }); } //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 InitialPaidDate,Enrollment_id as EnrollmentId,Student_name as StudentName,Father_name as FatherName,Course_name as CourseName,Sem_year as SemYear,CAST(Phone_number AS NUMBER) as PhoneNumber,University,Status as StudyMaterial_Status,CAST(Balance_fee AS NUMBER) as BalanceFee,Date INTO XLS("Study_material_status.xls",?) FROM ?',[mystyle,$scope.study_mat_data]); }; $scope.exportExcel= function () { alasql('SELECT * INTO CSV("Study_material_status.csv",{headers:true}) \ FROM HTML("#data",{headers:true})'); } /*modal controller * */ app.controller('studentModalDemoCtrl', ["$scope","$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope,$rootScope, $modal, $log, apiPoint, $http) { //Tooltip for print button $scope.dynamicTooltip = 'Student View'; // $scope.items = ['item1', 'item2', 'item3']; $scope.open = function (studentDetails) { // get student view details var getcourse = { method: 'POST', url: apiPoint.url + 'getStudentBasicInfo/', headers: { 'Content-Type': 'application/json' }, data: { requestedBy: studentDetails.Phone_number, requestedFrom: 3, branchCode:JSON.parse(localStorage.getItem('localObj')).localBranchID } }; $http(getcourse).then(function (response) { if (response.data.status == 200 && response.data.studentStatus == true) { $scope.courseEditLoading = false; // $scope.studentDetails = response.data.studentDetails; $scope.studentDetails = response.data; // $scope.courseDetails = response.data.courseDetails; var modalInstance = $modal.open({ templateUrl: 'assets/views/student/studentDetailsModal.html', controller: 'ModalInstanceCtrl', // size: size, resolve: { items: function () { return $scope.studentDetails; } } }); modalInstance.result.then(function (selectedItem) { $scope.selected = selectedItem; }, function () { $log.info('Modal dismissed at: ' + new Date()); }); } else { swal("Failed!", "This student is not registerd", "warning"); $scope.courseEditLoading = false; $scope.studentDetails = ""; $scope.courseDetails = ""; } }); }; $scope.open1 = function (values,type) { var modalInstance1 = $modal.open({ templateUrl: 'assets/views/student/studentPaymentModal.html', controller: 'ModalInstanceCtrl1', // size: size, resolve: { items1: function () { var myvalues = { "values":values, "type":type }; return myvalues; } } }); modalInstance1.result.then(function (selectedItem) { $scope.selected = selectedItem; }, function () { $log.info('Modal dismissed at: ' + new Date()); }); }; $scope.printStudentDetails = function (details) { $rootScope.pdfItems = details; var printInstance = $modal.open({ templateUrl: 'assets/views/student/studentPdf.html', controller: 'studentModalDemoCtrl', }); }; // generate pdf for student view $scope.export = function(getName) { kendo.drawing.drawDOM($("#exportthis")).then(function(group) { kendo.drawing.pdf.saveAs(group, getName+".pdf"); }); } }]); // Please note that $modalInstance represents a modal window (instance) dependency. // It is not the same as the $modal service used above. app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items", "WordsService", function ($scope, $modalInstance, items, WordsService) { $scope.items = items; $scope.selected = { item: $scope.items[0] }; $scope.ok = function () { $modalInstance.close($scope.selected.item); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }]); app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1", "WordsService", function ($scope, $modalInstance, items1, WordsService) { $scope.items1 = items1.values; $scope.selectedtype = items1.type; $scope.ok = function () { $modalInstance.close($scope.selected.item); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }]); /** * 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.study_mat_data.length; console.log(len); console.log($scope.study_mat_data); var i = 0; for(i=0;i