<?php
$driver    = $driver ?? [];
$employees = $employees ?? [];
?>
<div class="enterprise-settings-fields">
    <div class="enterprise-field enterprise-field--full">
        <label class="enterprise-field-label">Employee <span class="text-danger">*</span></label>
        <select name="employee_id" class="form-select" required>
            <option value="">Select employee</option>
            <?php foreach ($employees as $e): ?>
                <option value="<?= (int) $e['id'] ?>"
                    <?= (string) old('employee_id', $driver['employee_id'] ?? '') === (string) $e['id'] ? 'selected' : '' ?>>
                    <?= esc($e['full_name']) ?> (<?= esc($e['employee_number']) ?>)
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">License Number <span class="text-danger">*</span></label>
        <input type="text" name="license_number" class="form-control" maxlength="80" required
               value="<?= esc(old('license_number', $driver['license_number'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">License Class</label>
        <input type="text" name="license_class" class="form-control" maxlength="20"
               value="<?= esc(old('license_class', $driver['license_class'] ?? '')) ?>"
               placeholder="e.g. B, C, D">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">License Expiry</label>
        <input type="date" name="license_expiry" class="form-control"
               value="<?= esc(old('license_expiry', $driver['license_expiry'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Phone</label>
        <input type="text" name="phone" class="form-control" maxlength="30"
               value="<?= esc(old('phone', $driver['phone'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Status</label>
        <select name="status" class="form-select">
            <?php foreach (['active', 'inactive', 'suspended'] as $s): ?>
                <option value="<?= $s ?>" <?= old('status', $driver['status'] ?? 'active') === $s ? 'selected' : '' ?>>
                    <?= esc(ucfirst($s)) ?>
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field enterprise-field--full">
        <label class="enterprise-field-label">Notes</label>
        <textarea name="notes" class="form-control" rows="3"><?= esc(old('notes', $driver['notes'] ?? '')) ?></textarea>
    </div>
</div>
