implement JS password scoring, td_stock approve logicc

This commit is contained in:
Thanakorn S
2026-04-30 15:14:42 +07:00
parent db5c47b6ca
commit ac4fd9a5ad
3147 changed files with 1298 additions and 343 deletions
+91 -63
View File
@@ -7,6 +7,13 @@ if(!isset($_SESSION["otp"])){
require 'preset.php';
// ── User display data from session ────────────────────────────────────────────
$topbar_name = htmlspecialchars(trim(($_SESSION['login_name'] ?? '') . ' ' . ($_SESSION['login_surname'] ?? '')), ENT_QUOTES, 'UTF-8');
$topbar_username = htmlspecialchars($_SESSION['login_username'] ?? '', ENT_QUOTES, 'UTF-8');
$topbar_picture = $_SESSION['login_profile_picture'] ?? '';
$topbar_avatar_src = $topbar_picture
? htmlspecialchars($server_url . 'uploads/profile/' . $topbar_picture, ENT_QUOTES, 'UTF-8')
: htmlspecialchars($server_url . 'assets/images/avatar-1.jpg', ENT_QUOTES, 'UTF-8');
?>
<div id="overlay" class="overlay"></div>
@@ -17,6 +24,23 @@ require 'preset.php';
data-otp="<?php echo htmlspecialchars($_SESSION['otp'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
</div>
<!-- Switch Branch Modal -->
<div class="modal fade" id="switchBranchModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" style="max-width: 360px;">
<div class="modal-content">
<div class="modal-header border-dashed">
<h6 class="modal-title mb-0"><i class="ti ti-building me-2"></i>Switch Branch</h6>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body p-0">
<div id="branch_list" class="d-flex flex-column">
<div class="text-center text-muted small py-4">Loading...</div>
</div>
</div>
</div>
</div>
</div>
<!-- TOPBAR -->
<nav id="topbar" class="navbar bg-white border-bottom fixed-top topbar px-3">
<button id="toggleBtn" class="d-none d-lg-inline-flex btn btn-light btn-icon btn-sm ">
@@ -30,7 +54,6 @@ require 'preset.php';
<div>
<!-- Navbar nav -->
<ul class="list-unstyled d-flex align-items-center mb-0 gap-1">
<!-- Pages link -->
<!-- Bell icon -->
<li>
@@ -43,85 +66,41 @@ require 'preset.php';
<path d="M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6" />
<path d="M9 17v1a3 3 0 0 0 6 0v-1" />
</svg>
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger mt-2 ms-n2">
2
<span class="visually-hidden">unread messages</span>
</span>
</a>
<div class="dropdown-menu dropdown-menu-end dropdown-menu-md p-0">
<ul class="list-unstyled p-0 m-0">
<li class="p-3 border-bottom ">
<div class="d-flex gap-3">
<img src="<?php echo $server_url?>assets/images/avatar-1.jpg" alt=""
class="avatar avatar-sm rounded-circle" />
<div class="flex-grow-1 small">
<p class="mb-0">New order received</p>
<p class="mb-1">Order #12345 has been placed</p>
<div class="text-secondary">5 minutes ago</div>
</div>
</div>
</li>
<li class="p-3 border-bottom ">
<div class="d-flex gap-3">
<img src="<?php echo $server_url?>assets/images/avatar-4.jpg" alt=""
class="avatar avatar-sm rounded-circle" />
<div class="flex-grow-1 small">
<p class="mb-0">New user registered</p>
<p class="mb-1">User @john_doe has signed up</p>
<div class="text-secondary">30 minutes ago</div>
</div>
</li>
<li class="p-3 border-bottom">
<div class="d-flex gap-3">
<img src="<?php echo $server_url?>assets/images/avatar-2.jpg" alt=""
class="avatar avatar-sm rounded-circle" />
<div class="flex-grow-1 small">
<p class="mb-0">Payment confirmed</p>
<p class="mb-1">Payment of $299 has been received</p>
<div class="text-secondary">1 hour ago</div>
</div>
</div>
</li>
<li class="px-4 py-3 text-center">
<a href="#" class="text-primary ">View all notifications</a>
</li>
<li class="px-4 py-3 text-center text-muted small">No notifications</li>
</ul>
</div>
</li>
<!-- Dropdown -->
<!-- User dropdown -->
<li class="ms-3 dropdown">
<a href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<img src="<?php echo $server_url?>assets/images/avatar-1.jpg" alt=""
<img src="<?php echo $topbar_avatar_src; ?>" alt=""
class="avatar avatar-sm rounded-circle" />
</a>
<div class="dropdown-menu dropdown-menu-end p-0" style="min-width: 200px;">
<div>
<div class="d-flex gap-3 align-items-center border-dashed border-bottom px-3 py-3">
<img src="<?php echo $server_url?>assets/images/avatar-1.jpg" alt=""
<img src="<?php echo $topbar_avatar_src; ?>" alt=""
class="avatar avatar-md rounded-circle" />
<div>
<h4 class="mb-0 small">Shrina Tesla</h4>
<p class="mb-0 small">@imshrina</p>
<h4 class="mb-0 small"><?php echo $topbar_name; ?></h4>
<p class="mb-0 small">@<?php echo $topbar_username; ?></p>
</div>
</div>
<div class="p-3 d-flex flex-column gap-1 small lh-lg">
<a href="javascript" class="" onclick="switch_branch();">
<a href="javascript:;" onclick="switch_branch();">
<span>Switch Branch</span>
</a>
<a href="<?php echo $server_url?>setting/profile.php" class="">
<span> Setting</span>
<a href="<?php echo $server_url?>setting/profile.php">
<span>Setting</span>
</a>
<a href="javascript:;" class="" onclick="log_out();">
<span> Log Out</span>
<a href="javascript:;" onclick="log_out();">
<span>Log Out</span>
</a>
</div>
</div>
</div>
</li>
@@ -136,22 +115,71 @@ require 'preset.php';
var server_url = '<?php echo $server_url; ?>';
var prop_limit = '<?php echo $prop['limit']; ?>';
// log_out function
// ── Log out ───────────────────────────────────────────────────────────────────
function log_out() {
return ajax_request({
url: "<?php echo $server_url?>login/api/engine/back.php",
url: server_url + 'login/api/engine/back.php',
autoPrepare: true,
checkRequired: 0,
action: 'read',
onSuccess: function(res) {
window.location.href = server_url + 'index.php';
}
});
}
// ── Switch Branch ─────────────────────────────────────────────────────────────
function switch_branch() {
$('#switchBranchModal').modal('show');
ajax_request({
url: server_url + 'setting/api/engine/switch_branch.php',
autoPrepare: true,
checkRequired: 0,
action: 'read',
onSuccess: function(res) {
window.location.href = "<?php echo $server_url?>index.php";
var current = res.current;
var companies = res.output || [];
if (companies.length <= 1) {
$('#branch_list').html(
'<div class="text-center text-muted small py-4">You only belong to one branch.</div>'
);
return;
}
var html = '';
companies.forEach(function(c) {
var is_active = c.company_id == current;
html += '<a href="javascript:;" class="d-flex align-items-center gap-3 px-3 py-2 border-bottom ' +
(is_active ? 'bg-light' : '') + '" onclick="do_switch_branch(' + c.company_id + ')">' +
'<span class="d-flex align-items-center justify-content-center rounded-circle bg-label-primary flex-shrink-0" style="width:36px;height:36px;">' +
'<i class="ti ti-building small"></i></span>' +
'<div class="flex-grow-1 overflow-hidden">' +
'<p class="mb-0 small fw-semibold text-truncate">' + $('<span>').text(c.company_name).html() + '</p>' +
'<p class="mb-0 x-small text-muted">' + $('<span>').text(c.branch || c.role).html() + '</p>' +
'</div>' +
(is_active ? '<i class="ti ti-check text-success ms-auto"></i>' : '') +
'</a>';
});
$('#branch_list').html(html);
}
});
}
function do_switch_branch(company_id) {
ajax_request({
url: server_url + 'setting/api/engine/switch_branch.php',
autoPrepare: true,
checkRequired: 0,
action: 'update',
company_id: company_id,
onSuccess: function(res) {
window.location.reload();
}
});
}
</script>