From 2cbb4d7ffa988767a6925e97fb9b129c3a765d4c Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 10 Sep 2018 17:23:37 +0530 Subject: [PATCH] edit university payment details changes --- Apollo/api/application/config/routes.php | 2 + ...Receive_Enrolment_Fees_Univ_Controller.php | 37 ++++ .../Receive_Enrolment_Fees_Univ_model.php | 75 +++++++- .../js/controllers/univFormPaymentCtrl.js | 166 ++++++++++++++++++ .../views/student/UnivFormPaymentDetails.html | 9 +- .../student/updateUniversityPaymentModal.html | 103 +++++++++++ 6 files changed, 390 insertions(+), 2 deletions(-) create mode 100644 Apollo/assets/views/student/updateUniversityPaymentModal.html diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 0465bb22..472986f4 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -379,4 +379,6 @@ $route['getUniversityCodeForFormDetailsGet'] = 'Receive_Enrolment_Fees_Univ_Cont $route['getUnmatchedFormIdFeesDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/getUnmatchedFormIdFeesDetails'; $route['addToAccountStateList'] = 'Receive_Enrolment_Fees_Univ_Controller/addToAccountStateList'; $route['addUniversityPaymentDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/addUniversityPaymentDetails'; +$route['updateUniversityPaymentDetails'] = 'Receive_Enrolment_Fees_Univ_Controller/updateUniversityPaymentDetails'; + 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 01120c37..8cff220d 100644 --- a/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php +++ b/Apollo/api/application/controllers/Receive_Enrolment_Fees_Univ_Controller.php @@ -38,6 +38,7 @@ class Receive_Enrolment_Fees_Univ_Controller extends REST_Controller { $this->methods['addManualEnrolmentDetails_post']['limit'] = 1000; $this->methods['addUniversityPaymentDetails_post']['limit'] = 1000; + $this->methods['updateUniversityPaymentDetails_post']['limit'] = 1000; // load the model $this->load->model('Receive_Enrolment_Fees_Univ_model', 'receive_model'); @@ -517,6 +518,42 @@ class Receive_Enrolment_Fees_Univ_Controller extends REST_Controller { } } + /* + * update university payment details*/ + public function updateUniversityPaymentDetails_post(){ + $now = new DateTime(); + $now->setTimezone(new DateTimezone('Asia/Kolkata')); + $details=$this->post('details'); + $localData=$this->post('localDetails'); + $update['ID']=$details['ID']; + $update['PaymentID']=$details['paymentID']; + $payment['BillNo']=$details['billNo']; + $payment['ReceiptNo']=$details['receiptNo']; + $payment['Amount']=$details['billAmount']; + $payment['ApprovedDate']=$details['date']; + $payment['Remarks']=$details['comments']; + $payment['BranchCode']=$localData['localBranchID']; + $payment['updatedBy']=$localData['localUserID']; + $payment['updatedOn']=$now->format('Y-m-d H:i:s'); + // debit array + $debit['DebitAmount']=$details['billAmount']; + $debit['ApprovedDate']=$details['date']; + $debit['BranchCode']=$localData['localBranchID']; + $debit['updatedBy']=$localData['localUserID']; + $debit['updatedOn']=$now->format('Y-m-d H:i:s'); + $updatePaymentDetails=$this->receive_model->updatePaymentDetails($update,$payment,$debit); + if($updatePaymentDetails['status']==true){ + $this->response($updatePaymentDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else if($updatePaymentDetails['status']==false){ + $this->response($updatePaymentDetails, 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 e4c23cf8..4a5584d9 100644 --- a/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php +++ b/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php @@ -1352,7 +1352,7 @@ $result['updatedraftStatus'] = false; * 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,UNP.BillNo,UNP.PID as PaymentID'); + $this->db->select('UNCD.ID,UNCD.FormMapID,UNCD.PaymentMapID,UNCD.FormID,UNCD.CreditAmount,UNCD.DebitAmount,DATE_FORMAT(UNCD.ApprovedDate, "%d-%m-%Y") as FormatDate,UNCD.ApprovedDate,UNCD.UniversityCode,UNCD.UniversityName,UNCD.TypeID,ENU.EnrolmentNo,UNP.BillNo,UNP.PID as PaymentID,UNP.Amount,UNP.ReceiptNo,UNP.Remarks'); $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'); @@ -1467,4 +1467,77 @@ $result['updatedraftStatus'] = false; return $resultArray; } + /* + * update payment details + * created by kms + * */ + public function updatePaymentDetails($update=null,$payment=null,$debit=null){ + $resultArray=array(); + $this->db->where('UNP.BillNo', $payment['BillNo']); + $this->db->where('UNP.PID != ', $update['PaymentID']); + $this->db->select('UNP.BillNo'); + $this->db->from(UNIVERSITYPAYMENT.' as UNP'); + $billExist = $this->db->get(); + if($billExist->num_rows()<=0){ + if($payment['ReceiptNo']!='' AND $payment['ReceiptNo']!=null){ + $this->db->where('UNP1.ReceiptNo', $payment['ReceiptNo']); + $this->db->where('UNP1.PID != ', $update['PaymentID']); + $this->db->select('UNP1.ReceiptNo'); + $this->db->from(UNIVERSITYPAYMENT.' as UNP1'); + $receiptExist = $this->db->get(); + if($receiptExist->num_rows()<=0){ + $this->db->where('PID', $update['PaymentID']); + $this->db->update(UNIVERSITYPAYMENT, $payment); + if ($this->db->affected_rows() > 0) { + $this->db->where('ID', $update['ID']); + $this->db->update(UNIVERSITYCREDITDEBIY, $debit); + if ($this->db->affected_rows() > 0) { + $resultArray['status']=true; + $resultArray['message']="Payment update successfully"; + } + else{ + $resultArray['status']=false; + $resultArray['message']="Payment update 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->where('PID', $update['PaymentID']); + $this->db->update(UNIVERSITYPAYMENT, $payment); + if ($this->db->affected_rows() > 0) { + $this->db->where('ID', $update['ID']); + $this->db->update(UNIVERSITYCREDITDEBIY, $debit); + if ($this->db->affected_rows() > 0) { + $resultArray['status']=true; + $resultArray['message']="Payment update successfully"; + } + else{ + $resultArray['status']=false; + $resultArray['message']="Payment update 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 c78855d3..0f3bb313 100644 --- a/Apollo/assets/js/controllers/univFormPaymentCtrl.js +++ b/Apollo/assets/js/controllers/univFormPaymentCtrl.js @@ -176,6 +176,152 @@ app.controller('univFormPaymentCtrl', ["$scope","$rootScope","$filter", "ngTable }; $rootScope.addError=""; }; + /* + * update university payment details + * created by kms + * */ + $rootScope.updatePaymentModel = { + 'ID':"", + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'universityCode':"", + 'universityName':"", + 'paymentID':"" + + }; + $rootScope.viewPayment = function (values) { + var updateDate=new Date(values.ApprovedDate).toDateString(); + $rootScope.updateError=""; + $rootScope.updatePaymentModel = { + 'ID': values.ID, + 'billNo':values.BillNo, + 'date':$filter('date')(new Date(updateDate), 'yyyy-MM-dd'), + 'billAmount':values.DebitAmount, + 'receiptNo':values.ReceiptNo, + 'comments':values.Remarks, + 'universityCode':values.UniversityCode, + 'universityName':values.UniversityName, + 'paymentID':values.PaymentID + }; + $rootScope.updatePaymentModal = $modal.open({ + templateUrl: 'assets/views/student/updateUniversityPaymentModal.html', + // controller: 'univFormPaymentCtrl', + // size: size, + resolve: { + items: function () { + return $rootScope.updatePaymentModel; + } + } + }); + + $rootScope.updatePaymentModal.result.then(function (selectedItem) { + }, function () { + $rootScope.updatePaymentModal.close(); + $rootScope.updatePaymentModel = { + 'ID':"", + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'universityCode':"", + 'universityName':"", + 'paymentID':"" + + }; + }); + + } + + $rootScope.updateError=""; + $rootScope.updateUnivPayment = function (form,updateDetails) { + $rootScope.updateError=""; + var firstError = null; + if (form.$invalid) { + + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); + } + else{ + var changeDate; + if(angular.isObject(updateDetails.date)){ + var saveDate=new Date(updateDetails.date).toDateString(); + changeDate=$filter('date')(new Date(saveDate), 'yyyy-MM-dd'); + } + else{ + changeDate=updateDetails.date; + + } + $scope.univUpdateData = { + "universityCode":updateDetails.universityCode, + "universityName":updateDetails.universityName, + "billNo":updateDetails.billNo, + "billAmount":updateDetails.billAmount, + "date":changeDate, + "receiptNo":updateDetails.receiptNo, + "comments":updateDetails.comments, + "ID":updateDetails.ID, + "paymentID":updateDetails.paymentID, + } + + var updatePayment = { + method: 'POST', + url: apiPoint.url + 'updateUniversityPaymentDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localDetails: localDetail, + details: $scope.univUpdateData, + } + }; + $http(updatePayment).then(function (response) { + if (response.data.status==true) { + swal(" ", response.data.message, "success"); + $rootScope.updatePaymentModal.close(); + $rootScope.updatePaymentModel = { + 'ID':"", + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'universityCode':"", + 'universityName':"", + 'paymentID':"" + + }; + $rootScope.getPaymentVerificationDetails($scope.paymentVerficationModel); + + + } else { + $rootScope.updateError=response.data.message; + $timeout(function () { + $rootScope.updateError=""; + }, 4000); + + + } + }); + } + + } + + /* @@ -233,4 +379,24 @@ app.controller('univFormPaymentCtrl', ["$scope","$rootScope","$filter", "ngTable }); }; + /* + * cancel update modal + * */ + $rootScope.cancelUpdatePaymentModal=function () { + $rootScope.updatePaymentModal.close(); + /* $rootScope.updatePaymentModel = { + 'ID':"", + 'billNo':"", + 'date':"", + 'billAmount':"", + 'receiptNo':"", + 'comments':"", + 'universityCode':"", + 'universityName':"", + 'paymentID':"" + + };*/ + $rootScope.updateError=""; + }; + }]); \ No newline at end of file diff --git a/Apollo/assets/views/student/UnivFormPaymentDetails.html b/Apollo/assets/views/student/UnivFormPaymentDetails.html index eb2748c9..c35122ea 100644 --- a/Apollo/assets/views/student/UnivFormPaymentDetails.html +++ b/Apollo/assets/views/student/UnivFormPaymentDetails.html @@ -2,6 +2,10 @@ .universityPaid { background: #f4f4f7 !important; } + .spanCursor{ + cursor: pointer; + + }
@@ -65,6 +69,7 @@ Form ID Enrolment No Bill No + Date Payable Paid Balance @@ -75,7 +80,9 @@ {{p.FormID}} {{p.EnrolmentNo}} - {{p.BillNo}} + {{p.BillNo}} + {{p.FormatDate}} + {{p.CreditAmount}} diff --git a/Apollo/assets/views/student/updateUniversityPaymentModal.html b/Apollo/assets/views/student/updateUniversityPaymentModal.html new file mode 100644 index 00000000..b857d800 --- /dev/null +++ b/Apollo/assets/views/student/updateUniversityPaymentModal.html @@ -0,0 +1,103 @@ +
+
+ + Payment for : {{updatePaymentModel.universityName}} +
+
+
+ + + + Bill no is required +
+
+ + + + Bill amount is required + Enter a valid amount + +
+
+
+ + + Date is required. +
+ +
+
+
+
+ + + +
+
+ + +
+ +
+
+
+
+ {{updateError}} + + + + + +
+
+
+ +
+
+ +
\ No newline at end of file