<?php /* Date-range picker used at the top of every FleetAnalytics view. */ ?>
<form method="GET" action="" class="d-flex gap-2 flex-wrap align-items-end">
  <?php $presets = ['this_month' => 'This month', 'last_month' => 'Last month', 'this_quarter' => 'This quarter', 'ytd' => 'YTD', 'last_12m' => 'Last 12 months', 'all_time' => 'All time']; ?>
  <div>
    <label class="form-label small text-muted mb-1">Preset</label>
    <select name="preset" class="form-select form-select-sm" onchange="this.form.from.value=''; this.form.to.value=''; this.form.submit();">
      <?php foreach ($presets as $k => $lab): ?>
        <option value="<?= $k; ?>" <?= ($preset ?? '') === $k ? 'selected' : ''; ?>><?= htmlspecialchars($lab); ?></option>
      <?php endforeach; ?>
    </select>
  </div>
  <div>
    <label class="form-label small text-muted mb-1">From</label>
    <input type="date" name="from" class="form-control form-control-sm" value="<?= htmlspecialchars($from ?? ''); ?>" style="width:160px;">
  </div>
  <div>
    <label class="form-label small text-muted mb-1">To</label>
    <input type="date" name="to" class="form-control form-control-sm" value="<?= htmlspecialchars($to ?? ''); ?>" style="width:160px;">
  </div>
  <div><button class="btn btn-sm btn-primary"><i class="fas fa-sync"></i></button></div>
</form>
