From 408feb4e8a10e153add88a73760231c7988555bc Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 18 Dec 2017 11:35:12 +0530 Subject: [PATCH] course details changes done --- .../assets/js/controllers/feesStatusCtrl.js | 310 ++++++++++++++++++ 1 file changed, 310 insertions(+) diff --git a/Apollo/assets/js/controllers/feesStatusCtrl.js b/Apollo/assets/js/controllers/feesStatusCtrl.js index fca734e6..b60c8a72 100755 --- a/Apollo/assets/js/controllers/feesStatusCtrl.js +++ b/Apollo/assets/js/controllers/feesStatusCtrl.js @@ -5,5 +5,315 @@ */ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) { + $scope.myModel = { + "studentName": "", + "mobileNumber": "", + }; + + /* + * updateModel default value + * */ + + $scope.updateModel = { + "feesType": "", + "sessionName": "", + "STF_WR": "", + "others": "", + "waiver": "", + "total": "", + "date": "", + "billNo": "", + "billAmount": "", + "paymentOn": "", + "internalComments":"", + "studComments":"", + + }; + /* + * get payment options + * */ + $scope.paymentOptions = [ + { + "paymentOn":"CASH" + }, + { + "paymentOn":"CHEQUE" + }, + { + "paymentOn":"NEFT" + }, + { + "paymentOn":"CASH DEPOSIT" + } + + ]; + // sorting function for table params + $scope.sort = function(keyname){ + $scope.sortKey = keyname; //set the sortKey to the param passed + $scope.reverse = !$scope.reverse; //if true make it false and vice versa + } + + /* + * get student details + * created by kms + * */ + $scope.studentInfo=""; + $scope.getStudentDetails = function (form,myModel) { + 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, + requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(getStudent).then(function (response) { + if (response.data.status==200 && response.data.studentStatus) { + $scope.studentInfo=response.data.details; + + } else { + $scope.studentInfo=""; + + } + }); + + } + } + + /* + * get update fees details for student + * created by kms + * */ + $scope.editId=-1; + $scope.updateFees = function (p) { + $scope.getStudentFeesStructure(p.ID,p.CourseID,p.StudentID); + $scope.editId=p.ID; + + } + + /* + * update total fees amount after change value + * created by kms + * */ + $scope.changeTotalFees = function (model,type) { + if(type=='0'){ + if(model.feesType.PendingFees=='' || model.feesType.PendingFees==undefined){ + $scope.courseAmt=0; + } + else{ + $scope.courseAmt=model.feesType.PendingFees; + } + if(model.feesType.STFOrWR=='' || model.feesType.STFOrWR==undefined || model.feesType.STFOrWR=='0'){ + $scope.updateModel.STF_WR=""; + $scope.STFWRAmt=0; + } + else{ + $scope.STFWRAmt=model.feesType.STFOrWR; + $scope.updateModel.STF_WR=model.feesType.STFOrWR; + } + if(model.feesType.Others=='' || model.feesType.Others==undefined || model.feesType.Others=='0'){ + + $scope.otherAmt=0; + $scope.updateModel.others=""; + } + else{ + $scope.otherAmt=model.feesType.Others; + $scope.updateModel.others=model.feesType.Others; + } + if(model.feesType.Waiver=='' || model.feesType.Waiver==undefined || model.feesType.Waiver=='0'){ + $scope.waiverAmt=0; + $scope.updateModel.waiver=""; + + } + else{ + $scope.updateModel.waiver=model.feesType.Waiver; + } + } + + else{ + if(model.feesType.PendingFees=='' || model.feesType.PendingFees==undefined){ + $scope.courseAmt=0; + } + else{ + $scope.courseAmt=model.feesType.PendingFees; + } + if(model.STF_WR=='' || model.STF_WR==undefined){ + $scope.STFWRAmt=0; + } + else{ + $scope.STFWRAmt=model.STF_WR; + } + if(model.others=='' || model.others==undefined){ + $scope.otherAmt=0; + } + else{ + $scope.otherAmt=model.others; + } + if(model.waiver=='' || model.waiver==undefined){ + $scope.waiverAmt=0; + } + else{ + $scope.waiverAmt=model.waiver; + } + } + + + + $scope.updateModel.total = (parseFloat($scope.courseAmt)+parseFloat($scope.STFWRAmt)+parseFloat($scope.otherAmt))-parseFloat($scope.waiverAmt); + $scope.updateModel.billAmount = (parseFloat($scope.courseAmt)+parseFloat($scope.STFWRAmt)+parseFloat($scope.otherAmt))-parseFloat($scope.waiverAmt); + } + + + + /* + * save fees details for student + * created by kms + * */ + $scope.saveFees = function (myModel, form,updateModel, loading) { + if(isNaN(updateModel.date)){ + $scope.billDate = updateModel.date; + + } + else{ + $scope.getdate=new Date(updateModel.date).toDateString(); + + $scope.billDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy'); + } + var firstError = null; + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$stop_name; + } + + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + } else { + $scope.ldloading = {}; + + $scope.ldloading[loading.replace('-', '_')] = true; + + + var updateFees = { + method: 'POST', + url: apiPoint.url + 'updateFeesDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + studID: myModel.StudentID, + courseID:myModel.CourseID, + courseAmount:updateModel.feesType.PendingFees, + feesID: updateModel.feesType.ID, + STFWR:updateModel.STF_WR, + waiver: updateModel.waiver, + other: updateModel.others, + session: updateModel.sessionName, + billNO: updateModel.billNo, + billDate: $scope.billDate, + billAmount:updateModel.billAmount, + modeOfPayment: updateModel.paymentOn.paymentOn, + commentsForStudent: updateModel.studComments, + internalComments: updateModel.internalComments, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + + } + }; + $http(updateFees).then(function (response) { + if (response.data.status==200 && response.data.paidStatus) { + $scope.ldloading[loading.replace('-', '_')] = false; + // $rootScope.init(); + swal("Success!", response.data.message, "success"); + + $scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID); + $scope.updateModel = { + "feesType": "", + "sessionName": "", + "STF_WR": "", + "others": "", + "waiver": "", + "total": "", + "date": "", + "billNo": "", + "billAmount": "", + "paymentOn": "", + "internalComments":"", + "studComments":"", + + }; + + } else { + $scope.ldloading[loading.replace('-', '_')] = false; + //$rootScope.init(); + swal("Failed!", response.data.message, "error"); + $scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID); + } + + }); + } + }; + /* + * Global method for get student fees structure + * created by kms + * */ + $scope.studentFeesInfo=""; + $scope.getStudentFeesStructure = function(ID,courseID,studeID){ + var getFees = { + method: 'POST', + url: apiPoint.url + 'getStudentFeesStructure/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + ID:ID, + courseID: courseID, + studentID: studeID, + requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(getFees).then(function (response) { + if (response.data.status==200 && response.data.feesStatus) { + $scope.studentFeesInfo=response.data.feesDetails; + $scope.existStudentFeesDetails = response.data.getExistStudentFeesDetails; + + } else { + $scope.studentFeesInfo=""; + + } + }); + + } + $scope.cancel = function () { + $scope.editId=-1; + } + + }]); \ No newline at end of file