Suvodip 2025-03-07 16:49:09 +05:30
parent a6522f589d
commit 881c48d5bb
13 changed files with 800 additions and 189 deletions

View File

@ -20,7 +20,7 @@
<a class="nav-link" href="/customers/list">Customer List</a> <a class="nav-link" href="/customers/list">Customer List</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/admin/stat">Stat</a> <a class="nav-link" href="/admin/stat/">Stat</a>
</li> </li>
'; ';

View File

@ -4,9 +4,36 @@ require('../.hta_config/conf.php');
try { try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); $db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $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"); // Ensure the URL parameters work with or without trailing slash
$stmt->bindParam(':currentMonth', $currentMonth); $uri = $_SERVER['REQUEST_URI'];
parse_str(parse_url($uri, PHP_URL_QUERY), $queryParams);
// Default values: current month
$currentYear = date('Y');
$currentMonth = date('m');
$currentMonthStart = date('Y-m-01');
$currentMonthEnd = date('Y-m-t');
// Extract query parameters
$startDate = isset($queryParams['start_date']) ? $queryParams['start_date'] : $currentMonthStart;
$endDate = isset($queryParams['end_date']) ? $queryParams['end_date'] : $currentMonthEnd;
$selectedMonth = isset($queryParams['month']) ? $queryParams['month'] : "$currentYear-$currentMonth";
// If month is selected, override date range
if (isset($queryParams['month']) && preg_match('/^\d{4}-\d{2}$/', $selectedMonth)) {
$startDate = date('Y-m-01', strtotime($selectedMonth));
$endDate = date('Y-m-t', strtotime($selectedMonth));
}
// Validate date format
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $startDate) || !preg_match('/^\d{4}-\d{2}-\d{2}$/', $endDate)) {
die("Invalid date format. Please use YYYY-MM-DD.");
}
$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 e.emiDate BETWEEN :startDate AND :endDate ORDER BY e.emiDate ASC");
$stmt->bindParam(':startDate', $startDate);
$stmt->bindParam(':endDate', $endDate);
$stmt->execute(); $stmt->execute();
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC); $emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -16,45 +43,73 @@ try {
die("Database error: " . $e->getMessage()); 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 class="container mt-5">
<h3 class="text-primary mb-4 text-center">Pending EMIs (<?php echo date('F Y', strtotime($startDate)); ?>)</h3>
<!-- Date & Month Filter Form -->
<form method="GET" class="d-flex flex-wrap gap-3 align-items-end justify-content-center">
<div class="">
<label for="month" class="form-label">Select Month</label>
<input type="month" id="month" name="month" class="form-control" value="<?php echo htmlspecialchars($selectedMonth); ?>">
</div>
<div class="text-center" style="margin-bottom: 7px;">
<span class="fw-bold">OR</span>
</div>
<div class="">
<label for="start_date" class="form-label">Start Date</label>
<input type="date" id="start_date" name="start_date" class="form-control" value="<?php echo htmlspecialchars($startDate); ?>">
</div>
<div class="">
<label for="end_date" class="form-label">End Date</label>
<input type="date" id="end_date" name="end_date" class="form-control" value="<?php echo htmlspecialchars($endDate); ?>">
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary px-4">Filter</button>
</div>
</form>
<!-- EMI Table -->
<div class="table-responsive mt-4">
<table class="table table-bordered 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 class="text-center">
<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 text-muted">No pending EMIs in this period</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div> </div>
<!-- Total Demand Amount -->
<div class="alert alert-info text-center mt-3">
<h4 class="mb-0">Total Demand EMI Amount: $<?php echo number_format($totalDemand, 2); ?></h4>
</div>
</div> </div>

View File

@ -1,4 +1,5 @@
<?php <?php
session_start();
require('../.hta_slug/_header.php'); require('../.hta_slug/_header.php');
require('../.hta_slug/_nav.php'); require('../.hta_slug/_nav.php');
require_once('../.hta_config/var.php'); require_once('../.hta_config/var.php');
@ -15,4 +16,4 @@ if($slug=="") require_once('.hta_slug/_home.php');
elseif(file_exists(".hta_slug/".$slug.".php")) include ".hta_slug/".$slug.".php"; elseif(file_exists(".hta_slug/".$slug.".php")) include ".hta_slug/".$slug.".php";
else require_once('.hta_slug/_404.php'); else require_once('.hta_slug/_404.php');
require_once('../.hta_slug/_footer.php'); require_once('../.hta_slug/_footer.php');

View File

@ -0,0 +1,86 @@
<!-- additional-payment -->
<?php
require('../.hta_config/conf.php');
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if($_SERVER['REQUEST_METHOD'] === 'POST'){
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', $_GET['customerId']);
$stmt3->bindParam(':invoiceId', $_GET['invoiceId']);
$stmt3->bindParam(':adPaymentAmount', $_POST['adPaymentAmount']);
$stmt3->bindParam(':adPaymentDate', $_POST['adPaymentDate']);
$stmt3->bindParam(':adPaymentSource', $_POST['adPaymentSource']);
$stmt3->bindParam(':adPaymentTran', $_POST['adPaymentTran']);
$stmt3->bindParam(':adPaymentRemarks', $_POST['adPaymentRemarks']);
if($stmt3->execute()){
echo '<div class="alert alert-success">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> Paid Successfully.</div>';
}else{
echo '<div class="alert alert-danger">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> Payment Faild.</div>';
}
} catch(PDOException $e){
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
try {
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->execute();
$invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt2 = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId");
$stmt2->bindParam(':customerId', $_GET['customerId']);
$stmt2->execute();
$emiData = $stmt2->fetch(PDO::FETCH_ASSOC);
// var_dump($emiData);
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
?>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-lg">
<div class="card-header bg-primary text-white text-center">
<h4>Additional Payment</h4>
</div>
<div class="card-body">
<form method="POST">
<div class="form-group">
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" class="form-control" value="<?= htmlspecialchars($invoiceData['customerName']); ?>" required>
</div>
<div class="form-group">
<label for="adPaymentAmount">Payment Amount:</label>
<input type="text" id="adPaymentAmount" name="adPaymentAmount" class="form-control" value="<?= $emiData['emiAmount']; ?>" required>
</div>
<div class="form-group">
<label for="adPaymentDate">Payment Date:</label>
<input type="date" id="adPaymentDate" name="adPaymentDate" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentTran">Transaction ID:</label>
<input type="text" id="adPaymentTran" name="adPaymentTran" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentSource">Payment Source:</label>
<input type="text" id="adPaymentSource" name="adPaymentSource" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentRemarks">Remarks:</label>
<input type="text" id="adPaymentRemarks" name="adPaymentRemarks" class="form-control" >
</div>
<button type="submit" class="btn btn-success btn-block mt-2">Save Payment</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks -->

View File

@ -1,108 +1,226 @@
<?php <?php
require('../.hta_config/conf.php'); require('../.hta_config/conf.php');
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); $db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $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"); if($_SERVER['REQUEST_METHOD'] === 'POST'){
$stmt->bindParam(':customerId', $_GET['customerId']); try{
$stmt->bindParam(':payStatus', $_POST['payStatus'], PDO::PARAM_INT); $stmt3 = $db->prepare("INSERT INTO emi (customerId, invoiceId, adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks, payStatus) VALUES (:customerId, :invoiceId, :adPaymentAmount, :adPaymentDate, :adPaymentSource, :adPaymentTran, :adPaymentRemarks, 1)");
$stmt->bindParam(':emiId', $_POST['emiId'], PDO::PARAM_INT); $stmt3->bindParam(':customerId', $_GET['customerId']);
$stmt->execute(); $stmt3->bindParam(':invoiceId', $_GET['invoiceId']);
echo json_encode(['status' => 'success']); $stmt3->bindParam(':adPaymentAmount', $_POST['adPaymentAmount']);
} catch (PDOException $e) { $stmt3->bindParam(':adPaymentDate', $_POST['adPaymentDate']);
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]); $stmt3->bindParam(':adPaymentSource', $_POST['adPaymentSource']);
$stmt3->bindParam(':adPaymentTran', $_POST['adPaymentTran']);
$stmt3->bindParam(':adPaymentRemarks', $_POST['adPaymentRemarks']);
if($stmt3->execute()){
echo '<div class="alert alert-success">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> Paid Successfully.</div>';
}else{
echo '<div class="alert alert-danger">Additional Payment <strong>' . htmlspecialchars($_POST['adPaymentAmount']) . '</strong> Payment Faild.</div>';
}
} catch(PDOException $e){
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
} }
try {
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->execute();
$invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
exit; $stmt2 = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId");
} $stmt2->bindParam(':customerId', $_GET['customerId']);
$stmt2->execute();
$emiData = $stmt2->fetch(PDO::FETCH_ASSOC);
// Fetch EMI data // var_dump($emiData);
$stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiDate ASC"); } catch (PDOException $e) {
$stmt->bindParam(':customerId', $_GET['customerId']); echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
$stmt->bindParam(':invoiceId', $_GET['invoiceId']); }
$stmt->execute();
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['emiId'], $_POST['payStatus'])) {
// var_dump($emiPlans); 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()]);
}
}
try {
// 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 = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_GET['customerId']); $stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->execute(); $stmt->execute();
$customer = $stmt->fetch(PDO::FETCH_ASSOC); $customer = $stmt->fetch(PDO::FETCH_ASSOC);
// var_dump($customer); // var_dump($customer);
} catch (PDOException $e) { } catch (PDOException $e) {
die('<div class="alert alert-danger text-center">Error: ' . $e->getMessage() . '</div>'); die('<div class="alert alert-danger text-center">Error: ' . $e->getMessage() . '</div>');
} }
$currentOutstanding = 0;
$totalAmount = 0;
$bookingDate = null;
$currentOutstanding = 0;
$totalAmount = 0;
$bookingDate = null;
$tenure = null;
$frequency = null;
foreach ($emiPlans as $emi) {
$totalAmount = $emi['totalAmount'];
if ($bookingDate === null && !empty($emi['bookingDate'])) {
$bookingDate = $emi['bookingDate'];
}
if ($emi['payStatus'] == 0) {
$currentOutstanding += $emi['emiAmount'];
}
if ($tenure === null && isset($emi['tenure'])) {
$tenure = $emi['tenure'];
}
if ($frequency === null && isset($emi['frequency'])) {
$frequency = $emi['frequency'];
}
}
$currentOutstanding = round($currentOutstanding);
$tenure = $tenure !== null ? $tenure : 0;
$frequency = $frequency !== null ? $frequency : 0;
?> ?>
<div class="container mt-4"> <div class="container mt-4">
<h2 class="mb-3">EMI Details</h2> <h3 class="mb-3">EMI Details</h3>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div> <div>
<p>Customer Name: <strong><?php echo $customer['name']; ?></strong></p> <p>Customer Name: <strong><?php echo $customer['name']; ?></strong></p>
<p>Mobile Number: <strong><?php echo $customer['mobile']; ?></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 $bookingDate ? htmlspecialchars($bookingDate) : 'N/A'; ?></strong></p>
<p>EMI Booking Date: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p> <p>Invoice Id: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
</div> </div>
<div> <div>
<?php <p>Total Amount: <strong>$<?php echo $totalAmount; ?></strong></p>
$currentOutstanding = 0; <p>Outstanding: <strong>$<?php echo $currentOutstanding; ?></strong></p>
$totalAmount = 0; <p>Tenure: <strong><?php echo $tenure; ?></strong></p>
<p>Frequency: <strong><?php echo $frequency; ?></strong></p>
foreach ($emiPlans as $emi) { <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">Additional Payment</button>
$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>
</div> </div>
<table class="table table-striped table-bordered"> <hr >
<thead class="bg-primary text-white text-center"> <div class="d-flex flex-column gap-3">
<tr> <table class="table table-striped table-bordered">
<th>Number of EMI</th> <thead class="bg-primary text-white text-center">
<th>EMI Amount</th> <tr>
<th>EMI Date</th> <th>Number of EMI</th>
<th>Payment Status</th> <th>EMI Amount</th>
<th>Outstanding</th> <th>EMI Date</th>
<th>Action</th> <th>Payment Status</th>
</tr> <th>Outstanding</th>
</thead> <th>Action</th>
<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>
<td>
<select class="form-select paymentStatus" data-emi-id="<?= $emi['id']; ?>">
<option value="1" <?= $emi['payStatus'] == 1 ? 'selected' : ''; ?>>Paid</option>
<option value="0" <?= $emi['payStatus'] == 0 ? 'selected' : ''; ?>>Unpaid</option>
</select>
</td>
</tr> </tr>
<?php } ?> </thead>
</tbody> <tbody>
</table> <?php foreach ($emiPlans as $emi) { if($emi['emiAmount'] !== null){ ?>
<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>
<td>
<select class="form-select paymentStatus" data-emi-id="<?= $emi['id']; ?>">
<option value="1" <?= $emi['payStatus'] == 1 ? 'selected' : ''; ?>>Paid</option>
<option value="0" <?= $emi['payStatus'] == 0 ? 'selected' : ''; ?>>Unpaid</option>
</select>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
<?php
if($emiPlans[0]['adPaymentAmount'] !== null) { ?>
<h3 class="mb-3">Additional Payment Details</h3>
<table class="table table-striped table-bordered">
<thead class="bg-primary text-white text-center">
<tr>
<th>Amount</th>
<th>Payment Date</th>
<th>Transaction Id</th>
<th>Payment Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($emiPlans as $emi) { if($emi['emiAmount'] === null) { ?>
<tr id="row-<?= $emi['id']; ?>">
<td>$<?= $emi['adPaymentAmount']; ?></td>
<td><?= $emi['adPaymentDate']; ?></td>
<td><?= $emi['adPaymentTran']; ?></td>
<td>
<span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>">
<?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
</span>
</td>
</tr>
<?php } }?>
</tbody>
</table>
<?php } ?>
<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">
<div class="modal-header">
<h5 class="modal-title" id="modalLabel">Additional Payment</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form method="POST" class="">
<div class="form-group">
<label for="adPaymentAmount">Payment Amount:</label>
<input type="text" id="adPaymentAmount" name="adPaymentAmount" class="form-control" value="<?= $emiData['emiAmount']; ?>" required>
</div>
<div class="form-group">
<label for="adPaymentDate">Payment Date:</label>
<input type="date" id="adPaymentDate" name="adPaymentDate" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentTran">Transaction ID:</label>
<input type="text" id="adPaymentTran" name="adPaymentTran" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentSource">Payment Source:</label>
<input type="text" id="adPaymentSource" name="adPaymentSource" class="form-control" required>
</div>
<div class="form-group">
<label for="adPaymentRemarks">Remarks:</label>
<input type="text" id="adPaymentRemarks" name="adPaymentRemarks" class="form-control" >
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success btn-block mt-2">Save Payment</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div> </div>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {

View File

@ -0,0 +1,325 @@
<?php
require('../.hta_config/conf.php');
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'];
$frequency = $_POST['frequency'];
$bookingDate = $_POST['bookingDate'];
$paymentMode = $_POST['paymentMode'];
$salesAgent = $_POST['salesAgent'];
$adminNote = $_POST['adminNote'];
$invoiceId = $_POST['invoiceId'];
$customerName = $_POST['customerName'];
$customerAddress = $_POST['customerAddress'];
$marketingAgents = $_POST['marketingAgent'];
$marketingAgentList = implode(", ", $marketingAgents);
$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($bookingDate); // Set initial date
$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("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, tax = :tax, totalAmount = :totalAmount, adminNote = :adminNote, taxAmount = :taxAmount 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(':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>';
}
}
$invoiceData = null;
if (!empty($_GET['customerId'])) {
try {
$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");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->execute();
$invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
$invoiceDate = date('Y-m-d', strtotime($invoiceData['invoiceDate']));
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
?>
<div class="container mt-4">
<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="invoiceId" class="form-label">Invoice Id:</label>
<input type="text" class="form-control bg-white" id="invoiceId" name="invoiceId" value="<?= $invoiceData['invoiceId']; ?>">
</div>
<div class="mb-3">
<label for="name" class="form-label">Customer:</label>
<input readonly type="text" class="form-control bg-white" id="customerName" name="customerName" value="<?= htmlspecialchars($invoiceData['customerName']); ?>">
</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']); ?>">
</div>
<div class="mb-3">
<label for="frequency" class="form-label">Frequency:</label>
<select name="frequency" class="form-control" required>
<option value="">-Select-</option>
<option value="Weekly" <?php echo ($invoiceData['frequency'] === 'Weekly') ? 'selected' : ''; ?>>Weekly</option>
<option value="Monthly" <?php echo ($invoiceData['frequency'] === 'Monthly') ? 'selected' : ''; ?>>Monthly</option>
</select>
</div>
<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" value="<?= htmlspecialchars($invoiceDate); ?>" required>
</div>
</div>
</div>
<div class="w-100">
<div class="mb-3">
<label for="paymentMode" class="form-label">Payment Mode:</label>
<select name="paymentMode" class="form-control"required>
<option value="">-Select-</option>
<?php
$paymentModes = ["UPI", "Credit Card", "Debit Card", "Cash"];
foreach ($paymentModes as $mode) {
$selected = ($invoiceData['paymentMode'] === $mode) ? 'selected' : '';
echo "<option value=\"$mode\" $selected>$mode</option>";
}
?>
</select>
</div>
<div class="mb-3">
<label for="salesAgent" class="form-label">Sales Agent:</label>
<select name="salesAgent" 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="marketingAgent" class="form-label">Marketing Agent:</label>
<select name="marketingAgent[]" class="form-control" required multiple>
<?php
$marketingAgents = ["Prabhat Mishra", "Suvojit Mishra", "Aditya Sarkar", "Suvankar Sarkar"];
$selectedAgents = isset($invoiceData['marketingAgent']) && !empty($invoiceData['marketingAgent']) ? explode(',', $invoiceData['marketingAgent']) : [];
foreach ($marketingAgents as $agent) {
$selected = in_array(trim($agent), array_map('trim', $selectedAgents)) ? 'selected' : '';
echo "<option value=\"$agent\" $selected>$agent</option>";
}
?>
</select>
</div>
<?php
$tenureOptions = [ "1" => "One Time","3" => "3","6" => "6","9" => "9","12" => "12","0" => "Custom" ];
$selectedTenure = $invoiceData['tenure'] ?? ''; // Get selected tenure value
?>
<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>
<?php
foreach ($tenureOptions as $value => $label) {
$selected = ($selectedTenure == $value) ? 'selected' : '';
echo "<option value=\"$value\" $selected>$label</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"><?= htmlspecialchars($invoiceData['adminNote']); ?></textarea>
</div>
</div>
</div>
<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>
<input type="text" class="form-control w-100" name="item" id="item" value="<?= htmlspecialchars($invoiceData['item']); ?>" />
</td>
<td>
<input type="text" class="form-control w-100" name="description" id="description" value="<?= htmlspecialchars($invoiceData['description']); ?>"/>
</td>
<td>
<input class="form-control w-100" name="quantity" id="quantity" value="<?= htmlspecialchars($invoiceData['qty']); ?>"/>
</td>
<td>
<input class="form-control w-100" name="rate" id="rate" value="<?= htmlspecialchars($invoiceData['rate']); ?>"/>
</td>
<td>
<select name="tax" id="tax" class="form-control">
<option value="0">No Tax</option>
<?php
$taxOptions = ["5", "10", "12", "18"];
foreach ($taxOptions as $tax) {
$selected = ($invoiceData['tax'] === $tax) ? 'selected' : '';
echo "<option value=\"$tax\" $selected> $tax%</option>";
}
?>
</select>
</td>
<td>
<input readonly class="form-control" name="taxAmount" id="taxAmount" value="<?= htmlspecialchars($invoiceData['taxAmount']); ?>" />
</td>
<td>
<input readonly class="form-control" name="totalAmount" id="totalAmount" value="<?= htmlspecialchars($invoiceData['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>
function changeTenureField() {
const tenureAuto = document.getElementById('tenureAuto');
const tenureCustom = document.getElementById('tenureCustom');
if (tenureAuto.value === "0") {
tenureAuto.classList.add('visually-hidden');
tenureAuto.setAttribute('disabled', 'true');
tenureAuto.removeAttribute('name');
tenureCustom.classList.remove('visually-hidden');
tenureCustom.removeAttribute('disabled');
tenureCustom.setAttribute('name', 'tenure');
tenureCustom.focus();
}
}
function restoreDropdown(input) {
const tenureAuto = document.getElementById('tenureAuto');
if (input.value.trim() === "") {
tenureAuto.classList.remove('visually-hidden');
tenureAuto.removeAttribute('disabled');
tenureAuto.setAttribute('name', 'tenure');
tenureAuto.value = ""; // Reset dropdown selection
input.classList.add('visually-hidden');
input.setAttribute('disabled', 'true');
input.removeAttribute('name');
input.value = ""; // Clear input value
} else {
tenureAuto.value = "0"; // Ensure dropdown remains on "Custom" if input has a 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

@ -105,9 +105,9 @@
$customerAddress = $stmt->fetch(PDO::FETCH_ASSOC); $customerAddress = $stmt->fetch(PDO::FETCH_ASSOC);
} }
$stmt = $db->query("SELECT id FROM invoice ORDER BY id DESC LIMIT 1"); $stmt = $db->query("SELECT id FROM invoice WHERE DATE(invoiceDate) = CURDATE() ORDER BY id DESC LIMIT 1");
$lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC); $lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
$invoiceId = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1'); $invoiceId = "CB" . date('my') . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
$stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1"); $stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC); $lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC);
@ -136,7 +136,7 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="address" class="form-label">Address:</label> <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']; ?>"> <input id="address" readonly name="customerAddress" class="form-control bg-white" type="text" value="<?= htmlspecialchars($customer['address']); ?>">
</div> </div>
<div class="mb-3"> <div class="mb-3">

View File

@ -5,15 +5,16 @@
<h2 class="mb-3 text-center">Customer List</h2> <h2 class="mb-3 text-center">Customer List</h2>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-striped table-hover"> <table class="table table-bordered table-striped table-hover">
<thead class="bg-primary text-white text-center"> <thead class="bg-primary text-white text-center" style="font-size: 12px;">
<tr> <tr>
<th>Sl No</th> <th>Sl No</th>
<th>Name</th> <th>Name</th>
<th>Mobile</th> <th>Payment Start Date</th>
<th>Email</th> <th>Payment End Date</th>
<th>Invoice Id</th> <th>Number of Installments</th>
<th>Invoice Date</th> <th>Monthly Payment Date</th>
<th>Amount</th> <th>Monthly Payment Amount</th>
<th>Totoal Amount</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
@ -48,20 +49,22 @@
?> ?>
<tr> <tr>
<td><?php echo $customerSerial++; ?></td> <td><?php echo $customerSerial++; ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td> <td><a href="/customers/billing-details/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>"><?php echo htmlspecialchars($customer['name']); ?></a></td>
<td><?php echo htmlspecialchars($customer['mobile']); ?></td> <td>$<?php echo htmlspecialchars($invoice['totalAmount']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td> <td><?php echo htmlspecialchars($invoice['tenure']); ?></td>
<!-- Invoice Data --> <!-- Invoice Data -->
<td><?php echo htmlspecialchars($invoice['invoiceId']); ?></td> <td><?php echo htmlspecialchars($invoice['invoiceId']); ?></td>
<td><?php echo htmlspecialchars($invoice['invoiceDate']); ?></td> <td><?php echo htmlspecialchars($invoice['invoiceDate']); ?></td>
<td><?php echo htmlspecialchars($invoice['totalAmount']); ?></td> <td>$<?php echo htmlspecialchars($invoice['totalAmount']); ?></td>
<td> <td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a> <!-- <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/generate-invoice/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">New 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/edit-invoice/?customerId=<?php echo $customer['customerId'].'&invoiceId='.$invoice['invoiceId']; ?>" class="btn btn-primary btn-sm">Edit Invoice</a>
<a href="/customers/print-invoice/?customerId=<?php echo $customer['customerId'] . '&invoiceId=' . $invoice['invoiceId']; ?>" class="btn btn-primary btn-sm">Print</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> -->
<a href="/customers/additional-payment/?customerId=<?php echo $customer['customerId'].'&invoiceId='.$invoice['invoiceId']; ?>" class="btn btn-primary btn-sm">Payment</a>
</td> </td>
</tr> </tr>
<?php <?php
@ -76,9 +79,12 @@
<td><?php echo htmlspecialchars($customer['email']); ?></td> <td><?php echo htmlspecialchars($customer['email']); ?></td>
<td colspan="3">No invoice available</td> <td colspan="3">No invoice available</td>
<td> <td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a> <!-- <a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit Invoice</a> -->
<!-- <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/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> <!-- <a href="/customers/billing-details/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">EMI Details</a> -->
<a href="" class="btn btn-primary btn-sm">Additional Payment</a>
</td> </td>
</tr> </tr>
<?php <?php

View File

@ -6,48 +6,51 @@
<h4>Customer Registration</h4> <h4>Customer Registration</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<?php <?php
require('../.hta_config/conf.php'); require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try { try {
$customerId = str_replace('.', '', uniqid('cust_', true)); $customerId = str_replace('.', '', uniqid('cust_', true));
$userPassword = md5($_POST['password']); $userPassword = md5($_POST['password']);
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); $db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO customers (name, mobile, email, customerId) VALUES (:name, :mobile, :email, :customerId)"); $stmt = $db->prepare("INSERT INTO customers (name, mobile, email, customerId, company, address, sallery) VALUES (:name, :mobile, :email, :customerId, :company, :address, :sallery)");
$stmt->bindParam(':name', $_POST['name']); $stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':mobile', $_POST['mobile']); $stmt->bindParam(':mobile', $_POST['mobile']);
$stmt->bindParam(':email', $_POST['email']); $stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':customerId', $customerId); $stmt->bindParam(':company', $_POST['jobCompany']);
$stmt->bindParam(':address', $_POST['billingAddress']);
$stmt->bindParam(':sallery', $_POST['sallery']);
$stmt->bindParam(':customerId', $customerId);
$stmt2 = $db->prepare("INSERT INTO users (name, mobile, email, type, password, customerId) VALUES (:name, :mobile, :email, :type, :password, :customerId)"); $stmt2 = $db->prepare("INSERT INTO users (name, mobile, email, type, password, customerId) VALUES (:name, :mobile, :email, :type, :password, :customerId)");
$stmt2->bindParam(':name', $_POST['name']); $stmt2->bindParam(':name', $_POST['name']);
$stmt2->bindParam(':mobile', $_POST['mobile']); $stmt2->bindParam(':mobile', $_POST['mobile']);
$stmt2->bindParam(':email', $_POST['email']); $stmt2->bindParam(':email', $_POST['email']);
$stmt2->bindParam(':type', $_POST['type']); $stmt2->bindParam(':type', $_POST['type']);
$stmt2->bindParam(':password', $userPassword); $stmt2->bindParam(':password', $userPassword);
$stmt2->bindParam(':customerId', $customerId); $stmt2->bindParam(':customerId', $customerId);
if ($stmt->execute()) { if ($stmt->execute()) {
$stmt2->execute(); $stmt2->execute();
echo '<div class="alert alert-success">New Customer <strong>' . htmlspecialchars($_POST['name']) . '</strong> created successfully.</div>'; echo '<div class="alert alert-success">New Customer <strong>' . htmlspecialchars($_POST['name']) . '</strong> created successfully.</div>';
} else { } else {
echo '<div class="alert alert-danger">Error inserting into customers table: ' . $stmt->errorInfo()[2] . '</div>'; echo '<div class="alert alert-danger">Error inserting into customers table: ' . $stmt->errorInfo()[2] . '</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
} }
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
} }
}
?> ?>
<form method="POST"> <form method="POST">
<div class="form-group"> <div class="form-group">
<label for="name">Name:</label> <label for="name">Full Name:</label>
<input type="text" id="name" name="name" class="form-control" required> <input type="text" id="name" name="name" class="form-control" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mobile">Mobile:</label> <label for="mobile">Contact:</label>
<input type="text" id="mobile" name="mobile" class="form-control" required> <input type="text" id="mobile" name="mobile" class="form-control" required>
</div> </div>
@ -56,6 +59,21 @@
<input type="email" id="email" name="email" class="form-control" required> <input type="email" id="email" name="email" class="form-control" required>
</div> </div>
<div class="form-group">
<label for="jobCompany">Company:</label>
<input type="text" id="jobCompany" name="jobCompany" class="form-control" required>
</div>
<div class="form-group">
<label for="billingAddress">Billing Address:</label>
<input type="text" id="billingAddress" name="billingAddress" class="form-control" required>
</div>
<div class="form-group">
<label for="sallery">Sallery He Recieved:</label>
<input type="text" id="sallery" name="sallery" class="form-control" required>
</div>
<div class="form-group"> <div class="form-group">
<label for="type">User Type:</label> <label for="type">User Type:</label>
<select class="form-control" name="type" id="type" require> <select class="form-control" name="type" id="type" require>

