s44
This commit is contained in:
94
my-account/.hta_slug/_home.php
Normal file
94
my-account/.hta_slug/_home.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
require('../.hta_config/conf.php');
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
<h2 class="mb-3 text-center">Customer List</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover">
|
||||
<thead class="bg-primary text-white text-center">
|
||||
<tr>
|
||||
<th>Sl No</th>
|
||||
<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
|
||||
echo $_SESSION['customerId'];
|
||||
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 WHERE customerId = :customerId ORDER BY regDate DESC");
|
||||
$stmt->bindParam(':customerId', $_SESSION['customerId']);
|
||||
$stmt->execute();
|
||||
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// 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>
|
||||
|
||||
<!-- 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="/my-account/emi-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/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>
|
||||
Reference in New Issue
Block a user