352 lines
10 KiB
JavaScript
Executable File
352 lines
10 KiB
JavaScript
Executable File
'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":""
|
|
};
|
|
|
|
$scope.pdfModel = {
|
|
"universityDetails":"",
|
|
"studentDetails":"",
|
|
"batchDetails":"",
|
|
"courseDetails":"",
|
|
"centerDetails":"",
|
|
"semDataType":""
|
|
};
|
|
|
|
$rootScope.userType = JSON.parse(localStorage.getItem('localObj')).localType;
|
|
$scope.existSemesterSubjectMapDetails = [{"UniversityID":"2","UniversityName":"TWO","CourseName":"CNAME"},{"UniversityID":"3","UniversityName":"TWO","CourseName":"CNAME"},{"UniversityID":"4","UniversityName":"TWO","CourseName":"CNAME"}];
|
|
|
|
$scope.isTblShow = false;
|
|
$scope.isLoader = false;
|
|
$scope.isLoaderShow = false;
|
|
$scope.isLoaderTxt = "Loading...";
|
|
|
|
// 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 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;
|
|
}
|
|
|
|
|
|
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 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,
|
|
}
|
|
};
|
|
$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('API');
|
|
//console.log($scope.studentInfo);
|
|
|
|
}
|
|
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)
|
|
{
|
|
|
|
//console.log(e.target.id);
|
|
|
|
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);
|
|
//alert(val);
|
|
if(val)
|
|
{
|
|
if( pos == -1)
|
|
{
|
|
//console.log("PUSH");
|
|
$scope.selectedStudentsID.push(sid);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//console.log("POP");
|
|
$scope.selectedStudentsID.splice(pos,1);
|
|
}
|
|
|
|
//console.log($scope.selectedStudentsID);
|
|
|
|
}
|
|
|
|
|
|
$scope.isCheckAll = function(e)
|
|
{
|
|
var val = (e.target.checked ? true : false);
|
|
//$scope.selectedStudentsID = [];
|
|
if(val)
|
|
{
|
|
var len = $scope.studentInfo.length;
|
|
var i = 0;
|
|
for(i=0;i<len;i++)
|
|
{
|
|
if($scope.selectedStudentsID.indexOf($scope.studentInfo[i]) === -1)
|
|
{
|
|
$scope.selectedStudentsID.push($scope.studentInfo[i]);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$scope.selectedStudentsID = [];
|
|
}
|
|
//console.log($scope.selectedStudentsID);
|
|
}
|
|
|
|
$scope.generateHallTicket = function()
|
|
{
|
|
if($scope.studentInfo.length == 0)
|
|
|
|
{
|
|
swal('No Students Found','','warning');return false;
|
|
}
|
|
|
|
if($scope.myModel.centerName == "" || $scope.myModel.centerName == undefined || $scope.myModel.centerName == null)
|
|
{
|
|
swal('Select Center Name','','warning');return false;
|
|
}
|
|
|
|
if($scope.selectedStudentsID.length == 0)
|
|
{
|
|
swal('Select Student(s)','','warning');return false;
|
|
}
|
|
|
|
//console.log($scope.selectedStudentsID);
|
|
var university = $scope.myModel.universityName;
|
|
var course = $scope.myModel.courseName;
|
|
var batch = $scope.myModel.batchName;
|
|
|
|
var dataForHallTicket = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getHallTicket/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
universityID : university,
|
|
courseID :course,
|
|
batchName:batch,
|
|
StudentIDs:$scope.selectedStudentsID,
|
|
centerName:$scope.myModel.centerName,
|
|
branchId:JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(dataForHallTicket).then(function (response) {
|
|
if (response.data.status==200 && response.data.hallTicketStatus) {
|
|
// console.log(response.data);
|
|
$scope.pdfModel.universityDetails = response.data.hallTicketData.UniversityDetails;
|
|
$scope.pdfModel.studentDetails = response.data.hallTicketData.studentDetails;
|
|
//console.log('API');
|
|
//console.log($scope.pdfModel.studentDetails.length);
|
|
//console.log(response.data.hallTicketData.studentDetails.length);
|
|
$scope.pdfModel.batchDetails = $scope.myModel.batchName;
|
|
$scope.pdfModel.courseDetails = $scope.myModel.courseName;
|
|
$scope.pdfModel.centerDetails = $scope.myModel.centerName;
|
|
$scope.pdfModel.semDataType =response.data.semDataType;
|
|
|
|
$scope.open($scope.pdfModel);
|
|
}
|
|
},function(error){ swal('No Records Found','',error); });
|
|
}
|
|
|
|
//Below Functions defined for Hall Ticket generation
|
|
|
|
|
|
$scope.FeesName="" ;
|
|
$scope.open = function (PDFdata) {
|
|
|
|
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'assets/views/hallticket/hallTicketPDF.html',
|
|
controller: 'HallTicketPDFCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
pdfitems: function () {
|
|
//return $scope.FeesName;
|
|
return PDFdata;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
// }
|
|
// generate pdf for student view
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
// Controller for Hallticket Modal PDF
|
|
app.controller('HallTicketPDFCtrl', ["$scope", "$modalInstance", "pdfitems", function ($scope, $modalInstance, pdfitems) {
|
|
|
|
// console.log(pdfitems);
|
|
$scope.localPdfUniverityDetails = pdfitems.universityDetails;
|
|
$scope.universityNamePDF = $scope.localPdfUniverityDetails[0].UniversityName;
|
|
$scope.universityAddressPDF = $scope.localPdfUniverityDetails[0].Address;
|
|
$scope.universityEmailPDF = $scope.localPdfUniverityDetails[0].EmailID;
|
|
$scope.batchNamePDF = pdfitems.batchDetails.BatchName;
|
|
$scope.courseNamePDF = pdfitems.courseDetails.CourseName;
|
|
$scope.centerNamePDF = pdfitems.centerDetails.CenterName+''+ pdfitems.centerDetails.CenterAddress;
|
|
$scope.semDataTypePDF = pdfitems.semDataType;
|
|
|
|
//console.log($scope.universityNamePDF+'-'+$scope.localPdfUniverityDetails.UniversityName);
|
|
$scope.localPdfStudentDetails = pdfitems.studentDetails;
|
|
|
|
$scope.printStudentDetails = function() {
|
|
|
|
|
|
|
|
|
|
|
|
angular.forEach($scope.localPdfStudentDetails,function(value,key){
|
|
|
|
var tempID = '#export'+value.StudentID;
|
|
var PDFName = value.Firstname+'-'+value.Lastname;
|
|
kendo.drawing.drawDOM( $(tempID),{paperSize: "A4",margin: { top: "1cm", bottom: "1cm" ,left: "3cm",right:"3cm"},scale: 0.8,height: 500} ).then(function(group) {
|
|
|
|
kendo.drawing.pdf.saveAs(group, PDFName+".pdf");
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
}]); |