View File

@ -55,8 +55,8 @@ if ($invoiceInfo['tenure'] > 1) {
<td><?= $invoiceInfo['qty'] ?></td> <td><?= $invoiceInfo['qty'] ?></td>
<td><?= $invoiceInfo['rate'] ?></td> <td><?= $invoiceInfo['rate'] ?></td>
<td><?= $invoiceInfo['tax'] ?>%</td> <td><?= $invoiceInfo['tax'] ?>%</td>
<td><?= $invoiceInfo['taxAmount'] ?></td> <td>$<?= $invoiceInfo['taxAmount'] ?></td>
<td><?= number_format($invoiceInfo['totalAmount'], 2) ?></td> <td>$<?= number_format($invoiceInfo['totalAmount'], 2) ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -79,8 +79,8 @@ if ($invoiceInfo['tenure'] > 1) {
<tr> <tr>
<td><?= $emi['emiNumber'] ?></td> <td><?= $emi['emiNumber'] ?></td>
<td><?= $emi['emiDate'] ?></td> <td><?= $emi['emiDate'] ?></td>
<td><?= number_format($emi['emiAmount'], 2) ?></td> <td>$<?= number_format($emi['emiAmount'], 2) ?></td>
<td><?= number_format($emi['outstanding'], 2) ?></td> <td>$<?= number_format($emi['outstanding'], 2) ?></td>
<td> <td>
<?= ($emi['payStatus'] == 1) ? '<span class="badge bg-success">Paid</span>' : '<span class="badge bg-danger">Pending</span>' ?> <?= ($emi['payStatus'] == 1) ? '<span class="badge bg-success">Paid</span>' : '<span class="badge bg-danger">Pending</span>' ?>
</td> </td>

1
info.txt Normal file
View File

@ -0,0 +1 @@
http://localhost:2056/customers/billing-details/?customerId=cust_67c9925ff14f4834489101&invoiceId=CB03251 ? Additional Amount.

View File

@ -84,14 +84,14 @@ try {
<?php foreach ($emiPlans as $emi) { ?> <?php foreach ($emiPlans as $emi) { ?>
<tr id="row-<?= $emi['id']; ?>"> <tr id="row-<?= $emi['id']; ?>">
<td><?= $emi['emiNumber']; ?></td> <td><?= $emi['emiNumber']; ?></td>
<td><?= number_format($emi['emiAmount'], 2); ?></td> <td>$<?= number_format($emi['emiAmount'], 2); ?></td>
<td><?= date('d-m-Y', strtotime($emi['emiDate'])); ?></td> <td><?= date('d-m-Y', strtotime($emi['emiDate'])); ?></td>
<td> <td>
<span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>"> <span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>">
<?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?> <?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
</span> </span>
</td> </td>
<td><?= number_format($emi['outstanding'], 2); ?></td> <td>$<?= number_format($emi['outstanding'], 2); ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>

View File

@ -55,12 +55,13 @@ if ($invoiceInfo['tenure'] > 1) {
<td><?= $invoiceInfo['qty'] ?></td> <td><?= $invoiceInfo['qty'] ?></td>
<td><?= $invoiceInfo['rate'] ?></td> <td><?= $invoiceInfo['rate'] ?></td>
<td><?= $invoiceInfo['tax'] ?>%</td> <td><?= $invoiceInfo['tax'] ?>%</td>
<td><?= $invoiceInfo['taxAmount'] ?></td> <td>$<?= $invoiceInfo['taxAmount'] ?></td>
<td><?= number_format($invoiceInfo['totalAmount'], 2) ?></td> <td>$<?= number_format($invoiceInfo['totalAmount'], 2) ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- https://center.rgyci.org/printresult_admin_pdf.php?role=admin&reg=WB180Y2021R11308&sem=1
https://center.rgyci.org/printresult_admin.php?sid=&reg=WB180Y2021R11308&sem=1 -->
<!-- EMI Table (if tenure > 1) --> <!-- EMI Table (if tenure > 1) -->
<?php if ($invoiceInfo['tenure'] > 1): ?> <?php if ($invoiceInfo['tenure'] > 1): ?>
<h4 class="mt-4 text-blue">EMI Payment Plan</h4> <h4 class="mt-4 text-blue">EMI Payment Plan</h4>
@ -79,8 +80,8 @@ if ($invoiceInfo['tenure'] > 1) {
<tr> <tr>
<td><?= $emi['emiNumber'] ?></td> <td><?= $emi['emiNumber'] ?></td>
<td><?= $emi['emiDate'] ?></td> <td><?= $emi['emiDate'] ?></td>
<td><?= number_format($emi['emiAmount'], 2) ?></td> <td>$<?= number_format($emi['emiAmount'], 2) ?></td>
<td><?= number_format($emi['outstanding'], 2) ?></td> <td>$<?= number_format($emi['outstanding'], 2) ?></td>
<td> <td>
<?= ($emi['payStatus'] == 1) ? '<span class="badge bg-success">Paid</span>' : '<span class="badge bg-danger">Pending</span>' ?> <?= ($emi['payStatus'] == 1) ? '<span class="badge bg-success">Paid</span>' : '<span class="badge bg-danger">Pending</span>' ?>
</td> </td>