Update Voucher , Tiket , Dashboard
membuat perubahan dan update
This commit is contained in:
+286
-111
@@ -41,17 +41,28 @@
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Radius Server</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="radiuscek" value="1" id="checkbox1-0">
|
||||
<label class="form-check-label" for="checkbox1">
|
||||
Menggunakan Radius
|
||||
</label>
|
||||
</div>
|
||||
<i class="text-danger"><small>Saat ini radius hanya digunakan untuk Autentikasi saja, untuk limit masih di sisi mikrotik</small></i>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Jenis Profile</label>
|
||||
<select class="form-control" name="jenis" data-select="jenis-select1" required>
|
||||
<option value="">Pilih</option>
|
||||
<option value="PPPOE">PPPOE</option>
|
||||
<option value="Hotspot">Hotspot</option>
|
||||
<option value="DHCP" id="group-dhcp">DHCP IP Address</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" id="group-jenis0">
|
||||
<label>Nama Profile Di Mikrotik</label>
|
||||
<input type="text" class="form-control" name="profile" required>
|
||||
<input type="text" class="form-control" name="profile">
|
||||
<i class="text-danger"><small>Nama Profile Harus sama dengan yang ada di Mikrotik</small></i>
|
||||
</div>
|
||||
<div class="form-group" id="group-jenis1">
|
||||
@@ -85,6 +96,26 @@
|
||||
<input type="text" class="form-control" name="durasi" placeholder="6H" id="durasi">
|
||||
<i class="text-danger">Contoh : 3H => 3 Jam , 1D => 1 Hari </i>
|
||||
</div>
|
||||
<div class="form-group" id="group-use">
|
||||
<label>Limit Pengguna / Device</label>
|
||||
<input type="text" class="form-control" name="use_limit">
|
||||
</div>
|
||||
<div class="form-group" id="group-pool">
|
||||
<label>IP Pool</label>
|
||||
<input type="text" class="form-control" name="ip_pool">
|
||||
</div>
|
||||
<div class="form-group" id="group-rate">
|
||||
<label>Rate Limit</label>
|
||||
<input type="text" class="form-control" name="rate_limit" placeholder="( Opsional )">
|
||||
</div>
|
||||
<div class="form-group" id="group-session">
|
||||
<label>Session Timeout</label>
|
||||
<input type="text" class="form-control" name="session_time" placeholder="( Opsional )">
|
||||
</div>
|
||||
<div class="form-group" id="group-idle">
|
||||
<label>Idle Timeout</label>
|
||||
<input type="text" class="form-control" name="idle_time" placeholder="( Opsional )">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,118 +125,213 @@
|
||||
<input type="submit" name="tambah" class="btn btn-primary" value="Tambah">
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
if (isset($_POST['tambah'])) {
|
||||
try {
|
||||
// Ambil dan sanitasi data dari form
|
||||
$status = ($_POST['jenishs'] == 1) ? 1 : NULL;
|
||||
$nominal = preg_replace("/[^0-9]/", "", $_POST['harga']);
|
||||
$cekfee = preg_replace("/[^0-9]/", "", $_POST['fee']);
|
||||
$fee = (!empty($cekfee)) ? $cekfee : NULL;
|
||||
// === VALIDASI INPUT USER ===
|
||||
$requiredFields = ['ids', 'jenis', 'nama', 'harga'];
|
||||
foreach ($requiredFields as $field) {
|
||||
if (empty($_POST[$field])) {
|
||||
sweetAlert("Field " . $field. " tidak boleh kosong!", "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Ambil server dari database
|
||||
// === SANITASI DAN INISIALISASI ===
|
||||
$status = ($_POST['jenishs'] == 1) ? 1 : NULL;
|
||||
$nominal = preg_replace("/[^0-9]/", "", $_POST['harga']);
|
||||
$cekfee = preg_replace("/[^0-9]/", "", $_POST['fee']);
|
||||
$fee = (!empty($cekfee)) ? $cekfee : NULL;
|
||||
|
||||
$groupname = preg_replace(
|
||||
'/\s+/',
|
||||
'-',
|
||||
strtolower(trim(preg_replace('/[^a-z0-9 ]/i', '', $_POST['jenis'] . ' ' .$_POST['nama'])))
|
||||
) . '-' . $SvId;
|
||||
|
||||
$profile = $_POST['profile'] ?? '';
|
||||
$use_limit = $_POST['use_limit'] ?? '';
|
||||
$rate_limit = $_POST['rate_limit'] ?? '';
|
||||
$session_time = $_POST['session_time'] ?? '';
|
||||
$ip_pool = $_POST['ip_pool'] ?? '';
|
||||
$idle_time = $_POST['idle_time'] ?? '';
|
||||
|
||||
// === TRANSAKSI DATABASE UNTUK ROLLBACK JIKA GAGAL ===
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Ambil semua server
|
||||
$stmt = $pdo->prepare("SELECT * FROM setting_mikrotik WHERE id_data_server = :id_data_server");
|
||||
$stmt->execute([':id_data_server' => $_POST['ids']]);
|
||||
$servers = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$messages = []; // Array untuk menyimpan pesan
|
||||
$rollbackServers = [];
|
||||
$messages = []; // pesan error
|
||||
|
||||
// === RADIUS PROCESS ===
|
||||
if (!empty($_POST['radiuscek']) && $_POST['radiuscek'] == 1) {
|
||||
$radius = new CrudRadiusServer();
|
||||
|
||||
$radiusPayload = [
|
||||
'jenis' => $_POST['jenis'],
|
||||
'groupname' => $groupname,
|
||||
'profile' => $profile,
|
||||
'use_limit' => $use_limit,
|
||||
'rate_limit' => $rate_limit,
|
||||
'session_time' => $session_time,
|
||||
'ip_pool' => $ip_pool,
|
||||
'idle_time' => $idle_time
|
||||
];
|
||||
|
||||
$radius->request('add_paket', 'POST', $radiusPayload);
|
||||
$radius_data = json_encode($radiusPayload);
|
||||
} else {
|
||||
$radius_data = '';
|
||||
}
|
||||
|
||||
// === LOOPING SERVER MIKROTIK ===
|
||||
foreach ($servers as $server) {
|
||||
$mikrotikName = $server['nama'];
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Koneksi ke MikroTik
|
||||
if ($API->connect2($server['ip_address'], $server['username'], $server['password'], $server['port_api'])) {
|
||||
$profileName = $_POST['profile'];
|
||||
if ($API->connect2(
|
||||
$server['ip_address'],
|
||||
$server['username'],
|
||||
$server['password'],
|
||||
$server['port_api']
|
||||
)) {
|
||||
$profileName = $_POST['profile'] ?? '';
|
||||
$ipPool = $_POST['ip_pool'] ?? '';
|
||||
$profileFound = false;
|
||||
$poolFound = false;
|
||||
|
||||
// === CEK PROFILE ===
|
||||
if ($_POST['jenis'] == 'PPPOE') {
|
||||
// Cek profil PPPOE
|
||||
$profiles = $API->comm('/ppp/profile/print');
|
||||
$found = false;
|
||||
} elseif ($_POST['jenis'] == 'Hotspot') {
|
||||
$profiles = $API->comm('/ip/hotspot/user/profile/print');
|
||||
}
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
if ($profile['name'] === $profileName) {
|
||||
$found = true;
|
||||
if (!empty($profiles)) {
|
||||
foreach ($profiles as $p) {
|
||||
if ($p['name'] === $profileName) {
|
||||
$profileFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$messages[] = "Profil PPPOE <b>$profileName</b> di <b>$mikrotikName</b> tidak ada.";
|
||||
}
|
||||
} else {
|
||||
// Cek profil Hotspot
|
||||
$profiles = $API->comm('/ip/hotspot/user/profile/print');
|
||||
$found = false;
|
||||
$profileId = null;
|
||||
$profileFound = true;
|
||||
}
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
if ($profile['name'] === $profileName) {
|
||||
$profileId = $profile['.id'];
|
||||
$found = true;
|
||||
break;
|
||||
// === CEK IP POOL (HANYA UNTUK DHCP & HOTSPOT) ===
|
||||
if (!empty($ipPool) && ($_POST['jenis'] == 'DHCP')) {
|
||||
$poolcek = $API->comm('/ip/pool/print');
|
||||
if (!empty($poolcek)) {
|
||||
foreach ($poolcek as $pool) {
|
||||
if ($pool['name'] === $ipPool) {
|
||||
$poolFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
// Jika status sama dengan 1
|
||||
if ($status == 1 ) {
|
||||
// Pastikan intervalFormat() sudah terdefinisi
|
||||
$interval = intervalFormat($_POST['durasi']);
|
||||
|
||||
// Skrip On Login yang akan dipasang
|
||||
$onLoginScript = ':local nama $user; :local tanggal [/system clock get date]; :local waktu [/system clock get time]; :if ([/ip hotspot user get [find name=$nama] comment] = "") do={/ip hotspot user set [find name=$nama] comment="Login.$tanggal $waktu"; :log warning ("User " . $nama . " berhasil login.")} else={:log warning ("User " . $nama . " berhasil melakukan login ulang.")}; :if ([/system schedule find name=$nama] = "") do={/system schedule add name=$nama interval='.$interval.' on-event="/ip hotspot active remove [find user=$nama]; /ip hotspot user remove [find name=$nama]; /system schedule remove [find name=$nama]" start-date=$tanggal start-time=$waktu;}';
|
||||
|
||||
// Update skrip On Login
|
||||
$API->comm('/ip/hotspot/user/profile/set', [
|
||||
'.id' => $profileId,
|
||||
'on-login' => $onLoginScript,
|
||||
]);
|
||||
}
|
||||
// else {
|
||||
// $messages[] = "Gagal Upload Script: Profil Hotspot <b>$profileName</b> di <b>$mikrotikName</b> tidak aktif atau status tidak sesuai.";
|
||||
// }
|
||||
} else {
|
||||
$messages[] = "Profil Hotspot <b>$profileName</b> di <b>$mikrotikName</b> tidak ditemukan.";
|
||||
}
|
||||
} else {
|
||||
// Jika tidak perlu IP Pool, dianggap ditemukan
|
||||
$poolFound = true;
|
||||
}
|
||||
|
||||
// === VALIDASI PROFILE & IP POOL ===
|
||||
if (!$profileFound) {
|
||||
$messages[] = "Profil <b>$profileName</b> di <b>$mikrotikName</b> tidak ditemukan.";
|
||||
break; // gagal -> keluar loop
|
||||
}
|
||||
|
||||
if (!$poolFound) {
|
||||
$messages[] = "IP Pool <b>$ipPool</b> di <b>$mikrotikName</b> tidak ditemukan.";
|
||||
break; // gagal -> keluar loop
|
||||
}
|
||||
|
||||
// === JIKA HOTSPOT & STATUS AKTIF -> SET ON-LOGIN SCRIPT ===
|
||||
if ($_POST['jenis'] == 'Hotspot' && $status == 1 && empty($_POST['radiuscek'])) {
|
||||
$interval = intervalFormat($_POST['durasi']);
|
||||
$onLoginScript = ':local nama $user; :local tanggal [/system clock get date]; :local waktu [/system clock get time]; :if ([/ip hotspot user get [find name=$nama] comment] = "") do={/ip hotspot user set [find name=$nama] comment="Login.$tanggal $waktu"; :log warning ("User " . $nama . " berhasil login.")} else={:log warning ("User " . $nama . " berhasil melakukan login ulang.")}; :if ([/system schedule find name=$nama] = "") do={/system schedule add name=$nama interval='.$interval.' on-event="/ip hotspot active remove [find user=$nama]; /ip hotspot user remove [find name=$nama]; /system schedule remove [find name=$nama]" start-date=$tanggal start-time=$waktu;}';
|
||||
|
||||
$API->comm('/ip/hotspot/user/profile/set', [
|
||||
'.id' => $p['.id'],
|
||||
'on-login' => $onLoginScript,
|
||||
]);
|
||||
}
|
||||
|
||||
// Catat server yang berhasil untuk rollback jika ada error nanti
|
||||
$rollbackServers[] = $server;
|
||||
} else {
|
||||
$messages[] = "Gagal terhubung ke MikroTik <b>$mikrotikName</b>.";
|
||||
break; // gagal -> langsung keluar loop
|
||||
}
|
||||
}
|
||||
|
||||
// Cek pesan sebelum menyimpan ke database
|
||||
if (empty($messages)) {
|
||||
$stmt = $pdo->prepare("INSERT INTO profile_paket
|
||||
(id_data_server, jenis_profile, nama_profile, durasi, nama, harga_paket, vi_agen, status)
|
||||
VALUES (:id_data_server, :jenis_profile, :nama_profile, :durasi, :nama, :harga_paket, :vi_agen, :status)");
|
||||
$stmt->bindParam(':id_data_server', $_POST['ids']);
|
||||
$stmt->bindParam(':jenis_profile', $_POST['jenis']);
|
||||
$stmt->bindParam(':nama_profile', $_POST['profile']);
|
||||
$stmt->bindParam(':durasi', $_POST['durasi']);
|
||||
$stmt->bindParam(':nama', $_POST['nama']);
|
||||
$stmt->bindParam(':harga_paket', $nominal);
|
||||
$stmt->bindParam(':vi_agen', $fee);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->execute();
|
||||
sweetAlert("Profile Paket Telah ditambahkan", "success");
|
||||
} else {
|
||||
// Menampilkan pesan error jika ada
|
||||
|
||||
// === CEK ERROR DAN ROLLBACK JIKA PERLU ===
|
||||
if (!empty($messages)) {
|
||||
// Rollback ke DB
|
||||
$pdo->rollBack();
|
||||
|
||||
// Rollback radius jika ada
|
||||
if (!empty($_POST['radiuscek']) && $_POST['radiuscek'] == 1) {
|
||||
$radius->request('delete_paket', 'DELETE', [
|
||||
'groupname' => $groupname
|
||||
]);
|
||||
}
|
||||
|
||||
// Rollback ke server yang sudah diproses
|
||||
foreach ($rollbackServers as $srv) {
|
||||
$API = new RouterosAPI();
|
||||
if ($API->connect2($srv['ip_address'], $srv['username'], $srv['password'], $srv['port_api'])) {
|
||||
if ($_POST['jenis'] == 'PPPOE') {
|
||||
$API->comm('/ppp/profile/remove', [
|
||||
'numbers' => $profileName
|
||||
]);
|
||||
} else {
|
||||
$API->comm('/ip/hotspot/user/profile/remove', [
|
||||
'numbers' => $profileName
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$message = implode("<br>", $messages);
|
||||
detailAlert($message, strpos($message, 'tidak ada') !== false || strpos($message, 'Gagal') !== false);
|
||||
detailAlert("Rollback! $message", true);
|
||||
return;
|
||||
}
|
||||
|
||||
// === SIMPAN KE DATABASE ===
|
||||
$stmt = $pdo->prepare("INSERT INTO profile_paket
|
||||
(id_data_server, jenis_profile, nama_profile, durasi, nama, harga_paket, vi_agen, status, radius_data)
|
||||
VALUES (:id_data_server, :jenis_profile, :nama_profile, :durasi, :nama, :harga_paket, :vi_agen, :status, :radius_data)");
|
||||
$stmt->bindParam(':id_data_server', $_POST['ids']);
|
||||
$stmt->bindParam(':jenis_profile', $_POST['jenis']);
|
||||
$stmt->bindParam(':nama_profile', $_POST['profile']);
|
||||
$stmt->bindParam(':durasi', $_POST['durasi']);
|
||||
$stmt->bindParam(':nama', $_POST['nama']);
|
||||
$stmt->bindParam(':harga_paket', $nominal);
|
||||
$stmt->bindParam(':vi_agen', $fee);
|
||||
$stmt->bindParam(':status', $status);
|
||||
$stmt->bindParam(':radius_data', $radius_data);
|
||||
$stmt->execute();
|
||||
|
||||
$pdo->commit(); // commit transaksi
|
||||
sweetAlert("Profile Paket Telah ditambahkan", "success");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Menangani kesalahan dalam koneksi database atau query
|
||||
sweetAlert("Terjadi kesalahan: " . $e->getMessage(), "error");
|
||||
$pdo->rollBack();
|
||||
sweetAlert("Terjadi kesalahan DB: " . $e->getMessage(), "error");
|
||||
} catch (Exception $e) {
|
||||
// Menangani kesalahan umum
|
||||
$pdo->rollBack();
|
||||
sweetAlert("Terjadi kesalahan: " . $e->getMessage(), "error");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -229,7 +355,8 @@ if (isset($_POST['tambah'])) {
|
||||
<?php
|
||||
$apaket = mysqli_query($con,"SELECT * FROM profile_paket $SqlDataWHId ORDER BY nama ASC");
|
||||
while ($paket = mysqli_fetch_assoc($apaket))
|
||||
{
|
||||
{
|
||||
$data_radius = json_decode($paket['radius_data']);
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
@@ -258,7 +385,13 @@ if (isset($_POST['tambah'])) {
|
||||
</tr>
|
||||
<?php
|
||||
if (isset($_POST['hapus'.$paket['id']]))
|
||||
{
|
||||
{
|
||||
|
||||
$groupname = $data_radius->{'groupname'};
|
||||
$radius = new CrudRadiusServer();
|
||||
$radius->request('delete_paket', 'DELETE', [
|
||||
'groupname' => $groupname
|
||||
]);
|
||||
$iddata = $paket['id'];
|
||||
deleteAlert("profile_paket", $iddata);
|
||||
}
|
||||
@@ -280,8 +413,9 @@ if (isset($_POST['tambah'])) {
|
||||
<!-- /.content -->
|
||||
|
||||
<script>
|
||||
// Ambil semua elemen dropdown dalam modal
|
||||
// Ambil semua elemen dropdown & checkbox dalam modal
|
||||
const jenisSelects = document.querySelectorAll('[data-select]');
|
||||
const radiusCheckbox = document.querySelector('input[name="radiuscek"]');
|
||||
|
||||
// Sembunyikan semua grup pada awalnya
|
||||
document.querySelectorAll('[id^="group-"]').forEach(group => {
|
||||
@@ -292,60 +426,97 @@ document.querySelectorAll('[id^="group-"]').forEach(group => {
|
||||
function updateGroupVisibility() {
|
||||
const jenisSelect = document.querySelector('select[name="jenis"]');
|
||||
const jenishsSelect = document.querySelector('select[name="jenishs"]');
|
||||
const group0 = document.getElementById('group-jenis0');
|
||||
const group1 = document.getElementById('group-jenis1');
|
||||
const group2 = document.getElementById('group-jenis2');
|
||||
const group3 = document.getElementById('group-jenis3');
|
||||
const select2 = document.getElementById('jenis-select2');
|
||||
const groupdhcp = document.getElementById('group-dhcp');
|
||||
const radiusUse = document.getElementById('group-use');
|
||||
const radiusRate = document.getElementById('group-rate');
|
||||
const radiusSession = document.getElementById('group-session');
|
||||
const radiusIdle = document.getElementById('group-idle');
|
||||
const groupPool = document.getElementById('group-pool');
|
||||
const fee = document.getElementById('fee');
|
||||
const durasi = document.getElementById('durasi');
|
||||
|
||||
// Reset nilai input grup
|
||||
function resetGroup(group) {
|
||||
const input = group.querySelector('select, input');
|
||||
if (input) {
|
||||
input.value = '';
|
||||
// Helper untuk reset grup
|
||||
function resetGroup(group, resetValue = true) {
|
||||
if (resetValue) {
|
||||
const inputs = group.querySelectorAll('select, input');
|
||||
inputs.forEach(input => {
|
||||
if (input.type === 'checkbox' || input.type === 'radio') {
|
||||
input.checked = false;
|
||||
} else {
|
||||
input.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
group.style.display = 'none';
|
||||
}
|
||||
|
||||
// Tampilkan grup berdasarkan pilihan di dropdown
|
||||
// Reset semua grup dulu untuk menghindari tumpang tindih
|
||||
const allGroups = [
|
||||
group0, group1, group2, group3,
|
||||
groupdhcp, groupPool,
|
||||
radiusUse, radiusRate, radiusSession, radiusIdle
|
||||
];
|
||||
allGroups.forEach(g => resetGroup(g, false));
|
||||
|
||||
// Logic untuk dropdown jenis
|
||||
if (jenisSelect.value === "Hotspot") {
|
||||
group0.style.display = 'block';
|
||||
group1.style.display = 'block';
|
||||
group1.querySelector('select').required = true;
|
||||
} else {
|
||||
resetGroup(group1);
|
||||
} else if (jenisSelect.value === "PPPOE") {
|
||||
group0.style.display = 'block';
|
||||
} else if (jenisSelect.value === "DHCP") {
|
||||
groupPool.style.display = 'block';
|
||||
}
|
||||
|
||||
if (jenishsSelect) {
|
||||
// Logic untuk jenishs select
|
||||
if (jenisSelect.value === "Hotspot" && jenishsSelect.value === "1") {
|
||||
group2.style.display = 'block';
|
||||
group3.style.display = 'block';
|
||||
fee.required = true;
|
||||
durasi.required = true;
|
||||
} else {
|
||||
fee.required = false;
|
||||
durasi.required = false;
|
||||
if (jenishsSelect.value === "1") {
|
||||
group2.style.display = 'block';
|
||||
group3.style.display = 'block';
|
||||
jenishsSelect.required = true;
|
||||
fee.required = true;
|
||||
durasi.required = true;
|
||||
} else {
|
||||
resetGroup(group2);
|
||||
resetGroup(group3);
|
||||
jenishsSelect.required = false;
|
||||
fee.required = false;
|
||||
durasi.required = false;
|
||||
jenishsSelect.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Logic untuk checkbox radius
|
||||
if (radiusCheckbox.checked) {
|
||||
groupdhcp.style.display = 'block';
|
||||
|
||||
if (jenisSelect.value === "PPPOE") {
|
||||
radiusUse.style.display = 'block';
|
||||
radiusRate.style.display = 'block';
|
||||
} else if (jenisSelect.value === "Hotspot") {
|
||||
radiusUse.style.display = 'block';
|
||||
radiusSession.style.display = 'block';
|
||||
radiusRate.style.display = 'block';
|
||||
radiusIdle.style.display = 'block';
|
||||
} else if (jenisSelect.value === "DHCP") {
|
||||
radiusRate.style.display = 'block';
|
||||
groupPool.style.display = 'block';
|
||||
}
|
||||
} else {
|
||||
// Hanya reset grup radius & dhcp
|
||||
[radiusUse, radiusRate, radiusSession, radiusIdle, groupdhcp, groupPool].forEach(g => resetGroup(g));
|
||||
|
||||
// Jika jenisSelect saat ini DHCP, reset ke kosong supaya tidak memicu tampil lagi
|
||||
if (jenisSelect.value === "DHCP") {
|
||||
jenisSelect.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cek apakah select sudah ada isinya dan update tampilan
|
||||
// Inisialisasi tampilan saat halaman diload
|
||||
function initializeGroupVisibility() {
|
||||
const jenisSelect = document.querySelector('select[name="jenis"]');
|
||||
const jenishsSelect = document.querySelector('select[name="jenishs"]');
|
||||
|
||||
if (jenisSelect.value) {
|
||||
updateGroupVisibility();
|
||||
}
|
||||
|
||||
if (jenishsSelect && jenishsSelect.value) {
|
||||
updateGroupVisibility();
|
||||
}
|
||||
updateGroupVisibility();
|
||||
}
|
||||
|
||||
// Tambahkan event listener untuk setiap dropdown
|
||||
@@ -353,6 +524,10 @@ jenisSelects.forEach(select => {
|
||||
select.addEventListener('change', updateGroupVisibility);
|
||||
});
|
||||
|
||||
// Inisialisasi tampilan grup pada load
|
||||
// Tambahkan event listener untuk checkbox radius
|
||||
radiusCheckbox.addEventListener('change', updateGroupVisibility);
|
||||
|
||||
// Jalankan inisialisasi
|
||||
initializeGroupVisibility();
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user