625 lines
22 KiB
JavaScript
625 lines
22 KiB
JavaScript
'use strict';
|
|
/**
|
|
* controllers for ng-table
|
|
* Simple table with sorting and filtering on AngularJS
|
|
*/
|
|
app.controller('univFormPaymentCtrl', ["$scope","$rootScope","$filter", "ngTableParams", "API_POINTS", "$sessionStorage", "$http", "$state", "$modal", "$log", "SweetAlert", "$timeout", function ($scope,$rootScope, $filter, ngTableParams, apiPoint, $sessionStorage, $http, $state, $modal, SweetAlert, $log, $timeout) {
|
|
// ng-model object for payment search
|
|
$scope.paymentVerficationModel= {
|
|
'universitySearch':"",
|
|
'fromDate':"",
|
|
'toDate':"",
|
|
};
|
|
// load when html page load
|
|
var localDetail = JSON.parse(sessionStorage.getItem('localObj'));
|
|
|
|
$scope.init = function () {
|
|
|
|
if (localDetail != null) {
|
|
if (localDetail.localType === 'R004' || localDetail.localType === 'R003' || localDetail.localType === 'R002') {
|
|
$scope.getPaymentUnivSearchData();
|
|
} else {
|
|
sessionStorage.removeItem('localObj');
|
|
$state.go('login.signin');
|
|
}
|
|
} else {
|
|
$state.go('login.signin');
|
|
}
|
|
}
|
|
/*
|
|
* get university details for search
|
|
* cretaed by kms
|
|
* */
|
|
$scope.universityPaymentSearchData=[];
|
|
$scope.getPaymentUnivSearchData = function () {
|
|
var paymentSearch = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getUnivCourseFromFileDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetail
|
|
}
|
|
};
|
|
$http(paymentSearch).then(function (response) {
|
|
if (response.data.status) {
|
|
$scope.universityPaymentSearchData = response.data.details;
|
|
} else {
|
|
$scope.universityPaymentSearchData="";
|
|
}
|
|
});
|
|
}
|
|
/*
|
|
* add payment details
|
|
* created by kms
|
|
* */
|
|
$rootScope.addPaymentModel = {
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'university':[]
|
|
};
|
|
$scope.addUniversityPaymentModal = function (values) {
|
|
$rootScope.addError="";
|
|
$rootScope.addPaymentModel.university=angular.fromJson(values.universitySearch);
|
|
$rootScope.paymentModal = $modal.open({
|
|
templateUrl: 'assets/views/student/addUniversityPaymentModal.html',
|
|
// controller: 'univFormPaymentCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.univPayDetails;
|
|
}
|
|
}
|
|
});
|
|
|
|
$rootScope.paymentModal.result.then(function (selectedItem) {
|
|
}, function () {
|
|
$rootScope.paymentModal.close();
|
|
$rootScope.addPaymentModel = {
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'university':[]
|
|
};
|
|
});
|
|
};
|
|
/*
|
|
* add university payment details
|
|
* created by kms
|
|
* */
|
|
$rootScope.addError="";
|
|
$rootScope.addUnivPayment = function (form,addDetails) {
|
|
$rootScope.addError="";
|
|
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 getdate=new Date(addDetails.date).toDateString();
|
|
$scope.univPayData = {
|
|
"universityCode":addDetails.university.univCode,
|
|
"universityName":addDetails.university.univName,
|
|
"billNo":addDetails.billNo,
|
|
"billAmount":addDetails.billAmount,
|
|
"date":$filter('date')(new Date(getdate), 'yyyy-MM-dd'),
|
|
"receiptNo":addDetails.receiptNo,
|
|
"comments":addDetails.comments,
|
|
}
|
|
|
|
var submitPayment = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'addUniversityPaymentDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
localDetails: localDetail,
|
|
details: $scope.univPayData,
|
|
}
|
|
};
|
|
$http(submitPayment).then(function (response) {
|
|
if (response.data.status==true) {
|
|
swal(" ", response.data.message, "success");
|
|
$rootScope.paymentModal.close();
|
|
$rootScope.addPaymentModel = {
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'university':[]
|
|
};
|
|
$rootScope.getPaymentVerificationDetails($scope.paymentVerficationModel);
|
|
|
|
|
|
} else {
|
|
$rootScope.addError=response.data.message;
|
|
$timeout(function () {
|
|
$rootScope.addError="";
|
|
}, 4000);
|
|
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
/*
|
|
* cancel add modal
|
|
* */
|
|
$rootScope.cancelAddPaymentModal=function () {
|
|
$rootScope.paymentModal.close();
|
|
$rootScope.addPaymentModel = {
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'university':[]
|
|
};
|
|
$rootScope.addError="";
|
|
};
|
|
/*
|
|
* update university payment details
|
|
* created by kms
|
|
* */
|
|
$rootScope.updatePaymentModel = {
|
|
'ID':"",
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'universityCode':"",
|
|
'universityName':"",
|
|
'paymentID':""
|
|
|
|
};
|
|
$rootScope.viewPayment = function (values) {
|
|
var updateDate=new Date(values.ApprovedDate).toDateString();
|
|
$rootScope.updateError="";
|
|
$rootScope.updatePaymentModel = {
|
|
'ID': values.ID,
|
|
'billNo':values.BillNo,
|
|
'date':$filter('date')(new Date(updateDate), 'yyyy-MM-dd'),
|
|
'billAmount':values.DebitAmount,
|
|
'receiptNo':values.ReceiptNo,
|
|
'comments':values.Remarks,
|
|
'universityCode':values.UniversityCode,
|
|
'universityName':values.UniversityName,
|
|
'paymentID':values.PaymentID
|
|
};
|
|
$rootScope.updatePaymentModal = $modal.open({
|
|
templateUrl: 'assets/views/student/updateUniversityPaymentModal.html',
|
|
// controller: 'univFormPaymentCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $rootScope.updatePaymentModel;
|
|
}
|
|
}
|
|
});
|
|
|
|
$rootScope.updatePaymentModal.result.then(function (selectedItem) {
|
|
}, function () {
|
|
$rootScope.updatePaymentModal.close();
|
|
$rootScope.updatePaymentModel = {
|
|
'ID':"",
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'universityCode':"",
|
|
'universityName':"",
|
|
'paymentID':""
|
|
|
|
};
|
|
});
|
|
|
|
}
|
|
|
|
$rootScope.updateError="";
|
|
$rootScope.updateUnivPayment = function (form,updateDetails) {
|
|
$rootScope.updateError="";
|
|
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 changeDate;
|
|
if(angular.isObject(updateDetails.date)){
|
|
var saveDate=new Date(updateDetails.date).toDateString();
|
|
changeDate=$filter('date')(new Date(saveDate), 'yyyy-MM-dd');
|
|
}
|
|
else{
|
|
changeDate=updateDetails.date;
|
|
|
|
}
|
|
$scope.univUpdateData = {
|
|
"universityCode":updateDetails.universityCode,
|
|
"universityName":updateDetails.universityName,
|
|
"billNo":updateDetails.billNo,
|
|
"billAmount":updateDetails.billAmount,
|
|
"date":changeDate,
|
|
"receiptNo":updateDetails.receiptNo,
|
|
"comments":updateDetails.comments,
|
|
"ID":updateDetails.ID,
|
|
"paymentID":updateDetails.paymentID,
|
|
}
|
|
|
|
var updatePayment = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateUniversityPaymentDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
localDetails: localDetail,
|
|
details: $scope.univUpdateData,
|
|
}
|
|
};
|
|
$http(updatePayment).then(function (response) {
|
|
if (response.data.status==true) {
|
|
swal(" ", response.data.message, "success");
|
|
$rootScope.updatePaymentModal.close();
|
|
$rootScope.updatePaymentModel = {
|
|
'ID':"",
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'universityCode':"",
|
|
'universityName':"",
|
|
'paymentID':""
|
|
|
|
};
|
|
$rootScope.getPaymentVerificationDetails($scope.paymentVerficationModel);
|
|
|
|
|
|
} else {
|
|
$rootScope.updateError=response.data.message;
|
|
$timeout(function () {
|
|
$rootScope.updateError="";
|
|
}, 4000);
|
|
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
* get payment details
|
|
* cretaed by kms
|
|
* */
|
|
$scope.paymentVerificationData="";
|
|
$scope.emptyList=true;
|
|
$scope.searchLoader = false;
|
|
$scope.paymentDataForFilter="";
|
|
|
|
$rootScope.getPaymentVerificationDetails = function (searchData) {
|
|
$scope.paymentVerificationData="";
|
|
$scope.emptyList=true;
|
|
$scope.searchLoader = true;
|
|
$scope.paymentDataForFilter="";
|
|
var paymentVerification = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'paymentVerficationDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
localData: localDetail,
|
|
universityID: angular.fromJson(searchData.universitySearch).univCode,
|
|
universityName: angular.fromJson(searchData.universitySearch).univName,
|
|
}
|
|
};
|
|
$http(paymentVerification).then(function (response) {
|
|
if (response.data.status) {
|
|
$scope.searchLoader = false;
|
|
$scope.emptyList=false;
|
|
$scope.paymentVerificationData=response.data.details;
|
|
|
|
var tagMap = $scope.paymentVerificationData.reduce(function(map, tag,key) {
|
|
if(map.RunningBalance==undefined){
|
|
map['RunningBalance'] = parseInt(tag.CreditAmount)-parseInt(tag.DebitAmount);
|
|
tag['RunningBalance']=parseInt(tag.CreditAmount)-parseInt(tag.DebitAmount);
|
|
if(tag.TypeID==0){
|
|
tag['FormID']="";
|
|
tag['EnrolmentNo']="";
|
|
}
|
|
else{
|
|
tag['BillNo']="";
|
|
}
|
|
|
|
}
|
|
else{
|
|
if(parseInt(tag.DebitAmount)<=0){
|
|
map['RunningBalance'] = parseInt(map.RunningBalance)+parseInt(tag.CreditAmount);
|
|
tag['RunningBalance']=parseInt(map.RunningBalance);
|
|
if(tag.TypeID==0){
|
|
tag['FormID']="";
|
|
tag['EnrolmentNo']="";
|
|
}
|
|
else{
|
|
tag['BillNo']="";
|
|
}
|
|
}
|
|
else{
|
|
map['RunningBalance'] = parseInt(map.RunningBalance)-parseInt(tag.DebitAmount);
|
|
tag['RunningBalance']=parseInt(map.RunningBalance);
|
|
if(tag.TypeID==0){
|
|
tag['FormID']="";
|
|
tag['EnrolmentNo']="";
|
|
}
|
|
else{
|
|
tag['BillNo']="";
|
|
}
|
|
}
|
|
|
|
}
|
|
return map;
|
|
}, {});
|
|
$scope.paymentDataForFilter=$scope.paymentVerificationData;
|
|
|
|
// serach date format changes
|
|
if(searchData.fromDate !='' && searchData.fromDate !=null && searchData.fromDate !=undefined){
|
|
$scope.paymentVerficationModel.fromDate=$filter('date')(new Date(searchData.fromDate), 'yyyy-MM-dd');
|
|
}
|
|
if(searchData.toDate !='' && searchData.toDate !=null && searchData.toDate !=undefined){
|
|
$scope.paymentVerficationModel.toDate=$filter('date')(new Date(searchData.toDate), 'yyyy-MM-dd');
|
|
}
|
|
|
|
} else {
|
|
$scope.searchLoader = false;
|
|
$scope.emptyList=true;
|
|
$scope.paymentVerificationData=response.data.details;
|
|
}
|
|
});
|
|
|
|
};
|
|
/*
|
|
* filter payment details based on date
|
|
* created by kms
|
|
* */
|
|
$scope.$watchCollection('paymentVerficationModel', function(current,old){
|
|
$scope.paymentVerificationData=[];
|
|
if((current.fromDate!='' && current.fromDate!=null && current.fromDate!=undefined) && (current.toDate=='' || current.toDate==null || current.toDate==undefined)){
|
|
var searchFromDate1=new Date($scope.paymentVerficationModel.fromDate).toDateString();
|
|
$scope.from=$filter('date')(new Date(searchFromDate1), 'yyyy-MM-dd');
|
|
angular.forEach($scope.paymentDataForFilter,function (values,key) {
|
|
if($scope.from==values.ApprovedDate){
|
|
$scope.paymentVerificationData.push(values);
|
|
}
|
|
});
|
|
}
|
|
else if((current.fromDate!='' && current.fromDate!=null && current.fromDate!=undefined) && (current.toDate!='' && current.toDate!=null && current.toDate!=undefined)){
|
|
var searchFromDate1=new Date($scope.paymentVerficationModel.fromDate).toDateString();
|
|
$scope.from=$filter('date')(new Date(searchFromDate1), 'yyyy-MM-dd');
|
|
var searchToDate2=new Date($scope.paymentVerficationModel.toDate).toDateString();
|
|
$scope.to=$filter('date')(new Date(searchToDate2), 'yyyy-MM-dd');
|
|
angular.forEach($scope.paymentDataForFilter,function (values,key) {
|
|
if($scope.from<=values.ApprovedDate && values.ApprovedDate <=$scope.to){
|
|
$scope.paymentVerificationData.push(values);
|
|
}
|
|
});
|
|
}
|
|
else{
|
|
$scope.paymentVerficationModel.toDate="";
|
|
$scope.paymentVerificationData=$scope.paymentDataForFilter;
|
|
}
|
|
});
|
|
|
|
/*
|
|
* cancel update modal
|
|
* */
|
|
$rootScope.cancelUpdatePaymentModal=function () {
|
|
$rootScope.updatePaymentModal.close();
|
|
/* $rootScope.updatePaymentModel = {
|
|
'ID':"",
|
|
'billNo':"",
|
|
'date':"",
|
|
'billAmount':"",
|
|
'receiptNo':"",
|
|
'comments':"",
|
|
'universityCode':"",
|
|
'universityName':"",
|
|
'paymentID':""
|
|
|
|
};*/
|
|
$rootScope.updateError="";
|
|
};
|
|
//Export excel
|
|
var mystyle1 = {
|
|
sheetid: 'University Payment Details',
|
|
headers: true,
|
|
caption: {
|
|
title:'UNIVERSITY PAYMENT DETAILS',
|
|
width: '300px',
|
|
style:'font-size:50px;'
|
|
},
|
|
// style:'background:#00FF00',
|
|
column: {
|
|
style:'font-size:16px'
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.exportData = function () {
|
|
alasql('SELECT FormID,EnrolmentNo as EnrollmentID,BillNo as BillNo,FormatDate as Date,CAST(CreditAmount as NUMBER) as Payable,CAST(DebitAmount as NUMBER) as Paid,CAST(RunningBalance as NUMBER) as Balance INTO XLS("UniversityPaymentDetails.xls",?) FROM ?',[mystyle1,$scope.paymentVerificationData]);
|
|
};
|
|
//End of export excel
|
|
|
|
|
|
}]);
|
|
/*modal controller
|
|
* */
|
|
app.controller('studentModalDemoCtrl', ["$scope", "$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope, $rootScope, $modal, $log,apiPoint,$http) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Student View';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.open = function (studentDetails) {
|
|
// get student view details
|
|
var getcourse = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentBasicInfo/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy :studentDetails.MobileNumber,
|
|
requestedFrom: 4,
|
|
branchCode : JSON.parse(sessionStorage.getItem('localObj')).localBranchID
|
|
|
|
}
|
|
};
|
|
$http(getcourse).then(function (response) {
|
|
|
|
if (response.data.status == 200 && response.data.studentStatus== true) {
|
|
$scope.courseEditLoading = false;
|
|
// $scope.studentDetails = response.data.studentDetails;
|
|
$scope.studentDetails = response.data;
|
|
// $scope.courseDetails = response.data.courseDetails;
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentDetailsModal.html',
|
|
controller: 'ModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.studentDetails;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
modalInstance.close();
|
|
});
|
|
|
|
} else {
|
|
swal("Failed!", "This student is not registerd", "warning");
|
|
$scope.courseEditLoading = false;
|
|
$scope.studentDetails = "";
|
|
$scope.courseDetails = "";
|
|
|
|
}
|
|
});
|
|
};
|
|
$scope.open1 = function (values,type) {
|
|
|
|
var modalInstance1 = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPaymentModal.html',
|
|
controller: 'ModalInstanceCtrl1',
|
|
// size: size,
|
|
resolve: {
|
|
items1: function () {
|
|
var myvalues =
|
|
{
|
|
"values":values,
|
|
"type":type
|
|
};
|
|
return myvalues;
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
modalInstance1.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
modalInstance1.close();
|
|
});
|
|
};
|
|
$scope.printStudentDetails = function (details) {
|
|
$rootScope.pdfItems = details;
|
|
|
|
var printInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPdf.html',
|
|
controller: 'studentModalDemoCtrl',
|
|
});
|
|
};
|
|
// generate pdf for student view
|
|
$scope.export = function(getName) {
|
|
kendo.drawing.drawDOM($("#exportthis")).then(function(group) {
|
|
kendo.drawing.pdf.saveAs(group, getName+".pdf");
|
|
});
|
|
}
|
|
|
|
}]);
|
|
// 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');
|
|
};
|
|
}]);
|
|
app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1","WordsService", function ($scope, $modalInstance, items1,WordsService) {
|
|
|
|
$scope.items1 = items1.values;
|
|
$scope.selectedtype = items1.type;
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
}]); |