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

53 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
defined('SERUBI_ADMIN') || exit;
if ($draft !== null) {
$cbRows = array_values($draft['cb'] ?? []);
$cbTenors = $draft['cbtenor'] ?? [];
} else {
$cbRows = array_map(fn($t) => ['min' => fmt_idr($t['min']), 'share' => fmt_pct($t['nasabah'])], $params['cashbackTiers']);
$cbTenors = $params['cashbackTenors'];
}
?>
<form method="post" id="paramForm" data-kind="cashback" novalidate>
<?= csrf_field() ?>
<input type="hidden" name="action" value="save_cashback">
<section class="panel">
<header class="panel-head"><h2>Jangka waktu program</h2><p>Hanya jangka waktu yang dicentang yang mendapat cashback.</p></header>
<div class="check-row">
<?php foreach ($params['tenors'] as $t): ?>
<label class="check">
<input type="checkbox" name="cbtenor[<?= (int)$t ?>]" value="1" data-cbtenor="<?= (int)$t ?>" <?= in_array($t, $cbTenors, true) ? 'checked' : '' ?>>
<span><?= (int)$t ?> bulan</span>
</label>
<?php endforeach; ?>
</div>
</section>
<section class="panel">
<header class="panel-head"><h2>Porsi spread untuk nasabah</h2><p>Tingkat dengan nominal minimal tertinggi yang tercapai yang dipakai. Porsi bank = 100% − porsi nasabah. Nominal di bawah tingkat terendah tidak mendapat cashback.</p></header>
<?= field_error($errors, 'cb') ?>
<table class="tier-table cb-table" id="cbTable">
<thead><tr><th scope="col">Nominal minimal</th><th scope="col">Porsi nasabah</th><th scope="col">Porsi bank</th><th scope="col"><span class="visually-hidden">Hapus</span></th></tr></thead>
<tbody>
<?php foreach ($cbRows as $i => $r): ?>
<tr class="cb-row">
<td data-label="Nominal minimal">
<div class="input-affix is-idr"><span>Rp</span><input name="cb[<?= $i ?>][min]" class="cb-min" value="<?= e($r['min'] ?? '') ?>" inputmode="numeric" autocomplete="off" aria-label="Nominal minimal, baris <?= $i + 1 ?>"></div>
</td>
<td data-label="Porsi nasabah">
<div class="input-affix tier-rate"><input name="cb[<?= $i ?>][share]" class="cb-share" value="<?= e($r['share'] ?? '') ?>" inputmode="decimal" autocomplete="off" aria-label="Porsi nasabah persen, baris <?= $i + 1 ?>"><span>%</span></div>
</td>
<td data-label="Porsi bank" class="cb-bank">—</td>
<td class="tier-del-cell"><button type="button" class="icon-btn cb-del" aria-label="Hapus baris <?= $i + 1 ?>"><?= icon('trash') ?></button></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button type="button" class="btn btn-ghost cb-add"><?= icon('plus') ?><span>Tambah tingkat</span></button>
</section>
<div class="form-actions">
<button class="btn btn-primary" type="submit"><?= icon('save') ?><span>Simpan porsi cashback</span></button>
</div>
</form>