<?php
if (!defined('APP_INIT')) {
    exit;
}

# IDE Section

# Includes Section
use api\classes\API;

require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php";
$API = new API();

function showCard($module_name, $page_name): void
{
    $page = $GLOBALS['pages'][$module_name][$page_name];
    ?>
    <div class="col">
        <a href="<?php echo $page['page_url'] ?>">
            <div class="card-pricing2 card-<?php echo $page['page_color'] ?> text-center h-100">
                <div class="pricing-header">
                    <h3 class="fw-bold mb-3 text-center"><?php echo __($page['page_name']) ?></h3>
                </div>
                <div class="price-value">
                    <div class="value ">
                        <span class="amount"><i class="text-<?php echo $page['page_color'] ?> <?php echo $page['page_icon'] ?> mt-4"></i><span></span></span>
                    </div>
                </div>
                <div class="mt-5">
                    <small>
                        <br>
                        <?php echo __($page['page_description']) ?>
                    </small>
                </div>
            </div>
        </a>
    </div>
<?php } ?>

<div class="row row-cols-1 row-cols-md-3 row-cols-sm-2 g-3">
    <?php
    if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RO', true)) {
        showCard('customers', 'companies');
    }

    if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RO', true)) {
        showCard('servers', 'server_overview');
    }

    if ($GLOBALS['modules_enabled']['office'] && $API->checkPermissions('office-stompjes', 'RO', true)) {
        showCard('office', 'stompjeslist');
        showCard('office', 'travelReimburse');
    }

    if ($GLOBALS['modules_enabled']['autop']) {
        showCard('autop', 'platforms');
        showCard('autop', 'vendors');
        showCard('autop', 'devices');
        showCard('autop', 'device_settings');
        showCard('autop', 'provisioning');
        showCard('autop', 'phonebooks');
    }

    if ($GLOBALS['modules_enabled']['portal-management']) {
        showCard('portal-management', 'access_control');
        showCard('portal-management', 'portal-management');
    }
    ?>
</div>
