Suvodip 2025-03-01 18:55:53 +05:30
parent 5b49910791
commit 11187345d5
6 changed files with 411 additions and 78 deletions

View File

@ -7,7 +7,7 @@
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" href="#">Home</a>
<a class="nav-link active" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/customers/new">New Customer</a>

View File

@ -15,7 +15,6 @@ try {
$stmt->bindParam(':payStatus', $_POST['payStatus'], PDO::PARAM_INT);
$stmt->bindParam(':emiId', $_POST['emiId'], PDO::PARAM_INT);
$stmt->execute();
echo json_encode(['status' => 'success']);
} catch (PDOException $e) {
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
@ -25,8 +24,9 @@ try {
}
// Fetch EMI data
$stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId ORDER BY emiDate ASC");
$stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiDate ASC");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':invoiceId', $_GET['invoiceId']);
$stmt->execute();
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
// var_dump($emiPlans);
@ -48,6 +48,7 @@ try {
<p>Customer Name: <strong><?php echo $customer['name']; ?></strong></p>
<p>Mobile Number: <strong><?php echo $customer['mobile']; ?></strong></p>
<p>EMI Booking Date: <strong><?php echo $emiPlans[0]['bookingDate']; ?></strong></p>
<p>EMI Booking Date: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
</div>
<div>
<?php

View File

@ -1,54 +1,91 @@
<?php
require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['customerId'])) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_GET['customerId'])) {
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$totalAmount = $_POST['totalAmount'];
$tenure = $_POST['tenure'];
$firstEmiDate = $_POST['firstEmiDate'];
$totalAmount = $_POST['totalAmount'];
$frequency = $_POST['frequency'];
$bookingDate = $_POST['bookingDate'];
$paymentMode = $_POST['paymentMode'];
$salesAgent = $_POST['salesAgent'];
$adminNote = $_POST['adminNote'];
$invoiceId = $_POST['invoiceId'];
$customerName = $_POST['customerName'];
$customerAddress = $_POST['customerAddress'];
$marketingAgent = $_POST['marketingAgent'];
$item = $_POST['item'];
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$rate = $_POST['rate'];
$tax = $_POST['tax'];
$taxAmount = $_POST['taxAmount'];
// EMI Calculation
$emiAmount = round($totalAmount / $tenure, 2);
$outstandingAmount = $totalAmount;
$emiDate = new DateTime($firstEmiDate); // Set initial date
$emiAmount = round($totalAmount / $tenure, 2);
$outstandingAmount = $totalAmount;
$emiDate = new DateTime($bookingDate); // Set initial date
$stmt = $db->prepare("INSERT INTO emi (customerId, emiNumber, emiAmount, emiDate, totalAmount, outstanding, tenure, frequency, bookingDate, paymentMode, salesAgent) VALUES (:customerId, :emiNumber, :emiAmount, :emiDate, :totalAmount, :outstanding, :tenure, :frequency, bookingDate, :paymentMode, :salesAgent)");
for ($i = 1; $i <= $tenure; $i++) {
$outstandingAmount -= $emiAmount;
$emiDateFormatted = $emiDate->format('Y-m-d');
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':emiNumber', $i);
$stmt->bindParam(':emiAmount', $emiAmount);
$stmt->bindParam(':emiDate', $emiDateFormatted);
$stmt->bindParam(':totalAmount', $totalAmount);
$stmt->bindParam(':outstanding', $outstandingAmount);
$stmt->bindParam(':tenure', $tenure);
$stmt->bindParam(':frequency', $frequency);
$stmt->bindParam(':bookingDate', $bookingDate);
$stmt->bindParam(':paymentMode', $paymentMode);
$stmt->bindParam(':salesAgent', $salesAgent);
$stmt->execute();
// Move to the next month's EMI date
if($frequency === 'Weekly'){
$emiDate->modify('+1 week');
} elseif($frequency === 'Monthly'){
$emiDate->modify('+1 month');
}
$stmt = $db->prepare("INSERT INTO emi (customerId, emiNumber, emiAmount, emiDate, totalAmount, outstanding, tenure, frequency, bookingDate, invoiceId) VALUES (:customerId, :emiNumber, :emiAmount, :emiDate, :totalAmount, :outstanding, :tenure, :frequency, :bookingDate, :invoiceId)");
for ($i = 1; $i <= $tenure; $i++) {
$outstandingAmount -= $emiAmount;
$emiDateFormatted = $emiDate->format('Y-m-d');
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':emiNumber', $i);
$stmt->bindParam(':emiAmount', $emiAmount);
$stmt->bindParam(':emiDate', $emiDateFormatted);
$stmt->bindParam(':totalAmount', $totalAmount);
$stmt->bindParam(':outstanding', $outstandingAmount);
$stmt->bindParam(':tenure', $tenure);
$stmt->bindParam(':frequency', $frequency);
$stmt->bindParam(':bookingDate', $bookingDate);
$stmt->bindParam(':invoiceId', $invoiceId);
$stmt->execute();
// Move to the next EMI date
if (trim(strtolower($frequency)) === 'weekly') {
$emiDate->modify('+1 week');
} elseif (trim(strtolower($frequency)) === 'monthly') {
$emiDate->modify('+1 month');
}
}
// Insert into invoice table
$stmt2 = $db->prepare("INSERT INTO invoice (customerId, invoiceId, customerName, address, frequency, invoiceDate, paymentMode, salesAgent, marketingAgent, tenure, item, description, qty, rate, tax, totalAmount, adminNote, taxAmount) VALUES (:customerId, :invoiceId, :customerName, :address, :frequency, :invoiceDate, :paymentMode, :salesAgent, :marketingAgent, :tenure, :item, :description, :qty, :rate, :tax, :totalAmount, :adminNote, :taxAmount)");
$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', $marketingAgent);
$stmt2->bindParam(':tenure', $tenure);
$stmt2->bindParam(':item', $item);
$stmt2->bindParam(':description', $description);
$stmt2->bindParam(':qty', $quantity);
$stmt2->bindParam(':rate', $rate);
$stmt2->bindParam(':tax', $tax);
$stmt2->bindParam(':totalAmount', $totalAmount);
$stmt2->bindParam(':adminNote', $adminNote);
$stmt2->bindParam(':taxAmount', $taxAmount);
$stmt2->execute();
echo '<div class="alert alert-success">New EMI Plan Saved Successfully!</div>';
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("printBtn").classList.remove("visually-hidden");
});
</script>';
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
$customer = null;
if (!empty($_GET['customerId'])) {
try {
@ -67,6 +104,13 @@
$customerAddress = $stmt->fetch(PDO::FETCH_ASSOC);
}
$stmt = $db->query("SELECT id FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
$invoiceId = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
$stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC);
// $invoiceIdPrint = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
@ -74,29 +118,24 @@
}
?>
<div class="container mt-4">
<h2>Create Invoice</h2>
<?php if (!empty($customer)): ?>
<p><strong>Mobile:</strong> <?= htmlspecialchars($customer['mobile']) ?></p>
<?php else: ?>
<div class="alert alert-warning">Customer not found.</div>
<?php endif; ?>
<h4>Create New Invoice</h4>
<hr>
<form method="POST">
<div class="d-flex justify-content-between gap-4">
<div class="w-100">
<div class="mb-3">
<label for="totalAmount" class="form-label">Customer:</label>
<input disabled type="text" class="form-control" id="name" name="name" value="<?= htmlspecialchars($customer['name']); ?>">
<label for="invoiceId" class="form-label">Invoice Id:</label>
<input type="text" class="form-control bg-white" id="invoiceId" name="invoiceId" value="<?= $invoiceId; ?>">
</div>
<div class="mb-3">
<label for="totalAmount" class="form-label">Address:</label>
<input disabled class="form-control" type="text" value="<?= 'City: ' . $customerAddress['city'] .' District: '. $customerAddress['district'] . ' State: ' .$customerAddress['state'] . ' Pin Code: ' . $customerAddress['pinCode']; ?>">
<label for="name" class="form-label">Customer:</label>
<input readonly type="text" class="form-control bg-white" id="customerName" name="customerName" value="<?= htmlspecialchars($customer['name']); ?>">
</div>
<div class="mb-3">
<label for="totalAmount" class="form-label">Total Amount:</label>
<input type="number" class="form-control" id="totalAmount" name="totalAmount" required>
<label for="address" class="form-label">Address:</label>
<input id="address" readonly name="customerAddress" class="form-control bg-white" type="text" value="<?= 'City: ' . $customerAddress['city'] .' District: '. $customerAddress['district'] . ' State: ' .$customerAddress['state'] . ' Pin Code: ' . $customerAddress['pinCode']; ?>">
</div>
<div class="mb-3">
@ -110,11 +149,7 @@
<div class="d-flex w-100 gap-2">
<div class="mb-3 w-100">
<label for="bookingDate" class="form-label">Invoice Date:</label>
<input type="date" class="form-control" id="bookingDate" name="bookingDate" required>
</div>
<div class="mb-3 w-100">
<label for="firstEmiDate" class="form-label">Due Date:</label>
<input type="date" class="form-control" id="firstEmiDate" name="firstEmiDate" required>
<input type="date" class="form-control" id="bookingDate" name="bookingDate" value="" required>
</div>
</div>
</div>
@ -126,14 +161,7 @@
<option value="UPI">UPI</option>
<option value="Credit Card">Credit Card</option>
<option value="Debit Card">Debit Card</option>
</select>
</div>
<div class="mb-3">
<label for="currency" class="form-label">Currency:</label>
<select name="currency" class="form-control"required>
<option value="">-Select-</option>
<option value="USD">USD</option>
<option value="INR">INR</option>
<option value="Cash">Cash</option>
</select>
</div>
<div class="mb-3">
@ -145,17 +173,146 @@
</select>
</div>
<div class="mb-3">
<label for="tenure" class="form-label">Total Cycle:</label>
<select name="tenure" class="form-control"required>
<label for="marketingAgent" class="form-label">Marketing Agent:</label>
<select name="marketingAgent" class="form-control"required>
<option value="">-Select-</option>
<option value="Prabhat Mishra">Prabhat Mishra</option>
<option value="Suvojit Mishra">Suvojit Mishra</option>
</select>
</div>
<div class="mb-3">
<label for="tenure" class="form-label">Total Cycles:</label>
<select onchange="changeTenureField();" id="tenureAuto" name="tenure" class="form-control" required>
<option value="">-Select-</option>
<option value="1">One Time</option>
<option value="3">3</option>
<option value="6">6</option>
<option value="9">9</option>
<option value="12">12</option>
<option value="0">Custom</option>
</select>
<input type="text" name="tenure" id="tenureCustom" class="form-control visually-hidden" placeholder="Enter custom value" disabled onblur="restoreDropdown(this)" />
</div>
<div class="mb-3">
<label for="adminNote" class="form-label">Admin Note:</label>
<textarea class="form-control" name="adminNote" id="adminNote" cols="30" rows="4"></textarea>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Save EMI</button>
<div>
<table class="w-100">
<thead>
<tr class="bg-secondary text-white">
<th class="p-2">Item</th>
<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">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea class="form-control w-100" name="item" id="item" rows="3"></textarea>
</td>
<td>
<textarea class="form-control w-100" name="description" id="description" rows="3"></textarea>
</td>
<td>
<input class="form-control w-100" name="quantity" id="quantity" />
</td>
<td>
<input class="form-control w-100" name="rate" id="rate" />
</td>
<td>
<select name="tax" id="tax" class="form-control">
<option value="0">No Tax</option>
<option value="5">5 %</option>
<option value="10">10 %</option>
<option value="12">12 %</option>
<option value="18">18 %</option>
</select>
</td>
<td>
<input readonly class="form-control" name="taxAmount" id="taxAmount" />
</td>
<td>
<input readonly class="form-control" name="totalAmount" id="totalAmount" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end align-items-center">
<div>
<button class="btn btn-secondary">Discard</button>
<button type="submit" class="btn btn-primary">Save</button>
<a href="/customers/print-invoice/?customerId=<?= $_GET['customerId'] . '&invoiceId='. $lastInvoicePrint['invoiceId']; ?>" id="printBtn" class="btn btn-primary visually-">Print Invoice</a>
</div>
</div>
</form>
</div>
<script>
const today = new Date();
const formattedDate = today.toISOString().split('T')[0];
document.getElementById('bookingDate').value = formattedDate;
function changeTenureField() {
const tenureAuto = document.getElementById('tenureAuto');
const tenureCustom = document.getElementById('tenureCustom');
if (tenureAuto.value === "0") {
tenureAuto.classList.add('visually-hidden');
tenureCustom.classList.remove('visually-hidden');
tenureCustom.removeAttribute('disabled');
tenureAuto.setAttribute('disabled', 'true');
tenureAuto.removeAttribute('name');
tenureCustom.setAttribute('name', 'tenure');
tenureCustom.focus();
}
}
function restoreDropdown(input) {
const tenureAuto = document.getElementById('tenureAuto');
if (input.value.trim() === "") {
tenureAuto.classList.remove('visually-hidden');
input.classList.add('visually-hidden');
input.setAttribute('disabled', 'true');
input.removeAttribute('name');
tenureAuto.removeAttribute('disabled');
tenureAuto.setAttribute('name', 'tenure');
tenureAuto.value = "";
}
}
document.addEventListener("DOMContentLoaded", function () {
const quantityInput = document.getElementById("quantity");
const rateInput = document.getElementById("rate");
const taxSelect = document.getElementById("tax");
const taxAmountInput = document.getElementById("taxAmount");
const totalAmountInput = document.getElementById("totalAmount");
function calculateTotal() {
const quantity = parseFloat(quantityInput.value) || 0;
const rate = parseFloat(rateInput.value) || 0;
const tax = parseFloat(taxSelect.value) || 0;
let subtotal = quantity * rate;
let taxAmount = (subtotal * tax) / 100;
let grandTotal = subtotal + taxAmount;
taxAmountInput.value = taxAmount.toFixed(2); // Format Tax Amount
totalAmountInput.value = grandTotal.toFixed(2); // Format Total Amount
}
// Event listeners for real-time calculation
quantityInput.addEventListener("input", calculateTotal);
rateInput.addEventListener("input", calculateTotal);
taxSelect.addEventListener("change", calculateTotal);
});
</script>

