<?php
$rootConfig = dirname(__DIR__, 2) . '/config.php';
if (file_exists($rootConfig)) {
    require_once($rootConfig);
}

$view = $_REQUEST['view'] ?? 'checklists';
$allowedViews = ['checklists', 'templates', 'assessment'];
if (!in_array($view, $allowedViews, true)) {
    $view = 'checklists';
}
?>
<script>
document.getElementById('navBox').innerHTML =
    '<li class="breadcrumb-item active">PUWER Configuration</li>';
</script>

<div class="container-fluid">
    <div class="row mb-3">
        <div class="col-12">
            <h2 class="mb-3">PUWER Configuration</h2>
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link <?= $view === 'checklists' ? 'active' : '' ?>"
                       href="index.php?t=includes/master&p=puwer_config.php&view=checklists">Checklist Library</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?= $view === 'templates' ? 'active' : '' ?>"
                       href="index.php?t=includes/master&p=puwer_config.php&view=templates">Template Links</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?= $view === 'assessment' ? 'active' : '' ?>"
                       href="index.php?t=includes/master&p=puwer_config.php&view=assessment">Assessment Defaults</a>
                </li>
            </ul>
        </div>
    </div>

    <?php
    switch ($view) {
        case 'templates':
            require_once(ROOT_URL . '/includes/puwer/puwer_templates.php');
            break;

        case 'assessment':
            require_once(ROOT_URL . '/includes/puwer/puwer_assessment.php');
            break;

        case 'checklists':
        default:
            require_once(ROOT_URL . '/includes/puwer/puwer_checklists.php');
            break;
    }
    ?>
</div>