'use strict'; /** * controllers for ng-table * Simple table with sorting and filtering on AngularJS */ app.controller('generateHallTicketCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state","$modal","$log", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,$modal,$log) { $scope.myModel = { "universityName":"", "courseName":"", "batchName":"", "centerName":"" }; $scope.pdfModel = { "universityDetails":"", "studentDetails":"", "batchDetails":"", "courseDetails":"", "centerDetails":"", "semDataType":"" }; $rootScope.userType = JSON.parse(localStorage.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(localStorage.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.localStorage.clear(); // $state.go('login.signin'); // } // } var getUniv = { method: 'POST', url: apiPoint.url + 'getUniversityCourseDetails/', headers: { 'Content-Type': 'application/json' }, data: { requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID, branchId:JSON.parse(localStorage.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(localStorage.getItem('localObj')).localUserID, branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID, requestedDept: JSON.parse(localStorage.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; } 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.isClick = function(e) { var ide = e.target; var val = (ide.checked ? true : false); var sid = e.target.id; angular.forEach($scope.studentInfo,function(value,key){ if(sid == value.StudentID) { sid = value; } }); var pos = $scope.selectedStudentsID.indexOf(sid); if(val) { if( pos == -1) { $scope.selectedStudentsID.push(sid); } } else { $scope.selectedStudentsID.splice(pos,1); } } $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