569 lines
29 KiB
PHP
Executable File
569 lines
29 KiB
PHP
Executable File
<script>
|
||
$(document).ready(function() {
|
||
|
||
|
||
$('#loan_issued_date').datepicker({
|
||
format: "M-yyyy",
|
||
minViewMode: 1, // Month selection only
|
||
orientation: "bottom auto", // Ensures it opens downward
|
||
autoclose: true
|
||
});
|
||
|
||
$('#due_started').datepicker({
|
||
format: "M-yyyy",
|
||
minViewMode: 1, // Month selection only
|
||
orientation: "bottom auto", // Ensures it opens downward
|
||
autoclose: true
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<?php
|
||
|
||
|
||
$Pay_Data_ID = '';
|
||
$EmpID = '';
|
||
$Empname = "";
|
||
$Basic_Pay = '';
|
||
$HRA_Rate = '';
|
||
|
||
$Allowances = '';
|
||
$PF_Rate = '';
|
||
$ESI_Rate = '';
|
||
$is_Active = '';
|
||
$Food_Allowances = '';
|
||
$Incentives = '';
|
||
$Created_By = '';
|
||
$Created_Time = '';
|
||
$Last_Mod_By = '';
|
||
$Last_Mod_Time = '';
|
||
$HRA_Amount = 0.0;
|
||
$TotalSalary = 0.0;
|
||
$Loan_Amount = '';
|
||
$Loan_issued_date = '';
|
||
$Monthly_due = '';
|
||
$Due_start_date = '';
|
||
$No_of_dues = '';
|
||
$Remaining_Due = '';
|
||
$Paid_Due = '';
|
||
$Paid_Amount = 0;
|
||
$loanid = '';
|
||
$pending_due_amount = 0;
|
||
|
||
|
||
if (!empty($emppay)) {
|
||
// print_r($emppay);
|
||
// die();
|
||
foreach ($emppay as $ep) {
|
||
|
||
|
||
|
||
$Pay_Data_ID = $ep->Pay_Data_ID;
|
||
$EmpID = $ep->PAYEMPID;
|
||
$Empname = $ep->FirstName . " " . $ep->LastName;
|
||
$TotalSalary = $ep->TotalSalary;
|
||
$Basic_Pay = $ep->Basic_Pay;
|
||
$HRA_Rate = $ep->HRA_Rate;
|
||
$HRA_Amount = $ep->HRA_Amount;
|
||
|
||
$Allowances = $ep->Allowances;
|
||
$PF_Rate = $ep->PF_Rate;
|
||
$ESI_Rate = $ep->ESI_Rate;
|
||
$is_Active = $ep->is_Active;
|
||
$Food_Allowances = $ep->Food_Allowances;
|
||
$Incentives = $ep->Incentives;
|
||
$Loan_Amount = $ep->Loan_Amount;
|
||
if (empty($Loan_Amount)) {
|
||
$Loan_Amount = 0.00;
|
||
}
|
||
if (!empty($ep->Loan_Issued_Date)) {
|
||
$Loan_issued_date = new DateTime($ep->Loan_Issued_Date, new DateTimeZone('Asia/Kolkata'));
|
||
$Loan_issued_date = $Loan_issued_date->format('M-Y');
|
||
} else {
|
||
$Loan_issued_date = null;
|
||
}
|
||
|
||
$Monthly_due = $ep->Monthly_Due;
|
||
if (empty($Monthly_due)) {
|
||
$Monthly_due = 0.00;
|
||
}
|
||
if (!empty($ep->Due_Start_Date)) {
|
||
$Due_start_date = new DateTime($ep->Due_Start_Date, new DateTimeZone('Asia/Kolkata'));
|
||
$Due_start_date = $Due_start_date->format('M-Y');
|
||
} else {
|
||
$Due_start_date = null;
|
||
}
|
||
$No_of_dues = $ep->No_of_Dues;
|
||
if (empty($No_of_dues)) {
|
||
$No_of_dues = 0.00;
|
||
}
|
||
$Paid_Due = $ep->Paid_Due;
|
||
if (empty($Paid_Due)) {
|
||
$Paid_Due = 0.00;
|
||
}
|
||
$Remaining_Due = $ep->Remaining_Due;
|
||
if (empty($Remaining_Due)) {
|
||
$Remaining_Due = 0.00;
|
||
}
|
||
$Paid_Amount = $ep->Paid_Amount;
|
||
if (empty($Paid_Amount)) {
|
||
$Paid_Amount = 0.00;
|
||
}
|
||
$Created_By = $ep->Created_By;
|
||
$Created_Time = $ep->Created_Time;
|
||
$Last_Mod_By = $ep->Last_Mod_By;
|
||
$Last_Mod_Time = $ep->Last_Mod_Time;
|
||
$loanid = $ep->Loan_ID;
|
||
$request_letter = $ep->request_letter;
|
||
$payment_statement = $ep->payment_statement;
|
||
$pending_due_amount = $Remaining_Due * $Monthly_due;
|
||
}
|
||
}
|
||
|
||
|
||
?>
|
||
|
||
<style type="text/css">
|
||
.num {
|
||
text-align: right;
|
||
}
|
||
</style>
|
||
|
||
<div class="content-page">
|
||
<div class="content">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<h4 class="page-title">Edit Loan Details<?php echo $Empname ? " - ".$Empname." (".$EmpID.")" : "" ?></h4>
|
||
<a class="btn btn-secondary" href="<?php echo base_url(); ?>emppayListings"><span class="bold">Back</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<h4 class="header-title">Loan Details</h4>
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="p-2">
|
||
<form role="form" id="edit" action="<?php echo base_url() ?>emppaydate/editemppay" method="post" enctype="multipart/form-data">
|
||
<div class="box-body">
|
||
<!-- Supplier Information -->
|
||
<div class="col-md-12" style="margin-bottom: 27px;">
|
||
<input type="hidden" class="form-control required" id="Last_Modified_Time" name="Last_Modified_Time" value="<?php echo $Last_Mod_Time; ?>">
|
||
<input type="hidden" class="form-control required" id="LastModifiedBy" name="LastModifiedBy" value="<?php echo $name; ?>">
|
||
<input type="hidden" class="form-control required" id="Created_Time" name="Created_Time" value="<?php echo $Created_Time; ?>">
|
||
<input type="hidden" class="form-control required" id="CreatedBy" name="CreatedBy" value="<?php echo $Created_By; ?>">
|
||
<input type="hidden" readonly id="Pay_Data_ID" name="Pay_Data_ID" value="<?php echo $Pay_Data_ID; ?>">
|
||
<input type="hidden" class="form-control num" id="Old_Loan_Amount" value="<?php echo $Loan_Amount; ?>">
|
||
<input type="hidden" class="form-control num" id="Old_monthly_due" value="<?php echo $Monthly_due; ?>">
|
||
<div class="row">
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="EmpID">Employee ID</label>
|
||
<input type="text" class="form-control" readonly id="EmployeeID" name="EmpID" value="<?php echo $EmpID; ?>">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
|
||
<input type="hidden" name="loanid" value="<?php echo $loanid; ?>">
|
||
<label for="Pay_Data_ID">Loan Amount</label>
|
||
<input type="text" class="form-control num" id="Loan_Amount" name="Loan_Amount" value="<?php echo $Loan_Amount; ?>" pattern="([0-9]{1,7}([.][0-9]{1,2})?)" title="Minimum 4 digit,Maximum 6 Digit" onchange="duecalculation();">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="Basic_Pay">No Of Due(s)</label>
|
||
<input type="text" class="form-control requried num" id="no_of_due" name="no_of_due" value="<?php echo $No_of_dues; ?>" pattern="[0-9]{1,2}" title="Minimum 1 digit,Maximum 2 Digit" onchange="duecalculation();">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="Basic_Pay">Monthly Due</label>
|
||
<input type="text" class="form-control requried num" id="monthly_due" name="monthly_due" value="<?php echo $Monthly_due; ?>" pattern="([0-9]{1,7}([.][0-9]{1,2})?)" title="Minimum 4 digit,Maximum 6 Digit" readonly>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="EmpID">Loan Issue(d) Date</label>
|
||
<input type="text" class="form-control num" id="loan_issued_date" name="loan_issued_date" value="<?php echo $Loan_issued_date; ?>">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="Basic_Pay">Due Started</label>
|
||
<input type="text" class="form-control requried num" id="due_started" name="due_started" value="<?php echo $Due_start_date; ?>">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<div class="form-group">
|
||
<label for="Basic_Pay">Paid Amount</label>
|
||
<input type="text" class="form-control requried num" id="Paid_Amount" name="Paid_Amount" value="<?php echo $Paid_Amount; ?>" readonly>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="">Paid Due</label>
|
||
<input type="text" class="form-control requried num" id="paid_due" name="paid_due" value="<?php echo $Paid_Due; ?>" readonly>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="">Remaining Due</label>
|
||
<input type="text" class="form-control requried num" id="remaining_due" name="remaining_due" value="<?php echo $Remaining_Due; ?>" readonly>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-3">
|
||
<div class="form-group">
|
||
<label for="">Balance Amount</label>
|
||
<input type="text" class="form-control requried num" id="balance_due_amount" value="<?php echo $pending_due_amount; ?>" readonly>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- File -->
|
||
<h4 class="header-title mt-2 mb-2">Loan Documents</h4>
|
||
<!-- Text input-->
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<div class="form-group">
|
||
<label class="d-block" for="request_letter">Request letter</label>
|
||
<input type="file" accept=".docx,.pdf,.doc,.jpg,.png" id="request_letter" name="request_letter" style="margin-top: 5px;" />
|
||
<input type="hidden" id="hidden_request_letter" name="hidden_request_letter" value="<?php echo $request_letter; ?>" />
|
||
</div>
|
||
</div>
|
||
|
||
<?php if ($request_letter) { ?>
|
||
<div class="col-md-8">
|
||
<div class="form-group">
|
||
<br>
|
||
<u>
|
||
<a href="<?php echo base_url() . 'public/uploads/images/' . $request_letter ?>">
|
||
<span>Previously Uploaded Document - </span><small><?= $request_letter; ?></small>
|
||
</a>
|
||
</u>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
</div> <!-- 1st row div closed here -->
|
||
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<div class="form-group">
|
||
<label class="d-block" for="payment_statement">Payment Receipt</label>
|
||
<input type="file" accept=".docx,.pdf,.doc,.jpg,.png" id="payment_statement" name="payment_statement" style="margin-top: 5px;" />
|
||
<input type="hidden" id="hidden_payment_statement" name="hidden_payment_statement" value="<?php echo $payment_statement; ?>" />
|
||
</div>
|
||
</div>
|
||
|
||
<?php if ($payment_statement) { ?>
|
||
<div class="col-md-8">
|
||
<div class="form-group">
|
||
<br>
|
||
<u>
|
||
<a href="<?php echo base_url() . 'public/uploads/images/' . $payment_statement ?>">
|
||
<span>Previously Uploaded Document - </span><small><?= $payment_statement; ?></small>
|
||
</a>
|
||
</u>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
</div> <!-- 2nd row div closed here -->
|
||
|
||
|
||
|
||
<div class="container">
|
||
<h3>Loan History</h3>
|
||
<table class="table table-bordered table-striped">
|
||
<thead>
|
||
<tr>
|
||
<th>Due Amount</th>
|
||
<th>Balance Amount </th>
|
||
<th>Debit Date</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php if (!empty($loan_histoty)): ?>
|
||
<?php foreach ($loan_histoty as $history): ?>
|
||
<tr>
|
||
<td><?php echo number_format($history->Due_Amount, 2); ?></td>
|
||
<td><?php echo number_format($history->Balance_Amount, 2); ?></td>
|
||
<td><?php $entryDate = new DateTime($history->Entry_Date);
|
||
echo $entryDate->format('F j, Y, g:i A'); ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<?php else: ?>
|
||
<tr>
|
||
<td colspan="6" class="text-center">No Loan History Found</td>
|
||
</tr>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12 text-right">
|
||
<input type="button" class="btn btn-secondary" value="Delete" id="deleteemp" style="margin-right:15px;width:80px;border:none;" />
|
||
<input type="submit" onclick="return finalCheck();" value="Submit" class="btn btn-success">
|
||
<!-- <input type="submit" onmouseover="finalCheck();" value="Submit" class="btn btn-success"> -->
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
$listErrors = session()->getFlashdata('listErrors');
|
||
if ($listErrors) {
|
||
?>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('listErrors'); ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
</div>
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<!-- end row -->
|
||
</div>
|
||
</div> <!-- end card -->
|
||
</div><!-- end col -->
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
<!-- end row -->
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
|
||
<script>
|
||
// function duecalculation() {
|
||
// var totaldue = 0;
|
||
// var loan = document.getElementById('Loan_Amount').value;
|
||
// var due = document.getElementById('monthly_due').value;
|
||
|
||
// if (loan != 0) {
|
||
// if (due == 0) {
|
||
// alert("Enter Monthly Due Amount....!");
|
||
// $('#monthly_due').focus();
|
||
// } else {
|
||
|
||
// totaldue = loan / due;
|
||
|
||
// if (totaldue < 1) {
|
||
// alert("Please Enter Correct Due Amount..!");
|
||
// $('#monthly_due').focus();
|
||
// } else {
|
||
// document.getElementById('no_of_due').value = Math.ceil(totaldue);
|
||
// var noofdues = document.getElementById('no_of_due').value;
|
||
// $('#remaining_due').val(noofdues - $('#paid_due').val());
|
||
// // $('#Paid_Amount').val("0.00");
|
||
// // $('#paid_due').val(0);
|
||
// }
|
||
|
||
// }
|
||
// }
|
||
|
||
// dateCalulation();
|
||
|
||
|
||
// }
|
||
|
||
|
||
function duecalculation() {
|
||
var totaldue = 0;
|
||
var loan = document.getElementById('Loan_Amount').value;
|
||
var no_of_due = document.getElementById('no_of_due').value;
|
||
|
||
if (loan != 0) {
|
||
if (no_of_due == 0) {
|
||
alert("Enter No Of Due");
|
||
$('#no_of_due').focus();
|
||
} else {
|
||
|
||
|
||
paid_due = document.getElementById('paid_due').value;
|
||
no_of_due = no_of_due - paid_due;
|
||
|
||
Paid_Amount = document.getElementById('Paid_Amount').value;
|
||
loan = loan - Paid_Amount
|
||
totalDueAmt = loan / no_of_due;
|
||
balanceDueAmount = no_of_due * totalDueAmt;
|
||
|
||
|
||
document.getElementById('monthly_due').value = Math.ceil(totalDueAmt);
|
||
|
||
document.getElementById('remaining_due').value = Math.ceil(no_of_due);
|
||
|
||
document.getElementById('balance_due_amount').value = Math.ceil(balanceDueAmount);
|
||
|
||
|
||
}
|
||
}
|
||
|
||
dateCalulation();
|
||
|
||
|
||
}
|
||
|
||
function dateCalulation() {
|
||
|
||
var loanamount = document.getElementById('Loan_Amount').value;
|
||
if (loanamount == 0.00 || loanamount == "") {
|
||
$('#loan_issued_date').val("");
|
||
$('#due_started').val("");
|
||
$('#monthly_due').val("0.00");
|
||
$('#remaining_due').val(0);
|
||
$('#no_of_due').val(0);
|
||
$('#Loan_Amount').val("0.00");
|
||
$('#paid_due').val(0);
|
||
$('#Paid_Amount').val("0.00");
|
||
}
|
||
|
||
}
|
||
|
||
// function finalCheck() {
|
||
|
||
// var loanamount = document.getElementById('Loan_Amount').value;
|
||
// if (loanamount != "" && loanamount != 0.00) {
|
||
// var idate = document.getElementById('loan_issued_date').value;
|
||
// var due = document.getElementById('monthly_due').value;
|
||
// var dsdate = document.getElementById('due_started').value;
|
||
// if (idate == "" || due == "" || due == 0.00 || dsdate == "") {
|
||
// alert("Enter All Loan Information Correctly...!");
|
||
// return false;
|
||
// }
|
||
// }
|
||
|
||
// if ($('#Total_Salary').val() == '' || $('#HRA_Rate').val() == '' || $('#Allowances').val() == '' || $('#PF_Rate').val() == '' || $('#ESI_Rate').val() == '' || $('#Food_Allowances').val() == '' || $('#Incentives').val() == '') {
|
||
|
||
// alert("Please Enter All Information Correctly..!");
|
||
// return false;
|
||
// }
|
||
// }
|
||
function finalCheck() {
|
||
|
||
var loanamount = $('#Loan_Amount').val();
|
||
var emp = $("select[name=EmpID]").val();
|
||
|
||
if (loanamount !== "" && loanamount != 0.00) {
|
||
var idate = $('#loan_issued_date').val();
|
||
var due = $('#monthly_due').val();
|
||
var dsdate = $('#due_started').val();
|
||
|
||
if (idate === "" || due === "" || due == 0.00 || dsdate === "") {
|
||
console.log(idate);
|
||
alert("Enter All Loan Information Correctly...!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
if (emp === "0" || emp === "-1") {
|
||
alert('Please select the Employee');
|
||
return false;
|
||
}
|
||
|
||
if ($('#Total_Salary').val() == '' || $('#HRA_Rate').val() == '' || $('#Allowances').val() == '' || $('#PF_Rate').val() == '' || $('#ESI_Rate').val() == '' || $('#Food_Allowances').val() == '' || $('#Incentives').val() == '') {
|
||
|
||
alert("Please Enter All Information Correctly..!");
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
$("#deleteemp").click(function() {
|
||
var loanid = "<?php if (isset($Loan_ID)) {
|
||
echo $Loan_ID;
|
||
} else {
|
||
echo $emppay[0]->Loan_ID;
|
||
} ?>";
|
||
var i = confirm("Do you confirm to delete?");
|
||
|
||
if (i) {
|
||
|
||
$('#loader').show();
|
||
$.ajax({
|
||
data: {
|
||
id: loanid
|
||
},
|
||
type: "POST",
|
||
url: "<?php echo base_url(); ?>emppaydate/deleteEmpPay",
|
||
success: function(result) {
|
||
if (result) {
|
||
|
||
alert(result);
|
||
$('#loader').hide();
|
||
window.location.href = "<?php echo base_url(); ?>emppayListings";
|
||
|
||
}
|
||
|
||
},
|
||
error:function(error){
|
||
console.log("Error Ocurred");
|
||
console.log(error);
|
||
},
|
||
complete:function(){
|
||
$('#loader').hide();
|
||
console.log('Ajax call of route (post) - emppaydate/deleteEmpPay completed..!!')
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
</script>
|