diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 2f952bc8..f212cfeb 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -372,4 +372,5 @@ $route['addForFormIdDraftDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/add $route['draftMovetoList'] = 'Receive_Enrolment_Fees_Univ_Controller/draftMovetoList'; $route['editDraftFormIdFeesDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/editDraftFormIdFeesDetails'; $route['paymentVerficationDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/paymentVerficationDetails'; +$route['addUniversityPaymentDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/addUniversityPaymentDetails'; diff --git a/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php b/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php index dda9badb..3ade6ee6 100644 --- a/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php +++ b/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php @@ -37,6 +37,7 @@ class Receive_Enrolment_Fees_Univ_Controller extends REST_Controller { $this->methods['getExistStudentEnrolmentDetails_post']['limit'] = 1000; $this->methods['addManualEnrolmentDetails_post']['limit'] = 1000; + $this->methods['paymentVerficationDetails_post']['limit'] = 1000; // load the model $this->load->model('Receive_Enrolment_Fees_Univ_model', 'receive_model'); @@ -332,10 +333,65 @@ class Receive_Enrolment_Fees_Univ_Controller extends REST_Controller { } else { // Set the response and exit - $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + $this->response(['message' => 'No list were found', 'status' => false], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } + /* + * get payment verfication details + * created by kms + * */ + public function paymentVerficationDetails_post(){ + $fromDetails['UniversityCode']=$this->post('universityID'); + $fromDetails['UniversityName']=$this->post('universityName'); + $getVerificationDetails=$this->receive_model->getPaymentVerificationDetails($fromDetails); + if($getVerificationDetails['status']==true){ + $this->response($getVerificationDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + + } + else if($getVerificationDetails['status']==false){ + $this->response($getVerificationDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + + } + else{ + $this->response(['details' => 'No list were found', 'status' => false], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + + } + } + /* + * add university payment details + * created by kms + * */ + public function addUniversityPaymentDetails_post(){ + $now = new DateTime(); + $now->setTimezone(new DateTimezone('Asia/Kolkata')); + $details=$this->post('details'); + $localData=$this->post('localDetails'); + $fromDetails['BillNo']=$details['billNo']; + $fromDetails['ReceiptNo']=$details['receiptNo']; + $fromDetails['Amount']=$details['billAmount']; + $fromDetails['ApprovedDate']=$details['date']; + $fromDetails['UniversityCode']=$details['universityCode']; + $fromDetails['UniversityName']=$details['universityName']; + $fromDetails['Remarks']=$details['comments']; + $fromDetails['BranchCode']=$localData['localBranchID']; + $fromDetails['CreatedBy']=$localData['localUserID']; + $fromDetails['CreatedOn']=$now->format('Y-m-d H:i:s'); + $addPaymentDetails=$this->receive_model->addPaymentDetails($fromDetails); + if($addPaymentDetails['status']==true){ + $this->response($addPaymentDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + + } + else if($addPaymentDetails['status']==false){ + $this->response($addPaymentDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + + } + else{ + $this->response(['message' => 'Try again', 'status' => false], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + + } + } + } \ No newline at end of file diff --git a/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php b/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php index 118c4a71..a218b821 100644 --- a/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php +++ b/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php @@ -1083,4 +1083,124 @@ $result['updatedraftStatus'] = false; return $result; } + /* + * get payment verification details + * created by kms + * */ + public function getPaymentVerificationDetails($search){ + $this->db->select('UNCD.ID,UNCD.FormMapID,UNCD.PaymentMapID,UNCD.FormID,UNCD.CreditAmount,UNCD.DebitAmount,UNCD.ApprovedDate,UNCD.UniversityCode,UNCD.UniversityName,UNCD.TypeID,ENU.EnrolmentNo'); + $this->db->from(UNIVERSITYCREDITDEBIY.' as UNCD'); + $this->db->join(FORMFEESRECEIVEDFROMUNIV.' as UNFR', 'UNFR.ID = UNCD.FormMapID','left'); + $this->db->join(UNIVERSITYPAYMENT.' as UNP', 'UNP.PID = UNCD.PaymentMapID','left'); + $this->db->join(ENROLMENTRECEIVEDFROMUNIV.' as ENU', 'ENU.FormID = UNFR.FormID','left'); + $this->db->order_by('UNCD.ApprovedDate','DESC'); + $this->db->where('UNCD.UniversityCode',$search['UniversityCode']); + $this->db->order_by('UNCD.UniversityName',$search['UniversityName']); + $details = $this->db->get(); + $resultArray=array(); + if($details->result()){ + $resultArray['status']=true; + $resultArray['details']=$details->result(); + + } + + else{ + $resultArray['status']=false; + $resultArray['details']="No list were found"; + } + return $resultArray; + + } + /* + * add payment details + * created by kms + * */ + public function addPaymentDetails($fromDetails=null){ + $resultArray=array(); + $this->db->select('UNP.BillNo'); + $this->db->from(UNIVERSITYPAYMENT.' as UNP'); + $this->db->where('UNP.BillNo', $fromDetails['BillNo']); + $billExist = $this->db->get(); + if($billExist->num_rows()<=0){ + + if($fromDetails['ReceiptNo']!='' AND $fromDetails['ReceiptNo']!=null){ + $this->db->select('UNP1.ReceiptNo'); + $this->db->from(UNIVERSITYPAYMENT.' as UNP1'); + $this->db->where('UNP1.ReceiptNo', $fromDetails['ReceiptNo']); + $receiptExist = $this->db->get(); + if($receiptExist->num_rows()<=0){ + $this->db->insert(UNIVERSITYPAYMENT, $fromDetails); + if ($this->db->affected_rows() > 0) { + $updateDebitTable['PaymentMapID']=$this->db->insert_id(); + $updateDebitTable['DebitAmount']=$fromDetails['Amount']; + $updateDebitTable['ApprovedDate']=$fromDetails['ApprovedDate']; + $updateDebitTable['TypeID']=0; + $updateDebitTable['TypeName']="Debit"; + $updateDebitTable['UniversityCode']=$fromDetails['UniversityCode']; + $updateDebitTable['UniversityName']=$fromDetails['UniversityName']; + $updateDebitTable['BranchCode']=$fromDetails['BranchCode']; + $updateDebitTable['CreatedBy']=$fromDetails['CreatedBy']; + $updateDebitTable['CreatedOn']=$fromDetails['CreatedOn']; + $this->db->insert(UNIVERSITYCREDITDEBIY, $updateDebitTable); + if ($this->db->affected_rows() > 0) { + $resultArray['status']=true; + $resultArray['message']="Payment added successfully"; + } + else{ + $this->db->delete(UNIVERSITYPAYMENT); + $this->db->where('PID',$updateDebitTable['PaymentMapID']); + $resultArray['status']=false; + $resultArray['message']="Payment failed.try again"; + } + + } else { + $resultArray['status']=false; + $resultArray['message']="Payment failed.Try again"; + } + } + else{ + $resultArray['status']=false; + $resultArray['message']="Receipt no is already exist.."; + } + } + else{ + $this->db->insert(UNIVERSITYPAYMENT, $fromDetails); + if ($this->db->affected_rows() > 0) { + $updateDebitTable['PaymentMapID']=$this->db->insert_id(); + $updateDebitTable['DebitAmount']=$fromDetails['Amount']; + $updateDebitTable['ApprovedDate']=$fromDetails['ApprovedDate']; + $updateDebitTable['TypeID']=0; + $updateDebitTable['TypeName']="Debit"; + $updateDebitTable['UniversityCode']=$fromDetails['UniversityCode']; + $updateDebitTable['UniversityName']=$fromDetails['UniversityName']; + $updateDebitTable['BranchCode']=$fromDetails['BranchCode']; + $updateDebitTable['CreatedBy']=$fromDetails['CreatedBy']; + $updateDebitTable['CreatedOn']=$fromDetails['CreatedOn']; + $this->db->insert(UNIVERSITYCREDITDEBIY, $updateDebitTable); + if ($this->db->affected_rows() > 0) { + $resultArray['status']=true; + $resultArray['message']="Payment added successfully"; + } + else{ + $this->db->delete(UNIVERSITYPAYMENT); + $this->db->where('PID',$updateDebitTable['PaymentMapID']); + $resultArray['status']=false; + $resultArray['message']="Payment failed.try again"; + } + + } else { + $resultArray['status']=false; + $resultArray['message']="Payment failed.Try again"; + } + + } + } + else { + $resultArray['status']=false; + $resultArray['message']="Bill no is already exist.."; + } + return $resultArray; + + } + } \ No newline at end of file diff --git a/Apollo/assets/js/controllers/univFormPaymentCtrl.js b/Apollo/assets/js/controllers/univFormPaymentCtrl.js index e69de29b..c78855d3 100644 --- a/Apollo/assets/js/controllers/univFormPaymentCtrl.js +++ b/Apollo/assets/js/controllers/univFormPaymentCtrl.js @@ -0,0 +1,236 @@ +'use strict'; +/** + * controllers for ng-table + * Simple table with sorting and filtering on AngularJS + */ +app.controller('univFormPaymentCtrl', ["$scope","$rootScope","$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", "$modal", "$log", "SweetAlert", "$timeout", function ($scope,$rootScope, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, $modal, SweetAlert, $log, $timeout) { + // ng-model object for payment search + $scope.paymentVerficationModel= { + 'universitySearch':"", + }; + // load when html page load + var localDetail = JSON.parse(localStorage.getItem('localObj')); + + $scope.init = function () { + + if (localDetail != null) { + if (localDetail.localType === 'R004') { + $scope.getPaymentUnivSearchData(); + } else { + localStorage.removeItem('localObj'); + $state.go('login.signin'); + } + } else { + $state.go('login.signin'); + } + } + /* + * get university details for search + * cretaed by kms + * */ + $scope.universityPaymentSearchData=[]; + $scope.getPaymentUnivSearchData = function () { + var paymentSearch = { + method: 'POST', + url: apiPoint.url + 'getUnivCourseFromFileDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: localDetail + } + }; + $http(paymentSearch).then(function (response) { + if (response.data.status) { + $scope.universityPaymentSearchData = response.data.details; + } else { + $scope.universityPaymentSearchData=""; + } + }); + } + /* + * add payment details + * created by kms + * */ + $rootScope.addPaymentModel = { + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'university':[] + }; + $scope.addUniversityPaymentModal = function (values) { + $rootScope.addError=""; + $rootScope.addPaymentModel.university=angular.fromJson(values.universitySearch); + $rootScope.paymentModal = $modal.open({ + templateUrl: 'assets/views/student/addUniversityPaymentModal.html', + // controller: 'univFormPaymentCtrl', + // size: size, + resolve: { + items: function () { + return $scope.univPayDetails; + } + } + }); + + $rootScope.paymentModal.result.then(function (selectedItem) { + }, function () { + $rootScope.paymentModal.close(); + $rootScope.addPaymentModel = { + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'university':[] + }; + }); + }; + /* + * add university payment details + * created by kms + * */ + $rootScope.addError=""; + $rootScope.addUnivPayment = function (form,addDetails) { + $rootScope.addError=""; + var firstError = null; + if (form.$invalid) { + + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); + } + else{ + var getdate=new Date(addDetails.date).toDateString(); + $scope.univPayData = { + "universityCode":addDetails.university.univCode, + "universityName":addDetails.university.univName, + "billNo":addDetails.billNo, + "billAmount":addDetails.billAmount, + "date":$filter('date')(new Date(getdate), 'yyyy-MM-dd'), + "receiptNo":addDetails.receiptNo, + "comments":addDetails.comments, + } + + var submitPayment = { + method: 'POST', + url: apiPoint.url + 'addUniversityPaymentDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localDetails: localDetail, + details: $scope.univPayData, + } + }; + $http(submitPayment).then(function (response) { + if (response.data.status==true) { + swal(" ", response.data.message, "success"); + $rootScope.paymentModal.close(); + $rootScope.addPaymentModel = { + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'university':[] + }; + $rootScope.getPaymentVerificationDetails($scope.paymentVerficationModel); + + + } else { + $rootScope.addError=response.data.message; + $timeout(function () { + $rootScope.addError=""; + }, 4000); + + + } + }); + } + + } + /* + * cancel add modal + * */ + $rootScope.cancelAddPaymentModal=function () { + $rootScope.paymentModal.close(); + $rootScope.addPaymentModel = { + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'university':[] + }; + $rootScope.addError=""; + }; + + + /* + * get payment details + * cretaed by kms + * */ + $scope.paymentVerificationData=""; + $scope.emptyList=true; + $scope.searchLoader = false; + $rootScope.getPaymentVerificationDetails = function (searchData) { + $scope.paymentVerificationData=""; + $scope.emptyList=true; + $scope.searchLoader = true; + var paymentVerification = { + method: 'POST', + url: apiPoint.url + 'paymentVerficationDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localData: localDetail, + universityID: angular.fromJson(searchData.universitySearch).univCode, + universityName: angular.fromJson(searchData.universitySearch).univName, + } + }; + $http(paymentVerification).then(function (response) { + if (response.data.status) { + $scope.searchLoader = false; + $scope.emptyList=false; + $scope.paymentVerificationData=response.data.details; + var tagMap = $scope.paymentVerificationData.reduce(function(map, tag,key) { + if(map.RunningBalance==undefined){ + map['RunningBalance'] = parseInt(tag.CreditAmount)-parseInt(tag.DebitAmount); + tag['RunningBalance']=parseInt(tag.CreditAmount)-parseInt(tag.DebitAmount);; + } + else{ + if(parseInt(tag.DebitAmount)<=0){ + map['RunningBalance'] = parseInt(map.RunningBalance)+parseInt(tag.CreditAmount); + tag['RunningBalance']=parseInt(map.RunningBalance); + } + else{ + map['RunningBalance'] = parseInt(map.RunningBalance)-parseInt(tag.DebitAmount); + tag['RunningBalance']=parseInt(map.RunningBalance); + } + + } + return map; + }, {}); + + } else { + $scope.searchLoader = false; + $scope.emptyList=true; + $scope.paymentVerificationData=response.data.details; + } + }); + }; + +}]); \ No newline at end of file diff --git a/Apollo/assets/views/student/UnivFormPaymentDetails.html b/Apollo/assets/views/student/UnivFormPaymentDetails.html index 566549bd..d6ce30fc 100644 --- a/Apollo/assets/views/student/UnivFormPaymentDetails.html +++ b/Apollo/assets/views/student/UnivFormPaymentDetails.html @@ -1,10 +1,94 @@ - - -
- -| Form ID | +Enrolment No | +Payable | +Paid | +Balance | + +||
|---|---|---|---|---|---|---|
| {{p.FormID}} | +{{p.EnrolmentNo}} | ++ | {{p.CreditAmount}} | ++ | {{p.DebitAmount}} | +{{p.RunningBalance}} | + + +