139 lines
4.5 KiB
JavaScript
Executable File
139 lines
4.5 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", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
|
|
$scope.myModel = {
|
|
"studentName": "",
|
|
"mobileNumber": "",
|
|
"universityName":"",
|
|
"courseName":""
|
|
};
|
|
|
|
$rootScope.userType = JSON.parse(localStorage.getItem('localObj')).localType;
|
|
|
|
|
|
|
|
// 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 + 'getUniversityCourseForFees/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getUniv).then(function (response) {
|
|
if (response.data.status==200 && response.data.universityStatus) {
|
|
$scope.university=response.data.univerSityDetails;
|
|
|
|
|
|
} 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){
|
|
$scope.univId = "";
|
|
}
|
|
else{
|
|
$scope.univId = myModel.universityName.universityID;
|
|
}
|
|
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 {
|
|
var getStudent = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentListFees/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studentName: myModel.studentName,
|
|
mobileNumber: myModel.mobileNumber,
|
|
university: $scope.univId,
|
|
course:myModel.courseName,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
|
|
}
|
|
};
|
|
$http(getStudent).then(function (response) {
|
|
if (response.data.status==200 && response.data.studentStatus) {
|
|
$scope.studentInfo=response.data.details;
|
|
|
|
} else {
|
|
$scope.studentInfo="";
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
* get course subjects details
|
|
* created by kms
|
|
* */
|
|
$scope.getSubjectDetails = function (universityID,courseID) {
|
|
|
|
var getsubject = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getCourseSubjectDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
universityID : universityID,
|
|
courseID : courseID,
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getsubject).then(function (response) {
|
|
if (response.data.status==200 && response.data.universityStatus) {
|
|
$scope.university=response.data.univerSityDetails;
|
|
|
|
|
|
} else {
|
|
$scope.university="";
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
}]); |