'use strict'; /*** controller***/ app.controller('report_waiver_referalCtrl', ["$scope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService", function ($scope, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService) { // DataTables configurable options $scope.univModel = { "branch": "", "university": "", "batch": "", }; $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.filters = function () { var filterlist = { method: 'POST', url: apiPoint.url + 'report_filters/', headers: { 'Content-Type': 'application/json' }, data: { branch : JSON.parse(sessionStorage.getItem('localObj')).localBranchID, activity:"" } }; $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; 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.filterUniv = angular.fromJson($scope.univModel.university); $scope.waiver_referal_data = ''; $scope.message = ''; console.log($scope.waiver_referal_data); var response_data = { method: 'POST', url: apiPoint.url + 'report_wav_ref/', 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.wav_refList == true) { $scope.isLoaderShow1 =false; $scope.waiver_referal_data = response.data.wav_ref_data; for(var i=0;i<$scope.waiver_referal_data.length;i++) $scope.waiver_referal_data[i].SL_NO = i+1; } else { $scope.isLoaderShow1 =false; $scope.message = response.data.message; } }); $scope.getwaiver = function(){ var total = 0; for(var i = 0; i < $scope.waiver_referal_data.length; i++){ var item = $scope.waiver_referal_data[i]; total += parseFloat(item.Waiver_amount); } return total; } $scope.getref = function(){ var totalf = 0; for(var i = 0; i < $scope.waiver_referal_data.length; i++){ var item = $scope.waiver_referal_data[i]; totalf += parseFloat(item.Referal_amount); } return totalf; } } } var mystyle = { sheetid: 'WAIVER AND REFERAL REPORT', headers: true, caption: { title:'WAIVER AND REFERAL 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,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 AdmittedBy,staffname as Waiver_ReferalGivenBy,Waiver_bill as WaiverBillNo,CAST(Waiver_amount AS NUMBER) as WaiverAmount,Referal_bill as ReferalBillNo,CAST(Referal_amount AS NUMBER) as ReferalAmount,Comments as Comments INTO XLS("Waiver_referal_report.xls",?) FROM ?',[mystyle,$scope.waiver_referal_data]); }; /*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.userType=JSON.parse(sessionStorage.getItem('localObj')).localType; // $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(sessionStorage.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,filterby) { if(type == '1' || type == '2' ){ var result = []; for (var i = 0; i < values.length; i++){result.push(values[i]);} } if(type == '3' || type == '5' || type == '7' || type == '8'){ var result = []; for (var i = 0; i < values.length; i++) { if (values[i].Sem === filterby) { result.push(values[i]); } } } if(type == '4'){ var result = []; for (var i = 0; i < values.length; i++) { if (values[i].Sem_Year === filterby) { result.push(values[i]); } } } if(type == '6'){ var result = []; for (var i = 0; i < values.length; i++) { if (values[i].CertificateName === filterby) { result.push(values[i]); } } } var modalInstance1 = $modal.open({ templateUrl: 'assets/views/student/studentPaymentModal.html', controller: 'ModalInstanceCtrl1', // size: size, resolve: { items1: function () { var myvalues = { "values":result, "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'); }; }]); }]);