university payment changes

This commit is contained in:
gandhimathi 2018-09-08 19:50:10 +05:30
parent c7ad4d7f21
commit 3282671110
5 changed files with 507 additions and 10 deletions

View File

@ -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';

View File

@ -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
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
});
};
}]);

View File

@ -1,10 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<style>
.universityPaid {
background: #f4f4f7 !important;
}
</style>
<section id="page-title">
<div class="row">
<div class="col-sm-8">
</body>
</html>
<h1 class="mainTitle" translate="University Payment Details">{{ mainTitle }}</h1>
<span class="mainDescription">Form List. </span>
</div>
<div ncy-breadcrumb></div>
</div>
</section>
<div class="container-fluid container-fullw bg-white" ng-controller="univFormPaymentCtrl" data-ng-init="init()">
<div class="row">
<div style="margin-top: -21px">
<div class="col-md-3 col-sm-8">
<label for="form-field-select-2">
University <span class="symbol required"></span>
</label>
<select class="form-control" tabindex="1" class="cs-select cs-skin-elastic" name="universitySearch" id="universitySearch" ng-model="paymentVerficationModel.universitySearch">
<option value="" disabled selected>Select University</option>
<option ng-repeat="item in universityPaymentSearchData" value="{{item}}">{{item.univName}}</option>
</select>
</div>
<div class="col-md-2 col-sm-4" style="padding-top: 23px;">
<button type="button" class="btn btn-success btn-o" tabindex="2" ng-disabled="paymentVerficationModel.universitySearch == ''" ng-click="getPaymentVerificationDetails(paymentVerficationModel)">
Search
</button>
</div>
</div>
</div>
<div class="row" style="float: right;display: flex;">
<div class="container">
<button type="button" ng-if="emptyList==false" class="btn btn-info btn-o" tooltip="Click to add payment" tabindex="3" ng-click="addUniversityPaymentModal(paymentVerficationModel)">
Add Payment
</button>
</div>
</div>
<div class="row" style="position: relative;margin-top:4%;">
<div class="container">
<div ng-if="searchLoader">
<div align="center">
<h3 style="color: blue;">Loading...</h3>
</div>
</div>
<div ng-if="emptyList">
<div align="center">
<h2> {{paymentVerificationData}} </h2>
</div>
</div>
<div class="table-responsive" ng-if="emptyList==false">
<table class="table table-hover table-condensed table-bordered" >
<thead>
<tr>
<th> Form ID</th>
<th> Enrolment No</th>
<th> Payable</th>
<th> Paid </th>
<th> Balance</th>
<!--<th> University Name </th>-->
</tr>
</thead>
<tbody dir-paginate="p in paymentVerificationData|orderBy:sortKey:reverse|filter:search:strict|itemsPerPage:10| filter:query as results">
<tr ng-class="{universityPaid:p.TypeID==0}">
<td>{{p.FormID}}</td>
<td>{{p.EnrolmentNo}}</td>
<td ng-if="p.CreditAmount==0"></td>
<td ng-if="p.CreditAmount>0"><span style="float:right;">{{p.CreditAmount}}</span></td>
<td ng-if="p.DebitAmount==0"></td>
<td ng-if="p.DebitAmount>0"><span style="float:right;">{{p.DebitAmount}}</span></td>
<td><span style="float:right;">{{p.RunningBalance}}</span></td>
<!--<td>{{p.UniversityName}}</td>-->
</tr>
</tbody>
</table>
<dir-pagination-controls max-size="10" direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
</div>
</div>
</div>