897 lines
37 KiB
PHP
897 lines
37 KiB
PHP
<?php
|
|
ini_set('display_errors', 1);
|
|
error_reporting(E_ALL);
|
|
?>
|
|
<!-- Main content -->
|
|
<section class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
<h3 class="card-title">Generate Voucher Auto Pilot</h3>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<ol class="float-sm-right mb-0">
|
|
<a type="button" class="btn btn-secondary btn-sm m-1" data-toggle="modal" data-target="#ModalScript">Ambil Script</a>
|
|
<a type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#staticBackdrop">Generate</a>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Modal Tambah -->
|
|
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="modal-header bg-primary">
|
|
<h5 class="modal-title" id="staticBackdropLabel">Generate Voucher</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label>Nama Server</label>
|
|
<select class="form-control" name="ids" required>
|
|
<option value="">Pilih</option>
|
|
<?php
|
|
$List = new Listdata();
|
|
$List->set_list("data_server", $SqlDataWH);
|
|
foreach ($List->get_list() as $key => $value): ?>
|
|
<option value="<?php echo $value['id']; ?>"><?php echo $value['nama_server']; ?></option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Mikrotik</label>
|
|
<select class="form-control" name="idm" required>
|
|
<option value="">Pilih</option>
|
|
<?php
|
|
$List = new Listdata();
|
|
$List->set_list("setting_mikrotik", $SqlDataWHId);
|
|
foreach ($List->get_list() as $key => $value): ?>
|
|
<option value="<?php echo $value['id']; ?>"><?php echo $value['nama']; ?></option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
<div class="row g-3">
|
|
<div class="col-8">
|
|
<div class="form-group">
|
|
<label>Paket</label>
|
|
<select class="form-control" name="idp" required>
|
|
<option value="">Pilih</option>
|
|
<?php
|
|
$List = new Listdata();
|
|
$List->set_list("profile_paket", $SqlDataWHId . "AND jenis_profile = 'Hotspot' AND status = 1");
|
|
foreach ($List->get_list() as $key => $value): ?>
|
|
<option value="<?php echo $value['id']; ?>"><?php echo $value['nama']; ?></option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-4">
|
|
<div class="form-group">
|
|
<label>Jumlah</label>
|
|
<div class="input-group mb-3">
|
|
<input type="number" class="form-control" min="1" max="50" value="1" name="jumlah" id="jumlah" required>
|
|
<span class="input-group-text" id="basic-addon2">Pcs</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
<input type="submit" name="generate" class="btn btn-primary" value="Generate">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
if (isset($_POST['generate'])) {
|
|
|
|
try {
|
|
// Mulai transaksi DB
|
|
$pdo->beginTransaction();
|
|
|
|
// Ambil data paket
|
|
$stmt = $pdo->prepare("SELECT radius_data,durasi,nama_profile,harga_paket FROM profile_paket WHERE id = :idp");
|
|
$stmt->execute([':idp' => $_POST['idp']]);
|
|
$paket = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
// ====== KIRIM KE API MIKROTIK ======
|
|
$stmt = $pdo->prepare("SELECT ip_address,username,password,port_api,radius_nas_data FROM setting_mikrotik WHERE id = :id");
|
|
$stmt->execute([':id' => $_POST['idm']]);
|
|
$mikrotik = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
$dataMik = json_decode($mikrotik['radius_nas_data']);
|
|
|
|
if (!$paket) {
|
|
throw new Exception("Paket tidak ditemukan.");
|
|
}
|
|
|
|
$data = json_decode($paket['radius_data']);
|
|
$kode = $data ? 'VR' : 'VM'; // VR = Radius, VM = MikroTik
|
|
$jenis = $data ? 'sv-radius' : 'sv-mikrotik';
|
|
$karakter = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
|
|
$str = $paket['durasi'];
|
|
$jumlah = intval($_POST['jumlah']);
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
// Validasi jumlah
|
|
if ($jumlah < 1 || $jumlah > 200) {
|
|
throw new Exception("Jumlah voucher harus antara 1-200.");
|
|
}
|
|
|
|
// Generate voucher unik
|
|
$voucherList = [];
|
|
while (count($voucherList) < $jumlah) {
|
|
$kodevoucher = $str . substr(str_shuffle($karakter), 0, 7) . $kode;
|
|
|
|
// Pastikan tidak duplikat di DB & array
|
|
$cek = $pdo->prepare("SELECT COUNT(*) FROM ganerate_voucher WHERE voucher = :voucher");
|
|
$cek->execute([':voucher' => $kodevoucher]);
|
|
if ($cek->fetchColumn() == 0 && !in_array($kodevoucher, $voucherList)) {
|
|
$voucherList[] = $kodevoucher;
|
|
}
|
|
}
|
|
|
|
// Kirim ke Radius atau MikroTik
|
|
$successVoucher = [];
|
|
$failVoucher = [];
|
|
|
|
if ($data) {
|
|
// ====== KIRIM KE RADIUS ======
|
|
$radius = new CrudRadiusServer();
|
|
$apiResponse = $radius->request('add_user', 'POST', [
|
|
'jenis' => 'Hotspot',
|
|
'username' => $voucherList,
|
|
'password' => $voucherList,
|
|
'groupname' => $data->groupname,
|
|
'nasgroupname' => $dataMik->data->{'nasgroupname'}
|
|
]);
|
|
|
|
foreach ($apiResponse['results'] as $res) {
|
|
if ($res['status'] === 'success') {
|
|
$successVoucher[] = $res['username'];
|
|
} else {
|
|
$failVoucher[] = $res['username'];
|
|
}
|
|
}
|
|
|
|
if (empty($successVoucher)) {
|
|
throw new Exception("Tidak ada voucher yang berhasil dibuat di Radius.");
|
|
}
|
|
} else {
|
|
|
|
// require('router_api/routeros_api.class.php');
|
|
$API = new RouterosAPI();
|
|
$API->debug = false;
|
|
|
|
if (!$API->connect2($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password'], $mikrotik['port_api'])) {
|
|
throw new Exception("Gagal konek ke API MikroTik.");
|
|
}
|
|
|
|
foreach ($voucherList as $vcr) {
|
|
$result = $API->comm('/ip/hotspot/user/add', [
|
|
"name" => $vcr,
|
|
"password" => $vcr,
|
|
"profile" => $paket['nama_profile'], // pastikan field profile ada di DB
|
|
"server" => "all"
|
|
]);
|
|
|
|
if (isset($result['!trap'])) {
|
|
$failVoucher[] = $vcr;
|
|
} else {
|
|
$successVoucher[] = $vcr;
|
|
}
|
|
}
|
|
|
|
$API->disconnect();
|
|
|
|
if (empty($successVoucher)) {
|
|
throw new Exception("Tidak ada voucher yang berhasil dibuat di MikroTik.");
|
|
}
|
|
}
|
|
|
|
// Insert ke DB hanya yang sukses
|
|
$values = [];
|
|
$params = [];
|
|
foreach ($successVoucher as $voucher) {
|
|
$values[] = "(?, ?, ?, ?, ?, ?, ?)";
|
|
$params[] = $_POST['ids']; // id_data_server
|
|
$params[] = $_POST['idm']; // id_setting_mikrotik
|
|
$params[] = $_POST['idp']; // id_profile_paket
|
|
$params[] = $voucher; // voucher
|
|
$params[] = $paket['harga_paket']; // harga
|
|
$params[] = $jenis; // jenis
|
|
$params[] = $date; // create_time
|
|
}
|
|
|
|
$sql = "INSERT INTO ganerate_voucher
|
|
(id_data_server, id_setting_mikrotik, id_profile_paket, voucher, harga, jenis, create_time)
|
|
VALUES " . implode(", ", $values);
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute($params);
|
|
|
|
// Commit transaksi
|
|
$pdo->commit();
|
|
|
|
$totalSuccess = count($successVoucher);
|
|
$totalError = count($failVoucher);
|
|
|
|
sweetAlert("$totalSuccess voucher berhasil dibuat. Gagal: $totalError", "success");
|
|
} catch (Exception $e) {
|
|
$pdo->rollBack();
|
|
sweetAlert("Gagal membuat voucher: " . $e->getMessage(), "error");
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
<!--START Modal Data Script-->
|
|
<div class="modal fade" id="ModalScript" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="ModalScriptLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered modal-lg">
|
|
<div class="modal-content">
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="modal-header bg-secondary">
|
|
<h5 class="modal-title" id="staticBackdropLabel">Script Tambahan Login Page</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<?php
|
|
// ambil data server untuk script
|
|
$ListServer = new Listdata();
|
|
$ListServer->set_list("setting_mikrotik", $SqlDataWHId);
|
|
?>
|
|
<div class="form-group">
|
|
<label>Nama Server</label>
|
|
<select class="form-control" name="idmscript" id="idmscript">
|
|
<?php foreach ($ListServer->get_list() as $value):
|
|
$radius_data = json_decode($value['radius_nas_data']);
|
|
$nasgroupname = $radius_data->data->{'nasgroupname'} ?? '';
|
|
$dataUrl = encrypt_url(json_encode([
|
|
'board' => $value['board_id'],
|
|
'nasgroupname' => $nasgroupname
|
|
]));
|
|
?>
|
|
<option value="<?= htmlspecialchars($dataUrl) ?>">
|
|
<?= htmlspecialchars($value['nama']) ?>
|
|
</option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
<h6 class="mt-2 mb-2">Login Page Script</h6>
|
|
<div class="mb-3">
|
|
<div class="text-right" style="margin-bottom: -33px; margin-right: 2px;">
|
|
<a onclick="copyToClipboard('script-page')" class="btn btn-sm btn-light btn-icon" title="Copy">
|
|
<i class="fa fa-copy"></i>
|
|
</a>
|
|
</div>
|
|
<pre class="bg-light border rounded p-3 mb-2" id="script-page">
|
|
Loading script...
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--END Modal Data Script-->
|
|
|
|
|
|
<!-- /.card-header -->
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-5">
|
|
<div class="row">
|
|
<div class="col-md-3 mb-2">
|
|
|
|
</div>
|
|
<div class="col-md-6">
|
|
<center>
|
|
<p>Akumulasi Keuangan Voucher</p>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-lg-4 col-6">
|
|
<!-- small box -->
|
|
<div class="small-box bg-info" id="penjualanBox">
|
|
<div class="inner">
|
|
<h4 id="totalValue">0</h4>
|
|
<p><small>Total Penjualan</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-card"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-4 col-6">
|
|
<!-- small box -->
|
|
<div class="small-box bg-danger" id="lunasBox">
|
|
<div class="inner">
|
|
<h4 id="ditahanValue">0</h4>
|
|
<p><small>Saldo Ditahan</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-card"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-4 col-12">
|
|
<!-- small box -->
|
|
<div class="small-box bg-success" id="pendingBox">
|
|
<div class="inner">
|
|
<h4 id="tersediaValue">0</h4>
|
|
<p><small>Saldo Tersedia</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-card"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-7">
|
|
<div class="row">
|
|
<div class="col-md-3 mb-2">
|
|
|
|
</div>
|
|
<div class="col-md-6">
|
|
<center>
|
|
<p>Akumulasi Penjualan Voucher</p>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-success" id="boxgenerateSuccess">
|
|
<div class="inner">
|
|
<h4 id="generateSuccess">0</h4>
|
|
<p><small>Transaksi Success</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-info" id="boxgeneratePending">
|
|
<div class="inner">
|
|
<h4 id="generatePending">0</h4>
|
|
<p><small>Transaksi Pending</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-warning" id="boxgenerateCancel">
|
|
<div class="inner">
|
|
<h4 id="generateCancel">0</h4>
|
|
<p><small>Transaksi Cancel</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-info" id="boxgenerateBelumaktif">
|
|
<div class="inner">
|
|
<h4 id="generateBelumaktif">0</h4>
|
|
<p><small>Voucher Tersedia</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-success" id="boxgenerateAktif">
|
|
<div class="inner">
|
|
<h4 id="generateAktif">0</h4>
|
|
<p><small>Voucher Active</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-2 col-4">
|
|
<!-- small box -->
|
|
<div class="small-box bg-danger" id="boxgenerateNonaktif">
|
|
<div class="inner">
|
|
<h4 id="generateNonaktif">0</h4>
|
|
<p><small>Voucher Expired</small></p>
|
|
</div>
|
|
<div class="icon">
|
|
<i class="ion ion-wifi"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-5">
|
|
<div class="row">
|
|
<div class="col-md-9">
|
|
<center>
|
|
<p>Riwayat Pencairan Dana</p>
|
|
</center>
|
|
</div>
|
|
<div class="col-md-3 mb-2 text-right">
|
|
<a type="button" class="btn btn-primary btn-sm m-1" data-toggle="modal" data-target="#ModalPencairan">Pencairan Dana</a>
|
|
</div>
|
|
</div>
|
|
<table id="withdrawTable" class="table table-striped table-bordered" style="zoom: 90%; width: 100%;">
|
|
<thead>
|
|
<tr>
|
|
<th>Server</th>
|
|
<th>Dibuat</th>
|
|
<th>Nominal</th>
|
|
<th>User</th>
|
|
<th>Status</th>
|
|
<th>Diproses</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-7">
|
|
<div class="row">
|
|
<div class="col-md-9">
|
|
<center>
|
|
<p>Voucher List</p>
|
|
</center>
|
|
</div>
|
|
<div class="col-md-3 mb-2">
|
|
<select id="selectStatus" class="form-control form-select form-select-sm">
|
|
<option value="LUNAS" selected>Lunas</option>
|
|
<option value="BELUM BAYAR">Pending</option>
|
|
<option value="CANCELED">Cancel</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<table id="voucherTable" class="table table-striped table-bordered" style="zoom: 90%;">
|
|
<thead>
|
|
<tr>
|
|
<th>Server</th>
|
|
<th>Voucher</th>
|
|
<th>Harga</th>
|
|
<th>Biaya</th>
|
|
<th>Saldo</th>
|
|
<th>Status</th>
|
|
<th style="max-width: 100px;">Dibuat</th>
|
|
<th style="max-width: 100px;">Aktif</th>
|
|
<th style="max-width: 100px;">Expired</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!--ISI KONTEN-->
|
|
|
|
<!--START Modal WithDrow-->
|
|
<div class="modal fade" id="ModalPencairan" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="ModalPencairanLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="modal-header bg-primary">
|
|
<h5 class="modal-title" id="staticBackdropLabel">Pencairan Dana</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="card-body">
|
|
<?php
|
|
// ambil data server untuk script
|
|
$ListServer = new Listdata();
|
|
$ListServer->set_list("data_server", "WHERE id IN (" . $SvId . ")");
|
|
?>
|
|
<div class="form-group">
|
|
<label>Nama Server</label>
|
|
<select class="form-control" id="idgetSaldo" name="idgetSaldo">
|
|
<option value="0">-- PILIH --</option>
|
|
<?php foreach ($ListServer->get_list() as $value): ?>
|
|
<option value="<?= htmlspecialchars($value['id']) ?>">
|
|
<?= htmlspecialchars($value['nama_server']) ?>
|
|
</option>
|
|
<?php endforeach ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Saldo</label>
|
|
<div id="saldoServer" class="mt-2 text-success font-weight-bold" style="font-size: 24px;">Rp. 0</div>
|
|
</div>
|
|
<div class="form-group" id="formNominal">
|
|
<label>Nominal</label>
|
|
<input type="text" class="form-control rupiah" id="rupiah0" placeholder="Rp. 0" name="nominal" disabled readonly>
|
|
</div>
|
|
<i class="text-danger">Dana bisa di cairkan jika Saldo lebih dari Rp 10.000</i>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
<input type="submit" name="cairkan" class="btn btn-primary" value="Cairkan">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--END Modal WithDrow-->
|
|
|
|
</div>
|
|
<!-- /.card-body -->
|
|
</div>
|
|
<!-- /.card -->
|
|
</div>
|
|
<!-- /.col -->
|
|
</div>
|
|
<!-- /.row -->
|
|
</div>
|
|
<!-- /.container-fluid -->
|
|
</section>
|
|
<!-- /.content -->
|
|
|
|
<?php
|
|
if (isset($_POST['cairkan'])) {
|
|
|
|
$SQLCek = "SELECT nama_server, rekening_bank, rekening_nama, rekening_nomor, rekening_status
|
|
FROM data_server WHERE id = :idsv";
|
|
$stmt = $pdo->prepare($SQLCek);
|
|
$stmt->execute([':idsv' => $_POST['idgetSaldo']]);
|
|
$rek_data = $stmt->fetch(PDO::FETCH_ASSOC); // ✅ fetch single row
|
|
|
|
if (!empty($rek_data['rekening_nama'])) {
|
|
if ($rek_data['rekening_status'] == 'verificated') {
|
|
|
|
$nominal = preg_replace("/[^0-9]/", "", $_POST['nominal']);
|
|
|
|
$SQLCarikan = "INSERT INTO transaksi_withdraw
|
|
(id_data_server, start_time, nominal, user_create, status, jenis) VALUES
|
|
(:id_data_server, :start_time, :nominal, :user_create, 'pending', 'hotspot_auto')";
|
|
$stmt = $pdo->prepare($SQLCarikan);
|
|
$stmt->bindValue(':id_data_server', $_POST['idgetSaldo'], PDO::PARAM_INT);
|
|
$stmt->bindValue(':start_time', date('Y-m-d H:i:s')); // ✅ pakai bindValue
|
|
$stmt->bindValue(':nominal', $nominal, PDO::PARAM_INT);
|
|
$stmt->bindValue(':user_create', $SvNama, PDO::PARAM_STR); // pastikan $SvNama ada
|
|
$stmt->execute();
|
|
|
|
$Pesanwarek = "*PERMINTAAN PENCAIRAN DANA*
|
|
|
|
Server : " . $rek_data['nama_server'] . "
|
|
BANK : " . strtoupper($rek_data['rekening_bank']) . "
|
|
Rekening : *" . $rek_data['rekening_nomor'] . "*
|
|
Nama Rek : " . $rek_data['rekening_nama'] . "
|
|
|
|
Nominal : *" . $_POST['nominal'] . "*
|
|
|
|
|
|
_# Manja ~ Notif_
|
|
";
|
|
$nomorWArek = ["6281298698422", "6285655548738"];
|
|
$APIwa = new PesanWA();
|
|
$APIwa->Send_Pesan('1','sendMessage',$nomorWArek,$Pesanwarek);
|
|
|
|
sweetAlert("BERHASIL.! Pencairan akan segera diproses, mohon tunggu.", "success");
|
|
} else {
|
|
sweetAlert("GAGAL.! Rekening anda sedang diverifikasi mohon ditunggu.", "error");
|
|
}
|
|
} else {
|
|
sweetAlert("GAGAL.! Tidak ada rekening yang tersedia, silahkan isi rekening di Profile Master.", "error");
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
<!--END Modal WithDrow-->
|
|
<div class="modal fade" id="viewBuktiModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" style="max-width: fit-content; margin: auto;">
|
|
<div class="modal-content border-0 bg-transparent shadow-none" style="width: auto;">
|
|
<div class="position-relative d-inline-block">
|
|
|
|
<!-- Tombol Close -->
|
|
<button type="button" class="close text-white position-absolute"
|
|
data-dismiss="modal" aria-label="Close"
|
|
style="top: 10px; right: 10px; filter: invert(1); z-index: 10;">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
|
|
<!-- Gambar dari JS -->
|
|
<img id="viewBuktiImg" src=""
|
|
class="img-fluid rounded shadow d-block"
|
|
alt="Bukti Transaksi" style="max-height: 600px;">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
// Buat script HTML dengan escape karakter agar aman
|
|
function generateScript(dataUrl) {
|
|
return `<div id="voucher-container"></div>
|
|
<script src="https://manjapro.net/voucherpay/cl-style.js?i=${dataUrl}"></script>`;
|
|
}
|
|
|
|
// Update script ketika pilihan berubah
|
|
function updateScript() {
|
|
const selectedValue = document.getElementById('idmscript').value;
|
|
const preElement = document.getElementById('script-page');
|
|
preElement.textContent = generateScript(selectedValue);
|
|
}
|
|
|
|
// Event: saat select berubah
|
|
document.getElementById('idmscript').addEventListener('change', updateScript);
|
|
|
|
// Saat halaman pertama kali load
|
|
window.addEventListener('DOMContentLoaded', updateScript);
|
|
|
|
// Tombol copy
|
|
function copyToClipboard(preId) {
|
|
const text = document.getElementById(preId).textContent
|
|
.replace(/</g, "<").replace(/>/g, ">");
|
|
navigator.clipboard.writeText(text).then(() => {
|
|
// console.log("Script berhasil disalin!");
|
|
});
|
|
}
|
|
</script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
// Fungsi untuk mengambil data agen berdasarkan bulan yang dipilih
|
|
function fetchDataAgen() {
|
|
|
|
var idDataServer = "<?php echo encrypt_url($SvId); ?>"; // Ganti dengan ID yang sesuai atau ambil dari variabel PHP
|
|
|
|
// Buat request dengan menggunakan XMLHttpRequest
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "list_data/data_akumulasi_pendapatan.php?id=" + idDataServer, true);
|
|
|
|
// Ketika request selesai diproses
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState === 4) { // 4 berarti request telah selesai
|
|
if (xhr.status === 200) { // Jika status sukses (200)
|
|
// Parse data JSON dari PHP
|
|
var response = JSON.parse(xhr.responseText);
|
|
|
|
// Pastikan data tersedia sebelum mengaksesnya
|
|
if (response && response.length > 0) {
|
|
// Ambil data dari response (jika ada)
|
|
var data = response[0];
|
|
|
|
// Ambil nilai atau set ke 0 jika tidak ada
|
|
var total = parseFloat(data.total) || 0;
|
|
var ditahan = parseFloat(data.ditahan) || 0;
|
|
var tersedia = parseFloat(data.tersedia) || 0;
|
|
var jum_lunas = parseInt(data.jum_lunas) || 0;
|
|
var jum_pending = parseInt(data.jum_pending) || 0;
|
|
var jum_cancel = parseInt(data.jum_cancel) || 0;
|
|
var jum_belum_aktif = parseInt(data.jum_belum_aktif) || 0;
|
|
var jum_aktif = parseInt(data.jum_aktif) || 0;
|
|
var jum_nonaktif = parseInt(data.jum_nonaktif) || 0;
|
|
|
|
// Format angka dengan pemisah ribuan
|
|
total = total.toLocaleString();
|
|
ditahan = ditahan.toLocaleString();
|
|
tersedia = tersedia.toLocaleString();
|
|
|
|
// Masukkan data ke dalam elemen HTML yang sesuai
|
|
document.getElementById('totalValue').innerText = "Rp. "+total;
|
|
document.getElementById('ditahanValue').innerText = "Rp. "+ditahan;
|
|
document.getElementById('tersediaValue').innerText = "Rp. "+tersedia;
|
|
document.getElementById('generateSuccess').innerText = jum_lunas;
|
|
document.getElementById('generatePending').innerText = jum_pending;
|
|
document.getElementById('generateCancel').innerText = jum_cancel;
|
|
document.getElementById('generateBelumaktif').innerText = jum_belum_aktif;
|
|
document.getElementById('generateAktif').innerText = jum_aktif;
|
|
document.getElementById('generateNonaktif').innerText = jum_nonaktif;
|
|
} else {
|
|
// Jika data tidak ditemukan atau kosong
|
|
document.getElementById('result').innerHTML = "Tidak ada data untuk bulan yang dipilih.";
|
|
}
|
|
} else {
|
|
// Jika ada masalah dengan request
|
|
document.getElementById('result').innerHTML = "Error: Tidak dapat mengambil data.";
|
|
}
|
|
}
|
|
};
|
|
|
|
// Kirimkan request
|
|
xhr.send();
|
|
}
|
|
|
|
// Panggil fungsi setDefaultMonth saat halaman dimuat
|
|
window.onload = fetchDataAgen();
|
|
</script>
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
var defaultStatus = $('#selectStatus').val(); // ambil default (LUNAS)
|
|
|
|
var table = $('#voucherTable').DataTable({
|
|
"processing": true,
|
|
"serverSide": true,
|
|
"responsive": true,
|
|
"autoWidth": false,
|
|
"ajax": {
|
|
"url": "controller/voucher_auto.php?i=<?= $SvId; ?>&s=" + defaultStatus,
|
|
"type": "GET"
|
|
},
|
|
"pageLength": 10,
|
|
"columns": [
|
|
{ "data": 0 }, // server
|
|
{ "data": 1 }, // voucher
|
|
{ "data": 2 }, // harga
|
|
{ "data": 3, "orderable": false }, // biaya
|
|
{ "data": 4, "orderable": false }, // saldo
|
|
{ "data": 5 }, // status
|
|
{ "data": 6 }, // dibuat
|
|
{ "data": 7 }, // aktif
|
|
{ "data": 8 } // expired
|
|
],
|
|
"order": [[0, "desc"]]
|
|
});
|
|
|
|
// Reload data saat status berubah
|
|
$('#selectStatus').on('change', function() {
|
|
table.ajax.url("controller/voucher_auto.php?i=<?= $SvId; ?>&s=" + $(this).val()).load();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
$('#withdrawTable').DataTable({
|
|
"processing": true,
|
|
"serverSide": true,
|
|
"responsive": true,
|
|
"ajax": {
|
|
"url": "controller/get_withdrow.php?i=<?= $SvId; ?>&s=hotspot_auto",
|
|
"type": "POST"
|
|
},
|
|
"pageLength": 10,
|
|
"columns": [
|
|
{ "data": 0 }, // Server
|
|
{ "data": 1 }, // Dibuat
|
|
{ "data": 2 }, // Nominal
|
|
{ "data": 3 }, // User
|
|
{
|
|
"data": 4, // Status
|
|
"render": function(data, type, row, meta) {
|
|
if (data === 'pending') {
|
|
return `<span class="badge bg-primary p-2">${data.toUpperCase()}</span>`;
|
|
} else {
|
|
return `<span class="badge bg-success p-2">${data.toUpperCase()}</span>`;
|
|
}
|
|
}
|
|
},
|
|
{ "data": 5 }, // Diproses
|
|
{
|
|
"data": 6, // id unik
|
|
"render": function(data, type, row, meta) {
|
|
let btn = "";
|
|
|
|
if (row[4] === 'success') {
|
|
btn += `<button class="btn btn-sm btn-secondary me-1" onclick="viewBukti('${data.bukti_success}')">
|
|
<i class="fa fa-image"></i>
|
|
</button>`;
|
|
}
|
|
|
|
return btn;
|
|
}
|
|
}
|
|
],
|
|
"order": [[1, "desc"]] // urut berdasarkan Dibuat
|
|
});
|
|
});
|
|
|
|
// function viewBukti Transaksi
|
|
function viewBukti(imgPath) {
|
|
$("#viewBuktiImg").attr("src", imgPath);
|
|
$("#viewBuktiModal").modal("show");
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
var currentSaldo = 0; // simpan saldo terakhir
|
|
|
|
$("#idgetSaldo").on("change", function(){
|
|
var serverId = $(this).val();
|
|
var $nominalInput = $("#formNominal input");
|
|
|
|
if(serverId == 0){
|
|
$("#saldoServer").html("Rp. 0");
|
|
$nominalInput.prop("disabled", true).prop("readonly", true).val("");
|
|
currentSaldo = 0;
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url: "controller/get_saldo.php",
|
|
type: "GET",
|
|
data: { id: serverId },
|
|
dataType: "json",
|
|
success: function(res){
|
|
if(res && res.saldo !== undefined){
|
|
currentSaldo = parseInt(res.saldo) || 0;
|
|
$("#saldoServer").html("Rp. " + new Intl.NumberFormat().format(currentSaldo));
|
|
|
|
if(currentSaldo < 10000){
|
|
$nominalInput.prop("disabled", true).prop("readonly", true).val("");
|
|
} else {
|
|
$nominalInput.prop("disabled", false).prop("readonly", false);
|
|
}
|
|
} else {
|
|
$("#saldoServer").html("Rp. 0");
|
|
$nominalInput.prop("disabled", true).prop("readonly", true).val("");
|
|
currentSaldo = 0;
|
|
}
|
|
},
|
|
error: function(){
|
|
$("#saldoServer").html("Gagal mengambil saldo");
|
|
$nominalInput.prop("disabled", true).prop("readonly", true).val("");
|
|
currentSaldo = 0;
|
|
}
|
|
});
|
|
});
|
|
|
|
// Cek saat user input nominal
|
|
$("#formNominal input").on("input", function(){
|
|
var val = parseInt($(this).val().replace(/\D/g, '')) || 0; // ambil angka aja
|
|
if(val > currentSaldo){
|
|
val = currentSaldo; // batasin maksimal saldo
|
|
}
|
|
$(this).val(val); // set kembali ke input
|
|
});
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
<script>
|
|
document.getElementById('jumlah').addEventListener('input', function () {
|
|
let value = parseInt(this.value);
|
|
|
|
if (value > 50) {
|
|
this.value = 50; // set max
|
|
} else if (value < 1) {
|
|
this.value = 1; // set min
|
|
}
|
|
});
|
|
</script>
|