This commit is contained in:
Suvodip
2025-03-26 11:53:18 +05:30
parent 321e617580
commit 55874583eb
7 changed files with 122 additions and 116 deletions

View File

@@ -2,18 +2,39 @@
require('../.hta_config/conf.php');
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$customerId = $_GET['customerId'];
$invoiceId = $_GET['invoiceId'];
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['additional-payment'])){
$adPaymentAmount = floatval($_POST['adPaymentAmount']);
$adPaymentDate = $_POST['adPaymentDate'];
$adPaymentSource = $_POST['adPaymentSource'];
$adPaymentTran = $_POST['adPaymentTran'];
$adPaymentRemarks = $_POST['adPaymentRemarks'];
// Insert additional payment record
try{
$stmt3 = $db->prepare("INSERT INTO emi (customerId, invoiceId, adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks, payStatus) VALUES (:customerId, :invoiceId, :adPaymentAmount, :adPaymentDate, :adPaymentSource, :adPaymentTran, :adPaymentRemarks, 1)");
$stmt3->bindParam(':customerId', $customerId);
$stmt3->bindParam(':invoiceId', $invoiceId);
$stmt3->bindParam(':adPaymentAmount', $adPaymentAmount);
$stmt3->bindParam(':adPaymentDate', $adPaymentDate);
$stmt3->bindParam(':adPaymentSource', $adPaymentSource);
$stmt3->bindParam(':adPaymentTran', $adPaymentTran);
$stmt3->bindParam(':adPaymentRemarks', $adPaymentRemarks);
if ($stmt3->execute()) {
echo '<div class="alert alert-success">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> applied successfully.</div>';
} else {
echo '<div class="alert alert-danger">Failed to record the additional payment.</div>';
}
}catch(PDOException $e){
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$adPaymentAmount = floatval($_POST['adPaymentAmount']);
try {
// Get customer EMI details
$customerId = $_GET['customerId'];
$invoiceId = $_GET['invoiceId'];
$adPaymentAmount = floatval($_POST['adPaymentAmount']);
$adPaymentDate = $_POST['adPaymentDate'];
$adPaymentSource = $_POST['adPaymentSource'];
$adPaymentTran = $_POST['adPaymentTran'];
$adPaymentRemarks = $_POST['adPaymentRemarks'];
// Fetch EMIs of the customer (Assuming we have emiNumber in ascending order)
$stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiNumber DESC");
$stmt->bindParam(':customerId', $customerId);
@@ -52,20 +73,6 @@
$updateStmt->execute();
}
// Insert additional payment record
$stmt3 = $db->prepare("INSERT INTO emi (customerId, invoiceId, adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks, payStatus) VALUES (:customerId, :invoiceId, :adPaymentAmount, :adPaymentDate, :adPaymentSource, :adPaymentTran, :adPaymentRemarks, 1)");
$stmt3->bindParam(':customerId', $customerId);
$stmt3->bindParam(':invoiceId', $invoiceId);
$stmt3->bindParam(':adPaymentAmount', $adPaymentAmount);
$stmt3->bindParam(':adPaymentDate', $adPaymentDate);
$stmt3->bindParam(':adPaymentSource', $adPaymentSource);
$stmt3->bindParam(':adPaymentTran', $adPaymentTran);
$stmt3->bindParam(':adPaymentRemarks', $adPaymentRemarks);
if ($stmt3->execute()) {
echo '<div class="alert alert-success">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> applied successfully.</div>';
} else {
echo '<div class="alert alert-danger">Failed to record the additional payment.</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
@@ -157,12 +164,12 @@
$frequency = $frequency !== null ? $frequency : 0;
?>
<div class="container mt-4">
<h3 class="mb-3">Installment Details</h3>
<h3 class="mb-3">Installment Details</h3><hr/>
<div class="d-flex justify-content-between">
<div>
<p>Customer Name: <strong><?php echo $customer['name']; ?></strong></p>
<p>Mobile Number: <strong><?php echo $customer['mobile']; ?></strong></p>
<p>Booking Date: <strong><?php echo $bookingDate ? htmlspecialchars($bookingDate) : 'N/A'; ?></strong></p>
<p>Installment Start Date: <strong><?php echo $bookingDate ? htmlspecialchars($bookingDate) : 'N/A'; ?></strong></p>
<p>Invoice Id: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
<p>Email: <strong><?php echo $customer['email']; ?></strong></p>
</div>
@@ -216,31 +223,27 @@
<?php } } ?>
</tbody>
</table>
<?php
if($emiPlans[0]['adPaymentAmount'] > 0 ) { ?>
<h3 class="mb-3">Additional Payment Details</h3>
<table class="table table-striped table-bordered">
<thead class="text-white text-center" style="background-color: #374151;">
<tr>
<th>Amount</th>
<th>Payment Date</th>
<th>Transaction Id</th>
<th>Remarks</th>
<h3 class="mb-3">Additional Payment Details</h3>
<table class="table table-striped table-bordered">
<thead class="text-white text-center" style="background-color: #374151;">
<tr>
<th>Amount</th>
<th>Payment Date</th>
<th>Transaction Id</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php foreach ($emiPlans as $emi) { if($emi['adPaymentAmount'] !== null) { ?>
<tr id="row-<?= $emi['id']; ?>">
<td>$<?= $emi['adPaymentAmount']; ?></td>
<td><?= $emi['adPaymentDate']; ?></td>
<td><?= $emi['adPaymentTran']; ?></td>
<td><?= $emi['adPaymentRemarks']; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($emiPlans as $emi) { if($emi['adPaymentAmount'] !== null && $emi['emiAmount'] == 0) { ?>
<tr id="row-<?= $emi['id']; ?>">
<td>$<?= $emi['adPaymentAmount']; ?></td>
<td><?= $emi['adPaymentDate']; ?></td>
<td><?= $emi['adPaymentTran']; ?></td>
<td><?= $emi['adPaymentRemarks']; ?></td>
</tr>
<?php } }?>
</tbody>
</table>
<?php } ?>
<?php } }?>
</tbody>
</table>
<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered"> <!-- This centers the modal -->
<div class="modal-content">