<?php $this->start('body'); ?>

<div class="d-flex align-items-center justify-content-between mb-3">
  <h5 class="mb-0 fw-semibold"><i class="fas fa-plus me-2 text-muted"></i>New Payroll Period</h5>
  <a href="<?= PROOT; ?>Payroll" class="btn btn-sm btn-outline-secondary"><i class="fas fa-arrow-left me-1"></i>Back</a>
</div>

<?= flashHtml(); ?>

<div class="alert alert-info small">
  <i class="fas fa-info-circle me-1"></i>
  Creates a draft payroll period for the selected month. After creation you'll <strong>Compute</strong> to generate records for every active driver (base salary + commission from closed trips + statutory), review, then <strong>Approve</strong> to post the accrual JE, and <strong>Pay</strong> when the transfers actually happen.
</div>

<form method="POST" action="<?= PROOT; ?>Payroll/save" class="card border-0 shadow-sm" autocomplete="off">
  <?= csrf_field(); ?>
  <div class="card-body">
    <div class="row g-3">
      <div class="col-md-4"><label class="form-label">Year <span class="text-danger">*</span></label>
        <select name="year" class="form-select" required>
          <?php $ty = (int)date('Y'); for ($y = $ty + 1; $y >= 2020; $y--): ?>
            <option value="<?= $y; ?>" <?= $y === $ty ? 'selected' : ''; ?>><?= $y; ?></option>
          <?php endfor; ?>
        </select></div>
      <div class="col-md-4"><label class="form-label">Month <span class="text-danger">*</span></label>
        <select name="month" class="form-select" required>
          <?php $tm = (int)date('n'); for ($m = 1; $m <= 12; $m++): ?>
            <option value="<?= $m; ?>" <?= $m === $tm ? 'selected' : ''; ?>><?= date('F', mktime(0, 0, 0, $m, 1)); ?></option>
          <?php endfor; ?>
        </select></div>
    </div>
  </div>
  <div class="card-footer bg-white d-flex justify-content-end gap-2 py-3">
    <a href="<?= PROOT; ?>Payroll" class="btn btn-outline-secondary">Cancel</a>
    <button class="btn btn-primary"><i class="fas fa-save me-1"></i>Create draft period</button>
  </div>
</form>

<?php $this->end(); ?>
