'use strict'; /** * controllers for ng-table * Simple table with sorting and filtering on AngularJS */ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$sessionStorage", "$http", "$state", "installmentService", "SweetAlert", "dateListDescService","$modal", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $sessionStorage, $http, $state,installmentService,SweetAlert,dateListDescService,$modal) { $scope.myModel = { "studentName": "", "mobileNumber": "", "universityName":"", "courseName":"" }; // bill date restrict $scope.futureDate=new Date(); // end $rootScope.userType = JSON.parse(sessionStorage.getItem('localObj')).localType; $rootScope.financeType = JSON.parse(sessionStorage.getItem('localObj')).is_DayBookApproval_Access; /* * updateModel default value * */ //console.log(JSON.parse(sessionStorage.getItem('localObj')).localType) //console.log(JSON.parse(sessionStorage.getItem('localObj')).is_DayBookApproval_Access) $scope.updateModel = { "feesType": "", "date": "", "billNo": "", "billAmount": "", "paymentOn": "", "internalComments":"", "studComments":"", "statusCode":"" }; /* * set model * */ $scope.setModel = { "feesType": "", }; /* * get payment options * */ if(JSON.parse(sessionStorage.getItem('localObj')).localType=='R002' && JSON.parse(sessionStorage.getItem('localObj')).is_DayBookApproval_Access==0){ $scope.paymentOptions = [ { "paymentOn":"CASH" }, ]; } else{ $scope.paymentOptions = [ { "paymentOn":"CASH" }, { "paymentOn":"CHEQUE" }, { "paymentOn":"REFERRAL" }, { "paymentOn":"ONLINE TRANSACTION" }, { "paymentOn":"WAIVER" }, { "paymentOn":"Credit/Debit Card" } ]; } // 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 logcheck = JSON.parse(sessionStorage.getItem('localObj')); // const LOCALTYPE = logcheck.localType; // if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' )) { // console.log("if"); // }else { // if(logcheck != null && LOCALTYPE !='R001') { // console.log("else if"); // $state.go('app.dashboard'); // } else { // console.log("else else"); // //ipCookie.remove('cookiechk'); // // window.sessionStorage.clear(); // $state.go('login.signin'); // } // } console.log($scope.paymentOptions); $scope.isTrainee = false; var localUserType = JSON.parse(sessionStorage.getItem('localObj')).localType; if(localUserType === 'R005') { $scope.isTrainee = true; } var getUniv = { method: 'POST', url: apiPoint.url + 'getUniversityCourseForFees/', headers: { 'Content-Type': 'application/json' }, data: { requestedBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, branchCode:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $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(sessionStorage.getItem('localObj')).localUserID, branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, requestedDept: JSON.parse(sessionStorage.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 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; var localUserType = JSON.parse(sessionStorage.getItem('localObj')).localType; if(localUserType === 'R004' || localUserType === 'R003' ) { $scope.show = true; } else { $scope.show = false; } } /* * set fees for student * */ $scope.viewId=-1; $scope.setFees = function (p) { $scope.BatchDate =''; $scope.editId=-1; $scope.getStudentSetFees(p.ID,p.CourseID,p.StudentID); $scope.viewId=p.ID; } /* * Delete set fees for student * */ $scope.deleteSetFees = function (masterDetails,p) { SweetAlert.swal({ title: "Warning!", text: "Want to delete "+p.Sem_Year+" Fees ?", type: "warning", showCancelButton: true, confirmButtonColor: "#d43f3a", confirmButtonText: "Yes!" }, function (res) { if (res === true) { var deleteSetFees = { method: 'POST', url: apiPoint.url + 'deleteSetFeesDetails/', headers: { 'Content-Type': 'application/json' }, data: { feesAssignID: p.FeesAssignID, requestedtBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, } }; $http(deleteSetFees).then(function (response) { if (response.data.deleteStatus == true) { $scope.getStudentSetFees(masterDetails.ID,masterDetails.CourseID,masterDetails.StudentID); swal(" ", response.data.message, "success"); } else { swal(" ", response.data.message, "error"); } }); } }); } /* * update total fees amount after change value * created by kms * */ $scope.changeTotalFees = function (model,form) { //User wants to manually enter fees amount //$scope.updateModel.billAmount = model.BalanceAmount; $scope.updateModel.date = $filter('date')(new Date(), 'dd-MM-yyyy'); $scope.updateModel.billAmount=""; form.billAmount.$setPristine(true); } /* * change session details * created by kms * */ $scope.changeSessions = function (details,type) { // console.log(details.Sem_Year);return false; // console.log($scope.setfeedetails);return false; var role = JSON.parse(sessionStorage.getItem('localObj')).localType; if($scope.setfeedetails.length != 0) { angular.forEach($scope.setfeedetails,function (setfeedetails,key) { if(setfeedetails.Sem_Year == details.Sem_Year) { if(role == 'R002') { console.log('if staff') $scope.readonlycheck =false; } else { console.log('ses'); $scope.readonlycheck =false; } } }); } if(details.SessionName!=undefined && details.SessionName!='') { console.log('if raju'); $scope.sessionDetails=[]; $scope.sessionDetailsTo=[]; if(type==1) { $scope.setModel.feesType.ToSessionName=""; } else { $scope.setModel.feesType.ToSessionName=details.ToSessionName; } if(details.ProgramType=='Y001' && details.SNo=='1') { //console.log('if1') // get session details var found = $filter('getById')($scope.masterSessionDetails, details.SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if((svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID)){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); } else if(details.ProgramType=='Y001' && details.SNo!='1') { // console.log('if else1') if($scope.feesStructureInfo[0].SessionName!='') { // console.log('else if if') // get session details var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[details.SNo-2].SessionName); //console.log(found) $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if((svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID) && $scope.ExistSessionDate < new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); // console.log($scope.sessionDetails) } // after branch changes else { // console.log('else if else') angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); } } else { console.log('else') // get session details var found = $filter('getById')($scope.masterSessionDetails, details.SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); if($scope.ExistSessionDate < new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetailsTo.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } } }); } } else { console.log('function else') //console.log(details.ProgramType); // alert("function else"); if(details.ProgramType=='Y001' && details.SNo!='1') { //console.log('else if') // alert("else if"); $scope.sessionDetails=[]; $scope.sessionDetailsTo=[]; if(type==1){ $scope.setModel.feesType.ToSessionName=""; } else{ $scope.setModel.feesType.ToSessionName=details.ToSessionName; } if($scope.feesStructureInfo[0].SessionName!=''){ // get session details var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[details.SNo-2].SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if((svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID) && $scope.ExistSessionDate < new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName , "SessionID":svalues.SessionID, }); } }); // console.log($scope.sessionDetails.length); var len = $scope.sessionDetails.length-1; $scope.setModel.feesType.SessionName = $scope.sessionDetails[len].SessionID; // $scope.setModel.feesType.SessionName = $scope.sessionDetails[0].SessionID; } else{ //console.log('else') angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); } } else { console.log('else else') //alert("else else"); $scope.sessionDetails=[]; $scope.sessionDetailsTo=[]; if(details.SessionName=='' || details.SessionName==null || details.SessionName==undefined) { console.log('else else if') angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' ){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); var len = $scope.sessionDetails.length-1; $scope.setModel.feesType.SessionName = $scope.sessionDetails[len].SessionID; $scope.setModel.feesType.ToSessionName = $scope.sessionDetails[len-1].SessionID; // console.log($scope.sessionDetails[len-1].SessionID) //$scope.setModel.feesType.SessionName = $scope.sessionDetails[0].SessionID; } else { // console.log('else else else') // get session details var found = $filter('getById')($scope.masterSessionDetails, details.SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName , "SessionID":svalues.SessionID, }); if($scope.ExistSessionDate < new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetailsTo.push({ "SessionName":svalues.SessionName , "SessionID":svalues.SessionID, }); } } }); } } } } /* * save fees details for student * created by kms * */ $scope.saveFees = function (myModel, form,updateModel, loading) { // alert('save');return false; $scope.currentBalance = 0; if(parseInt(updateModel.feesType.BalanceAmount) >= parseInt(updateModel.billAmount)){ $scope.currentBalance = parseInt(updateModel.feesType.BalanceAmount)-parseInt(updateModel.billAmount); } else{ $scope.currentBalance = 0; } 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 { // count exist payment length report purpose $scope.existPaidCount=1; angular.forEach($scope.existStudentFeesDetails,function (values) { if(updateModel.feesType.FeesID==values.FeesID){ $scope.existPaidCount=parseInt($scope.existPaidCount)+parseInt(values.paidDetails.length); } }); $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, feesName: updateModel.feesType.Sem_Year, billNO: updateModel.billNo, billDate: $scope.billDate, billAmount:updateModel.billAmount, modeOfPayment: updateModel.paymentOn.paymentOn, commentsForStudent: updateModel.studComments, internalComments: updateModel.internalComments, createdBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, mobileNumber: myModel.MobileNumber, studentName: myModel.Firstname, university: myModel.UniversityName, course: myModel.CourseName, //statusCode: updateModel.statusCode, requestedBranch : JSON.parse(sessionStorage.getItem('localObj')).localBranchID, currentBalance : $scope.currentBalance, existPaidCount : $scope.existPaidCount } }; $http(updateFees).then(function (response) { if (response.data.status==200 && response.data.paidStatus) { console.log(response.data.BillNO); $scope.ldloading[loading.replace('-', '_')] = false; swal("Success!", "Updated successfully For Bill No "+response.data.BillNO, "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) { //alert('set fee page');return false; //console.log(form) var firstError = null; if (form.$invalid) { //alert('if'); 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(); swal("", "Please check session details/installment details", "warning"); } else { // alert('in') /* 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 }); }*/ if(updateModel.Sem_Year!='TC' && updateModel.Sem_Year!='PPC' && updateModel.Sem_Year!='DC' && updateModel.Sem_Year!='MC' && updateModel.Sem_Year!='OTHER'){ var checkTotamt=0; angular.forEach($rootScope.updateMoreItems, function (value, key) { console.log(value.Amount) checkTotamt=parseInt(checkTotamt)+parseInt(value.Amount); if(isNaN(value.DueDate)){ $scope.correctDate=''; } else{ $scope.convertGetDate2=new Date(value.DueDate).toDateString(); $scope.pushDueDate2 = $filter('date')(new Date($scope.convertGetDate2), 'dd-MM-yyyy'); $rootScope.updateMoreItems[key].DueDate=$scope.pushDueDate2; } }); // console.log($scope.setTotalAmount); //console.log(checkTotamt) // if(parseInt($scope.setTotalAmount)checkTotamt){ // var statusUpdate=false; // swal("Please check total/installment amount "); // } // else if(parseInt($scope.setTotalAmount)==checkTotamt){ var statusUpdate=true; // } } else{ if(updateModel.Valid=='1'){ var statusUpdate=true; } else{ var statusUpdate=false; swal("", "Course fees are not paid so unable to set course fees", "warning"); } } if(statusUpdate==true){ $scope.setSessionTo=""; if(updateModel.ProgramType=='P001' || updateModel.ProgramType=='P002'){ $scope.setSessionTo=updateModel.ToSessionName; } $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, comments:updateModel.Comments, waiver: updateModel.Waiver, other: updateModel.Others, session: updateModel.SessionName, sessionTo: $scope.setSessionTo, rollNo: updateModel.RollNo, createdBy: JSON.parse(sessionStorage.getItem('localObj')).localUserID, installmentItems:$rootScope.updateMoreItems, batchCode:updateModel.BatchCode, branchCode:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $http(updateFees).then(function (response) { if (response.data.status==200 && response.data.setStatus) { $scope.ldloading5[loading.replace('-', '_')] = false; swal("Success!", "Fees set successfully.", "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=[]; $scope.setTotalAmount=''; 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(sessionStorage.getItem('localObj')).localUserID, branchCode:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $http(getFees).then(function (response) { if (response.data.status==200 && response.data.feesStatus) { $scope.studentFeesInfo=response.data.feesDetails; //console.log($scope.studentFeesInfo); $scope.existStudentFeesDetails = response.data.getExistStudentFeesDetails; $scope.getFeesUpdateStatus = response.data.getFeesUpdateStatus; console.log($scope.existStudentFeesDetails); $scope.updateModel = { "feesType": $scope.studentFeesInfo[0], //User wants to manually enter fees amount //"billAmount":$scope.studentFeesInfo[0].BalanceAmount, "date":$filter('date')(new Date(), 'dd-MM-yyyy') }; //console.log($scope.updateModel); /* $scope.billCurrentDate=$filter('date')(new Date(), 'dd-MM-yyyy'); alert($scope.billCurrentDate);*/ } else { $scope.studentFeesInfo=""; $scope.existStudentFeesDetails=""; $scope.getFeesUpdateStatus=""; swal("Warning!", response.data.message, "warning"); $scope.editId=-1; } }); } /* * get student set fees details * */ $scope.feesStructureInfo=""; $scope.BatchDetails=[]; $scope.masterSessionDetails=""; $scope.sessionDetails=[]; $scope.setfeedetails=''; $scope.readonlycheck =""; $scope.lastsetfee =''; $scope.getStudentSetFees = function (ID,courseID,studeID) { // alert('in') $scope.BatchDetails=[]; $scope.sessionDetails=[]; $scope.sessionDetailsTo=[]; $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(sessionStorage.getItem('localObj')).localUserID, branchCode:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $http(setFees).then(function (response) { if (response.data.status==200 && response.data.feesStatus) { // console.log(response.data.sessionDetails); var role = JSON.parse(sessionStorage.getItem('localObj')).localType; //console.log(role); $scope.setfeedetails=response.data.feesetDetails; //console.log($scope.setfeedetails); $scope.masterSessionDetails =response.data.sessionDetails; //console.log($scope.masterSessionDetails); $scope.readonlycheck =false; if($scope.setfeedetails.length != 0) { if(role=='R002' || role == 'R005') { $scope.readonlycheck =true; } } else { $scope.readonlycheck =false; } // $scope.masterSessionDetails = response.data.sessionDetails; //console.log($scope.masterSessionDetails); // service call for session master list in desc order based on date angular.forEach($scope.masterSessionDetails,function (fvalue,fkey) { var parts = fvalue.SessionDate.split("-"); fvalue.givenDateObject=new Date(parts[2], parts[1] - 1, parts[0]); }); // $scope.masterSessionDetails=dateListDescService.getOrderByList($scope.masterSessionDetails); // end for service call $scope.feesStructureInfo=response.data.feesDetails; $scope.temfee = response.data.feesDetails; // console.log($scope.feesStructureInfo); var lastval =''; var loopc = true; angular.forEach($scope.temfee,function (temfee,key) { if(loopc) { if(temfee.FeesAssignID !='' ) { lastval = key; $scope.lastsetfee= key; } } }); //$scope.setModel.feesType = $scope.feesStructureInfo[lastval]; //console.log($scope.lastsetfee);return false; $scope.setModel = { "feesType": $scope.feesStructureInfo[$scope.lastsetfee], }; angular.forEach($scope.feesStructureInfo[$scope.lastsetfee].batchDetails,function (values,key) { var parts = values.BatchDate.split("-"); $scope.BatchDetails.push({ "BatchCode":values.BatchCode, "BatchName":values.BatchName, "BatchDate":values.BatchDate, "givenDateObject":new Date(parts[2], parts[1] - 1, parts[0]) }) }); if($scope.BatchDetails.length == 0) { //console.log('null') $scope.setModel.feesType.BatchCode='Not applicable'; } //console.log($scope.BatchDetails); // call service for make a list in desc order based on date $scope.BatchDetails=dateListDescService.getOrderByList($scope.BatchDetails); $scope.setTotalAmount=$scope.feesStructureInfo[$scope.lastsetfee].PayableFees; $rootScope.updateMoreItems=[]; if($scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails == '') { //console.log('in') $scope.obj = $scope.feesStructureInfo[$scope.lastsetfee].batchDetails.find(x => x.IsDefault == true); if($scope.obj==undefined || $scope.obj=='' || $scope.obj==null){ $scope.setModel.feesType.BatchCode = $scope.feesStructureInfo[$scope.lastsetfee].batchDetails[0].BatchCode; $scope.BatchDate = new Date($scope.feesStructureInfo[$scope.lastsetfee].batchDetails[0].BatchDate.substring(6,10)+'-'+$scope.feesStructureInfo[0].batchDetails[0].BatchDate.substring(3,5)+'-'+$scope.feesStructureInfo[0].batchDetails[0].BatchDate.substring(0,2)); } else{ $scope.setModel.feesType.BatchCode = $scope.obj.BatchCode; $scope.BatchDate = new Date($scope.obj.BatchDate.substring(6,10)+'-'+$scope.obj.BatchDate.substring(3,5)+'-'+$scope.obj.BatchDate.substring(0,2)); } $scope.calculateInstallemnts($scope.feesStructureInfo[$scope.lastsetfee],$scope.setTotalAmount); // get session details angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1'){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName, "SessionID":svalues.SessionID, }); } }); ///console.log($scope.feesStructureInfo) } else { //console.log('in else') /* $scope.myModelInstallemt.ID=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].ID; $scope.myModelInstallemt.name=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].Name; $scope.myModelInstallemt.amount=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].Amount; $scope.myModelInstallemt.date=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].DueDate; $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date;*/ for(var i=0; i < $scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails.length; i++){ $rootScope.updateMoreItems.push($scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails[i]); $scope.getDateArray.push({ "Date":new Date($scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails[i].DueDate.substring(6,10)+'-'+$scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails[i].DueDate.substring(3,5)+'-'+$scope.feesStructureInfo[$scope.lastsetfee].InstallmentDetails[i].DueDate.substring(0,2)) }); } $scope.setModel.feesType.BatchCode = $scope.feesStructureInfo[$scope.lastsetfee].BatchCode; $scope.ExistSessionDate=""; // get session details var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[$scope.lastsetfee].SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); //console.log($scope.ExistSessionDate); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { if(svalues.IsActive=='1' || $scope.feesStructureInfo[$scope.lastsetfee].SessionName==svalues.SessionID || $scope.feesStructureInfo[$scope.lastsetfee].ToSessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName , "SessionID":svalues.SessionID, }); if($scope.ExistSessionDate <= new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetailsTo.push({ "SessionName":svalues.SessionName , "SessionID":svalues.SessionID, }); } } }); // console.log($scope.sessionDetails) $scope.setModel.feesType.SessionName=$scope.feesStructureInfo[$scope.lastsetfee].SessionName; $scope.setModel.feesType.ToSessionName=$scope.feesStructureInfo[$scope.lastsetfee].ToSessionName; $scope.dateValidations(); //console.log($scope.setModel.feesType.SessionName); // console.log($scope.feesStructureInfo) } } else { $scope.feesStructureInfo=""; $scope.setModel = { "feesType": "", }; } }); } /* * change batch details * createdcby kms * */ $scope.changeBatch = function (Details) { if(Details.InstallmentDetails != ''){ $scope.setFeesTotalAmount(Details,'2',Details,'1'); } else{ /*$scope.$watch('setModel.feesType.BatchCode', function(newValue, oldValue) { if(newValue!=oldValue){ $rootScope.updateMoreItems=[]; $scope.setFeesTotalAmount(Details,'1',Details,'1'); } });*/ $scope.setFeesTotalAmount(Details,'1',Details,'1'); } } $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 (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(); swal("", "Please check session details/installment details", "warning"); } else { if(isNaN($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate)){ $scope.pushDueDate= $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate; } else{ $scope.convertGetDate=new Date($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate).toDateString(); $scope.pushDueDate = $filter('date')(new Date($scope.convertGetDate), 'dd-MM-yyyy'); } var MoreInsAmt= Math.round($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount * 50 / 100); var afterMoreInsAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount)-parseInt(MoreInsAmt); $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = MoreInsAmt; $rootScope.updateMoreItems.push({ ID:"", Name: installmentService.installmentWords($rootScope.updateMoreItems.length+1), Amount: MoreInsAmt, DueDate: $scope.pushDueDate }); /*if(model.ID !='' && model.ID !==null && model.ID !=undefined){ $rootScope.updateMoreItems.push({ ID:model.ID, Name: model.name, Amount: MoreInsAmt, DueDate: $scope.pushDueDate }); } else{ $rootScope.updateMoreItems.push({ ID:"", Name: model.name, Amount: MoreInsAmt, DueDate: $scope.pushDueDate }); }*/ /* $scope.myModelInstallemt.ID=""; $scope.myModelInstallemt.name=installmentService.installmentWords($rootScope.updateMoreItems.length+1); $scope.myModelInstallemt.amount=parseInt(afterMoreInsAmt); $scope.myModelInstallemt.date=$scope.pushDueDate;*/ $scope.dateValidations(); } } /* * change installment values * */ $scope.changeInstallemt = function (model,form) { if(model.Sem_Year!='TC' && model.Sem_Year!='PPC' && model.Sem_Year!='DC' && model.Sem_Year!='MC' && model.Sem_Year!='OTHER'){ $scope.BatchDetails=[]; $rootScope.updateMoreItems=[]; angular.forEach(model.batchDetails,function (values,key) { var parts1 = values.BatchDate.split("-"); $scope.BatchDetails.push({ "BatchCode":values.BatchCode, "BatchName":values.BatchName, "BatchDate":values.BatchDate, "givenDateObject":new Date(parts1[2], parts1[1] - 1, parts1[0]) }) }); $scope.BatchDetails=dateListDescService.getOrderByList($scope.BatchDetails); 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; i++){ $rootScope.updateMoreItems.push(model.InstallmentDetails[i]); } $scope.setModel.feesType.BatchCode = model.BatchCode; /*$scope.setModel.feesType.SessionName=model.SessionName; $scope.setModel.feesType.ToSessionName=model.ToSessionName;*/ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(values.DueDate.length>10 || values.DueDate.length==undefined){ $rootScope.updateMoreItems[key].DueDate = $filter('date')(values.DueDate,'dd-MM-yyyy'); } }); } else{ $scope.obj = model.batchDetails.find(x => x.IsDefault == true); if($scope.obj==undefined || $scope.obj=='' || $scope.obj==null){ $scope.setModel.feesType.BatchCode = $scope.BatchDetails[0].BatchCode; $scope.BatchDate = new Date($scope.BatchDetails[0].BatchDate.substring(6,10)+'-'+$scope.BatchDetails[0].BatchDate.substring(3,5)+'-'+$scope.BatchDetails[0].BatchDate.substring(0,2)); } else{ $scope.setModel.feesType.BatchCode = $scope.obj.BatchCode; $scope.BatchDate = new Date($scope.obj.BatchDate.substring(6,10)+'-'+$scope.obj.BatchDate.substring(3,5)+'-'+$scope.obj.BatchDate.substring(0,2)); } /* $scope.myModelInstallemt.ID=""; $scope.myModelInstallemt.name=""; $scope.myModelInstallemt.amount=""; $scope.myModelInstallemt.date=""; $rootScope.lastInstallemtDate="";*/ $rootScope.updateMoreItems=[]; } $scope.setFeesTotalAmount(model,'1',model,'1'); } else{ $scope.setFeesTotalAmount(model,'3',model,'1'); } // form.$setPristine(true); //console.log($scope.setfeedetails) //console.log('im'); var loopcheck = true; angular.forEach($scope.setfeedetails,function (setfeedetails,skey) { if(loopcheck) { if(setfeedetails.Sem_Year == model.Sem_Year ) { $scope.readonlycheck =true; loopcheck = false; } else { $scope.readonlycheck =false; } } }); } $scope.setTotalAmount=''; /* * get set fees total amount * */ $scope.setFeesTotalAmount = function (values,type,beforeValues,from) { //alert('set fee') if(type==3 || values.Sem_Year=='TC' || values.Sem_Year=='PPC' || values.Sem_Year=='DC' || values.Sem_Year=='MC' || values.Sem_Year=='OTHER'){ //alert('if') if(values.Valid=='0'){ swal("", "Course fees are not paid so unable to set course fees", "warning"); } if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ $scope.actFees=0; } else{ $scope.actFees=values.ActualFees; } if(values.Others=='' || values.Others==null || values.Others==undefined){ $scope.othersFees=0; } else{ $scope.othersFees=values.Others; } if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ $scope.stfFees=0; } else{ $scope.stfFees=values.STFOrWR; } if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ $scope.wiverFees=0; } else{ $scope.wiverFees=values.Waiver; } $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); $scope.setModel.feesType.BatchCode = "Not applicable"; $scope.setModel.feesType.SessionName = "Not applicable"; $scope.setModel.feesType.BatchName = "Not applicable"; $rootScope.updateMoreItems=[]; $scope.BatchDetails=''; } else{ if($scope.setTotalAmount=='' || $scope.setTotalAmount==null || $scope.setTotalAmount==0){ $scope.beforeSetTotalAmount=0; } else{ $scope.beforeSetTotalAmount=$scope.setTotalAmount; } angular.forEach(values.batchDetails,function (values1,key) { if(values1.BatchCode==values.BatchCode){ $scope.BatchDate = new Date(values1.BatchDate.substring(6,10)+'-'+values1.BatchDate.substring(3,5)+'-'+values1.BatchDate.substring(0,2)); } }); if(type=='1'){ if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ $scope.actFees=0; } else{ $scope.actFees=values.ActualFees; } if(values.Others=='' || values.Others==null || values.Others==undefined){ $scope.othersFees=0; } else{ $scope.othersFees=values.Others; } if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ $scope.stfFees=0; } else{ $scope.stfFees=values.STFOrWR; } if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ $scope.wiverFees=0; } else{ $scope.wiverFees=values.Waiver; } $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length==0){ $scope.calculateInstallemnts(values,$scope.setTotalAmount); } else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ if(from=='1'){ $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } else{ $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); } } else{ if(from=='1'){ $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } else{ $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); } } } else{ if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ $scope.actFees=0; } else{ $scope.actFees=values.ActualFees; } if(values.Others=='' || values.Others==null || values.Others==undefined){ $scope.othersFees=0; } else{ $scope.othersFees=values.Others; } if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ $scope.stfFees=0; } else{ $scope.stfFees=values.STFOrWR; } if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ $scope.wiverFees=0; } else{ $scope.wiverFees=values.Waiver; } $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length==0){ $scope.calculateInstallemnts(values,$scope.setTotalAmount); } else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ if(from=='1'){ $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } else{ $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); } } else{ if(from=='1'){ $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } else{ $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); } } } } } /* * calculate installments * created by kms * */ $scope.calculateInstallemnts =function (model,totAmt) { // $scope.setTotalAmount=totAmt; $rootScope.updateMoreItems=[]; var cDate = moment(); var bDate = moment($scope.BatchDate); var startPayableAmt = parseInt(totAmt); for (var i = 1; i <= 2; i++) { if (i == 1) { startPayableAmt = parseInt(totAmt); var percentage = Math.round(startPayableAmt * 70 / 100); percentage = Math.round(percentage / 10) * 10; startPayableAmt = startPayableAmt - percentage; // alert(startPayableAmt); $scope.insFirstDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); $scope.insSecondDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); $scope.updateMoreItems.push({ ID: "", Name: installmentService.installmentWords(i), Amount: percentage, DueDate: $scope.insFirstDate }); } else { startPayableAmt = Math.round(startPayableAmt); $scope.updateMoreItems.push({ ID: "", Name: installmentService.installmentWords(i), Amount: startPayableAmt, DueDate: $scope.insSecondDate }); } } $scope.dateValidations(); } /* * calculate exist installment * created by kms * */ $scope.calculateInstallemntsExist = function (model,totAmt,other,type,type1,checkPermission) { var exBatchDate = moment($scope.BatchDate); if(type==2 || type==1){ if($rootScope.updateMoreItems.length>0){ var existLoop=0; var existTotAmt=0 angular.forEach($rootScope.updateMoreItems,function (item,position) { var exDatenew1; var exDatenew2; var exitPayAmt=parseInt(totAmt-other); /* if(isNaN(moment($rootScope.updateMoreItems[position].DueDate))){ exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); exDatenew1 = moment(exDatenew1); }*/ if($rootScope.updateMoreItems[position].DueDate.length<=10){ exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); exDatenew1 = moment(exDatenew1); } else{ exDatenew1 = moment($rootScope.updateMoreItems[position].DueDate); } if (exDatenew1 <= exBatchDate) { if(type=='1'){ $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); // $scope.setModel.feesType.Others = Math.round(parseInt(other)); $scope.setModel.feesType.Others = ''; } else{ if(other==0){ $scope.setModel.feesType.Others = ''; $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); } else{ $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); $scope.setModel.feesType.Others = ''; } } var existPercentage = Math.round($scope.setTotalAmount * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt($scope.setTotalAmount)-parseInt(existPercentage); if(position==0){ $rootScope.updateMoreItems[position].Amount = existPercentage; } else if(position==1){ $rootScope.updateMoreItems[position].Amount = exitPayAmt; } /* if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); }*/ existTotAmt = parseInt(existTotAmt)+parseInt($rootScope.updateMoreItems[position].Amount); } else if(exDatenew1 > exBatchDate && existLoop==0){ exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); var dayDiff = exDatenew1.diff(exBatchDate, 'days'); dayDiff = dayDiff+1; var todatlFineAmt = 0; var fineAmt1 = 0; var fineAmt11 = 0; var countDays = 0; for (var k = 1; k <= dayDiff; k++) { if (k <= 90) { if (exitPayAmt <= 10000) { fineAmt1 = 300; } else if ((exitPayAmt > 10000) && (exitPayAmt <= 20000)) { fineAmt1 = 600; } else if (exitPayAmt > 20000) { fineAmt1 = 900; } } else { countDays = countDays+1; if (countDays<30) { if(countDays==1){ fineAmt11 = parseInt(fineAmt11)+300; } } else{ countDays=0; } } } todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11); if(type1=='2'){ $scope.setTotalAmount = Math.round(parseInt(totAmt) -parseInt(other) + parseInt(todatlFineAmt)); $scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt)); } else{ $scope.setTotalAmount = Math.round(parseInt(totAmt)); if(other==0){ $scope.setModel.feesType.Others = ''; } else{ $scope.setModel.feesType.Others = Math.round(parseInt(other)); } } if($rootScope.updateMoreItems[position-1]!=undefined){ existLoop=1; exitPayAmt = parseInt($scope.setTotalAmount); var existPercentage = Math.round(exitPayAmt * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt(exitPayAmt)-parseInt(existPercentage); $rootScope.updateMoreItems[0].Amount = existPercentage; $rootScope.updateMoreItems[1].Amount = exitPayAmt; /* if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); }*/ } else{ existLoop=1; exitPayAmt = parseInt($scope.setTotalAmount); var existPercentage = Math.round(exitPayAmt * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt(exitPayAmt)-parseInt(existPercentage); $rootScope.updateMoreItems[0].Amount = existPercentage; $rootScope.updateMoreItems[1].Amount = exitPayAmt; /* if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); }*/ } } }); if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); } if(checkPermission=='1'){ // check batch date for confirmation angular.forEach($rootScope.updateMoreItems,function (list,keyV) { var inDate; var inBatchDate=moment(exBatchDate).add('30','days') if(list.DueDate.length<=10){ inDate = new Date(list.DueDate.substring(6,10)+'-'+list.DueDate.substring(3,5)+'-'+list.DueDate.substring(0,2)); inDate = moment(inDate); } else{ inDate = moment(list.DueDate).add('1','days'); } if(exBatchDate30){ SweetAlert.swal({ title: "", text: "The selected installment date is crossing the maximum allowed period. Do you want to continue (Yes/No). If yes you need to get approval from the higher authorities", type: "info", showCancelButton: true, confirmButtonColor: "#eea236",confirmButtonText: "Yes", cancelButtonText: "No", closeOnConfirm: true, closeOnCancel: true }, function(isConfirm) { if (isConfirm==false) { angular.forEach($rootScope.updateMoreItems,function (updateV,updateK) { $rootScope.updateMoreItems[updateK].DueDate=$filter('date')(new Date(inBatchDate), 'dd-MM-yyyy'); }); $scope.rollBackFeesDetails(model,totAmt,other,type,type1); } }) } }); } } } $scope.dateValidations(); } /* * this function used to roll back the details if no * */ $scope.rollBackFeesDetails = function (model,totAmt,other,type,type1) { var exBatchDate = moment($scope.BatchDate); if(type==2 || type==1){ if($rootScope.updateMoreItems.length>0){ var existLoop=0; var existTotAmt=0 angular.forEach($rootScope.updateMoreItems,function (item,position) { var exDatenew1; var exitPayAmt=parseInt(totAmt-other); /* if(isNaN(moment($rootScope.updateMoreItems[position].DueDate))){ exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); exDatenew1 = moment(exDatenew1); }*/ if($rootScope.updateMoreItems[position].DueDate.length<=10){ exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); exDatenew1 = moment(exDatenew1); } else{ exDatenew1 = moment($rootScope.updateMoreItems[position].DueDate); } if (exDatenew1 <= exBatchDate) { if(type=='1'){ $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); // $scope.setModel.feesType.Others = Math.round(parseInt(other)); $scope.setModel.feesType.Others = ''; } else{ if(other==0){ $scope.setModel.feesType.Others = ''; $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); } else{ $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); $scope.setModel.feesType.Others = ''; } } var existPercentage = Math.round($scope.setTotalAmount * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt($scope.setTotalAmount)-parseInt(existPercentage); if(position==0){ $rootScope.updateMoreItems[position].Amount = existPercentage; } else if(position==1){ $rootScope.updateMoreItems[position].Amount = exitPayAmt; } if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); } existTotAmt = parseInt(existTotAmt)+parseInt($rootScope.updateMoreItems[position].Amount); } else if(exDatenew1 > exBatchDate && existLoop==0){ exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); var dayDiff = exDatenew1.diff(exBatchDate, 'days'); dayDiff = dayDiff+1; var todatlFineAmt = 0; var fineAmt1 = 0; var fineAmt11 = 0; var countDays = 0; for (var k = 1; k <= dayDiff; k++) { if (k <= 90) { if (exitPayAmt <= 10000) { fineAmt1 = 300; } else if ((exitPayAmt > 10000) && (exitPayAmt <= 20000)) { fineAmt1 = 600; } else if (exitPayAmt > 20000) { fineAmt1 = 900; } } else { countDays = countDays+1; if (countDays<30) { if(countDays==1){ fineAmt11 = parseInt(fineAmt11)+300; } } else{ countDays=0; } } } todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11); if(type1=='2'){ $scope.setTotalAmount = Math.round(parseInt(totAmt) -parseInt(other) + parseInt(todatlFineAmt)); $scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt)); } else{ $scope.setTotalAmount = Math.round(parseInt(totAmt)); if(other==0){ $scope.setModel.feesType.Others = ''; } else{ $scope.setModel.feesType.Others = Math.round(parseInt(other)); } } if($rootScope.updateMoreItems[position-1]!=undefined){ existLoop=1; exitPayAmt = parseInt($scope.setTotalAmount); var existPercentage = Math.round(exitPayAmt * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt(exitPayAmt)-parseInt(existPercentage); $rootScope.updateMoreItems[0].Amount = existPercentage; $rootScope.updateMoreItems[1].Amount = exitPayAmt; if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); } } else{ existLoop=1; exitPayAmt = parseInt($scope.setTotalAmount); var existPercentage = Math.round(exitPayAmt * 70 / 100); existPercentage = Math.round(existPercentage / 10) * 10; exitPayAmt = parseInt(exitPayAmt)-parseInt(existPercentage); $rootScope.updateMoreItems[0].Amount = existPercentage; $rootScope.updateMoreItems[1].Amount = exitPayAmt; if($rootScope.updateMoreItems.length>2){ angular.forEach($rootScope.updateMoreItems,function (values,key) { if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ var currentElementAmt = $rootScope.updateMoreItems[key].Amount; var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; } }); } } } }); } } $scope.dateValidations(); } $scope.changeInstallemtAmt = function (old,present,index,values) { if($rootScope.updateMoreItems[index+1]!=undefined){ var currentValue=present; var pastValue=old; if(currentValue==undefined || currentValue==''){ var currentValue=0; } if(pastValue==undefined || pastValue==''){ pastValue=0; } if(parseInt(currentValue)<=parseInt($scope.setTotalAmount)){ if(currentValue<=pastValue){ var diffVal1=parseInt(pastValue)-parseInt(currentValue); $rootScope.updateMoreItems[index+1].Amount=parseInt($rootScope.updateMoreItems[index+1].Amount)+parseInt(diffVal1); } else if(pastValue$rootScope.updateMoreItems[index+1].Amount){ $rootScope.updateMoreItems[index+1].Amount=parseInt(diffVal2)-parseInt($rootScope.updateMoreItems[index+1].Amount); } else{ $rootScope.updateMoreItems[index+1].Amount=parseInt($rootScope.updateMoreItems[index+1].Amount)-parseInt(diffVal2); } } } else{ var diffVal3=parseInt(currentValue)-parseInt(pastValue); // alert(diffVal3); if(diffVal3>$rootScope.updateMoreItems[index].Amount){ $rootScope.updateMoreItems[index].Amount=parseInt(diffVal3)-parseInt($rootScope.updateMoreItems[index].Amount); } else{ $rootScope.updateMoreItems[index].Amount=parseInt($rootScope.updateMoreItems[index].Amount)-parseInt(diffVal3); } } $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } } /*while changing installment date/amount calculate fine amount * created by kms * */ $scope.calculateDueAmount = function (beforeTot,afterTot) { $scope.getInsTotAmt=0; for(var i=0;i<$rootScope.updateMoreItems.length-1;i++){ $scope.getInsTotAmt=parseInt($scope.getInsTotAmt) + parseInt($rootScope.updateMoreItems[i].Amount); } if(parseInt(afterTot)>0 && parseInt(afterTot)>parseInt($scope.getInsTotAmt)){ $scope.finalTotAmt=parseInt(afterTot)-parseInt($scope.getInsTotAmt); $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt($scope.finalTotAmt); } else{ $scope.finalTotAmt=0; $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt($scope.finalTotAmt); } /* if(values.ActualFees=='' || values.ActualFees==undefined){ var gettotAmt = 0; } else{ var gettotAmt = values.ActualFees; } if(values.Others=='' || values.Others==undefined){ var getother = 0; } else{ var getother = values.Others; } if(values.STFOrWR=='' || values.STFOrWR==undefined){ var getSTFOrWR = 0; } else{ var getSTFOrWR = values.STFOrWR; } if(beforeValues.STFOrWR=='' || beforeValues.STFOrWR==undefined){ var getBeforeSTFOrWR = 0; } else{ var getBeforeSTFOrWR = beforeValues.STFOrWR; } if(beforeValues.Others=='' || beforeValues.Others==undefined){ var getBeforeother = 0; } else{ var getBeforeother = beforeValues.Others; } var lastInstallAmt; if(parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) > parseInt(getBeforeSTFOrWR)){ lastInstallAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) - parseInt(getBeforeSTFOrWR); } else{ lastInstallAmt = parseInt(getBeforeSTFOrWR) - parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount); } if(parseInt(lastInstallAmt) > parseInt(getBeforeother)){ lastInstallAmt = parseInt(lastInstallAmt) - parseInt(getBeforeother); } else{ lastInstallAmt = parseInt(getBeforeother) - parseInt(lastInstallAmt); } if($rootScope.updateMoreItems.length>0){ $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt(lastInstallAmt) + parseInt(getSTFOrWR) + parseInt(getother); }*/ $scope.dateValidations(); } /* * roll back after installment date No * created by kms * */ $scope.dueDetailsRollup = function (totAmt,other,checkPermission,STFOrWR,lastInstallAmt,beforeSTF) { if(isNaN(parseInt(totAmt))){ var gettotAmt = 0; } else{ var gettotAmt = totAmt; } if(isNaN(parseInt(other))){ var getother = 0; } else{ var getother = other; } if(isNaN(parseInt(STFOrWR))){ var getSTFOrWR = 0; } else{ var getSTFOrWR = STFOrWR; } if(isNaN(parseInt(beforeSTF))){ var getBeforeSTFOrWR = 0; } else{ var getBeforeSTFOrWR = beforeSTF; } var lastInstallAmt; if(parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) > parseInt(getBeforeSTFOrWR)){ lastInstallAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) - parseInt(getBeforeSTFOrWR); } else{ lastInstallAmt = parseInt(getBeforeSTFOrWR) - parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount); } if(parseInt(lastInstallAmt) > parseInt(getother)){ lastInstallAmt = parseInt(lastInstallAmt) - parseInt(getother); } else{ lastInstallAmt = parseInt(getother) - parseInt(lastInstallAmt); } var exBatchDate = moment($scope.BatchDate); if($rootScope.updateMoreItems.length>0){ var existLoop=0; var exitPayAmt=0; var finalFineAmt=0; angular.forEach($rootScope.updateMoreItems,function (item,position) { var exDatenew1; var exDatenew2; // var exitPayAmt=parseInt(totAmt-other); if($rootScope.updateMoreItems[position].DueDate.length<=10){ exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); exDatenew1 = moment(exDatenew1); } else{ exDatenew1 = moment($rootScope.updateMoreItems[position].DueDate); } if (exDatenew1 <= exBatchDate) { $scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR)); $scope.setModel.feesType.Others = 0; finalFineAmt=0; } else if(exDatenew1 > exBatchDate && existLoop==0){ // exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); angular.forEach($rootScope.updateMoreItems,function (listVal,listKey) { if(listKey>=position){ exitPayAmt = parseInt(exitPayAmt)+parseInt($rootScope.updateMoreItems[listKey].Amount); } }) if(exitPayAmt>getBeforeSTFOrWR){ exitPayAmt = parseInt(exitPayAmt) - parseInt(getBeforeSTFOrWR); } else{ exitPayAmt = parseInt(getBeforeSTFOrWR) - parseInt(exitPayAmt); } if(exitPayAmt>getother){ exitPayAmt = parseInt(exitPayAmt) - parseInt(getother) + parseInt(getSTFOrWR); } else{ exitPayAmt = parseInt(getother) - parseInt(exitPayAmt) + parseInt(getSTFOrWR); } existLoop=1; var dayDiff = exDatenew1.diff(exBatchDate, 'days'); dayDiff = dayDiff+1; var todatlFineAmt = 0; var fineAmt1 = 0; var fineAmt11 = 0; var countDays = 0; for (var k = 1; k <= dayDiff; k++) { if (k <= 90) { if (exitPayAmt <= 10000) { fineAmt1 = 300; } else if ((exitPayAmt > 10000) && (exitPayAmt <= 20000)) { fineAmt1 = 600; } else if (exitPayAmt > 20000) { fineAmt1 = 900; } } else { countDays = countDays+1; if (countDays<30) { if(countDays==1){ fineAmt11 = parseInt(fineAmt11)+300; } } else{ countDays=0; } } } todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11); finalFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11); $scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR) + parseInt(todatlFineAmt)); $scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt)); } }); $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt(lastInstallAmt) + parseInt(getSTFOrWR) + parseInt(finalFineAmt); } $scope.dateValidations(); } $scope.getDateArray = []; /* * validate installment date * */ $scope.dateValidations = function () { $scope.getDateArray = []; $scope.getDateArray=[ { "Date":'' } ]; angular.forEach($rootScope.updateMoreItems,function (values,key) { if(values.DueDate.length==10){ $scope.getDateArray.push({ "Date":new Date(values.DueDate.substring(6,10)+'-'+values.DueDate.substring(3,5)+'-'+values.DueDate.substring(0,2)) }) } else{ $scope.getDateArray.push({ "Date":values.DueDate }) } }); $scope.getDateArray.push({ "Date":'' }) return true; } // this is for watch function /* $scope.$watch('updateMoreItems', function (newValue, oldValue) { for (var i = 0; i < newValue.length; i++) { if (newValue[i].Amount != oldValue[i].Amount) { alert(); var currentValue=0; var pastValue=0; if(newValue[i].Amount>oldValue[i].Amount){ currentValue = parseInt(newValue[i].Amount)-oldValue[i].Amount; } else if(newValue[i].AmountparseInt($scope.updateModel.feesType.BalanceAmount)){ $scope.payableAmtInfo=0; } else{ $scope.payableAmtInfo=$scope.updateModel.feesType.BalanceAmount; } }); /* watch function for receive fees semd year options changes */ $scope.$watch('updateModel.feesType.BalanceAmount', function (newValue,oldValue) { if(parseInt(newValue)){ $scope.payableAmtInfo=newValue; } else { $scope.payableAmtInfo = 0; } }); }]); /*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: 'FeesModalInstanceCtrl', // 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('FeesModalInstanceCtrl', ["$scope", "$modalInstance", "$timeout", "items","WordsService", function ($scope, $modalInstance, $timeout, 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.receiptNo=""; $scope.sessionName=""; $scope.paymentType=""; $scope.billDate=""; $scope.amountInWords = ""; $scope.billAmount = ""; $scope.branchName = ""; $scope.ReceivedBy = ""; $scope.BranchAddr = ""; $scope.BranchLogo = ""; $scope.FeesReceiptTitle = ""; $scope.myPdfView = ''; $scope.cur_url = ''; $scope.ShowHide = function (pdfValue,print) { $timeout(()=> { //alert(this.print); $scope.printPdf(print); }, 0); $scope.myPdfView = 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.ReceivedBy = pdfValue.ReceivedBy; $scope.BranchAddr = pdfValue.Address; $scope.BranchLogo = pdfValue.LogoPath; $scope.FeesReceiptTitle = pdfValue.FeesReceiptTitle; $scope.receiptNo=pdfValue.ReceiptNo; $scope.cur_url = window.location.hostname + window.location.pathname; console.log($scope.cur_url); console.log($scope.BranchLogo); } //testing for print $scope.printPdf = function (print) { var printHtml = document.getElementById(print).outerHTML; //var currentPage = document.body.innerHTML; var popupWinindow = window.open('', '_blank', 'width=1200,height=700,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no'); var elementPage = '' + printHtml + '





