58 lines
2.8 KiB
PHP
58 lines
2.8 KiB
PHP
<?php
|
|
defined('SERUBI_ADMIN') || exit;
|
|
$rows = settings_rows();
|
|
$byGroup = [];
|
|
foreach ($rows as $key => $row) {
|
|
$byGroup[$row['grp']][$key] = $row;
|
|
}
|
|
$unitSuffix = ['pct' => '%', 'idr' => null, 'days' => 'hari'];
|
|
?>
|
|
<form method="post" class="param-form" id="paramForm" data-kind="settings" novalidate>
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="action" value="save_settings">
|
|
<?php foreach (SERUBI_GROUPS as $grp => [$title, $desc]): if (empty($byGroup[$grp])) continue; ?>
|
|
<section class="panel">
|
|
<header class="panel-head"><h2><?= e($title) ?></h2><p><?= e($desc) ?></p></header>
|
|
<div class="setting-list">
|
|
<?php foreach ($byGroup[$grp] as $key => $row):
|
|
$val = $draft[$key] ?? fmt_setting($row);
|
|
$err = isset($errors["s.$key"]);
|
|
$id = 's-' . $key; ?>
|
|
<div class="setting<?= $err ? ' is-invalid' : '' ?>">
|
|
<div class="setting-text">
|
|
<label for="<?= e($id) ?>"><?= e($row['label']) ?></label>
|
|
<p id="<?= e($id) ?>-d"><?= e($row['description']) ?></p>
|
|
<?= field_error($errors, "s.$key") ?>
|
|
</div>
|
|
<div class="input-affix<?= $row['unit'] === 'idr' ? ' is-idr' : '' ?>">
|
|
<?php if ($row['unit'] === 'idr'): ?><span>Rp</span><?php endif; ?>
|
|
<input id="<?= e($id) ?>" name="s[<?= e($key) ?>]" value="<?= e($val) ?>" data-setting="<?= e($key) ?>" data-unit="<?= e($row['unit']) ?>"
|
|
inputmode="<?= $row['unit'] === 'idr' || $row['unit'] === 'days' ? 'numeric' : 'decimal' ?>" autocomplete="off"
|
|
aria-describedby="<?= e($id) ?>-d" <?= $err ? 'aria-invalid="true"' : '' ?>>
|
|
<?php if ($unitSuffix[$row['unit']] ?? null): ?><span><?= e($unitSuffix[$row['unit']]) ?></span><?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php endforeach; ?>
|
|
<div class="form-actions">
|
|
<button class="btn btn-primary" type="submit"><?= icon('save') ?><span>Simpan parameter</span></button>
|
|
</div>
|
|
</form>
|
|
|
|
<details class="panel panel-danger"<?= isset($errors['reset']) ? ' open' : '' ?>>
|
|
<summary><h2>Kembalikan ke nilai file Excel</h2><?= icon('chevron', 'icon chev') ?></summary>
|
|
<form method="post" class="danger-body">
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="action" value="reset_defaults">
|
|
<p>Semua parameter, rate produk, rate deposito, dan porsi cashback diganti dengan nilai dari <b>CALCULATOR CASHBACK SERUB KANTOR CABANG 22092026.xlsx</b>. Perubahan tercatat di riwayat.</p>
|
|
<div class="form-field">
|
|
<label for="confirmReset">Ketik <b>RESET</b> untuk konfirmasi</label>
|
|
<input id="confirmReset" name="confirm" autocomplete="off" autocapitalize="characters">
|
|
<?= field_error($errors, 'reset') ?>
|
|
</div>
|
|
<button class="btn btn-danger" type="submit"><?= icon('reset') ?><span>Kembalikan semua parameter</span></button>
|
|
</form>
|
|
</details>
|