'use strict'; /** * controllers for ng-table * Simple table with sorting and filtering on AngularJS */ app.controller('generateHallTicketCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$sessionStorage", "$http", "$state","$modal","$log", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $sessionStorage, $http, $state,$modal,$log) { $scope.myModel = { "universityName":"", "courseName":"", "batchName":"", "centerName":"" }; $scope.pdfModel = { "universityDetails":"", "studentDetails":"", "batchDetails":"", "courseDetails":"", "centerDetails":"", "semDataType":"" }; $rootScope.userType = JSON.parse(sessionStorage.getItem('localObj')).localType; $scope.isTblShow = false; $scope.isLoader = false; $scope.isLoaderShow = false; $scope.isLoaderTxt = "Loading..."; $scope.generateButtonTxt = "GENERATE"; $scope.generateButtonStatus = false; // sorting function for table params $scope.sort = function(keyname){ $scope.sortKey = keyname; //set the sortKey to the param passed $scope.reverse = !$scope.reverse; //if true make it false and vice versa } /* * init function * created by kms * */ $scope.init = function () { // var logcheck = JSON.parse(sessionStorage.getItem('localObj')); // const LOCALTYPE = logcheck.localType; // if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' )) { // console.log("if"); // }else { // if(logcheck != null && LOCALTYPE !='R001') { // console.log("else if"); // $state.go('app.dashboard'); // } else { // console.log("else else"); // //ipCookie.remove('cookiechk'); // window.sessionStorage.clear(); // $state.go('login.signin'); // } // } var getUniv = { method: 'POST', url: apiPoint.url + 'getUniversityCourseDetails/', headers: { 'Content-Type': 'application/json' }, data: { requestedBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, branchId:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $http(getUniv).then(function (response) { if (response.data.status==200 && response.data.universityStatus) { $scope.university = response.data.univerSityDetails; $scope.centers = response.data.centerDetails; //console.log( $scope.university); } else { $scope.university = ""; } }); } /* * get student details * created by kms * */ $scope.studentInfo=""; $scope.getStudentDetails = function (form,myModel) { if(myModel.universityName == null || myModel.universityName == '' || myModel.universityName == undefined){ swal('Select University','','warning'); return false; } if(myModel.courseName == '' || myModel.courseName == null || myModel.courseName == undefined){ swal('Select Course','','warning'); return false; } if(myModel.batchName == null || myModel.batchName == '' || myModel.batchName == undefined){ swal('Select Batch','','warning'); return false; } if(myModel.centerName == null || myModel.centerName == '' || myModel.centerName == undefined){ swal('Select Center','','warning'); return false; } var firstError = null; if (form.$invalid) { var field = null, firstError = null; for (field in form) { if (field[0] != '$') { if (firstError === null && !form[field].$valid) { firstError = form[field].$name; } if (form[field].$pristine) { form[field].$dirty = true; } } } angular.element('.ng-invalid[name=' + firstError + ']').focus(); // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); } else { $scope.selectedStudentsID = []; $scope.isLoaderShow = true; $scope.myModel.all = false; $scope.isTblShow = false; var university = myModel.universityName; var course = myModel.courseName; var batch = myModel.batchName; var centerDetails = myModel.centerName; var getStudents = { method: 'POST', url: apiPoint.url + 'getStudentListForHallTicket/', headers: { 'Content-Type': 'application/json' }, data: { university: university, course:course, batch:batch, requestedtBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, requestedDept: JSON.parse(sessionStorage.getItem('localObj')).localType, center:centerDetails } }; $http(getStudents).then(function (response) { if (response.data.status == 200 && response.data.studentStatus) { $scope.studentInfo = response.data.studentDetails; $scope.isLoaderShow = false; $scope.isTblShow = true; //console.log($scope.studentInfo); // angular.forEach(($scope.studentInfo),function(studentInfo,key) // { // //console.log($scope.studentInfo); // if(studentInfo.balpayable != 0) // { // var mobileno = studentInfo.MobileNumber; // var sendmsg = // { // method: 'POST', // url: apiPoint.url + 'SendMessagetoFeeBalance/', // headers: // { // 'Content-Type': 'application/json' // }, // data: // { // mobileno:mobileno, // branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, // } // }; // $http(sendmsg).then(function (response) // { // console.log(response.data); // }); // } // //break; // }); } else { $scope.studentInfo=""; $scope.isLoaderShow = true; $scope.isTblShow = false; $scope.isLoaderTxt = "No Records Found"; } },function(error){ $scope.isLoaderShow = true; $scope.isTblShow = false; $scope.isLoaderTxt = "No Records Found"; }); } } /* * get student details * created by kms * */ // $scope.getstudent=""; $scope.StudentDetails = function (form,myModel) { if(myModel.universityName == null || myModel.universityName == '' || myModel.universityName == undefined){ swal('Select University','','warning'); return false; } if(myModel.courseName == '' || myModel.courseName == null || myModel.courseName == undefined){ swal('Select Course','','warning'); return false; } if(myModel.batchName == null || myModel.batchName == '' || myModel.batchName == undefined){ swal('Select Batch','','warning'); return false; } if(myModel.centerName == null || myModel.centerName == '' || myModel.centerName == undefined){ swal('Select Center','','warning'); return false; } var firstError = null; if (form.$invalid) { var field = null, firstError = null; for (field in form) { if (field[0] != '$') { if (firstError === null && !form[field].$valid) { firstError = form[field].$name; } if (form[field].$pristine) { form[field].$dirty = true; } } } angular.element('.ng-invalid[name=' + firstError + ']').focus(); // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); } else { $scope.selectedStudentsID = []; $scope.isLoaderShow = true; $scope.myModel.all = false; $scope.isTblShow = false; var university = myModel.universityName; var course = myModel.courseName; var batch = myModel.batchName; var centerDetails = myModel.centerName; var getStudents = { method: 'POST', url: apiPoint.url + 'getallStudentdetails/', headers: { 'Content-Type': 'application/json' }, data: { university: university, course:course, batch:batch, requestedtBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, requestedDept: JSON.parse(sessionStorage.getItem('localObj')).localType, center:centerDetails } }; $http(getStudents).then(function (response) { if (response.data.status == 200 && response.data.studentStatus) { swal("success!"); $scope.studentInfo = response.data.studentDetails; $scope.isLoaderShow = false; $scope.isTblShow = true; } else { $scope.studentInfo=""; $scope.isLoaderShow = true; $scope.isTblShow = false; $scope.isLoaderTxt = "No Records Found"; } },function(error){ $scope.isLoaderShow = true; $scope.isTblShow = false; $scope.isLoaderTxt = "No Records Found"; }); } } $scope.selectedStudentsID = []; $scope.Sem_id = ''; $scope.isClick = function(e) { // alert(); var ide = e.target; var val = (ide.checked ? true : false); var sid1 = e.target.id; /* From Front End Checkbox ID Comes with StudentID and SemID Merged (78596) => here 7859 is student id and 6 is sem id So have to split it using substr function */ var sid = sid1.substr(0,4); var sem = sid1.substr(4,2); $scope.Sem_id = sem; console.log(sid); console.log(sem); angular.forEach($scope.studentInfo,function(value,key){ if(parseInt(sid) == value.StudentID) { //console.log(value); // var invalue = value.FeeDetails.filter(fees=>fees.Sem_Year == sem); // console.log(invalue); sid = value; // sid.FeeDetails = invalue; } }); var pos = $scope.selectedStudentsID.indexOf(sid); if(val) { if( pos == -1) { $scope.selectedStudentsID.push(sid); } } else { $scope.selectedStudentsID.splice(pos,1); } // console.log('check Box Click Funciton'); // console.log($scope.selectedStudentsID); } $scope.isCheckAll = function(e) { var val = (e.target.checked ? true : false); if(val) { var len = $scope.studentInfo.length; var i = 0; for(i=0;i'); popupWinindow.document.write(''); popupWinindow.document.write(innerContents); popupWinindow.document.write('
'); popupWinindow.document.write('
'); popupWinindow.document.write('
'); popupWinindow.document.write('
'); //popupWinindow.document.write(innerContents); popupWinindow.document.write(''); popupWinindow.document.close(); popupWinindow.focus(); popupWinindow.print(); popupWinindow.close(); } }]);