s44
This commit is contained in:
0
my-account/.hta_slug/_404.php
Normal file
0
my-account/.hta_slug/_404.php
Normal file
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>
|
||||
99
my-account/.hta_slug/emi-details.php
Normal file
99
my-account/.hta_slug/emi-details.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
require('../.hta_config/conf.php');
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['emiId'], $_POST['payStatus'])) {
|
||||
header('Content-Type: application/json');
|
||||
ob_end_clean(); // Clears any accidental HTML output
|
||||
|
||||
try {
|
||||
$stmt = $db->prepare("UPDATE emi SET payStatus = :payStatus WHERE customerId = :customerId AND id = :emiId");
|
||||
$stmt->bindParam(':customerId', $_GET['customerId']);
|
||||
$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()]);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch EMI data
|
||||
$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);
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
|
||||
$stmt->bindParam(':customerId', $_GET['customerId']);
|
||||
$stmt->execute();
|
||||
$customer = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
// var_dump($customer);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die('<div class="alert alert-danger text-center">Error: ' . $e->getMessage() . '</div>');
|
||||
}
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
<h2 class="mb-3">EMI Details</h2>
|
||||
<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>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
|
||||
$currentOutstanding = 0;
|
||||
$totalAmount = 0;
|
||||
|
||||
foreach ($emiPlans as $emi) {
|
||||
$totalAmount = $emi['totalAmount'];
|
||||
|
||||
if ($emi['payStatus'] == 0) {
|
||||
$currentOutstanding += $emi['emiAmount'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p>Total Amount: <strong><?php echo $totalAmount; ?></strong></p>
|
||||
<p>Outstanding: <strong><?php echo round($currentOutstanding); ?></strong></p>
|
||||
<p>Tenure: <strong><?php echo $emiPlans[0] ? $emiPlans[0]['tenure'] : 0; ?></strong></p>
|
||||
<p>Frequency: <strong><?php echo $emiPlans[0] ? $emiPlans[0]['frequency'] : 0; ?></strong></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="bg-primary text-white text-center">
|
||||
<tr>
|
||||
<th>Number of EMI</th>
|
||||
<th>EMI Amount</th>
|
||||
<th>EMI Date</th>
|
||||
<th>Payment Status</th>
|
||||
<th>Outstanding</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($emiPlans as $emi) { ?>
|
||||
<tr id="row-<?= $emi['id']; ?>">
|
||||
<td><?= $emi['emiNumber']; ?></td>
|
||||
<td>₹<?= number_format($emi['emiAmount'], 2); ?></td>
|
||||
<td><?= date('d-m-Y', strtotime($emi['emiDate'])); ?></td>
|
||||
<td>
|
||||
<span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>">
|
||||
<?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>₹<?= number_format($emi['outstanding'], 2); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
60
my-account/.hta_slug/stat.php
Normal file
60
my-account/.hta_slug/stat.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
require('../.hta_config/conf.php');
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$currentMonth = date('Y-m');
|
||||
$stmt = $db->prepare(" SELECT e.customerId, c.name, e.emiAmount, e.emiDate, e.payStatus, e.outstanding FROM emi e JOIN customers c ON e.customerId = c.customerId WHERE DATE_FORMAT(e.emiDate, '%Y-%m') = :currentMonth ORDER BY e.emiDate ASC");
|
||||
$stmt->bindParam(':currentMonth', $currentMonth);
|
||||
$stmt->execute();
|
||||
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Calculate total demand amount
|
||||
$totalDemand = array_sum(array_column($emiPlans, 'emiAmount'));
|
||||
} catch (PDOException $e) {
|
||||
die("Database error: " . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">Pending EMIs for <?php echo date('F Y'); ?></h2>
|
||||
<table class="table table-bordered table-striped table-hover">
|
||||
<thead class="bg-primary text-white text-center">
|
||||
<tr>
|
||||
<th>Customer Name</th>
|
||||
<th>EMI Amount</th>
|
||||
<th>EMI Date</th>
|
||||
<th>Pay Status</th>
|
||||
<th>Outstanding</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($emiPlans)) : ?>
|
||||
<?php foreach ($emiPlans as $emi) : ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($emi['name']); ?></td>
|
||||
<td>₹<?php echo number_format($emi['emiAmount'], 2); ?></td>
|
||||
<td><?php echo date('d M Y', strtotime($emi['emiDate'])); ?></td>
|
||||
<td>
|
||||
<?php if ($emi['payStatus'] == 0) : ?>
|
||||
<span class="badge bg-danger">Pending</span>
|
||||
<?php else : ?>
|
||||
<span class="badge bg-success">Paid</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>₹<?php echo number_format($emi['outstanding'], 2); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">No pending EMIs this month</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="mt-3">
|
||||
<h4>Total Demand EMI Amount: ₹<?php echo number_format($totalDemand, 2); ?></h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user