View File

@ -11,39 +11,86 @@
<th>Name</th>
<th>Mobile</th>
<th>Email</th>
<th>Invoice Id</th>
<th>Invoice Date</th>
<th>Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
try {
// Connect to the database
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch customer data
$stmt = $db->prepare("SELECT * FROM customers ORDER BY regDate DESC");
$stmt->execute();
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
$customerSerial = 1; // Moved outside loop
// Fetch invoice data
$stmt2 = $db->prepare("SELECT * FROM invoice");
$stmt2->execute();
$invoiceContent = $stmt2->fetchAll(PDO::FETCH_ASSOC);
// Loop through each customer
$customerSerial = 1;
foreach ($content as $customer) {
// Find all invoices for the current customer
$matchingInvoices = array_filter($invoiceContent, function ($invoice) use ($customer) {
return $invoice['customerId'] === $customer['customerId'];
});
// If there are matching invoices, loop through them
if (!empty($matchingInvoices)) {
foreach ($matchingInvoices as $invoice) {
?>
<tr>
<td><?php echo $customerSerial++; ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td>
<td><?php echo htmlspecialchars($customer['mobile']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="/customers/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Invoice</a>
<a href="/customers/billing-details/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Installment Details</a>
</td>
</tr>
<tr>
<td><?php echo $customerSerial++; ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td>
<td><?php echo htmlspecialchars($customer['mobile']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<!-- Invoice Data -->
<td><?php echo htmlspecialchars($invoice['invoiceId']); ?></td>
<td><?php echo htmlspecialchars($invoice['invoiceDate']); ?></td>
<td><?php echo htmlspecialchars($invoice['totalAmount']); ?></td>
<td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="/customers/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Create Invoice</a>
<a href="/customers/billing-details/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn btn-primary btn-sm">EMI Details</a>
<a href="/customers/print-invoice/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn btn-primary btn-sm">Print</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><?php echo htmlspecialchars($customer['mobile']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td colspan="3">No invoice available</td>
<td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="/customers/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Create Invoice</a>
<a href="/customers/billing-details/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">EMI Details</a>
</td>
</tr>
<?php
}
}
} catch (PDOException $e) {
echo '<tr><td colspan="5" class="text-danger text-center">Error: ' . $e->getMessage() . '</td></tr>';
}
?>
</tbody>
</table>
</div>
</div>

View File

@ -48,4 +48,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,132 @@
<?php
require('../.hta_config/conf.php');
?>
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':invoiceId', $_GET['invoiceId']);
$stmt->execute();
$invoiceInfo = $stmt->fetch(PDO::FETCH_ASSOC);
$emiPlans = [];
if ($invoiceInfo['tenure'] > 1) {
$stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiDate ASC");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':invoiceId', $_GET['invoiceId']);
$stmt->execute();
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<div class="container my-5">
<div class="invoice-box">
<h2 class="text-center text-blue">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>
</div>
<table class="table table-bordered mt-3">
<thead class="table-dark">
<tr>
<th>Item</th>
<th>Description</th>
<th>Qty</th>
<th>Rate</th>
<th>Tax(%)</th>
<th>Tax</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= $invoiceInfo['item'] ?></td>
<td><?= $invoiceInfo['description'] ?></td>
<td><?= $invoiceInfo['qty'] ?></td>
<td><?= $invoiceInfo['rate'] ?></td>
<td><?= $invoiceInfo['tax'] ?>%</td>
<td><?= $invoiceInfo['taxAmount'] ?></td>
<td><?= number_format($invoiceInfo['totalAmount'], 2) ?></td>
</tr>
</tbody>
</table>
<!-- EMI Table (if tenure > 1) -->
<?php if ($invoiceInfo['tenure'] > 1): ?>
<h4 class="mt-4 text-blue">EMI Payment Plan</h4>
<table class="table table-striped">
<thead>
<tr>
<th>EMI No.</th>
<th>EMI Date</th>
<th>EMI Amount</th>
<th>Outstanding</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($emiPlans as $emi): ?>
<tr>
<td><?= $emi['emiNumber'] ?></td>
<td><?= $emi['emiDate'] ?></td>
<td><?= number_format($emi['emiAmount'], 2) ?></td>
<td><?= number_format($emi['outstanding'], 2) ?></td>
<td>
<?= ($emi['payStatus'] == 1) ? '<span class="badge bg-success">Paid</span>' : '<span class="badge bg-danger">Pending</span>' ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<p class="text-muted mt-3"><strong>Admin Note:</strong> <?= $invoiceInfo['adminNote'] ?></p>
<!-- Print Button -->
<button onclick="window.print()" class="btn btn-primary btn-print w-100">Print Invoice</button>
</div>
</div>
<style>
body {
background-color: #f8f9fa;
}
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
border: 1px solid #ddd;
background: #fff;
border-radius: 10px;
}
.text-blue { color: #007bff; }
.btn-print { margin-top: 20px; }
@media print {
body * {
visibility: hidden;
}
.invoice-box, .invoice-box * {
visibility: visible;
}
.invoice-box {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
.btn-print {
display: none; /* Hide print button */
}
}
</style>