Autosave: 20260219-182758
This commit is contained in:
parent
bcb2b82800
commit
1ce3baa5a2
74
index.php
74
index.php
@ -1655,6 +1655,7 @@ $page_permissions = [
|
||||
'logs' => 'users_view',
|
||||
'cash_registers' => 'users_view',
|
||||
'register_sessions' => 'pos_view',
|
||||
'licenses' => 'users_view',
|
||||
];
|
||||
|
||||
if (isset($page_permissions[$page]) && !can($page_permissions[$page])) {
|
||||
@ -2304,6 +2305,11 @@ switch ($page) {
|
||||
$data['cash_registers'] = db()->query("SELECT * FROM cash_registers WHERE status = 'active'")->fetchAll();
|
||||
$data['users'] = db()->query("SELECT id, username FROM users ORDER BY username ASC")->fetchAll();
|
||||
break;
|
||||
case 'licenses':
|
||||
$res = LicenseService::listLicenses();
|
||||
$data['licenses'] = $res['success'] ? $res['data'] : [];
|
||||
$data['license_error'] = $res['success'] ? '' : ($res['error'] ?? 'Failed to fetch licenses.');
|
||||
break;
|
||||
default:
|
||||
$data['customers'] = db()->query("SELECT * FROM customers WHERE type = 'customer' ORDER BY id DESC LIMIT 5")->fetchAll();
|
||||
// Dashboard stats
|
||||
@ -2616,6 +2622,9 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
|
||||
<a href="index.php?page=backups" class="nav-link <?= $page === 'backups' ? 'active' : '' ?>">
|
||||
<i class="fas fa-database"></i> <span><?= __('backups') ?></span>
|
||||
</a>
|
||||
<a href="index.php?page=licenses" class="nav-link <?= $page === 'licenses' ? 'active' : '' ?>">
|
||||
<i class="fas fa-key"></i> <span><?= $lang === 'ar' ? 'إدارة التراخيص' : 'Manage Licenses' ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -7151,6 +7160,71 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($page === 'licenses'): ?>
|
||||
<div class="card border-0 shadow-sm rounded-4">
|
||||
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center border-0">
|
||||
<div>
|
||||
<h5 class="m-0 fw-bold text-primary" data-en="Manage Licenses" data-ar="إدارة التراخيص">Manage Licenses</h5>
|
||||
<p class="text-muted small mb-0" data-en="View and search license keys activated on your system" data-ar="عرض والبحث في مفاتيح التراخيص المفعلة في نظامك">View and search license keys activated on your system</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button onclick="location.reload()" class="btn btn-light btn-sm rounded-pill px-3">
|
||||
<i class="bi bi-arrow-clockwise"></i> <span data-en="Refresh" data-ar="تحديث">Refresh</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if (!empty($data['license_error'])): ?>
|
||||
<div class="alert alert-danger border-0 rounded-3">
|
||||
<i class="bi bi-exclamation-circle me-2"></i>
|
||||
<?= htmlspecialchars($data['license_error']) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0" id="licensesTable">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th data-en="ID" data-ar="المعرف">ID</th>
|
||||
<th data-en="License Key" data-ar="مفتاح الترخيص">License Key</th>
|
||||
<th data-en="Max Activations" data-ar="أقصى تفعيل">Max</th>
|
||||
<th data-en="Current Activations" data-ar="التفعيلات الحالية">Used</th>
|
||||
<th data-en="Status" data-ar="الحالة">Status</th>
|
||||
<th data-en="Created At" data-ar="تاريخ الإنشاء">Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($data['licenses'])): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-key fs-1 d-block mb-3 opacity-25"></i>
|
||||
<span data-en="No license data found on the server." data-ar="لم يتم العثور على بيانات ترخيص على السيرفر.">No license data found on the server.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($data['licenses'] as $l): ?>
|
||||
<tr>
|
||||
<td><span class="badge bg-light text-dark border">#<?= $l['id'] ?></span></td>
|
||||
<td><code class="fw-bold text-primary"><?= htmlspecialchars($l['license_key']) ?></code></td>
|
||||
<td><span class="badge bg-secondary"><?= (int)$l['max_activations'] ?></span></td>
|
||||
<td><span class="badge bg-<?= $l['activations_count'] >= $l['max_activations'] ? 'danger' : 'info' ?>"><?= (int)$l['activations_count'] ?></span></td>
|
||||
<td>
|
||||
<?php if ($l['is_active']): ?>
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle rounded-pill">Active</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle rounded-pill">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="small text-muted"><?= htmlspecialchars($l['created_at']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($page === 'users'): ?>
|
||||
<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
|
||||
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center border-0">
|
||||
|
||||
@ -137,6 +137,13 @@ class LicenseService {
|
||||
return ['success' => true];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all licenses from the remote server.
|
||||
*/
|
||||
public static function listLicenses() {
|
||||
return self::callRemoteApi('/list', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote API Caller
|
||||
*/
|
||||
|
||||
@ -109,3 +109,5 @@
|
||||
2026-02-19 18:07:51 - POST: {"license_key":"FLAT-TEST-1234-5678","activate":""}
|
||||
2026-02-19 18:08:00 - POST: {"license_key":"FLAT-TEST-1234-5678","activate":""}
|
||||
2026-02-19 18:08:08 - POST: {"license_key":"FLAT-TEST-1234-5678","activate":""}
|
||||
2026-02-19 18:15:44 - POST: {"license_key":"FLAT-5FDB-C2BB","activate":""}
|
||||
2026-02-19 18:26:28 - POST: {"license_key":"FLAT-5FDB-C2BB","activate":""}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user