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">

View File

@ -56,25 +56,18 @@
// }
// Insert into invoice table
$stmt2 = $db->prepare("UPDATE invoice SET customerName = :customerName, address = :address, frequency = :frequency, invoiceDate = :invoiceDate, paymentMode = :paymentMode, salesAgent = :salesAgent, marketingAgent = :marketingAgent, tenure = :tenure, item = :item, description = :description, qty = :qty, rate = :rate, discount = :discount, totalAmount = :totalAmount, adminNote = :adminNote, discount = :discount WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt2 = $db->prepare("UPDATE invoice SET customerName = :customerName, address = :address, invoiceDate = :invoiceDate, paymentMode = :paymentMode, salesAgent = :salesAgent, marketingAgent = :marketingAgent, item = :item, description = :description, adminNote = :adminNote WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt2->bindParam(':customerId', $_GET['customerId']);
$stmt2->bindParam(':invoiceId', $invoiceId);
$stmt2->bindParam(':customerName', $customerName);
$stmt2->bindParam(':address', $customerAddress);
$stmt2->bindParam(':frequency', $frequency);
$stmt2->bindParam(':invoiceDate', $bookingDate);
$stmt2->bindParam(':paymentMode', $paymentMode);
$stmt2->bindParam(':salesAgent', $salesAgent);
$stmt2->bindParam(':marketingAgent', $marketingAgentList);
$stmt2->bindParam(':tenure', $tenure);
$stmt2->bindParam(':item', $item);
$stmt2->bindParam(':description', $description);
$stmt2->bindParam(':qty', $quantity);
$stmt2->bindParam(':rate', $rate);
$stmt2->bindParam(':discount', $discount);
$stmt2->bindParam(':totalAmount', $totalAmount);
$stmt2->bindParam(':adminNote', $adminNote);
$stmt2->bindParam(':discountAmount', $discountAmount);
$stmt2->execute();
echo '<div class="alert alert-success">New EMI Plan Saved Successfully!</div>';
echo '<script>
@ -120,7 +113,7 @@
</div>
<div class="mb-3">
<label for="address" class="form-label">Address:</label>
<input id="address" readonly name="customerAddress" class="form-control bg-white" type="text" value="<?= htmlspecialchars($invoiceData['address']); ?>">
<input id="address" name="customerAddress" class="form-control bg-white" type="text" value="<?= htmlspecialchars($invoiceData['address']); ?>">
</div>
<div class="mb-3">
@ -214,8 +207,8 @@
<th class="p-2">Description</th>
<th class="p-2">Qty</th>
<th class="p-2">Rate</th>
<th class="p-2">Tax % </th>
<th class="p-2">Tax Amount</th>
<th class="p-2">Discount&nbsp;% </th>
<th class="p-2">Discount&nbsp;&#36;</th>
<th class="p-2">Amount</th>
</tr>
</thead>

View File

@ -136,7 +136,7 @@
</div>
<div class="mb-3">
<label for="address" class="form-label">Address:</label>
<input id="address" readonly name="customerAddress" class="form-control bg-white" type="text" value="<?= htmlspecialchars($customer['address']); ?>">
<input id="address" name="customerAddress" class="form-control bg-white" type="text" value="<?= htmlspecialchars($customer['address']); ?>">
</div>
<div class="mb-3">

View File

@ -110,12 +110,11 @@
} else {
$emi = [];
}
?>
?>
<tr>
<td><?php echo $customerSerial++; ?></td>
<td>
<a href="/customers/billing-details/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>">
<a class="fw-bold" href="/customers/billing-details/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>">
<?php echo htmlspecialchars($customer['name']); ?>
</a>
</td>
@ -129,35 +128,35 @@
<td class="d-flex gap-1">
<a href="/customers/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">New</a>
<a href="/customers/edit-invoice/?customerId=<?php echo $customer['customerId'].'&invoiceId='.$invoice['invoiceId']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Edit</a>
<a href="/customers/print-invoice/?customerId=<?php echo $customer['customerId'].'&invoiceId='.$invoice['invoiceId']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Print</a>
<a href="/customers/print-invoice/?customerId=<?php echo $customer['customerId'].'&invoiceId='.$invoice['invoiceId']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;" target="_blank">Print</a>
<a href="/customers/change-password/?customerId=<?php echo $customer['customerId'].'&userName='.$customer['name']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Password</a>
<form method="post">
<input type="hidden" name="customerId" value="<?php echo htmlspecialchars($customer['customerId']); ?>" />
<input type="hidden" name="invoiceId" value="<?php echo htmlspecialchars($invoice['invoiceId']); ?>" />
<button type="submit" name="delete" class="btn btn-danger btn-sm" style="font-size: 13px;">Delete</button>
</form>
<a href="/customers/change-password/?customerId=<?php echo $customer['customerId'].'&userName='.$customer['name']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Change Password</a>
</td>
</tr>
<?php
}
} else {
// For customers without an invoice, you can still display their info but leave invoice data empty
?>
?>
<tr>
<td><?php echo $customerSerial++; ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td>
<td class="fw-bold"><?php echo htmlspecialchars($customer['name']); ?></td>
<td colspan="6" class="text-center">No EMI or Invoice Data</td>
<td class="d-flex gap-1">
<a href="/customers/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">New</a>
<a href="/customers/change-password/?customerId=<?php echo $customer['customerId'].'&userName='.$customer['name']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Password</a>
<form method="post">
<input type="hidden" name="customerId" value="<?php echo htmlspecialchars($customer['customerId']); ?>" />
<input type="hidden" name="invoiceId" value="<?php echo htmlspecialchars($invoice['invoiceId']); ?>" />
<button type="submit" name="delete" class="btn btn-danger btn-sm" style="font-size: 13px;">Delete</button>
</form>
<a href="/customers/change-password/?customerId=<?php echo $customer['customerId'].'&userName='.$customer['name']; ?>" class="btn btn-sm text-white" style="font-size: 13px; background-color: #374151;">Change Password</a>
</td>
</tr>
<?php
<?php
}
}
} catch (PDOException $e) {

View File

@ -22,21 +22,32 @@ if ($invoiceInfo['tenure'] > 1) {
<div class="container my-5">
<div class="invoice-box" id="invoice-box">
<h2 class="text-center fw-bold" style="color: #374151;">Invoice</h2><hr>
<div class="d-flex justify-content-between">
<div class="w-100">
<h6>Invoice ID: <?= $invoiceInfo['invoiceId'] ?></h6>
<h6>Customer: <?= $invoiceInfo['customerName'] ?></h6>
<p style="width: 70%;"><strong>Address:</strong> <?= $invoiceInfo['address'] ?></p>
</div>
<div class="w-100 d-flex flex-column align-items-end">
<h6>Invoice Date: <?= $invoiceInfo['invoiceDate'] ?></h6>
<h6>Payment Mode: <?= $invoiceInfo['paymentMode'] ?></h6>
<p><strong>Agent:</strong> <?= $invoiceInfo['salesAgent'] ?></p>
<div class="d-flex justify-content-between" >
<img src="/assets/logo_dark.png" alt="" style="width: 150px; height: fit-content;" />
<div>
<h3 class="text-center fw-bold" style="color: #374151;">Invoice</h3>
<p style="margin-top: -10px;"><strong># <?= $invoiceInfo['invoiceId'] ?></strong></p>
</div>
</div>
<table class="table table-bordered mt-3">
<div class="d-flex justify-content-between gap-2">
<div>
<p style="font-size: 14px;"><strong>Bill To:</strong></p>
<p style="margin-top: -10px; font-size: 13px;">
<span><strong><?= $invoiceInfo['customerName'] ?></strong></span><br>
<span style=""><?= $invoiceInfo['address'] ?></span>
</p>
<p style="margin-top: -15px; font-size: 14px;">Invoice Date: <?= $invoiceInfo['invoiceDate'] ?></p>
</div>
<div>
<p style="font-size: 14px;"><strong>CLASSBOXES TECHNOLOGY</strong></p>
<p style="margin-top: -15px; font-size: 13px; text-align: right;">
<span>371 Hoes Lane, Suite #200</span><br>
<span>Piscataway New Jersey</span><br>
<span>US 08854</span>
</p>
</div>
</div>
<table class="table table-bordered mt-3" style="font-size: 14px;">
<thead class="text-white" style="background-color: #374151;">
<tr>
<th>Item</th>
@ -63,8 +74,8 @@ if ($invoiceInfo['tenure'] > 1) {
<!-- EMI Table (if tenure > 1) -->
<?php if ($invoiceInfo['tenure'] > 1): ?>
<h5 class="mt-4" style="color: #374151;">EMI Payment Plan</h5>
<table class="table table-striped">
<h6 class="mt-4" style="color: #374151;">EMI Payment Plan</h6>
<table class="table table-striped" style="font-size: 14px;">
<thead>
<tr>
<th>EMI No.</th>
@ -91,37 +102,37 @@ if ($invoiceInfo['tenure'] > 1) {
</tbody>
</table>
<?php endif; ?>
<h5 class="mt-4" style="color: #374151;">Additional Payment Details:</h5>
<table class="table table-striped " style="font-size: 12px;">
<thead class="">
<tr>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Payment Source</th>
<th>Transaction ID</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php
foreach ($emiPlans as $emiAdditional) {
if (!is_null($emiAdditional['adPaymentAmount']) && $emiAdditional['adPaymentAmount'] > 0) {
?>
<?php if(!is_null($emiPlans[0]['adPaymentAmount']) && $emiPlans[0]['adPaymentAmount'] > 0) { ?>
<h6 class="mt-4" style="color: #374151;">Additional Payment Details:</h6>
<table class="table table-striped " style="font-size: 14px;">
<thead class="">
<tr>
<td><?= number_format($emiAdditional['adPaymentAmount'], 2) ?></td>
<td><?= !empty($emiAdditional['adPaymentDate']) ? $emiAdditional['adPaymentDate'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentSource']) ? $emiAdditional['adPaymentSource'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentTran']) ? $emiAdditional['adPaymentTran'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentRemarks']) ? $emiAdditional['adPaymentRemarks'] : '-' ?></td>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Payment Source</th>
<th>Transaction ID</th>
<th>Remarks</th>
</tr>
<?php
}
}
?>
</tbody>
</table>
</thead>
<tbody>
<?php
foreach ($emiPlans as $emiAdditional) {
if (!is_null($emiAdditional['adPaymentAmount']) && $emiAdditional['adPaymentAmount'] > 0) {
?>
<tr>
<td><?= number_format($emiAdditional['adPaymentAmount'], 2) ?></td>
<td><?= !empty($emiAdditional['adPaymentDate']) ? $emiAdditional['adPaymentDate'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentSource']) ? $emiAdditional['adPaymentSource'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentTran']) ? $emiAdditional['adPaymentTran'] : '-' ?></td>
<td><?= !empty($emiAdditional['adPaymentRemarks']) ? $emiAdditional['adPaymentRemarks'] : '-' ?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php } ?>
<p class="text-muted mt-3"><strong>Admin Note:</strong> <?= $invoiceInfo['adminNote'] ?></p>
<p style="font-size: 12px;"><strong>Invoice Generate Date: </strong><span id="invoiceGenDate"></span></p>
<div class="d-flex gap-1">

View File

@ -62,7 +62,7 @@
<td>
<a href="/my-account/emi-details/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn text-white btn-sm" style="background-color: #374151;">Details</a>
<a href="/my-account/print-invoice/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn text-white btn-sm" style="background-color: #374151;">Print</a>
<a href="/my-account/print-invoice/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn text-white btn-sm" style="background-color: #374151;" target="_blank">Print</a>
</td>
</tr>
<?php

View File

@ -76,7 +76,7 @@ try {
<p>Customer Name: <strong><?php echo $customer['name']; ?></strong></p>
<p>Mobile Number: <strong><?php echo $customer['mobile']; ?></strong></p>
<p>Installment Start Date: <strong><?php echo $bookingDate ? htmlspecialchars($bookingDate) : 'N/A'; ?></strong></p>
<p>Booking Date: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
<p>Invoice Id: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
</div>
<div>
<p>Total Amount: <strong>&#36;<?php echo $totalAmount; ?></strong></p>