This commit is contained in:
ns77@siliconpin.com
2025-09-03 14:04:44 +00:00
parent 10881c6a5b
commit 533d1b572d
12 changed files with 410 additions and 218 deletions

View File

@@ -59,21 +59,45 @@ date_default_timezone_set('Asia/Kolkata');
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li> <?php
<li><a href="/Admin/Create_AC_FD">New FD</a></li> $userType = $_SESSION['type'] ?? '';
<li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
<li><a href="/Admin/Add_group">Add New Group</a></li> if ($userType === 'admin') {
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li> // Admin gets everything
<li><a href="/Admin/Trans_New">Transaction</a></li> ?>
<li><a href="/Admin/Due">Deemand Sheet</a></li> <li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li>
<li><a href="/Admin/Report">Report</a></li> <li><a href="/Admin/Create_AC_FD">New FD</a></li>
<!-- <li><a href="/Admin/Revert">Revert</a></li> --> <li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
<?php <li><a href="/Admin/Add_group">Add New Group</a></li>
if($_SESSION['type'] === 'admin'){ ?> <li><a href="/Admin/Trans_New">Transaction</a></li>
<li><a href="/Admin/agent_View_report">Commission</a></li> <li><a href="/Admin/agent-targets">Agent Targets</a></li>
<li><a href="/Admin/agent-targets">Agent Targets</a></li> <li><a href="/Admin/agent_View_report">Commission</a></li>
<li><a href="/Admin/Settings_Agent">Agent Settings</a></li> <li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
<?php } ?> <li><a href="/Admin/Report">Report</a></li>
<li><a href="/Admin/Due">Deemand Sheet</a></li>
<li><a href="/Admin/Settings_Agent">Agent Settings</a></li>
<?php
} elseif ($userType === 'bm') {
// Branch Manager menu
?>
<li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li>
<li><a href="/Admin/Create_AC_FD">New FD</a></li>
<li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
<li><a href="/Admin/Add_group">Add New Group</a></li>
<li><a href="/Admin/Trans_New">Transaction</a></li>
<li><a href="/Admin/agent-targets">Agent Targets</a></li>
<li><a href="/Admin/agent_View_report">Commission</a></li>
<?php
} elseif ($userType === 'agent') {
// Agent menu
?>
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
<li><a href="/Admin/Due">Deemand Sheet</a></li>
<li><a href="/Admin/Report">Report</a></li>
<li><a href="/Admin/agent_View_report">Commission</a></li>
<?php
}
?>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
@@ -82,4 +106,4 @@ date_default_timezone_set('Asia/Kolkata');
</ul> </ul>
</div> </div>
</div> </div>
</nav> </nav>

View File

