apollodec/Apollo/assets/js/controllers/studentUnivFormIdFeeDetailsCtrl.js
2018-09-08 18:36:25 +05:30

671 lines
21 KiB
JavaScript

'use strict';
/**
* controllers for ng-table
* Simple table with sorting and filtering on AngularJS
* kdk
*/
app.controller('studentUnivFormIdFeeDetailsCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$http", "API_POINTS", "$state", '$rootScope', '$cookies', 'md5', 'ipCookie', '$timeout', '$window', "flowFactory", "$interval", 'SweetAlert', function ($scope, toaster, $filter, ngTableParams, $http, apiPoint, $state, $rootScope, $cookies, md5, ipCookie, $timeout, $window, flowFactory, $interval, SweetAlert) {
/**
* student university fee details compare
*/
// get local client details
var localDetail = JSON.parse(localStorage.getItem('localObj'));
var localDetails = ipCookie('cookiechk');
// load when html page load
$scope.init = function () {
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE == 'R005')) {
console.log("if");
} else {
if (logcheck != null && LOCALTYPE != 'R001') {
console.log("else if");
$state.go('app.dashboard');
} else {
console.log("else else");
window.localStorage.clear();
$state.go('login.signin');
}
}
if (localDetail != null) {
if (localDetails.localType === 'R004') {
// $scope.getUniversityList();
$scope.getUniversitySearchList();
$scope.getUniveesityListFromApp();
} else {
ipCookie.remove('cookiechk');
$window.localStorage.clear();
$state.go('login.signin');
}
} else {
}
}
$scope.universityData = '';
$scope.getUniveesityListFromApp = function () {
var empListreq = {
method: 'POST',
url: apiPoint.url + 'getUniversityCodeForFormDetailsGet/',
headers: {
'Content-Type': 'application/json'
},
data: {
data: localDetails
}
};
$http(empListreq).then(function (response) {
if (response.data.univList) {
$scope.universityData = response.data.university_details;
} else {
}
});
}
// get University List
$scope.universitySearchData = '';
$scope.getUniversitySearchList = function () {
var empListreq = {
method: 'POST',
url: apiPoint.url + 'getUnivCourseFromFileDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
data: localDetails
}
};
$http(empListreq).then(function (response) {
if (response.data.status) {
$scope.universitySearchData = response.data.details;
} else {
$scope.universitySearchData = "";
}
});
};
$scope.semDetails=["1","2","3","4","5","6","7","8"];
$scope.searchData = {
"University": "",
"Course": "",
"Sem": ""
}
$scope.myUnivSearch = "";
$scope.courseData = "";
$scope.getUniveId = function (univ) {
$scope.sessionData = "";
if (univ === '') {
$scope.myUnivSearch = "";
$scope.courseData = "";
$scope.searchData.University = '';
$scope.searchData.Course = '';
} else {
let name = JSON.parse(univ);
$scope.searchData.University = name.univCode;
$scope.courseData = name.univCourseDetails;
}
};
//For session dropdown
$scope.filterSessionDetails = "";
$scope.$watch('searchData.University', function (newValue, oldValue) {
if (newValue == undefined || newValue == '') {
$scope.filterSessionDetails = "";
}
else {
if (angular.isString(newValue)) {
$scope.filterSessionDetails = angular.fromJson(newValue);
}
}
});
$scope.Searchloader = false;
$scope.studentData = false;
$scope.onSubmit = function () {
$scope.Searchloader = true;
if ($scope.searchData.University !== '' && $scope.searchData.Course !== '') {
$scope.Searchloader = true;
var empListreq = {
method: 'POST',
url: apiPoint.url + 'getStudentUnivFormIdFeeDatailsList/',
headers: {
'Content-Type': 'application/json'
},
data: {
data: localDetails,
search: $scope.searchData,
}
};
$http(empListreq).then(function (response) {
if (response.data.formTypeStatus) {
$scope.Searchloader = false;
$scope.studentData = true;
$scope.data = response.data.studentFeeCompareDetails;
$scope.studentListLength = $scope.data.length;
// $scope.statusMessage = $scope.data.message;
} else {
$scope.Searchloader = false;
$scope.studentData = false;
$scope.statusMessage = $scope.data.message;
}
});
} else {
}
}
$scope.myObj = {
// "color" : "green",
"font-size" : "inherit"
}
$scope.myObjErr = {
"text-decoration": "underline",
"text-decoration-color": "red",
"font-size" : "inherit"
}
$scope.editId = -1;
$scope.setEditId = function (id) {
$scope.editId = id;
}
/*upload model*/
$scope.uploadModel = {
university: "",
uploadFor: "",
}
/*
* upload options json
* */
$scope.uploadOptions = [{
id: 1,
name: 'Received Enrolment From University',
},
{
id: 2,
name: 'Received Fees From University'
},
];
/*
watch upload model for enable upload options
*/
$scope.showFile = "1";
// $scope.$watchCollection('uploadModel', function (newValue, oldValue) {
// if (newValue.university != '' && newValue.university != null) {
// $scope.showFile = "1";
// }
// else {
// $scope.showFile = "0";
// }
// });
$scope.extractFormIDDetails = "";
$scope.readXlsxFormDetails = function (workbook) {
$scope.extractFormIDDetails = "";
/* DO SOMETHING WITH workbook HERE */
for (var sheetName in workbook.Sheets) {
var jsonData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]);
if (jsonData.length != 0) {
$scope.extractFormIDDetails = jsonData;
}
}
$scope.error = function (e) {
/* DO SOMETHING WHEN ERROR IS THROWN */
//console.log(e);
}
}
$scope.formUploadUnivSelectID = {
'univCode': ''
};
$scope.receiveFormIdFeeDetails = function (details) {
console.log(details);
var updateUniversityEnrolment = {
method: 'POST',
url: apiPoint.url + 'insertFormIdUnivFeeDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details: details,
univ: $scope.formUploadUnivSelectID
}
};
$http(updateUniversityEnrolment).then(function (response) {
if (response.data.stuFeeList == true) {
swal("", "Updated Successfully", "success");
$state.go($state.current, {}, { reload: true });
} else {
swal("", "Failed", "error");
}
});
}
$scope.popupLoad = false;
$scope.popupLoadData = false;
$scope.formPaymentDetails = "";
// Fee compare details get
$scope.getFeeCompareDetails = function (formId, enrolmentId) {
$scope.popupLoadData = false;
$scope.formPaymentDetails = "";
$scope.popupLoad = true;
var getFeeCompareDetailsList = {
method: 'POST',
url: apiPoint.url + 'formIDFeeCompareDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
formId: formId,
enrolmentId: enrolmentId
}
};
$http(getFeeCompareDetailsList).then(function (response) {
if (response.data.status == true) {
$scope.popupLoad = false;
$scope.popupLoadData = true;
$scope.formPaymentDetails = response.data;
} else {
$scope.popupLoad = false;
$scope.popupLoadData = true;
$scope.formPaymentDetails = response.data;
}
});
}
$scope.formIdMissMatchUnivSelectID = {
'univCode': ''
};
$scope.unMatchedLoadingStatus = false;
// Get unmached details
$scope.getUnmatchedRecord = function (ss) {
$scope.unMatchedRecordDetails = '';
$scope.unMatchedNoRecordFound = false;
$scope.unMatchedLoadingStatus = true;
var getFeeCompareDetailsList = {
method: 'POST',
url: apiPoint.url + 'getUnmatchedFormIdFeesDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
getDetailsFor: $scope.formIdMissMatchUnivSelectID
}
};
$http(getFeeCompareDetailsList).then(function (response) {
if (response.data.unMatchedRecordStatus == true) {
$scope.unMatchedLoadingStatus = false;
$scope.unMatchedNoRecordFound = false;
$scope.unMatchedRecordDetails = response.data.unMatchedRecordDetails;
$scope.unMatchedRecordDetailsType = response.data.unMatchedRecordFor;
} else {
$scope.unMatchedLoadingStatus = false;
$scope.unMatchedNoRecordFound = true;
$scope.unMatchedRecordDetails = response.data.unMatchedRecordDetails;
}
});
}
// get subtab details for the formid fee details get form the university
$scope.subTabActive= function(tab){
if( tab == 'subTabactive2'){
getDraftFormIdDetails();
}
}
$scope.draftManualEntryDetails = {
'FormID': '',
'FormType': 'NEW',
'CentreCode': '',
'Session':'',
'Year':'',
'Semester':'',
'Student_Name':'',
'Father_Name':'',
'CourseCode':'',
'ActualCourseFee':'0',
'CourseFee':'0',
'ExamFee': '0',
'EnrollmentFee': '0',
'ProspectusFee': '0',
'ReRegFee': '0',
'CreditTransferFee': '0',
'LateralEntryFee': '0',
'DualSpclFee': '0',
'OtherFee': '0',
'NRIFEE':'0',
'ProvisionalFee': '0',
'MigrationFee': '0',
'UrgentResultDMCFee': '0',
'AdditionalFee': '0',
'Amount': '0'
}
$scope.draftListDetails = '';
$scope.draftListDetailsNoRecordFound = false;
$scope.draftListDetailsLoading = false;
// get draft form id details
function getDraftFormIdDetails(){
$scope.draftListDetailsLoading = true;
$scope.draftListDetailsNoRecordFound = false;
$scope.draftListDetails = '';
var getFormIdDraftDetailsList = {
method: 'POST',
url: apiPoint.url + 'getForFormIdDraftDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail
}
};
$http(getFormIdDraftDetailsList).then(function (response) {
if (response.data.draftStatus == true) {
$scope.draftListDetailsLoading = false;
$scope.draftListDetails = response.data.draftDetails;
$scope.draftListDetailsNoRecordFound = false;
} else {
$scope.draftListDetailsLoading = false;
$scope.draftListDetailsNoRecordFound = true;
}
});
}
// manual entry details add
$scope.addManualData = function() {
alert(JSON.stringify($scope.draftManualEntryDetails));
var addDraftDetailsList = {
method: 'POST',
url: apiPoint.url + 'addForFormIdDraftDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details : $scope.draftManualEntryDetails,
univ: $scope.formUploadUnivSelectID
}
};
$http(addDraftDetailsList).then(function (response) {
if (response.data.draftStatus == true) {
swal("", response.data.draftDetailsMessagae, "success");
getDraftFormIdDetails();
getEmptycall();
} else {
swal("", response.data.draftDetailsMessagae, "warning");
getDraftFormIdDetails();
getEmptycall();
}
});
}
function getEmptycall(){
$scope.draftManualEntryDetails = {
'FormID': '',
'FormType': 'NEW',
'CentreCode': '',
'Session':'',
'Year':'',
'Semester':'',
'Student_Name':'',
'Father_Name':'',
'CourseCode':'',
'ActualCourseFee':'0',
'CourseFee':'0',
'ExamFee': '0',
'EnrollmentFee': '0',
'ProspectusFee': '0',
'ReRegFee': '0',
'CreditTransferFee': '0',
'LateralEntryFee': '0',
'DualSpclFee': '0',
'OtherFee': '0',
'NRIFEE':'0',
'ProvisionalFee': '0',
'MigrationFee': '0',
'UrgentResultDMCFee': '0',
'AdditionalFee': '0',
'Amount': '0'
}
return 0;
}
$scope.addToList = function(id){
swal({
title: "Are you sure?",
text: "You Want to Add this Record to List!",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes',
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm){
var selectedItems = [];
function getUpdateDetails(id) {
this.ID = id;
this.DraftStatus = 0;
}
let itemGetID = new getUpdateDetails(id);
selectedItems.push(itemGetID);
var draftMoveToList = {
method: 'POST',
url: apiPoint.url + 'draftMovetoList/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details : selectedItems
}
};
$http(draftMoveToList).then(function (response) {
if (response.data.draftStatus == true) {
// alert();
swal("", response.data.draftDetailsMessagae, "success");
getDraftFormIdDetails();
} else {
swal("", response.data.draftDetailsMessagae, "warning");
}});
} else {
swal("Cancelled", "Your record not added to list :)", "error");
}
});
}
$scope.editId = -1;
$scope.leader = {};
$scope.editList = function(details, d){
$scope.leader = {};
angular.copy(d, $scope.leader);
$scope.editId = details;
}
$scope.updateFeeIDDetails = function(id, p){
var editDraftMoveToList = {
method: 'POST',
url: apiPoint.url + 'editDraftFormIdFeesDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details : p,
detailsID: id
}
};
$http(editDraftMoveToList).then(function (response) {
if (response.data.updatedraftStatus == true) {
// alert();
swal("", response.data.updatedraftDetailsMessagae, "success");
getDraftFormIdDetails();
$scope.editId = -1;
$scope.leader = {};
} else {
swal("", response.data.updatedraftDetailsMessagae, "warning");
}});
}
$scope.statusUpdateEditId = -1;
$scope.statusUpdate = function(id){
$scope.statusUpdateEditId = id;
$scope.statusUpdateFormIdDetails = {
"Status": "",
"Comments": ""
}
}
$scope.StatusListDetails = '';
$scope.getFormIdDetailsStatusListLoading = false;
$scope.getFormIdDetailsStatusList = function(id){
$scope.getFormIdDetailsStatusListLoading = true;
var getFormIdDetailsStatusList = {
method: 'POST',
url: apiPoint.url + 'getFormIdDetailsStatusUpdateList/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
detailsID : id
}
};
$http(getFormIdDetailsStatusList).then(function (response) {
if (response.data.formIdstatusListStatus == true) {
$scope.getFormIdDetailsStatusListLoading = false;
$scope.StatusListDetails = response.data.formIdstatusListDetails;
} else {
$scope.getFormIdDetailsStatusListLoading = false;
$scope.StatusListDetails = response.data.formIdstatusListDetails;
$scope.StatusListDetailsApiMessage = response.data.formIdstatusListMessagae;
}});
}
$scope.statusUpdateFormIdDetails = {
"Status": "",
"Comments": ""
}
$scope.resetStatusUpdateForm = function(){
$scope.statusUpdateFormIdDetails = {
"Status": "",
"Comments": ""
}
}
$scope.addStatusUpdateDetails = function(id, formId){
var addStatusUpdateDetailsStatusList = {
method: 'POST',
url: apiPoint.url + 'insertStatusUpdateDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details : $scope.statusUpdateFormIdDetails,
id: id,
formId : formId
}
};
$http(addStatusUpdateDetailsStatusList).then(function (response) {
if (response.data.insertStatusUpdateDetailsStatus == true) {
$scope.statusUpdateFormIdDetails = {
"Status": "",
"Comments": ""
}
$scope.statusUpdateEditId = -1;
swal("", response.data.insertStatusUpdateDetailsMessagae, "success");
} else {
swal("", response.data.insertStatusUpdateDetailsMessagae, "success");
// $scope.getFormIdDetailsStatusListLoading = false;
// $scope.StatusListDetails = response.data.formIdstatusListDetails;
// $scope.StatusListDetailsApiMessage = response.data.formIdstatusListMessagae;
}});
}
$scope.addToAccountState = function(id){
swal({
title: "Are you sure?",
text: "You Want to Add this Record to Account State List!",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes',
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm){
var selectedItems = [];
function getUpdateDetails(id) {
this.ID = id;
}
let itemGetID = new getUpdateDetails(id);
selectedItems.push(itemGetID);
var addToAccountStateList = {
method: 'POST',
url: apiPoint.url + 'addToAccountStateList/',
headers: {
'Content-Type': 'application/json'
},
data: {
localDetails: localDetail,
details : selectedItems
}
};
$http(addToAccountStateList).then(function (response) {
if (response.data.accountStateMoveStatus == true) {
swal("", response.data.accountStateMoveMessagae, "success");
$scope.onSubmit();
} else {
swal("", response.data.accountStateMoveMessagae, "warning");
}});
} else {
swal("Cancelled", "Your record not added to list :)", "error");
}
});
}
}]);