Files
calcserubi/admin/views/_tiers.php
T
2026-10-20 13:16:38 +09:00

44 lines
1.7 KiB
PHP

<?php
defined('SERUBI_ADMIN') || exit;
// Expects: $prefix (input name prefix), $rows (list of ['max' => str, 'rate' => str]), $tierId.
$last = count($rows) - 1;
?>
<div class="tier-editor" data-tiers="<?= e($tierId) ?>" data-prefix="<?= e($prefix) ?>">
<table class="tier-table">
<thead>
<tr>
<th scope="col">Nominal</th>
<th scope="col">Rate p.a.</th>
<th scope="col"><span class="visually-hidden">Hapus</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $i => $r): ?>
<tr class="tier-row">
<td data-label="Nominal">
<div class="tier-range">
<span class="tier-from"></span>
<div class="input-affix is-idr tier-max-wrap">
<span>Rp</span>
<input name="<?= e($prefix) ?>[<?= $i ?>][max]" class="t-max" value="<?= e($i === $last ? '' : ($r['max'] ?? '')) ?>"
inputmode="numeric" autocomplete="off" aria-label="Sampai dengan nominal, baris <?= $i + 1 ?>">
</div>
</div>
</td>
<td data-label="Rate p.a.">
<div class="input-affix tier-rate">
<input name="<?= e($prefix) ?>[<?= $i ?>][rate]" class="t-rate" value="<?= e($r['rate'] ?? '') ?>"
inputmode="decimal" autocomplete="off" aria-label="Rate persen per tahun, baris <?= $i + 1 ?>">
<span>%</span>
</div>
</td>
<td class="tier-del-cell">
<button type="button" class="icon-btn tier-del" aria-label="Hapus baris <?= $i + 1 ?>"><?= icon('trash') ?></button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button type="button" class="btn btn-ghost tier-add"><?= icon('plus') ?><span>Tambah tingkat</span></button>
</div>