@@ -28,7 +28,7 @@
while($a = $agents->fetch_assoc()){ while($a = $agents->fetch_assoc()){
$selected = (isset($_GET['agent']) && $_GET['agent']==$a['user_id']) ? "selected" : ""; $selected = (isset($_GET['agent']) && $_GET['agent']==$a['user_id']) ? "selected" : "";
echo "<option value='".$a['user_id']."' $selected>".$a['user_name']." (".$a['user_id'].")</option>"; echo "<option value='".$a['user_id']."' $selected>".$a['user_name']." (".$a['user_id'].")</option>";
} }
} }
?> ?>
</select> </select>
@@ -113,11 +113,12 @@ function report_view($type, $dt) {
$result = $conn->query($sql); $result = $conn->query($sql);
if ($result && $result->num_rows > 0) { if ($result && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) { while($row = $result->fetch_assoc()) {
$kolkataTime = date("d M Y, h:i A", strtotime($row["AT_TIMESTAMP"] . " +5 hours 30 minutes"));
echo " echo "
<tr> <tr>
<td>".$row["AT_ID"]."</td> <td>".$row["AT_ID"]."</td>
".($_SESSION['type'] === 'admin' ? "<td>".$row["AA_AGENT"]."</td>" : "")." ".($_SESSION['type'] === 'admin' ? "<td>".$row["AA_AGENT"]."</td>" : "")."
<td>".$row["AT_TIMESTAMP"]."</td> <td>".$kolkataTime."</td>
<td>".$row["AT_ACID"]."</td> <td>".$row["AT_ACID"]."</td>
<td>".$row["AA_NAME"]."</td> <td>".$row["AA_NAME"]."</td>
<td>".$row["AT_AMOUNT"]."</td> <td>".$row["AT_AMOUNT"]."</td>

View File

@@ -7,42 +7,56 @@
if ($conn->connect_error) { if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); die("Connection failed: " . $conn->connect_error);
} }
// grafinn01
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user_id = $_POST['user_id']; $user_id = $_POST['user_id'];
$user_name = $_POST['user_name'] ?? '';
$user_phone = $_POST['user_phone'] ?? '';
$type = $_POST['type'] ?? 'agent';
$comiRate = $_POST['comi_rate'] ?? null;
$passwordPlain = $_POST['password'] ?? '';
if (empty($_POST['user_name']) || empty($_POST['user_phone']) || empty($_POST['password'])) { // Validation
die("All fields are required."); if (empty($user_name) || empty($user_phone) || empty($passwordPlain)) {
} $error = "All fields are required.";
} elseif (!preg_match("/^[0-9]{10}$/", $user_phone)) {
$error = "Invalid phone number format.";
} else {
$password = password_hash($passwordPlain, PASSWORD_DEFAULT);
$user_name = $_POST['user_name']; // Profile Picture Upload
$user_phone = $_POST['user_phone']; $profilePicPath = null;
$type = $_POST['type'] ?? 'agent'; if (isset($_FILES['profile_pic']) && $_FILES['profile_pic']['error'] === UPLOAD_ERR_OK) {
$password = password_hash($_POST['password'], PASSWORD_DEFAULT); $uploadDir = __DIR__ . "/picture/";
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$fileTmp = $_FILES['profile_pic']['tmp_name'];
$fileName = time() . "_" . basename($_FILES['profile_pic']['name']);
$filePath = $uploadDir . $fileName;
if (move_uploaded_file($fileTmp, $filePath)) {
$profilePicPath = "picture/" . $fileName;
} else {
$error = "Failed to upload profile picture.";
}
}
if (!preg_match("/^[0-9]{10}$/", $user_phone)) { if (!isset($error)) {
die("Invalid phone number format"); $table = $GLOBALS['arif_users'] ?? 'arif_users';
} $sql = "INSERT INTO `$table`
(user_id, password, type, user_name, user_phone, comi_rate, profile_pic)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssssss", $user_id, $password, $type, $user_name, $user_phone, $comiRate, $profilePicPath);
$table = $GLOBALS['arif_users'] ?? 'arif_users'; if ($stmt->execute()) {
$success = "User <strong>{$user_name}</strong> added successfully.";
$sql = "INSERT INTO `$table` (user_id, password, type, user_name, user_phone) VALUES (?, ?, ?, ?, ?)"; } else {
$stmt = $conn->prepare($sql); $error = "Failed to add user: " . $stmt->error;
}
if (!$stmt) { $stmt->close();
die("Prepare failed: " . $conn->error); }
} }
$stmt->bind_param("sssss", $user_id, $password, $type, $user_name, $user_phone);
if ($stmt->execute()) {
echo "<div class='alert alert-success'>User <strong>{$user_name}</strong> added successfully.</div>";
} else {
echo "<div class='alert alert-danger'>Failed to add user <strong>{$user_name}</strong>. Error: " . $stmt->error . "</div>";
}
$stmt->close();
$conn->close();
} }
$getAgentListsQuery = "SELECT * FROM " . $GLOBALS['arif_users'] . " ORDER BY type, user_id"; $getAgentListsQuery = "SELECT * FROM " . $GLOBALS['arif_users'] . " ORDER BY type, user_id";
@@ -65,7 +79,7 @@
<div class="container"> <div class="container">
<h3>Add New Agent</h3><hr> <h3>Add New Agent</h3><hr>
<form method="post"> <form method="post" enctype="multipart/form-data">
<div class="row"> <div class="row">
<!-- Left Column --> <!-- Left Column -->
<div class="col-md-6"> <div class="col-md-6">
@@ -84,17 +98,27 @@
</div> </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" id="type" name="type" required> <select onchange="showCommissionField();" class="form-control" id="user-type" name="type" required>
<option value="agent" selected>Agent</option> <option value="">-Select-</option>
<option value="agent" >Agent</option>
<option value="admin">Admin</option> <option value="admin">Admin</option>
<option value="supervisor">Supervisor</option> <option value="bm">BRanch Manager</option>
</select> </select>
</div> </div>
<div class="form-group" id="commission-field" style="display: none;">
<label for="comi_rate">Commission Rate (%)</label>
<input type="number" class="form-control" id="comi_rate" name="comi_rate" value="3" placeholder="" required>
</div>
<div class="form-group"> <div class="form-group">
<label for="password">Password</label> <label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required> <input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required>
</div> </div>
<div class="form-group">
<label for="profile_pic">Profile Picture</label>
<input type="file" class="form-control" id="profile_pic" name="profile_pic" accept="image/*">
</div>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-success w-100">Add Agent</button> <button type="submit" class="btn btn-success w-100">Add Agent</button>
@@ -115,10 +139,12 @@
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Profile</th>
<th>User ID</th> <th>User ID</th>
<th>User Type</th> <th>User Type</th>
<th>Name</th> <th>Name</th>
<th>Phone</th> <th>Phone</th>
<th>Comi Rate (%)</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@@ -127,6 +153,14 @@
<?php foreach ($agentList as $user): ?> <?php foreach ($agentList as $user): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($user['id']); ?></td> <td><?php echo htmlspecialchars($user['id']); ?></td>
<td>
<?php if(!empty($user['profile_pic'])): ?>
<img src="/CONTENT/ROOT_URI/Admin/<?php echo $user['profile_pic']; ?>" width="40" height="40" style="border-radius:50%;">
<?php else: ?>
<span>No Photo</span>
<?php endif; ?>
</td>
<td><?php echo htmlspecialchars($user['user_id']); ?></td> <td><?php echo htmlspecialchars($user['user_id']); ?></td>
<td class="badge-cell"> <td class="badge-cell">
<span class="badge <?php echo $user['type'] === 'admin' ? 'badge-primary' : 'badge-secondary'; ?>"> <span class="badge <?php echo $user['type'] === 'admin' ? 'badge-primary' : 'badge-secondary'; ?>">
@@ -135,6 +169,7 @@
</td> </td>
<td><?php echo htmlspecialchars($user['user_name']); ?></td> <td><?php echo htmlspecialchars($user['user_name']); ?></td>
<td><?php echo htmlspecialchars($user['user_phone']); ?></td> <td><?php echo htmlspecialchars($user['user_phone']); ?></td>
<td><?php echo htmlspecialchars($user['comi_rate']); ?></td>
<td> <td>
<a href="edit_user?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-warning">Edit</a> <a href="edit_user?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-warning">Edit</a>
<?php if($user['type'] !== 'admin') { ?> <?php if($user['type'] !== 'admin') { ?>
@@ -234,6 +269,18 @@
} }
notif.innerHTML = res_txt; notif.innerHTML = res_txt;
} }
function showCommissionField(){
const selectedUserType = document.getElementById('user-type').value;
const commissionField = document.getElementById('commission-field');
if(selectedUserType === 'agent'){
commissionField.style.display = 'block';
}else{
commissionField.style.display = 'none';
}
}
</script> </script>

