<?= $this->extend('layouts/enterprise') ?>

<?= $this->section('styles') ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css">
<?= $this->endSection() ?>

<?= $this->section('content') ?>

<?= view('partials/workspace_hero', [
    'workspaceCrumbPill'    => 'Transport',
    'workspaceCrumbCurrent' => 'Edit Vehicle',
    'workspaceTitle'        => 'Edit Vehicle',
    'workspaceDesc'         => 'Update vehicle details, assignment, and location.',
]) ?>

<article class="enterprise-settings-card" style="max-width:860px;">
    <div class="enterprise-settings-card__head">
        <i class="fa-solid fa-pen"></i>
        <h2 class="enterprise-settings-card__title"><?= esc($vehicle['registration_number']) ?></h2>
    </div>

    <?= $this->include('Modules\Transport\Views\partials\form_errors') ?>

    <form action="<?= base_url('transport/vehicles/' . $vehicle['id']) ?>" method="post" novalidate>
        <?= csrf_field() ?>
        <?= $this->include('Modules\Transport\Views\vehicles\_form') ?>
        <div class="enterprise-settings-card__footer">
            <a href="<?= base_url('transport/vehicles/' . $vehicle['id']) ?>" class="btn btn-outline-secondary">Cancel</a>
            <button type="submit" class="btn btn-primary">Save Changes</button>
        </div>
    </form>
</article>

<?= $this->endSection() ?>

<?= $this->section('scripts') ?>
<?php if (($mapSettings['default_provider'] ?? 'openstreetmap') === 'google' && ! empty($mapSettings['google_api_key'])): ?>
    <script src="https://maps.googleapis.com/maps/api/js?key=<?= esc($mapSettings['google_api_key']) ?>"></script>
<?php else: ?>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
<?php endif; ?>
<script src="<?= base_url('assets/js/transport-map.js') ?>"></script>
<?= $this->endSection() ?>
