1) user invitation 2) app access control 3) txn quota guard
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
require_once __DIR__ . '/dbconn.php';
|
||||
require_once __DIR__ . '/assets/utils/classes/UsageGuard.php';
|
||||
|
||||
// Redirect to login if the user has not completed full authentication.
|
||||
// login_company_id is only written by login_confirm.php after OTP is verified —
|
||||
// using it (not "otp") ensures half-logged-in sessions are also redirected.
|
||||
@@ -47,6 +51,11 @@ if (empty($_SESSION['login_current_app'])) {
|
||||
|
||||
$topbar_show_wms = in_array($topbar_app_access, ['all', 'wms']);
|
||||
$topbar_show_accounting = in_array($topbar_app_access, ['all', 'accounting']);
|
||||
|
||||
$_usage = (new UsageGuard($pdo1, (int)$_SESSION['login_company_id'], $packages))->getStatus();
|
||||
$_usage_max_pct = max($_usage['daily_pct'], $_usage['weekly_pct']);
|
||||
$_usage_warn = $_usage_max_pct >= 80 && $_usage_max_pct < 100;
|
||||
$_usage_full = $_usage_max_pct >= 100;
|
||||
?>
|
||||
|
||||
<?php if (($_SESSION['login_current_app'] ?? 'wms') === 'accounting'): ?>
|
||||
@@ -183,6 +192,22 @@ $topbar_show_accounting = in_array($topbar_app_access, ['all', 'accounting']);
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Usage limit warning -->
|
||||
<?php if ($_usage_full || $_usage_warn): ?>
|
||||
<li>
|
||||
<span class="badge <?php echo $_usage_full ? 'bg-danger' : 'bg-warning text-dark'; ?> d-flex align-items-center gap-1 px-2 py-1"
|
||||
style="font-size:11px; cursor:default;"
|
||||
title="Daily: <?php echo $_usage['daily_count']; ?>/<?php echo $_usage['daily_limit'] ?: '∞'; ?> | Weekly: <?php echo $_usage['weekly_count']; ?>/<?php echo $_usage['weekly_limit'] ?: '∞'; ?>">
|
||||
<i class="ti <?php echo $_usage_full ? 'ti-circle-x' : 'ti-alert-triangle'; ?>"></i>
|
||||
<?php if ($_usage_full): ?>
|
||||
Limit reached — reports locked
|
||||
<?php else: ?>
|
||||
<?php echo $_usage_max_pct; ?>% usage
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- User dropdown -->
|
||||
<li class="ms-3 dropdown">
|
||||
<a class="position-relative btn-icon btn-sm btn-primary btn rounded-circle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
|
||||
Reference in New Issue
Block a user