<?php
$recon        = $recon ?? [];
$bankAccounts = $bankAccounts ?? [];
$includeBank  = $includeBank ?? true;
?>
<div class="enterprise-settings-fields">
    <?php if ($includeBank): ?>
        <div class="enterprise-field">
            <label class="enterprise-field-label">Bank Account <span class="text-danger">*</span></label>
            <select name="bank_account_id" class="form-select" required>
                <option value="">— Select —</option>
                <?php foreach ($bankAccounts as $a): ?>
                    <option value="<?= $a['id'] ?>" <?= (string) old('bank_account_id', $recon['bank_account_id'] ?? '') === (string) $a['id'] ? 'selected' : '' ?>>
                        <?= esc($a['code']) ?> · <?= esc($a['name']) ?>
                    </option>
                <?php endforeach; ?>
            </select>
        </div>
    <?php endif; ?>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Statement Date <span class="text-danger">*</span></label>
        <input type="date" name="statement_date" class="form-control" required
               value="<?= esc(old('statement_date', $recon['statement_date'] ?? date('Y-m-d'))) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Statement Ending Balance <span class="text-danger">*</span></label>
        <input type="number" name="statement_ending_balance" class="form-control" step="0.01" required
               value="<?= esc(old('statement_ending_balance', $recon['statement_ending_balance'] ?? '')) ?>">
    </div>
    <div class="enterprise-field" style="grid-column: 1 / -1;">
        <label class="enterprise-field-label">Notes</label>
        <textarea name="notes" class="form-control" rows="3"><?= esc(old('notes', $recon['notes'] ?? '')) ?></textarea>
    </div>
</div>