' + printHtml + ''; popupWinindow.document.body.innerHTML = elementPage; popupWinindow.document.body.innerHTML = elementPage; popupWinindow.print(); //window.location.reload(); popupWinindow.document.close(); } // $scope.mouseLeave = function(){ // $scope.showButton = false; // $scope.billNo=""; // $scope.sessionName=""; // $scope.paymentType=""; // $scope.billDate=""; // $scope.amountInWords = ""; // $scope.billAmount = ""; // $scope.branchName = ""; // $scope.ReceivedBy=""; // $scope.BranchAddr = ""; // $scope.BranchLogo = ""; // $scope.FeesReceiptTitle=""; // $scope.receiptNo=""; // } }]); app.directive('visible', function() { return { restrict: 'A', link: function(scope, element, attributes) { scope.$watch(attributes.visible, function(value){ element.css('visibility', value ? 'visible' : 'hidden'); }); } }; }); /*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: 3, 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 () { $log.info('Modal dismissed at: ' + new Date()); }); } 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 () { $log.info('Modal dismissed at: ' + new Date()); }); }; $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"); }); } /** * Created by Viual Studio. * User: sriram * Date: 8/9/18 * */ $scope.reregisterPDF = function(student){ var coursefiltered = $scope.studentInfo.filter((universitycourse)=>universitycourse.ID == $scope.viewId); //console.log(coursefiltered); var getsubject = { method:'post', url:apiPoint.url +"getSubject", headers: { 'Content-Type': 'application/json' }, data:{ SemNum:student.Sem_Year, Course:coursefiltered[0].CourseID, branchId: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, } }; $http(getsubject).then(function(response){ // console.log(response); if(response.data.status ==200 && response.data.SubjectStatus){ //angular.forEach($scope.selectedStudentsID,function(studentdata,key){ // angular.forEach(response.data.SubjectDetails[key],function(subjectdata,subkey){ // console.log(subkey); // $scope.subjectDetails.push(subjectdata); // }); $scope.openReregistration(coursefiltered,response.data.SubjectDetails,student); //}); } // if(response.data.message == "Something Went Wrong!" ){ // //alert(); // swal('No Subject Available','','warning'); },function(error){ swal('No Subject Available','','warning'); }); } $scope.openReregistration = function(coursefiltered,Subjects,sem){ // console.log(PDFdata); //$rootScope.Student = PDFdata; // console.log($rootScope.Student); // return false; $rootScope.sem = sem.Sem_Year; //console.log($rootScope.sem); $rootScope.Course = coursefiltered[0]; //console.log($rootScope.Course); $rootScope.Subject = Subjects; // console.log($rootScope.Subject); // return false; var modalInstance = $modal.open({ templateUrl: 'assets/views/reregistration/reregistrationformpdf.html', controller: 'studentModalDemoCtrl', // size: size, resolve: { pdfitems: function () { //return $scope.FeesName; return sem; } } }); modalInstance.result.then(function (selectedItem) { $scope.selected = selectedItem; }, function () { $log.info('Modal dismissed at: ' + new Date()); }); }; $scope.generatePDF = function(){ var innerContents = document.getElementById("reregisterform").innerHTML; var popupWinindow = window.open('', '_blank', 'width=1200,height=700,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no'); popupWinindow.document.open(); popupWinindow.document.write(''); popupWinindow.document.write(''); popupWinindow.document.write(innerContents); popupWinindow.document.write('
'); popupWinindow.document.write('
'); popupWinindow.document.write('
'); popupWinindow.document.write('
'); //popupWinindow.document.write(innerContents); popupWinindow.document.write(''); popupWinindow.document.close(); popupWinindow.focus(); popupWinindow.print(); popupWinindow.close(); // var sem = "Sem/Year:"+$scope.sem; // var universityaddress = encodeURIComponent($scope.Course.Address).replace(/[%2C %20]/g,' '); // $scope.universityAddress = universityaddress.replace(" "," ");; // $scope.universitydetails = "Mobile: "+$scope.Course.UnivMobileNumber+",E-mail id:"+$scope.Course.EmailID; // $scope.Enroll = "Enrolment No: "; // $scope.courseDetails = "Course Name: "+$scope.Course.CourseName+" specialization: "+$scope.Course.Specilization +sem // $scope.StudentName = "Name of the Candidate: "+$scope.Course.Firstname +' '+ $scope.Course.Lastname; // $scope.StudentFatername = "Father's Name: "+$scope.Course.Fathername; // $scope.StudentMotherName = "Mother's Name: "+$scope.Course.MotherName; // //var str = $scope.Student.PresentAddress; // var str = encodeURIComponent($scope.Course.PermanentAddress).replace(/[%2C %20 %0A]/g,' '); // // str.replace("%0A"," "); // // str.replace("%20"," "); // // str.replace("%2C"," "); // $scope.StudnetAddress = "Address: "+ str.replace(" "," "); // $scope.StudentPin = "Pincode: .................. Mobile No: "+$scope.Course.MobileNumber+" Email ID: "+$scope.Course.EmailID; // // var sem1 = doc.autoTableHtmlToJson(document.getElementById(subject)); // var universityname = $scope.Course.UniversityName; // var universityCap = universityname.toUpperCase(); // var doc = new jsPDF('A4'); // var img = document.getElementById("logo"); // var canvas = document.createElement("canvas"); // canvas.width = 100; // canvas.height = 100; // var ctx = canvas.getContext("2d"); // ctx.drawImage(img, 0, 0,100,100); // var dataURL = canvas.toDataURL("image/png"); // doc.rect(10, 10, 190, 280); // doc.text(70, 20, universityCap); // doc.text(80, 26,$scope.universityAddress); // doc.addImage(dataURL, 'jpeg', 50, 13, 10, 10); // doc.setFontSize(14); // doc.text(70,32,"RE-REGISTRATION FORM"); // doc.setFontSize(12); // doc.text(40,42,$scope.universitydetails); // doc.setFontSize(10); // doc.setFontSize(10); // var formdetails = "The form should be complete in all respects and to be filled by student in English CAPITAL letters in blue /black ink."; // var details = doc.splitTextToSize(formdetails,200); // doc.text(15,50,details); // doc.setFontSize(12); // doc.line(10, 45, 200, 45); // var col = 45; // var EnLen = $scope.Course.EnrollmentID.length; // //console.log(EnLen); // var k = 0; // if(EnLen !=0){ // while( k<= EnLen-1){ // //console.log(k); // doc.text(15,60,$scope.Enroll);doc.rect(col,57,5,5); // col = col+1; // doc.text(col,61,$scope.Course.EnrollmentID[k]); // col = parseInt(col)+4; // k++; // } // }else{ // doc.text(15,60,$scope.Enroll); doc.rect(45,55,5,5);doc.rect(50,55,5,5);doc.rect(55,55,5,5);doc.rect(60,55,5,5);doc.rect(65,55,5,5);doc.rect(70,55,5,5);doc.rect(75,55,5,5);doc.rect(80,55,5,5);doc.rect(85,55,5,5);doc.rect(90,55,5,5);doc.rect(95,55,5,5);doc.rect(100,55,5,5);doc.rect(105,55,5,5);doc.rect(110,55,5,5);doc.rect(115,55,5,5);doc.rect(120,55,5,5);doc.rect(125,55,5,5); // // doc.text(46,59,$scope.Student.EnrollmentID[0]);doc.text(51,59,$scope.Student.EnrollmentID[1]);doc.text(56,59,$scope.Student.EnrollmentID[2]);doc.text(61,59,$scope.Student.EnrollmentID[3]);doc.text(66,59,$scope.Student.EnrollmentID[4]); // // doc.text(71,59,$scope.Student.EnrollmentID[5]);doc.text(76,59,$scope.Student.EnrollmentID[6]);doc.text(81,59,$scope.Student.EnrollmentID[7]);doc.text(86,59,$scope.Student.EnrollmentID[8]);doc.text(91,59,$scope.Student.EnrollmentID[9]); // // doc.text(96,59,$scope.Student.EnrollmentID[10]);doc.text(101,59,$scope.Student.EnrollmentID[11]);doc.text(106,59,$scope.Student.EnrollmentID[12]); // // //doc.text(111,59,$scope.Student.EnrollmentID[13]);doc.text(116,59,$scope.Student.EnrollmentID[14]);doc.text(121,59,$scope.Student.EnrollmentID[15]); // } // doc.setFontSize(10); // doc.text(15,70,$scope.courseDetails); // doc.setFontSize(12); // doc.text(15,80,"Examination Session: January ");doc.rect(73,77,5,5);doc.text(80,80,"June");doc.rect(90,77,5,5);doc.text(100,80,"Semester Mode");doc.rect(131,77,5,5);doc.text(140,80,"Yearly Mode");doc.rect(165,77,5,5); // // doc.autoTable(sem1.columns, sem1.data, {margin: {top: 100},theme:'grid'}); // doc.line(10, 83, 200, 83); // doc.text(15,88,$scope.StudentName); // doc.text(60,89,"......................................................................................................................"); // doc.text(15,95,$scope.StudentFatername); // doc.text(43,96,"...................................................................................................................................."); // doc.text(15,102,$scope.StudentMotherName); // doc.text(43,103,"...................................................................................................................................."); // doc.text(15,110,$scope.StudnetAddress); // doc.text(30,111,"................................................................................................................................................"); // doc.text(15,121,$scope.StudentPin); // doc.text // doc.line(10, 125, 200,125); // doc.text(45,130,"SUBJECT / PAPER IN WHICH CANDIDATE APPEARING") // doc.line(10, 131, 200, 131); // doc.text(20,135,"SR.NO"); // doc.text(60,135,"Subject Code"); // doc.text(110,135,"Subject/Paper Code"); // doc.line(10,137,200,137); // var row = 137; // var no = 1; // //console.log(); // angular.forEach($scope.Subject[0],function(subjectData,key){ // //for(var i=0;i<=$scope.Subject[key].length-1;i++){ // // console.log(subjectData); // doc.line(10,row,200,row); // no = no.toString(); // doc.text(20,row+5,no); // doc.text(65,row+5,subjectData.SubjectCode); // doc.setFontSize(10); // doc.text(100,row+5,subjectData.SubjectName); // row = row+6; // no = parseInt(no)+1; // doc.line(10,row,200,row); // }); // var index = 14; // var len = index-$scope.Subject[0].length; // //console.log(len); // for(var j=0;j<=len;j++){ // if(no <=9){ // no = no.toString(); // doc.text(20,row+5,no); // }else{ // no = no.toString(); // doc.text(19,row+5,no); // } // // doc.text(75,row+5,"--"); // // doc.text(120,row+5,"--"); // row = row+6; // no = parseInt(no)+1; // doc.line(10,row,200,row); // } // doc.line(10,240,200,240); // doc.text(15,250,"Fees Details: Cash / Cheque / DD"); // doc.text(15,260,"DD No / Cheque No ....................... Dated ............... Bank ...................."); // doc.text(15,270,"Amount ..................."); // doc.text(150,280,"Signature of Candidate"); // doc.save($scope.Course.Firstname +'_'+ $scope.Course.Lastname+'_'+$scope.sem+'.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'); }; }]); app.filter('unique', function() { return function(collection, primaryKey, secondaryKey) { //optional secondary key var output = [], keys = []; angular.forEach(collection, function(item) { var key; secondaryKey === undefined ? key = item[primaryKey] : key = item[primaryKey][secondaryKey]; if(keys.indexOf(key) === -1) { keys.push(key); output.push(item); } }); return output; }; }); app.filter('getById', function() { return function(input, id) { var i=0, len=input.length; for (; i