Suvodip 2025-03-25 20:33:59 +05:30
parent d9b4921a12
commit 321e617580
6 changed files with 176 additions and 31 deletions

View File

@ -72,8 +72,6 @@
}
try {
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt->bindParam(':invoiceId', $_GET['invoiceId']);
@ -159,13 +157,14 @@
$frequency = $frequency !== null ? $frequency : 0;
?>
<div class="container mt-4">
<h3 class="mb-3">EMI Details</h3>
<h3 class="mb-3">Installment Details</h3>
<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>Invoice Id: <strong><?php echo $emiPlans[0]['invoiceId']; ?></strong></p>
<p>Email: <strong><?php echo $customer['email']; ?></strong></p>
</div>
<div>
<p>Total Amount: <strong>$<?php echo $totalAmount; ?></strong></p>

View File

@ -0,0 +1,127 @@
<?php
require('../.hta_config/conf.php');
if (!isset($_SESSION['isLogedin']) || $_SESSION['isLogedin'] != 1) {
header("Location: /login");
exit;
}
?>
<?php
$message = ""; // Variable to store error or success messages
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_password'])) {
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch input values
$customerId = $_GET['customerId'];
$newPassword = md5($_POST['new_password']);
$confirmPassword = md5($_POST['confirm_password']);
if ($newPassword !== $confirmPassword) {
$message = '<div class="alert alert-danger">New passwords do not match. Please try again.</div>';
} else {
// Update password
$stmt = $db->prepare("UPDATE users SET password = :password WHERE customerId = :customerId");
$stmt->bindParam(':password', $newPassword, PDO::PARAM_STR);
$stmt->bindParam(':customerId', $customerId, PDO::PARAM_STR);
if ($stmt->execute()) {
$message = '<div class="alert alert-success">Password updated successfully!</div>';
} else {
$message = '<div class="alert alert-danger">Failed to update password. Try again later.</div>';
}
}
} catch (PDOException $e) {
$message = '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
?>
<style>
.profile-container {
max-width: 600px;
margin: 80px auto;
}
.profile-card {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
}
.profile-header {
text-align: center;
margin-bottom: 20px;
}
.profile-header img {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 10px;
}
.btn-primary {
background: #394fc0;
border: none;
}
.btn-primary:hover {
background: #2e3b8c;
}
</style>
<div class="profile-container">
<div class="profile-card">
<div class="profile-header">
<svg style="background-color: #37415110; border: 2px solid #374151;border-radius: 50%; padding: 3px; box-shadow: 0 0 10px 0;" width="100px" height="100px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <defs> <style>.cls-1{fill:#374151;}.cls-2{fill:#374151;}</style> </defs> <title></title> <g id="fill"> <circle class="cls-1" cx="16" cy="7.48" r="5.48"></circle> <path class="cls-2" d="M23.54,30H8.46a4.8,4.8,0,0,1-4.8-4.8h0A10.29,10.29,0,0,1,13.94,14.92h4.12A10.29,10.29,0,0,1,28.34,25.2h0A4.8,4.8,0,0,1,23.54,30Z"></path> </g> </g></svg>
<p class="fw-bold mt-2">Chnage <?php echo $_GET['userName']; ?>'s password</p>
<!-- <p class="text-muted">Email: <?php echo $_SESSION['userEmail']; ?></p> -->
</div>
<div class="mt-3">
<h5>Change Password</h5><hr>
<?= $message ?>
<form method="POST">
<div class="mb-3">
<input type="password" class="form-control" id="newPassword" name="new_password" placeholder="New Password" required>
</div>
<div class="mb-3">
<input type="password" class="form-control" id="confirmPassword" name="confirm_password" placeholder="Confirm New Password" required>
</div>
<button name="update_password" type="submit" class="btn w-100 text-white" style="background-color: #374151">Update Password</button>
</form>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
const newPassword = document.getElementById("newPassword");
const confirmPassword = document.getElementById("confirmPassword");
const submitBtn = document.querySelector("button[type='submit']");
const errorMessage = document.createElement("small");
errorMessage.style.color = "red";
confirmPassword.parentNode.appendChild(errorMessage);
confirmPassword.addEventListener("input", function () {
if (newPassword.value !== confirmPassword.value) {
errorMessage.style.color = "red";
errorMessage.textContent = "Passwords do not match!";
submitBtn.disabled = true;
} else {
errorMessage.style.color = "green";
errorMessage.textContent = "Passwords matched!";
submitBtn.disabled = false;
}
});
form.addEventListener("submit", function (e) {
if (newPassword.value !== confirmPassword.value) {
e.preventDefault();
errorMessage.textContent = "Passwords do not match!";
submitBtn.disabled = true;
}
});
});
</script>

View File

@ -135,6 +135,7 @@
<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
@ -153,6 +154,7 @@
<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

View File

@ -70,7 +70,7 @@
</div>
<div class="form-group">
<label for="sallery">Sallery He Recieved:</label>
<label for="sallery">Salary:</label>
<input type="text" id="sallery" name="sallery" class="form-control" required>
</div>

View File

@ -2,7 +2,7 @@
require('../.hta_config/conf.php');
?>
<div class="container mt-4">
<h2 class="mb-3 text-center">Customer List</h2>
<h2 class="mb-3 text-left">My Account</h2><hr>
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<thead class="text-white text-center" style="background-color: #374151;">
@ -61,7 +61,7 @@
<td><?php echo htmlspecialchars($invoice['totalAmount']); ?></td>
<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;">EMI Details</a>
<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>
</td>
</tr>
@ -77,7 +77,7 @@
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td colspan="3">No invoice available</td>
<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;">EMI Details</a>
<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>
</td>
</tr>
<?php

View File

@ -41,47 +41,64 @@ try {
die('<div class="alert alert-danger text-center">Error: ' . $e->getMessage() . '</div>');
}
?>
<?php
$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">
<h2 class="mb-3">EMI Details</h2>
<h2 class="mb-3">Installment 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>
<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>
</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>
<p>Total Amount: <strong>&#36;<?php echo $totalAmount; ?></strong></p>
<p>Outstanding: <strong>&#36;<?php echo round($currentOutstanding); ?></strong></p>
<p>Tenure: <strong><?php echo $tenure; ?></strong></p>
<p>Frequency: <strong><?php echo $frequency; ?></strong></p>
</div>
</div>
<table class="table table-striped table-bordered">
<thead class="text-white text-center" style="background-color: #374151;">
<tr>
<th>Number of EMI</th>
<th>EMI Amount</th>
<th>EMI Date</th>
<th>Installment</th>
<th>Amount</th>
<th>Date</th>
<th>Payment Status</th>
<th>Outstanding</th>
</tr>
</thead>
<tbody>
<?php foreach ($emiPlans as $emi) { ?>
<?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>
@ -93,7 +110,7 @@ try {
</td>
<td>$<?= number_format($emi['outstanding'], 2); ?></td>
</tr>
<?php } ?>
<?php } } ?>
</tbody>
</table>
</div>