28 lines
1.3 KiB
PHP
28 lines
1.3 KiB
PHP
<?php
|
|
defined('SERUBI_ADMIN') || exit;
|
|
// Rows as display strings: from the failed POST, or from the database.
|
|
$tierRows = [];
|
|
foreach (SERUBI_PRODUCTS as $key => $label) {
|
|
if ($draft !== null) {
|
|
$tierRows[$key] = array_values((array)($draft[$key] ?? []));
|
|
} else {
|
|
$tierRows[$key] = array_map(fn($t) => ['max' => fmt_idr($t['max']), 'rate' => fmt_pct($t['rate'])], $params['productRates'][$key]);
|
|
}
|
|
}
|
|
?>
|
|
<form method="post" id="paramForm" data-kind="products" novalidate>
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="action" value="save_products">
|
|
<p class="hint-block"><?= icon('info') ?><span>Tingkat dibaca dari atas: nominal sampai dengan batas pertama memakai rate pertama, dan seterusnya. Baris terakhir berlaku untuk semua nominal di atasnya.</span></p>
|
|
<?php foreach (SERUBI_PRODUCTS as $key => $label): ?>
|
|
<section class="panel">
|
|
<header class="panel-head"><h2><?= e($label) ?></h2></header>
|
|
<?= field_error($errors, "tiers.$key") ?>
|
|
<?php $prefix = "tiers[$key]"; $rows = $tierRows[$key]; $tierId = $key; require __DIR__ . '/_tiers.php'; ?>
|
|
</section>
|
|
<?php endforeach; ?>
|
|
<div class="form-actions">
|
|
<button class="btn btn-primary" type="submit"><?= icon('save') ?><span>Simpan rate produk</span></button>
|
|
</div>
|
|
</form>
|