<?php require('template/header.phtml') ?>
    <div class="row">
        <div class="col-5">
            <p><?php echo $view->dbMessage; ?></p>
        </div>
        <div class="col-auto">
            <p>Current script <?php echo $_SERVER["PHP_SELF"]; ?></p>
        </div>
    </div>

    <div class="row">
        <div class="container-fluid p-3">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Facility ID</th>
                        <th>Title</th>
                        <th>Category</th>
                        <th>Status</th>
                        <th>Description</th>
                        <th>Address</th>
                        <th>Postcode</th>
                        <th>Lat/Long</th>
                        <th>Contributor</th>
                        <?php if($view->user->getAccessLevel() == 1): ?>
                        <th>Actions</th>
                        <?php endif; ?>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($view->pageData   as $facilityData): ?>
                    <tr>
                        <td><?= htmlspecialchars($facilityData->getId() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars($facilityData->getTitle() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars($facilityData->getCategory() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars($facilityData->getStatus() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars($facilityData->getDescription() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars(trim(($facilityData->getHouseNumber() ?? '') . ' ' .
                                ($facilityData->getStreetName() ?? '') . ' ' .
                                ($facilityData->getCounty() ?? '') . ' ' .
                                ($facilityData->getTown() ?? ''))) ?></td>
                        <td><?= htmlspecialchars($facilityData->getPostcode() ?? 'N/A') ?></td>
                        <td><?= htmlspecialchars(($facilityData->getLat() ?? 'N/A') . ', ' .
                                ($facilityData->getLng() ?? 'N/A')) ?></td>
                        <td><?= htmlspecialchars($facilityData->getContributor() ?? 'N/A') ?></td>
                        <?php if($view->user->getAccessLevel() == 1): ?>
                            <td class="btn-group">
                                <?php require("template/updateModal.phtml") ?>
                                <?php require("template/deleteModal.phtml") ?>
                            </td>
                        <?php endif; ?>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>


<?php require('template/footer.phtml') ?>

