673 lines
21 KiB
JavaScript
Executable File
673 lines
21 KiB
JavaScript
Executable File
'use strict';
|
|
/**
|
|
* controllers for ng-table
|
|
* Simple table with sorting and filtering on AngularJS
|
|
*/
|
|
app.controller('feesStatusCtrl', ["$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;
|
|
/*
|
|
* updateModel default value
|
|
* */
|
|
|
|
$scope.updateModel = {
|
|
"feesType": "",
|
|
"date": "",
|
|
"billNo": "",
|
|
"billAmount": "",
|
|
"paymentOn": "",
|
|
"internalComments":"",
|
|
"studComments":"",
|
|
"statusCode":""
|
|
|
|
};
|
|
|
|
/*
|
|
* set model
|
|
* */
|
|
$scope.setModel = {
|
|
"feesType": "",
|
|
|
|
|
|
};
|
|
/*
|
|
* get payment options
|
|
* */
|
|
$scope.paymentOptions = [
|
|
{
|
|
"paymentOn":"CASH"
|
|
},
|
|
{
|
|
"paymentOn":"CHEQUE"
|
|
},
|
|
{
|
|
"paymentOn":"NEFT"
|
|
},
|
|
{
|
|
"paymentOn":"CASH DEPOSIT"
|
|
}
|
|
|
|
];
|
|
// 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
|
|
}
|
|
};
|
|
$http(getStudent).then(function (response) {
|
|
if (response.data.status==200 && response.data.studentStatus) {
|
|
$scope.studentInfo=response.data.details;
|
|
|
|
} else {
|
|
$scope.studentInfo="";
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
* get update fees details for student
|
|
* created by kms
|
|
* */
|
|
$scope.editId=-1;
|
|
$scope.updateFees = function (p) {
|
|
$scope.viewId=-1
|
|
$scope.getStudentFeesStructure(p.ID,p.CourseID,p.StudentID);
|
|
$scope.editId=p.ID;
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* set fees for student
|
|
* */
|
|
$scope.viewId=-1;
|
|
$scope.setFees = function (p) {
|
|
$scope.editId=-1;
|
|
$scope.getStudentSetFees(p.ID,p.CourseID,p.StudentID);
|
|
$scope.viewId=p.ID;
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* update total fees amount after change value
|
|
* created by kms
|
|
* */
|
|
$scope.changeTotalFees = function (model) {
|
|
$scope.updateModel.billAmount = model.BalanceAmount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* save fees details for student
|
|
* created by kms
|
|
* */
|
|
$scope.saveFees = function (myModel, form,updateModel, loading) {
|
|
if(isNaN(updateModel.date)){
|
|
$scope.billDate = updateModel.date;
|
|
|
|
}
|
|
else{
|
|
$scope.getdate=new Date(updateModel.date).toDateString();
|
|
|
|
$scope.billDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy');
|
|
}
|
|
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].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
} else {
|
|
$scope.ldloading = {};
|
|
|
|
$scope.ldloading[loading.replace('-', '_')] = true;
|
|
|
|
|
|
var updateFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateFeesDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studID: myModel.StudentID,
|
|
courseID:myModel.CourseID,
|
|
courseAmount:updateModel.feesType.ActualFees,
|
|
feesID: updateModel.feesType.FeesID,
|
|
billNO: updateModel.billNo,
|
|
billDate: $scope.billDate,
|
|
billAmount:updateModel.billAmount,
|
|
modeOfPayment: updateModel.paymentOn.paymentOn,
|
|
commentsForStudent: updateModel.studComments,
|
|
internalComments: updateModel.internalComments,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
mobileNumber: myModel.MobileNumber,
|
|
studentName: myModel.Firstname,
|
|
university: myModel.UniversityName,
|
|
course: myModel.CourseName,
|
|
//statusCode: updateModel.statusCode,
|
|
requestedBranch : JSON.parse(localStorage.getItem('localObj')).localBranchID
|
|
|
|
|
|
}
|
|
};
|
|
$http(updateFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.paidStatus) {
|
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
|
swal("Success!", response.data.message, "success");
|
|
/*$scope.updateModel = {
|
|
"feesType": "",
|
|
"date": "",
|
|
"billNo": "",
|
|
"billAmount": "",
|
|
"paymentOn": "",
|
|
"internalComments":"",
|
|
"studComments":"",
|
|
"statusCode":""
|
|
|
|
};*/
|
|
form.$setPristine(true);
|
|
$scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
|
|
|
|
|
|
} else {
|
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
|
swal("Failed!", response.data.message, "error");
|
|
//$scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
}
|
|
|
|
});
|
|
}
|
|
};
|
|
/*
|
|
* set fees for student
|
|
* */
|
|
$scope.submitFeesForStudent = function (myModel, form,updateModel, loading,installment) {
|
|
|
|
|
|
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].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
} else {
|
|
if(isNaN(installment.date)){
|
|
$scope.pushDueDate1= $rootScope.lastInstallemtDate;
|
|
}
|
|
else{
|
|
$scope.convertGetDate1=new Date(installment.date).toDateString();
|
|
$scope.pushDueDate1 = $filter('date')(new Date($scope.convertGetDate1), 'dd-MM-yyyy');
|
|
|
|
}
|
|
if(installment.ID !='' && installment.ID !==null && installment.ID !=undefined){
|
|
$rootScope.updateMoreItems.push({
|
|
ID: installment.ID,
|
|
Name: installment.name,
|
|
Amount: installment.amount,
|
|
DueDate: $scope.pushDueDate1
|
|
});
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems.push({
|
|
ID: "",
|
|
Name: installment.name,
|
|
Amount: installment.amount,
|
|
DueDate: $scope.pushDueDate1
|
|
});
|
|
}
|
|
|
|
|
|
$scope.ldloading5 = {};
|
|
|
|
$scope.ldloading5[loading.replace('-', '_')] = true;
|
|
|
|
|
|
var updateFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'setFeesForStudent/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studID: myModel.StudentID,
|
|
courseID:myModel.CourseID,
|
|
courseAmount:updateModel.ActualFees,
|
|
feesID: updateModel.ID,
|
|
STFWR:updateModel.STFOrWR,
|
|
waiver: updateModel.Waiver,
|
|
other: updateModel.Others,
|
|
session: updateModel.SessionName,
|
|
rollNo: updateModel.RollNo,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
installmentItems:$rootScope.updateMoreItems
|
|
|
|
}
|
|
};
|
|
$http(updateFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.setStatus) {
|
|
$scope.ldloading5[loading.replace('-', '_')] = false;
|
|
swal("Success!", response.data.message, "success");
|
|
|
|
$scope.getStudentSetFees(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
/*$scope.setModel = {
|
|
"feesType": "",
|
|
};*/
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
$rootScope.updateMoreItems=[];
|
|
form.$setPristine(true);
|
|
|
|
} else {
|
|
$scope.ldloading5[loading.replace('-', '_')] = false;
|
|
swal("Failed!", response.data.message, "error");
|
|
$rootScope.updateMoreItems.splice($scope.updateMoreItems.length-1);
|
|
// $scope.getStudentSetFees(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
}
|
|
|
|
});
|
|
}
|
|
};
|
|
/*
|
|
* Global method for get student fees structure
|
|
* created by kms
|
|
* */
|
|
$scope.studentFeesInfo="";
|
|
$scope.getStudentFeesStructure = function(ID,courseID,studeID){
|
|
$scope.updateModel = {
|
|
"feesType": "",
|
|
|
|
};
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
var getFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentFeesStructure/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
ID:ID,
|
|
courseID: courseID,
|
|
studentID: studeID,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.feesStatus) {
|
|
$scope.studentFeesInfo=response.data.feesDetails;
|
|
$scope.existStudentFeesDetails = response.data.getExistStudentFeesDetails;
|
|
$scope.getFeesUpdateStatus = response.data.getFeesUpdateStatus;
|
|
|
|
|
|
} else {
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
swal("Warning!", response.data.message, "warning");
|
|
$scope.editId=-1;
|
|
|
|
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
/*
|
|
* get student set fees details
|
|
* */
|
|
$scope.feesStructureInfo="";
|
|
$scope.getStudentSetFees = function (ID,courseID,studeID) {
|
|
$scope.feesStructureInfo="";
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
$rootScope.lastInstallemtDate="";
|
|
$rootScope.updateMoreItems=[];
|
|
var setFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentFeesAssign/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
ID:ID,
|
|
courseID: courseID,
|
|
studentID: studeID,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(setFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.feesStatus) {
|
|
$scope.feesStructureInfo=response.data.feesDetails;
|
|
$scope.setModel = {
|
|
"feesType": "",
|
|
|
|
};
|
|
|
|
} else {
|
|
$scope.feesStructureInfo="";
|
|
$scope.setModel = {
|
|
"feesType": "",
|
|
};
|
|
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
$scope.cancel = function () {
|
|
$scope.editId=-1;
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
|
|
$scope.viewId=-1;
|
|
}
|
|
/*
|
|
* get add more installment array
|
|
* created by kms
|
|
* */
|
|
|
|
$scope.myModelInstallemt = {
|
|
"ID":"",
|
|
"amount":"",
|
|
"name":"",
|
|
"date":"",
|
|
|
|
|
|
};
|
|
$rootScope.updateMoreItems=[];
|
|
$rootScope.clickMoreItems = function (model,form,setModel) {
|
|
$scope.convertGetDate='';
|
|
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].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
}
|
|
|
|
else {
|
|
|
|
if(isNaN(model.date)){
|
|
$scope.pushDueDate= $rootScope.lastInstallemtDate;
|
|
}
|
|
else{
|
|
$scope.convertGetDate=new Date(model.date).toDateString();
|
|
$scope.pushDueDate = $filter('date')(new Date($scope.convertGetDate), 'dd-MM-yyyy');
|
|
|
|
}
|
|
if(model.ID !='' && model.ID !==null && model.ID !=undefined){
|
|
$rootScope.updateMoreItems.push({
|
|
ID:model.ID,
|
|
Name: model.name,
|
|
Amount: model.amount,
|
|
DueDate: $scope.pushDueDate
|
|
});
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems.push({
|
|
ID:"",
|
|
Name: model.name,
|
|
Amount: model.amount,
|
|
DueDate: $scope.pushDueDate
|
|
});
|
|
|
|
}
|
|
|
|
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
}
|
|
}
|
|
/*
|
|
* change installment values
|
|
* */
|
|
$scope.changeInstallemt = function (model,form) {
|
|
$rootScope.updateMoreItems=[];
|
|
|
|
if(model.InstallmentDetails != ''){
|
|
$scope.myModelInstallemt.ID=model.InstallmentDetails[model.InstallmentDetails.length-1].ID;
|
|
|
|
$scope.myModelInstallemt.name=model.InstallmentDetails[model.InstallmentDetails.length-1].Name;
|
|
$scope.myModelInstallemt.amount=model.InstallmentDetails[model.InstallmentDetails.length-1].Amount;
|
|
$scope.myModelInstallemt.date=model.InstallmentDetails[model.InstallmentDetails.length-1].DueDate;
|
|
$rootScope.lastInstallemtDate = $scope.myModelInstallemt.date;
|
|
for(var i=0; i < model.InstallmentDetails.length-1; i++){
|
|
$rootScope.updateMoreItems.push(model.InstallmentDetails[i]);
|
|
|
|
}
|
|
}
|
|
else{
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
$rootScope.lastInstallemtDate="";
|
|
}
|
|
|
|
form.$setPristine(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}]);
|
|
|
|
/*modal controller
|
|
* */
|
|
app.controller('ModalDemoCtrl', ["$scope", "$modal", "$log", function ($scope, $modal, $log) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Click to View Bill Details';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.FeesName="" ;
|
|
$scope.open = function (values) {
|
|
$scope.FeesName = values;
|
|
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'myModalContent.html',
|
|
controller: 'ModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.FeesName;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
|
|
|
|
}]);
|
|
|
|
// 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');
|
|
};
|
|
//show hide function for pdf design
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
$scope.ShowHide = function (pdfValue) {
|
|
$scope.showButton = true;
|
|
$scope.billNo = pdfValue.BillNO;
|
|
$scope.paymentType=pdfValue.ModeOfPayment;
|
|
$scope.billDate=pdfValue.BillDate;
|
|
$scope.amountInWords = WordsService.convertNumberToWords(pdfValue.BillAmount);
|
|
$scope.billAmount = pdfValue.BillAmount;
|
|
$scope.branchName = pdfValue.BranchName;
|
|
|
|
|
|
}
|
|
|
|
$scope.mouseLeave = function(){
|
|
$scope.showButton = false;
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
}
|
|
|
|
}]);
|
|
app.directive('visible', function() {
|
|
|
|
return {
|
|
restrict: 'A',
|
|
|
|
link: function(scope, element, attributes) {
|
|
scope.$watch(attributes.visible, function(value){
|
|
element.css('visibility', value ? 'visible' : 'hidden');
|
|
});
|
|
}
|
|
};
|
|
}) |