View File

@@ -382,11 +382,12 @@ if(isset($_GET["no"])){
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { while($row = $result->fetch_assoc()) {
//$ID=$row["GC_ID"]; //$ID=$row["GC_ID"];
$kolkataTime = date("d M Y, h:i A", strtotime($row["AT_TIMESTAMP"] . " +5 hours 30 minutes"));
echo " echo "
<tr> <tr>
<td>".$rowcount. "</td> <td>".$rowcount. "</td>
<td>".$row["AT_ID"]. "</td> <td>".$row["AT_ID"]. "</td>
<td>".$row["AT_TIMESTAMP"]. "</td> <td>".$kolkataTime. "</td>
<td>".$row["AT_ADMIN"]. "</td> <td>".$row["AT_ADMIN"]. "</td>
<td>".$row["AT_ACID"]. "</td> <td>".$row["AT_ACID"]. "</td>
<td>".$row["AT_AMOUNT"]. "</td> <td>".$row["AT_AMOUNT"]. "</td>

View File

@@ -161,7 +161,7 @@ function view_list_ac($type) {
} else { } else {
$sql = "SELECT * FROM `".$GLOBALS['arif_ac']."` WHERE `AA_TYPE`='".$type."' AND `AA_AGENT`='".$_SESSION['user_id']."' ORDER BY `AA_ID` DESC"; $sql = "SELECT * FROM `".$GLOBALS['arif_ac']."` WHERE `AA_TYPE`='".$type."' AND `AA_AGENT`='".$_SESSION['user_id']."' ORDER BY `AA_ID` DESC";
} }
} elseif($_SESSION['type'] === 'admin') { } elseif($_SESSION['type'] === 'admin' || $_SESSION['type'] === 'bm') {
if($type === 'Closed-Acc') { if($type === 'Closed-Acc') {
$sql = "SELECT * FROM `".$GLOBALS['arif_ac']."` WHERE `AA_TYPE`='Loan' AND `STATUS`='closed' ORDER BY `AA_ID` DESC"; $sql = "SELECT * FROM `".$GLOBALS['arif_ac']."` WHERE `AA_TYPE`='Loan' AND `STATUS`='closed' ORDER BY `AA_ID` DESC";
} elseif($type === 'Matured-Recurring') { } elseif($type === 'Matured-Recurring') {

View File

@@ -1,120 +1,118 @@
<div class="container">
<table>
<!-- <tr>
<td>
<form>
<input type="date" name="tday">
<input type="submit" class="btn-info" value="Daily Report">
</form>
</td>
<td>
<form>
<input type="date" name="tmonth">
<input type="submit" class="btn-info" value="Monthly Report">
</form>
</td>
</tr> -->
<tr><td>.</td><td>.</td></tr>
<tr>
<td colspan="2">
<form method="post">
<select name="Agent">
<option value=""> Select Agent </option>
<?php
$users = glob(APP_DIR.'/CONTENT/ROOT_URI/Admin/users/*');
$user_arr = array();
for($i = 0; $i < count($users); $i++) {
$new_user = explode('/', $users[$i]);
$new_user = end($new_user);
echo '<option value="'.$new_user.'">'.$new_user.'</option>';
// $user_arr[$i] = $new_user;
}
?>
</select>
<label for="">From </label><input type="date" name="dFrom">
<label for="">To </label><input type="date" name="dTo">
<input type="submit" class="btn-info" value="Report">
</form>
</td>
</tr>
</table>
</div>
<?php <?php
// ---- Default date range ----
function report_view($type,$dt) { $today = date("Y-m-d"); // Today date
$dateFrom=$dt; $monthStart = date("Y-m-01"); // first date of each month
if($type!="month" || $type!="day") { $dFrom = $_GET['dFrom'] ?? $monthStart;
$dateFrom= strtotime($dt); $dateFrom = date("Y-m-d", $dateFrom); $dTo = $_GET['dTo'] ?? $today;
$dateTo= strtotime('+1 day', strtotime($type)); $dateTo = date("Y-m-d", $dateTo); ?>
}
//$dateFrom=$dt; <div class="container mt-4">
else{ <div class="card shadow-lg p-4 rounded-3">
if($type=="month") {$dateFrom= strtotime('-1 day', strtotime($dt)); $dateFrom = date("Y-m-d", $dateFrom);} <h4 class="mb-3">Commission Report</h4>
$dateTo = strtotime('+1 '.$type, strtotime($dt)); <form method="get" class="row g-3">
$dateTo = date("Y-m-d", $dateTo); <div class="col-md-3">
} <label class="form-label">From</label>
echo '<div class="container"> <h3>'.$dateFrom." -> ".$dateTo."(Up to)</h3> </div>"; <input value="<?= $dFrom ?>" type="date" name="dFrom" class="form-control" required>
</div>
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']); <div class="col-md-3">
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); <label class="form-label">To</label>
<input value="<?= $dTo ?>" type="date" name="dTo" class="form-control" required>
$totalAmount=0; </div>
$agent="";if(isset($_POST['Agent'])) $agent=$_POST['Agent']; else $agent=$_SESSION['EMAIL']; <div class="col-md-3 d-flex align-items-end" style="margin-top: 25px;">
<button type="submit" class="btn btn-info w-100">Generate Report</button>
echo ' </div>
<div class="container" style="margin-top: 70px;"> </form>
<h5>VIEW REPORT:::::::: </h5><hr> </div>
</div> </div>
<div class="container">
<table class="table table-striped table-bordered table-hover table-responsive">
<tr> <?php
<th>Transaction ID</th> function commission_report($dateFrom, $dateTo) {
<th>Time</th> echo '<div class="container mt-4">
<th>AC No</th> <div class="alert alert-primary shadow-sm">
<th>Name</th> <h5 class="mb-0">Commission Report: '.$dateFrom." → ".$dateTo.'</h5>
<th>Amount</th> </div>
<th>commission</th> </div>';
</tr>';
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM `".$GLOBALS['arif_tran']."` INNER JOIN `".$GLOBALS['arif_ac']."` ON `".$GLOBALS['arif_tran']."`.`AT_ACID`=`".$GLOBALS['arif_ac']."`.`AA_ACNO` WHERE `AT_TIMESTAMP` BETWEEN '".$dateFrom." 00:00:00.000000' AND '".$dateTo." 00:00:00.000000'
AND `AA_AGENT`= '".$agent."' ORDER BY `AT_ID` DESC"; // ---- Login user type check ----
$result = $conn->query($sql); $loginType = $_SESSION['type'] ?? ''; // login session-এ type আছে
if ($result->num_rows > 0) { $loginId = $_SESSION['user_id']; // login user_id
while($row = $result->fetch_assoc()) {
//$ID=$row["GC_ID"]; // ---- Base Query ----
// $tt=$row["AT_ID"]-10; $sql = "SELECT u.user_id, u.user_name, u.comi_rate, COALESCE(SUM(t.AT_AMOUNT),0) as total_amount FROM `".$GLOBALS['arif_users']."` u LEFT JOIN `".$GLOBALS['arif_ac']."` a ON u.user_id = a.AA_AGENT LEFT JOIN `".$GLOBALS['arif_tran']."` t ON a.AA_ACNO = t.AT_ACID AND t.AT_TIMESTAMP BETWEEN '".$dateFrom." 00:00:00' AND '".$dateTo." 23:59:59' WHERE u.type = 'agent'";
echo "
<tr> // ---- if Agent self data filter ----
<td>".$row["AT_ID"]. "</td> if ($loginType === 'agent') {
<td>".$row["AT_TIMESTAMP"]. "</td> $sql .= " AND u.user_id = '".$loginId."'";
<td>".$row["AT_ACID"]. "</td> }
<td>".$row["AA_NAME"]. "</td>
<td>".$row["AT_AMOUNT"]. "</td> $sql .= " GROUP BY u.user_id, u.user_name, u.comi_rate ORDER BY u.user_name ASC";
<td>".$row["AT_AMOUNT"]/100*2.5 . "</td>
</tr>";$totalAmount+=$row["AT_AMOUNT"]; $result = $conn->query($sql);
}
} else { echo '
echo "0 results"; <div class="container mt-3">
} <div class="card shadow-sm rounded-3">
$conn->close(); <div class="card-body">
<div class="table-responsive">
echo ' <table class="table table-bordered table-hover align-middle">
</table> <thead class="table-light">
<hr> <h2> Total Transaction amount : '.$totalAmount.'</h2> <tr>
<hr> <h2> Total Commission amount : '.$totalAmount/100*2.5 .'</h2> <th>Agent ID</th>
</div> <th>Agent Name</th>
'; <th>Total Collection</th>
} <th>Total Commission</th>
</tr>
if(isset($_POST['tday']) && $_POST['tday']!="") report_view('day',$_POST['tday']); </thead>
if(isset($_POST['tmonth']) && $_POST['tmonth']!="") report_view('month',$_POST['tmonth']); <tbody>';
if(isset($_POST['dFrom']) && $_POST['dTo']!="") report_view($_POST['dTo'],$_POST['dFrom']);
$grandTotalCommission = 0;
//if(isset($_GET['Type']) && $_GET['Type']=="Loan") view_list_ac('Loan'); $grandTotalCollection = 0;
// if(isset($_GET['Type']) && $_GET['Type']=="Recurring") view_list_ac('Recurring');
// if(isset($_GET['Type']) && $_GET['Type']=="FD") view_list_ac('FD'); if ($result && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$collection = $row["total_amount"];
$commission = ($collection * $row["comi_rate"]) / 100;
$grandTotalCollection += $collection;
$grandTotalCommission += $commission;
echo "
<tr>
<td>".$row["user_id"]."</td>
<td>".$row["user_name"]."</td>
<td>".number_format($collection,2)."</td>
<td>".number_format($commission,2)."</td>
</tr>";
}
} else {
echo "<tr><td colspan='4' class='text-center text-muted'>No agents found</td></tr>";
}
echo '
</tbody>
</table>';
// ---- if admin/bm then show grand total ----
if ($loginType !== 'agent') {
echo '<h5 class="text-end">
Grand Total Collection : <b>'.number_format($grandTotalCollection,2).'</b><br>
Grand Total Commission : <b>'.number_format($grandTotalCommission,2).'</b>
</h5>';
}
echo '
</div>
</div>
</div>
';
$conn->close();
}
// ---- Call commission function ----
commission_report($dFrom, $dTo);
?> ?>

View File

@@ -1,10 +1,5 @@
<?php <?php
session_start(); session_start();
// Check if user is logged in and is admin
// if (!isset($_SESSION['type']) || $_SESSION['type'] !== 'admin') {
// header("Location: login.php");
// exit();
// }
// Database connection // Database connection
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']); $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
@@ -37,6 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user_phone = $_POST['user_phone']; $user_phone = $_POST['user_phone'];
$type = $_POST['type']; $type = $_POST['type'];
$user_id = $_POST['user_id']; $user_id = $_POST['user_id'];
$profilePicPath = $user['profile_pic']; // default old pic
// Validate inputs // Validate inputs
if (empty($user_name) || empty($user_phone) || empty($user_id)) { if (empty($user_name) || empty($user_phone) || empty($user_id)) {
@@ -44,29 +40,40 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} elseif (!preg_match("/^[0-9]{10}$/", $user_phone)) { } elseif (!preg_match("/^[0-9]{10}$/", $user_phone)) {
$error = "Invalid phone number format"; $error = "Invalid phone number format";
} else { } else {
// --- Handle Profile Picture Upload ---
if (isset($_FILES['profile_pic']) && $_FILES['profile_pic']['error'] === UPLOAD_ERR_OK) {
$uploadDir = __DIR__ . "/picture/";
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$fileTmp = $_FILES['profile_pic']['tmp_name'];
$fileName = time() . "_" . basename($_FILES['profile_pic']['name']);
$filePath = $uploadDir . $fileName;
if (move_uploaded_file($fileTmp, $filePath)) {
$profilePicPath = "/picture/" . $fileName;
// পুরনো ফাইল ডিলিট (যদি থাকে)
if (!empty($user['profile_pic']) && file_exists(__DIR__ . "/" . $user['profile_pic'])) {
unlink(__DIR__ . "/" . $user['profile_pic']);
}
}
}
// Update query // Update query
if (!empty($_POST['password'])) { if (!empty($_POST['password'])) {
// Update with password
$password = password_hash($_POST['password'], PASSWORD_DEFAULT); $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$sql = "UPDATE `".$GLOBALS['arif_users']."` SET $sql = "UPDATE `".$GLOBALS['arif_users']."`
user_id = ?, SET user_id = ?, user_name = ?, user_phone = ?, type = ?, password = ?, profile_pic = ?
user_name = ?,
user_phone = ?,
type = ?,
password = ?
WHERE id = ?"; WHERE id = ?";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->bind_param("sssssi", $user_id, $user_name, $user_phone, $type, $password, $id); $stmt->bind_param("ssssssi", $user_id, $user_name, $user_phone, $type, $password, $profilePicPath, $id);
} else { } else {
// Update without password $sql = "UPDATE `".$GLOBALS['arif_users']."`
$sql = "UPDATE `".$GLOBALS['arif_users']."` SET SET user_id = ?, user_name = ?, user_phone = ?, type = ?, profile_pic = ?
user_id = ?,
user_name = ?,
user_phone = ?,
type = ?
WHERE id = ?"; WHERE id = ?";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->bind_param("ssssi", $user_id, $user_name, $user_phone, $type, $id); $stmt->bind_param("sssssi", $user_id, $user_name, $user_phone, $type, $profilePicPath, $id);
} }
if ($stmt->execute()) { if ($stmt->execute()) {
@@ -99,7 +106,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<?php endif; ?> <?php endif; ?>
<?php if (!empty($user)): ?> <?php if (!empty($user)): ?>
<form method="post"> <form method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($user['id']); ?>"> <input type="hidden" name="id" value="<?php echo htmlspecialchars($user['id']); ?>">
<div class="row"> <div class="row">
@@ -114,6 +121,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<input type="text" class="form-control" id="user_name" name="user_name" <input type="text" class="form-control" id="user_name" name="user_name"
value="<?php echo htmlspecialchars($user['user_name']); ?>" required> value="<?php echo htmlspecialchars($user['user_name']); ?>" required>
</div> </div>
<div class="form-group mb-3">
<label for="profile_pic" class="form-label">Profile Picture</label><br>
<?php if (!empty($user['profile_pic'])): ?>
<img src="/CONTENT/ROOT_URI/Admin/<?php echo htmlspecialchars($user['profile_pic']); ?>" width="80" height="80" style="border-radius:50%; margin-bottom:10px;"><br>
<?php endif; ?>
<input type="file" class="form-control" id="profile_pic" name="profile_pic" accept="image/*">
</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@@ -133,21 +148,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</div> </div>
</div> </div>
<div class="row"> <div class="form-group mb-3">
<div class="col-md-12"> <label for="password" class="form-label">New Password (leave blank to keep current)</label>
<div class="form-group mb-3"> <input type="password" class="form-control" id="password" name="password">
<label for="password" class="form-label">New Password (leave blank to keep current)</label> <small class="text-muted">Password must be at least 8 characters long</small>
<input type="password" class="form-control" id="password" name="password">
<small class="text-muted">Password must be at least 8 characters long</small>
</div>
</div>
</div> </div>
<div class="row"> <div class="form-group mb-3">
<div class="col-md-12"> <button type="submit" class="btn btn-primary">Update User</button>
<button type="submit" class="btn btn-primary">Update User</button> <a href="/Admin/Settings_Agent" class="btn">Cancel</a>
<a href="/Admin/Settings_Agent" class="btn ">Cancel</a>
</div>
</div> </div>
</form> </form>
<?php else: ?> <?php else: ?>
@@ -165,19 +174,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
}); });
</script> </script>
<style> <style>
.badge-primary {
background-color: #007bff;
}
.badge-secondary {
background-color: #6c757d;
}
.badge-warning {
background-color: #ffc107;
}
.container { .container {
max-width: 800px; max-width: 800px;
margin-top: 30px; margin-top: 30px;
} }
img { border:1px solid #ccc; }
</style> </style>
<?php $conn->close(); ?> <?php $conn->close(); ?>

View File

@@ -27,6 +27,7 @@
$_SESSION['user_id'] = $user['user_id']; $_SESSION['user_id'] = $user['user_id'];
$_SESSION['type'] = $user['type']; $_SESSION['type'] = $user['type'];
$_SESSION['name'] = $user['user_name']; $_SESSION['name'] = $user['user_name'];
$_SESSION['profile_pic'] = $user['profile_pic'] ?? '';
echo "<div class='alert alert-success'>Login successful. Redirecting...</div>"; echo "<div class='alert alert-success'>Login successful. Redirecting...</div>";
echo "<script>setTimeout(() => { window.location.href = '/Admin/View_AC?Type=Loan'; }, 2000);</script>"; echo "<script>setTimeout(() => { window.location.href = '/Admin/View_AC?Type=Loan'; }, 2000);</script>";

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,119 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* table/insert/continue_insertion_form.twig */
class __TwigTemplate_904307a5a5f694a38d058a83a4fa8120 extends Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
// line 1
echo "<form id=\"continueForm\" method=\"post\" action=\"";
echo PhpMyAdmin\Url::getFromRoute("/table/replace");
echo "\" name=\"continueForm\">
";
// line 2
echo PhpMyAdmin\Url::getHiddenInputs(($context["db"] ?? null), ($context["table"] ?? null));
echo "
<input type=\"hidden\" name=\"goto\" value=\"";
// line 3
echo twig_escape_filter($this->env, ($context["goto"] ?? null), "html", null, true);
echo "\">
<input type=\"hidden\" name=\"err_url\" value=\"";
// line 4
echo twig_escape_filter($this->env, ($context["err_url"] ?? null), "html", null, true);
echo "\">
<input type=\"hidden\" name=\"sql_query\" value=\"";
// line 5
echo twig_escape_filter($this->env, ($context["sql_query"] ?? null), "html", null, true);
echo "\">
";
// line 7
if (($context["has_where_clause"] ?? null)) {
// line 8
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(($context["where_clause_array"] ?? null));
foreach ($context['_seq'] as $context["key_id"] => $context["where_clause"]) {
// line 9
echo " <input type=\"hidden\" name=\"where_clause[";
echo twig_escape_filter($this->env, $context["key_id"], "html", null, true);
echo "]\" value=\"";
// line 10
echo twig_escape_filter($this->env, twig_trim_filter($context["where_clause"]), "html", null, true);
echo "\">
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['key_id'], $context['where_clause'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 12
echo " ";
}
// line 13
echo "
";
// line 14
ob_start(function () { return ''; });
// line 15
echo " <input type=\"number\" name=\"insert_rows\" id=\"insert_rows\" value=\"";
// line 16
echo twig_escape_filter($this->env, ($context["insert_rows_default"] ?? null), "html", null, true);
echo "\" min=\"1\">
";
$context["insert_rows"] = ('' === $tmp = ob_get_clean()) ? '' : new Markup($tmp, $this->env->getCharset());
// line 18
echo " ";
echo twig_sprintf(_gettext("Continue insertion with %s rows"), ($context["insert_rows"] ?? null));
echo "
</form>
";
}
public function getTemplateName()
{
return "table/insert/continue_insertion_form.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 93 => 18, 88 => 16, 86 => 15, 84 => 14, 81 => 13, 78 => 12, 70 => 10, 66 => 9, 61 => 8, 59 => 7, 54 => 5, 50 => 4, 46 => 3, 42 => 2, 37 => 1,);
}
public function getSourceContext()
{
return new Source("", "table/insert/continue_insertion_form.twig", "/home/suvo/web/graffin.ns77.siliconpin.com/public_html/pma/templates/table/insert/continue_insertion_form.twig");
}
}