<?php
/**
 * Licence entries for the account dropdown.
 *
 * Included inside the IsAdmin() branch of every console navbar, so the four
 * navbars stay in step instead of drifting apart as they did before.
 *
 * Expects: $baseUrl
 */
$ppLicState = '';
try {
    if (\PpPhp\Core\Licensing\LicenseGate::enforced()) {
        $ppLicState = (string) (\PpPhp\Core\Licensing\LicenseGate::status()['status'] ?? '');
    }
} catch (\Throwable $e) {
    $ppLicState = '';
}
?>
<li><a class="dropdown-item" href="<?= $baseUrl ?>/licensing" data-tip="View and manage this installation’s licence &amp; activation">
    <i class="bi bi-shield-check me-2"></i>Licence
    <?php if ($ppLicState === 'grace'): ?>
        <span class="badge bg-warning text-dark ms-1" style="font-size:.65rem">action needed</span>
    <?php elseif ($ppLicState !== '' && $ppLicState !== 'ok'): ?>
        <span class="badge bg-danger ms-1" style="font-size:.65rem">inactive</span>
    <?php endif; ?>
</a></li>
<?php
/* The licence-server console only exists in the SERVER edition — a client
   bundle ships without those files and without their routes, so the link is
   gated on the class actually being present, not just on the role. */
if (\PpPhp\Core\Security::IsOwner()
    && class_exists(\PpPhp\Modules\Licensing\Controllers\LicenseServerController::class)): ?>
    <li><a class="dropdown-item" href="<?= $baseUrl ?>/licensing/server" data-tip="Owner’s licence-server console: issue &amp; manage customer licences">
        <i class="bi bi-key me-2"></i>Licence server
    </a></li>
<?php endif; ?>
