Add remaining project files (exclude ignored folders)

This commit is contained in:
WD - Dev
2025-07-05 15:11:40 +07:00
parent a96eb2b958
commit b440b80882
4697 changed files with 1365702 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
// Include your database connection
include '../config/connect.php';
if (isset($_GET['id'])) {
$id = intval($_GET['id']); // Sanitize the input to prevent SQL injection
// Prepare the SQL statement to fetch the server data
$stmt = $pdo->prepare("SELECT id, id_data_server, start_time, pemasukan, pengeluaran, keterangan, metode_pembayaran, status FROM transaksi WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
// Fetch the data
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($data) {
// Return the data as JSON
echo json_encode($data);
} else {
// If no data found, return an error message
echo json_encode(['error' => 'Data not found']);
}
} else {
// If no ID is provided, return an error message
echo json_encode(['error' => 'Invalid ID']);
}
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
// Include your database connection
include '../config/connect.php';
if (isset($_GET['id'])) {
$id = intval($_GET['id']); // Sanitize the input to prevent SQL injection
// Prepare the SQL statement to fetch the server data
$stmt = $pdo->prepare("SELECT * FROM daftar_akun_transaksi WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
// Fetch the data
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($data) {
// Return the data as JSON
echo json_encode($data);
} else {
// If no data found, return an error message
echo json_encode(['error' => 'Data not found']);
}
} else {
// If no ID is provided, return an error message
echo json_encode(['error' => 'Invalid ID']);
}
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
// Include your database connection using PDO
include '../config/connect.php';
// Ambil parameter 'w' dan 'j' dari URL
$w = $_GET['w'];
$j = $_GET['j'];
// Array akun_pengeluaran
$akun_static = ($j == 1) ? array('Pendapatan PPPOE','Pendapatan Hotspot','Hutang Jangka Pendek','Hutang Jangka Panjang','Modal Tambahan','Modal Awal','Piutang Usaha','Piutang Karyawan','Piutang Lain-lain') : array('Bayar Bandwidth','Pajak','Gaji Karyawan','Barang Habis Pakai','Pembayaran Sewa','Admin Bank','Listrik','Hutang Barang','Hutang Jangka Pendek','Hutang Jangka Panjang','Piutang Usaha','Piutang Karyawan','Piutang Lain-lain');
// Siapkan query SQL untuk mengambil nama akun berdasarkan jenis yang diterima
$sql = "SELECT nama FROM daftar_akun_transaksi WHERE jenis = :jenis";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':jenis', $j, PDO::PARAM_STR);
$stmt->execute();
// Ambil hasil query dan masukkan ke dalam array akun transaksi
$akun_transaksi = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Gabungkan akun_pengeluaran dan akun_transaksi dalam satu array
$combined_data = array_merge(
array_map(function($item) { return ['nama' => $item]; }, $akun_static),
array_map(function($item) { return ['nama' => $item['nama']]; }, $akun_transaksi)
);
// Kembalikan data dalam format JSON
echo json_encode($combined_data);
?>
+15
View File
@@ -0,0 +1,15 @@
<?php
// Include your database connection
include '../config/connect.php';
$w = $_GET['w'];
// Prepare the SQL statement to fetch the server list
$stmt = $pdo->prepare("SELECT id, nama_server FROM data_server $w");
$stmt->execute();
// Fetch the data
$servers = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Return the data as JSON
echo json_encode($servers);
?>
@@ -0,0 +1,40 @@
<?php
// Koneksi ke database
include '../config/connect.php';
// Pastikan input yang diterima dari GET aman
$id_data_server = isset($_GET['id']) ? intval($_GET['id']) : 0;
$generate_time = isset($_GET['tgl']) ? $_GET['tgl'] : '';
// Memastikan nilai yang diterima valid dan menghindari SQL injection
if ($id_data_server > 0 && !empty($generate_time)) {
$data_akumulasi = [];
// Query yang lebih aman menggunakan prepared statements
$stmt = $pdo->prepare("SELECT generate_time,
SUM(debet) as total_debet,
SUM(kredit) as total_kredit,
SUM(saldo) as total_saldo,
SUM(jumlah_voucher) as total_voucher,
SUM(jumlah_voucher_belum_aktif) as total_belum_aktif,
SUM(jumlah_voucher_aktif) as total_aktif,
SUM(jumlah_voucher_expaired) as total_expaired
FROM v_detail_agen_pascabayar
WHERE id_data_server = :id_data_server AND generate_time = :generate_time");
$stmt->bindValue(':id_data_server', $id_data_server, PDO::PARAM_INT);
$stmt->bindValue(':generate_time', $generate_time, PDO::PARAM_STR);
$stmt->execute();
// Mengambil hasil query dan menyimpannya dalam array
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$data_akumulasi[] = $row;
}
// Mengatur header untuk output JSON
header('Content-Type: application/json');
echo json_encode($data_akumulasi);
} else {
echo json_encode(['error' => 'Invalid parameters']);
}
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
// Koneksi ke database
include '../config/connect.php';
// Pastikan input yang diterima dari GET aman
$id_data_server = isset($_GET['id']) ? intval($_GET['id']) : 0;
// $generate_time = isset($_GET['tgl']) ? $_GET['tgl'] : '';
// Memastikan nilai yang diterima valid dan menghindari SQL injection
if ($id_data_server > 0) {
$data_akumulasi = [];
// Query yang lebih aman menggunakan prepared statements
$stmt = $pdo->prepare("SELECT id_data_server,
SUM(total) as total,
SUM(ditahan) as ditahan,
SUM(tersedia) as tersedia
FROM v_akumulasi_paygw
WHERE id_data_server = :id_data_server");
$stmt->bindValue(':id_data_server', $id_data_server, PDO::PARAM_INT);
// $stmt->bindValue(':generate_time', $generate_time, PDO::PARAM_STR);
$stmt->execute();
// Mengambil hasil query dan menyimpannya dalam array
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$data_akumulasi[] = $row;
}
// Mengatur header untuk output JSON
header('Content-Type: application/json');
echo json_encode($data_akumulasi);
} else {
echo json_encode(['error' => 'Invalid parameters']);
}
?>
+151
View File
@@ -0,0 +1,151 @@
<?php
// Aktifkan error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$tabel = $_POST['tabel'] ?? '';
$id = $_POST['id'] ?? '';
// Validasi input
include '../config/connect.php';
include '../config/routeros_api.class.php';
// Array untuk menyimpan daftar data yang dihapus
$deletedItems = [];
$totalDeleted = 0;
// Apabila yang dihapus adalah pelanggan
if ($tabel === 'pelanggan') {
// Ambil data pelanggan
$stmt = $pdo->prepare("SELECT id_setting_mikrotik, akun, jenis_layanan FROM pelanggan WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($data === false) {
echo json_encode(['success' => false, 'error' => 'Data pelanggan tidak ditemukan']);
exit;
}
$user = $data['akun'];
// Get Mikrotik Setting
$Mikro = $pdo->prepare("SELECT ip_address, port_api, username, password FROM setting_mikrotik WHERE id = :idset");
$Mikro->bindParam(':idset', $data['id_setting_mikrotik'], PDO::PARAM_INT);
$Mikro->execute();
$Mikrot = $Mikro->fetch(PDO::FETCH_ASSOC);
if ($Mikrot === false) {
echo json_encode(['success' => false, 'error' => 'Setting Mikrotik tidak ditemukan']);
exit;
}
$m_ip = $Mikrot['ip_address'];
$m_user = $Mikrot['username'];
$m_pass = $Mikrot['password'];
$m_port = $Mikrot['port_api'];
$API = new RouterosAPI();
$API->debug = false;
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
if ($data['jenis_layanan'] == 'Hotspot') {
$arrIDh = $API->comm("/ip/hotspot/user/getall", [
".proplist" => ".id",
"?name" => $user,
]);
if (!empty($arrIDh)) {
$API->comm("/ip/hotspot/user/remove", [
".id" => $arrIDh[0][".id"],
]);
$deletedItems[] = ['table' => 'hotspot', 'count' => 1];
$totalDeleted++;
}
} else {
$arrID = $API->comm("/ppp/secret/getall", [
".proplist" => ".id",
"?name" => $user,
]);
if (!empty($arrID)) {
$API->comm("/ppp/secret/remove", [
".id" => $arrID[0][".id"],
]);
$deletedItems[] = ['table' => 'ppp_secret', 'count' => 1];
$totalDeleted++;
}
}
// Menyiapkan perintah SQL untuk menghapus data tagihan
$sql1 = "DELETE FROM tagihan WHERE id_pelanggan = ?";
$stmt = $pdo->prepare($sql1);
$stmt->bindParam(1, $id, PDO::PARAM_INT);
$stmt->execute();
$deletedTagihanCount = $stmt->rowCount();
if ($deletedTagihanCount > 0) {
$deletedItems[] = ['table' => 'tagihan', 'count' => $deletedTagihanCount];
$totalDeleted += $deletedTagihanCount;
}
// Menyiapkan perintah SQL untuk menghapus data tiket gangguan
$sql2 = "DELETE FROM tiket_gangguan WHERE id_pelanggan = ?";
$stmt = $pdo->prepare($sql2);
$stmt->bindParam(1, $id, PDO::PARAM_INT);
$stmt->execute();
$deletedTiketCount = $stmt->rowCount();
if ($deletedTiketCount > 0) {
$deletedItems[] = ['table' => 'tiket_gangguan', 'count' => $deletedTiketCount];
$totalDeleted += $deletedTiketCount;
}
// Menyiapkan perintah SQL untuk menghapus data dari tabel utama
$sql = "DELETE FROM pelanggan WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $id, PDO::PARAM_INT);
$stmt->execute();
// Menyiapkan respons JSON
$response = [
'success' => true,
'deleted_count' => $totalDeleted,
'deleted_items' => $deletedItems
];
} else {
echo json_encode(['success' => false, 'error' => 'Mikrotik tidak terhubung']);
exit;
}
} else {
// Menyiapkan perintah SQL untuk menghapus data dari tabel lain
$sql = "DELETE FROM $tabel WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $id, PDO::PARAM_INT);
if ($stmt->execute()) {
$deletedCount = $stmt->rowCount();
$response = [
'success' => true,
'deleted_count' => $deletedCount,
'deleted_items' => [['table' => 'data yang anda hapus', 'count' => $deletedCount]]
];
} else {
$response = ['success' => false, 'error' => 'Gagal menghapus data'];
}
}
$stmt->closeCursor();
$pdo = null; // Menutup koneksi PDO
header('Content-Type: application/json');
echo json_encode($response);
} else {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Invalid request method']);
}
?>
+62
View File
@@ -0,0 +1,62 @@
<?php
include "../config/connect.php";
// Menggunakan PDO untuk koneksi database
try {
// Mengambil parameter 'dropdown', 'option', dan 'option1' dari query string
$dropdown = $_GET['dropdown'] ?? '';
$option = $_GET['option'] ?? '';
$option1 = $_GET['option1'] ?? '';
$options = [];
switch ($dropdown) {
case 'dropdown2':
// Query untuk data paket
$stmt = $pdo->prepare("SELECT id, nama FROM profile_paket WHERE id_data_server = :id_data_server AND jenis_profile = :jenis_profile AND status IS NULL");
$stmt->execute([':id_data_server' => $option, ':jenis_profile' => $option1]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
case 'dropdown3':
$stmt = $pdo->prepare("SELECT id, nama FROM user_akses WHERE FIND_IN_SET(:id_data_server, id_data_server)");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
case 'dropdown4':
// Query untuk data desa
$stmt = $pdo->prepare("SELECT id, nama FROM master_desa WHERE id_data_server = :id_data_server");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
case 'dropdown5':
// Query untuk setting mikrotik
$stmt = $pdo->prepare("SELECT id, nama FROM setting_mikrotik WHERE id_data_server = :id_data_server");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
case 'dropdown6':
// Query untuk profile tagihan
$stmt = $pdo->prepare("SELECT id, nama FROM profile_tagihan WHERE id_data_server = :id_data_server");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
default:
$options = [];
break;
}
// Mengembalikan data dalam format JSON
header('Content-Type: application/json');
echo json_encode($options);
} catch (PDOException $e) {
// Mengembalikan error dalam format JSON
header('Content-Type: application/json');
echo json_encode(['error' => $e->getMessage()]);
}
?>
+51
View File
@@ -0,0 +1,51 @@
<?php
include '../config/connect.php';
header('Content-Type: application/json');
$category_id = isset($_GET['category_id']) ? intval($_GET['category_id']) : 0;
$sql = "SELECT id,port_odp FROM pelanggan WHERE id_master_topologi = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("i", $category_id);
$stmt->execute();
$result = $stmt->get_result();
$sql2 = "SELECT jumlah_port FROM master_topologi WHERE id = ?";
$stmt2 = $con->prepare($sql2);
$stmt2->bind_param("i", $category_id);
$stmt2->execute();
$result2 = $stmt2->get_result();
$row2 = $result2->fetch_assoc();
$jum = $row2['jumlah_port'];
if ($result->num_rows > 0)
{
$angka = [];
while ($row = $result->fetch_assoc()) {
$angka[] = $row['port_odp'];
}
$ang = range(1, $jum);
$kosong=array_diff($ang,$angka);
$subcategories = [];
foreach ($kosong as $key)
{
$subcategories[] = array("id'" => $key, "port_odp" => $key);
}
}
else
{
$a = 1;
$subcategories = [];
while ($a <= $jum) {
$subcategories[] = array("id'" => $a, "port_odp" => $a);
$a ++;
}
}
echo json_encode($subcategories);
$stmt->close();
$con->close();
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
include "../config/connect.php";
// Menggunakan PDO untuk koneksi database
try {
// Mengambil parameter 'dropdown' dan 'option' dari query string
$dropdown = isset($_GET['dropdown']) ? $_GET['dropdown'] : '';
$option = isset($_GET['option']) ? $_GET['option'] : '';
$options = array();
switch ($dropdown) {
case 'dropoption2':
// Query untuk data paket
$stmt = $pdo->prepare("SELECT id_data_server, nama FROM v_list_gudang WHERE id_data_server = :id_data_server");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
default:
$options = [];
break;
}
// Mengembalikan data dalam format JSON
header('Content-Type: application/json');
echo json_encode($options);
} catch (PDOException $e) {
// Mengembalikan error dalam format JSON
header('Content-Type: application/json');
echo json_encode(['error' => $e->getMessage()]);
}
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
include "../config/connect.php";
// Menggunakan PDO untuk koneksi database
try {
// Mengambil parameter 'dropdown' dan 'option' dari query string
$dropdown = isset($_GET['dropdown']) ? $_GET['dropdown'] : '';
$option = isset($_GET['option']) ? $_GET['option'] : '';
$options = array();
switch ($dropdown) {
case 'dropoption2':
// Query untuk data paket
$stmt = $pdo->prepare("SELECT id,id_data_server, nama, keluar, sisa, start_time FROM v_jumlah_data_gudang WHERE id_data_server = :id_data_server and sisa > '0'");
$stmt->execute([':id_data_server' => $option]);
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
break;
default:
$options = [];
break;
}
// Mengembalikan data dalam format JSON
header('Content-Type: application/json');
echo json_encode($options);
} catch (PDOException $e) {
// Mengembalikan error dalam format JSON
header('Content-Type: application/json');
echo json_encode(['error' => $e->getMessage()]);
}
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
session_start();
$uploadedFiles = [];
if (isset($_SESSION['uploaded_files'])) {
foreach ($_SESSION['uploaded_files'] as $formId => $fileName) {
$uploadedFiles[] = [
'formId' => $formId,
'fileName' => $fileName
];
}
}
header('Content-Type: application/json');
echo json_encode($uploadedFiles);
?>
+45
View File
@@ -0,0 +1,45 @@
<?php
// class Listdata {
// // Properties
// public $list;
// // Methods
// function set_list($list,$kondisi='') {
// include '../bilspro/config/connect.php';
// $listd = array();
// $ambil=mysqli_query($con,"SELECT * FROM $list $kondisi");
// while ($tiap = $ambil->fetch_assoc())
// {
// $listd[] = $tiap;
// }
// $this->list = $listd;
// }
// function get_list() {
// return $this->list;
// }
// }
?>
<?php
class Listdata {
public $list;
function set_list($list, $kondisi = '') {
include '../bilspro/config/connect.php';
$listd = array();
$query = "SELECT * FROM $list $kondisi";
try {
$stmt = $pdo->prepare($query);
$stmt->execute();
while ($tiap = $stmt->fetch(PDO::FETCH_ASSOC)) {
$listd[] = $tiap;
}
$this->list = $listd;
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
function get_list() {
return $this->list;
}
}
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
// Include your database connection
include '../config/connect.php';
if (isset($_GET['id'])) {
$id = intval($_GET['id']); // Sanitize the input to prevent SQL injection
// Prepare the SQL statement to fetch the server data
$stmt = $pdo->prepare("SELECT * FROM gudang WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
// Fetch the data
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($data) {
// Return the data as JSON
echo json_encode($data);
} else {
// If no data found, return an error message
echo json_encode(['error' => 'Data not found']);
}
} else {
// If no ID is provided, return an error message
echo json_encode(['error' => 'Invalid ID']);
}
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
include '../config/connect.php';
$id_agen_voucher = isset($_GET['id']) ? intval($_GET['id']) : 0;
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
$limit = isset($_GET['limit']) ? intval($_GET['limit']) : 25;
$search = isset($_GET['search']) ? $_GET['search'] : '';
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
if ($id_agen_voucher > 0) {
$data_voucher = [];
$sql = "SELECT voucher, harga, create_time, active_time, expaired_time
FROM ganerate_voucher
WHERE id_agen_voucher = :id_agen_voucher";
if ($start_date) {
$sql .= " AND create_time >= :start_date";
}
if ($end_date) {
$sql .= " AND create_time <= :end_date";
}
if ($search) {
$sql .= " AND (
voucher LIKE :search OR
DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') LIKE :search OR
DATE_FORMAT(active_time, '%Y-%m-%d %H:%i:%s') LIKE :search OR
DATE_FORMAT(expaired_time, '%Y-%m-%d %H:%i:%s') LIKE :search
)";
}
$sql .= " ORDER BY create_time DESC LIMIT :offset, :limit";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':id_agen_voucher', $id_agen_voucher, PDO::PARAM_INT);
if ($start_date) {
$stmt->bindValue(':start_date', $start_date, PDO::PARAM_STR);
}
if ($end_date) {
$stmt->bindValue(':end_date', $end_date, PDO::PARAM_STR);
}
if ($search) {
$searchTerm = '%' . $search . '%';
$stmt->bindValue(':search', $searchTerm, PDO::PARAM_STR);
}
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->execute();
$data_voucher = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($data_voucher as &$voucher) {
foreach ($voucher as $key => &$value) {
if (is_null($value)) {
$value = '-';
}
}
}
header('Content-Type: application/json');
echo json_encode(['data' => $data_voucher]);
} else {
echo json_encode(['error' => 'Invalid parameters']);
}
?>
+53
View File
@@ -0,0 +1,53 @@
<?php
// load_data.php
include '../config/connect.php';
$offset = isset($_GET['offset']) ? (int)$_GET['offset'] : 0;
$limit = 15; // Jumlah data per permintaan
$search = isset($_GET['search']) ? $_GET['search'] : '';
$startDate = isset($_GET['start_date']) ? $_GET['start_date'] : '';
$endDate = isset($_GET['end_date']) ? $_GET['end_date'] : '';
$id_data_server = isset($_GET['ids']) ? $_GET['ids'] : '';
// Siapkan query SQL
$query = "SELECT id, nama_server, start_time, keterangan, pemasukan, status, metode_pembayaran, nama FROM v_transaksi WHERE 1=1 AND pemasukan IS NOT NULL AND id_data_server IN ($id_data_server)";
// Tambahkan kondisi pencarian
if (!empty($search)) {
$query .= " AND (nama_server LIKE :search OR start_time LIKE :search OR keterangan LIKE :search OR pemasukan LIKE :search OR metode_pembayaran LIKE :search OR status LIKE :search)";
}
// Tambahkan kondisi untuk filter tanggal
if (!empty($startDate)) {
$query .= " AND start_time >= :startDate";
}
if (!empty($endDate)) {
$query .= " AND start_time <= :endDate";
}
$query .= " ORDER BY start_time DESC, id DESC LIMIT :limit OFFSET :offset";
$stmt = $pdo->prepare($query);
// Bind parameter pencarian
if (!empty($search)) {
$stmt->bindValue(':search', '%' . $search . '%', PDO::PARAM_STR);
}
// Bind parameter filter tanggal
if (!empty($startDate)) {
$stmt->bindValue(':startDate', $startDate, PDO::PARAM_STR);
}
if (!empty($endDate)) {
$stmt->bindValue(':endDate', $endDate, PDO::PARAM_STR);
}
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalRows = $stmt->rowCount();
echo json_encode(['data' => $data, 'total' => $totalRows]);
?>
+53
View File
@@ -0,0 +1,53 @@
<?php
// load_data.php
include '../config/connect.php';
$offset = isset($_GET['offset']) ? (int)$_GET['offset'] : 0;
$limit = 15; // Jumlah data per permintaan
$search = isset($_GET['search']) ? $_GET['search'] : '';
$startDate = isset($_GET['start_date']) ? $_GET['start_date'] : '';
$endDate = isset($_GET['end_date']) ? $_GET['end_date'] : '';
$id_data_server = isset($_GET['ids']) ? $_GET['ids'] : '';
// Siapkan query SQL
$query = "SELECT id, nama_server, start_time, keterangan, pengeluaran, status, metode_pembayaran FROM v_transaksi WHERE 1=1 AND pengeluaran IS NOT NULL AND id_data_server IN ($id_data_server)";
// Tambahkan kondisi pencarian
if (!empty($search)) {
$query .= " AND (nama_server LIKE :search OR start_time LIKE :search OR keterangan LIKE :search OR pengeluaran LIKE :search OR metode_pembayaran LIKE :search OR status LIKE :search)";
}
// Tambahkan kondisi untuk filter tanggal
if (!empty($startDate)) {
$query .= " AND start_time >= :startDate";
}
if (!empty($endDate)) {
$query .= " AND start_time <= :endDate";
}
$query .= " ORDER BY start_time DESC, id DESC LIMIT :limit OFFSET :offset";
$stmt = $pdo->prepare($query);
// Bind parameter pencarian
if (!empty($search)) {
$stmt->bindValue(':search', '%' . $search . '%', PDO::PARAM_STR);
}
// Bind parameter filter tanggal
if (!empty($startDate)) {
$stmt->bindValue(':startDate', $startDate, PDO::PARAM_STR);
}
if (!empty($endDate)) {
$stmt->bindValue(':endDate', $endDate, PDO::PARAM_STR);
}
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalRows = $stmt->rowCount();
echo json_encode(['data' => $data, 'total' => $totalRows]);
?>
+79
View File
@@ -0,0 +1,79 @@
<?php
// Aktifkan error reporting untuk debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Koneksi database
include '../config/connect.php';
try {
// Parameter dari DataTable
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
$length = isset($_GET['length']) ? (int)$_GET['length'] : 10;
$idSv = isset($_GET['idsv']) ? $_GET['idsv'] : '';
$draw = isset($_GET['draw']) ? (int)$_GET['draw'] : 1;
$searchValue = $_GET['search']['value'] ?? '';
$orderColumnIndex = $_GET['order'][0]['column'] ?? 0;
$orderColumnName = $_GET['columns'][$orderColumnIndex]['data'] ?? 'id';
$orderDirection = ($_GET['order'][0]['dir'] ?? 'asc') === 'asc' ? 'ASC' : 'DESC';
// Query utama
$sql = "SELECT * FROM v_tagihan WHERE $idSv status = 'lunas'";
$params = [];
// Filter pencarian
if (!empty($searchValue)) {
$sql .= " AND (nama LIKE :search OR akun LIKE :search OR alamat LIKE :search OR verifikasi_tagihan LIKE :search OR tanggal_bayar LIKE :search OR nama_server LIKE :search OR nomor_whatsapp LIKE :search OR nama_paket LIKE :search OR jenis_layanan LIKE :search OR pelunas LIKE :search OR catatan LIKE :search OR keterangan LIKE :search)";
$params[':search'] = "%$searchValue%";
}
// Ambil total data tanpa filter
$totalQuery = "SELECT COUNT(*) FROM v_tagihan WHERE status = 'lunas'";
$totalData = $pdo->query($totalQuery)->fetchColumn();
// Ambil total data setelah filter
$totalFilteredQuery = "SELECT COUNT(*) FROM ($sql) AS filtered";
$totalFilteredStmt = $pdo->prepare($totalFilteredQuery);
foreach ($params as $key => $value) {
$totalFilteredStmt->bindValue($key, $value);
}
$totalFilteredStmt->execute();
$totalFiltered = $totalFilteredStmt->fetchColumn();
// Tambahkan pengurutan dan paginasi
$sql .= " ORDER BY $orderColumnName $orderDirection LIMIT :start, :length";
$stmt = $pdo->prepare($sql);
// Bind parameter pencarian
foreach ($params as $key => $value) {
$stmt->bindValue($key, $value);
}
// Bind limit dan offset
$stmt->bindValue(':start', $start, PDO::PARAM_INT);
$stmt->bindValue(':length', $length, PDO::PARAM_INT);
// Eksekusi query data
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Format JSON untuk DataTable
$response = [
'draw' => $draw,
'recordsTotal' => $totalData,
'recordsFiltered' => $totalFiltered,
'data' => $data
];
// Output JSON
header('Content-Type: application/json');
echo json_encode($response);
} catch (Exception $e) {
// Tangani error dan kirimkan pesan dalam format JSON
header('Content-Type: application/json');
echo json_encode([
'error' => true,
'message' => $e->getMessage()
]);
}
?>
+53
View File
@@ -0,0 +1,53 @@
<?php
// load_data.php
include '../config/connect.php';
$offset = isset($_GET['offset']) ? (int)$_GET['offset'] : 0;
$limit = 15; // Jumlah data per permintaan
$search = isset($_GET['search']) ? $_GET['search'] : '';
$startDate = ($_GET['start_date'] != '') ? $_GET['start_date'].' 00:00:00' : '';
$endDate = ($_GET['end_date'] != '') ? $_GET['end_date'].' 23:59:59' : '';
$id_data_server = isset($_GET['ids']) ? $_GET['ids'] : '';
// Siapkan query SQL
$query = "SELECT id, nama_server, start_time, keterangan, pemasukan, pengeluaran, status, metode_pembayaran, bukti_pembayaran, nama FROM v_transaksi WHERE 1=1 AND id_data_server IN ($id_data_server)";
// Tambahkan kondisi pencarian
if (!empty($search)) {
$query .= " AND (nama_server LIKE :search OR start_time LIKE :search OR keterangan LIKE :search OR pemasukan LIKE :search OR pengeluaran LIKE :search OR metode_pembayaran LIKE :search OR status LIKE :search)";
}
// Tambahkan kondisi untuk filter tanggal
if (!empty($startDate)) {
$query .= " AND start_time >= :startDate";
}
if (!empty($endDate)) {
$query .= " AND start_time <= :endDate";
}
$query .= " ORDER BY start_time DESC, id DESC LIMIT :limit OFFSET :offset";
$stmt = $pdo->prepare($query);
// Bind parameter pencarian
if (!empty($search)) {
$stmt->bindValue(':search', '%' . $search . '%', PDO::PARAM_STR);
}
// Bind parameter filter tanggal
if (!empty($startDate)) {
$stmt->bindValue(':startDate', $startDate, PDO::PARAM_STR);
}
if (!empty($endDate)) {
$stmt->bindValue(':endDate', $endDate, PDO::PARAM_STR);
}
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalRows = $stmt->rowCount();
echo json_encode(['data' => $data, 'total' => $totalRows]);
?>
+85
View File
@@ -0,0 +1,85 @@
<?php
include "../config/connect.php";
$db = mysqli_query($con,"SELECT url_whatsapp_gateway,apikey_whatsapp FROM data_server WHERE id = '$_GET[id]' ");
$data = mysqli_fetch_assoc($db);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $data['url_whatsapp_gateway'].'getState',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS => 'apiKey='.$data['apikey_whatsapp'],
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$dataArray = json_decode($response, true);
$stat = $dataArray['results']['state'];
echo "<center>";
if ($stat == "CONNECTED") {
echo '<img src="img/qrimg/connect.png" width="400px"/><br>';
}
elseif ($stat == "SERVICE_OFF") {
echo '<img src="img/qrimg/disconnect.png" width="400px"/><br>';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $data['url_whatsapp_gateway'].'serviceStart',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS => 'apiKey='.$data['apikey_whatsapp'],
));
$response = curl_exec($curl);
curl_close($curl);
}
elseif ($stat == "SERVICE_SCAN" ) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $data['url_whatsapp_gateway'].'getQR',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS => 'apiKey='.$data['apikey_whatsapp'],
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$dataArray = json_decode($response, true);
$dataqr = $dataArray['results']['qrString'];
echo '<img src="'.$dataqr.'" width="400px"/><br>';
}
else{
echo '<img src="img/qrimg/map_loader.gif" width="400px"/><br>';
}
echo "</center>";
// echo "<pre>";
// print_r($dataArray);
?>
<script>
document.getElementById('time').innerText = new Date().toLocaleTimeString();
</script>
+147
View File
@@ -0,0 +1,147 @@
<?php
// Pastikan untuk menonaktifkan tampilan error
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Termasuk file koneksi Mikrotik dan sesi
include '../config/connect.php';
include '../config/routeros_api.class.php';
include '../config/tanggal_indo.php';
session_start();
// Fungsi untuk menangani respon JSON
function sendResponse($success, $message) {
// Kirim respons JSON dengan status dan pesan
echo json_encode(['success' => $success, 'message' => $message]);
exit;
}
// Menyimpan data ke session
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Simpan data POST ke session (termasuk data Mikrotik jika ada)
foreach ($_POST as $key => $value) {
if (!empty($value)) {
$_SESSION[$key] = $value; // Menyimpan data POST ke session
}
}
$mikrotikValid = true; // Flag untuk validasi koneksi Mikrotik
// Cek apakah ada data Mikrotik yang diperlukan
if (isset($_POST['ipa'], $_POST['usm'], $_POST['psw'], $_POST['pam'])) {
try {
$API = new RouterosAPI();
$API->debug = false;
// Ambil data koneksi Mikrotik dari $_POST
$ip_address = $_POST['ipa']; // IP Mikrotik
$username = $_POST['usm']; // Username Mikrotik
$password = $_POST['psw']; // Password Mikrotik
$port_api = $_POST['pam']; // Port API Mikrotik
// Menghubungkan ke API Mikrotik menggunakan data yang dikirim melalui POST
if ($API->connect2($ip_address, $username, $password, $port_api)) {
sendResponse(true, 'Data Form Komplit, Koneksi ke Mikrotik berhasil.');
} else {
$mikrotikValid = false;
sendResponse(false, 'Koneksi ke Mikrotik gagal, silakan perbaiki koneksi.');
}
} catch (Exception $e) {
$mikrotikValid = false;
sendResponse(false, 'Terjadi kesalahan saat menghubungkan ke Mikrotik: ' . $e->getMessage());
}
}
// Jika ada data selain Mikrotik, cek validasi untuk jenis dan profile
if (isset($_POST['jenis'], $_POST['profile'])) {
try {
$API = new RouterosAPI();
$API->debug = false;
// Mengambil data koneksi Mikrotik dari session jika sudah ada
$ip_address = $_SESSION['ipa'] ?? ''; // IP Mikrotik
$username = $_SESSION['usm'] ?? ''; // Username Mikrotik
$password = $_SESSION['psw'] ?? ''; // Password Mikrotik
$port_api = $_SESSION['pam'] ?? 8728; // Default port API Mikrotik
// Cek apakah koneksi Mikrotik valid
if ($API->connect2($ip_address, $username, $password, $port_api)) {
// Cek status jenis layanan dan profile
$profileName = $_POST['profile'];
if ($_POST['jenis'] == 'PPPOE') {
// Cek profil PPPOE di Mikrotik
$profiles = $API->comm('/ppp/profile/print');
$found = false;
foreach ($profiles as $profile) {
if ($profile['name'] === $profileName) {
$found = true;
break;
}
}
if ($found) {
sendResponse(true, 'Data Form Komplit, Profile PPPOE di Mikrotik sesuai.');
} else {
sendResponse(false, 'Profil PPPOE tidak ditemukan di Mikrotik.');
}
} else {
// Cek profil Hotspot di Mikrotik
$profiles = $API->comm('/ip/hotspot/user/profile/print');
$found = false;
$profileId = null;
foreach ($profiles as $profile) {
if ($profile['name'] === $profileName) {
$profileId = $profile['.id'];
$found = true;
break;
}
}
if ($found) {
$status = ($_POST['jenishs'] == 1) ? 1 : NULL;
if ($status == 1) {
// Format interval durasi jika diperlukan
$interval = intervalFormat($_POST['durasi']);
// Skrip On Login yang akan dipasang di profil Hotspot
$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
$response = $API->comm('/ip/hotspot/user/profile/set', [
'.id' => $profileId,
'on-login' => $onLoginScript,
]);
}
sendResponse(true, 'Data Form Komplit, Profile Hotspot di Mikrotik sesuai.');
} else {
sendResponse(false, 'Profil Hotspot tidak ditemukan di Mikrotik.');
}
}
} else {
$mikrotikValid = false;
sendResponse(false, 'Koneksi ke Mikrotik gagal, silakan perbaiki koneksi.');
}
} catch (Exception $e) {
$mikrotikValid = false;
sendResponse(false, 'Terjadi kesalahan saat menghubungkan ke Mikrotik: ' . $e->getMessage());
}
}
// Kirimkan respon sukses jika data berhasil disimpan
sendResponse(true, 'Data Form Komplit.');
} else {
sendResponse(false, 'Permintaan tidak valid.');
}
?>
+112
View File
@@ -0,0 +1,112 @@
<?php
function sweetAlert($message, $type = 'success', $backurl = '') {
if ($backurl == '') {
$urlback = basename($_SERVER['REQUEST_URI']);
}
else{
//Modif String URL for Other URL
$urlback = $backurl;
}
$judul = ucfirst($type);
echo "<script src='https://cdn.jsdelivr.net/npm/sweetalert2@11'></script>";
echo "<script>
Swal.fire({
title: '$judul',
text: '$message',
icon: '$type'
}).then(function() {
window.location = '".$urlback."';
});
</script>";
}
function deleteAlert($tabel, $id, $backurl = '') {
if ($backurl == '') {
$urlback = basename($_SERVER['REQUEST_URI']);
} else {
$urlback = $backurl;
}
echo "<script src='https://cdn.jsdelivr.net/npm/sweetalert2@11'></script>";
echo "<script>
Swal.fire({
title: 'Apa kamu yakin?',
text: 'Anda tidak dapat mengembalikannya!',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batalkan'
}).then((result) => {
if (result.isConfirmed) {
// Melakukan permintaan AJAX untuk menghapus item
fetch('list_data/delete.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
'tabel': '" . addslashes($tabel) . "',
'id': '" . addslashes($id) . "'
})
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
}).then(data => {
if (data.success) {
// Menyusun daftar item yang dihapus
let deletedItemsText = '';
data.deleted_items.forEach(item => {
deletedItemsText += item.count + ' item dari ' + item.table + '\\n';
});
Swal.fire({
title: 'Dihapus!',
text: 'Data telah dihapus: \\n' + deletedItemsText,
icon: 'success'
}).then(function() {
window.location = '".$urlback."';
});
} else {
Swal.fire({
title: 'Error!',
text: data.error || 'Terjadi kesalahan saat menghapus data.',
icon: 'error'
}).then(function() {
window.location = '".$urlback."';
});
}
}).catch(error => {
Swal.fire({
title: 'Error!',
text: 'Gagal mendapatkan respons dari server: ' + error.message,
icon: 'error'
}).then(function() {
window.location = '".$urlback."';
});
});
} else {
window.location = '".$urlback."';
}
});
</script>";
}
function detailAlert($data) {
echo "<script src='https://cdn.jsdelivr.net/npm/sweetalert2@11'></script>";
echo "<script>
Swal.fire({
title: 'Gagal..!',
html: `$data`,
icon: 'error',
confirmButtonText: 'Oke'
});
</script>";
}
?>
+58
View File
@@ -0,0 +1,58 @@
<?php
include "../config/connect.php";
// try {
// $sqlData = "SELECT id, email FROM pelanggan WHERE id_data_server = '12' AND email = 'mikrotikbackupdnynet@gmail.com'";
// $stmtData = $pdo->query($sqlData);
// $no = 1;
// while ($dataambil = $stmtData->fetch(PDO::FETCH_ASSOC)) {
// $num = str_pad($no, 4, '0', STR_PAD_LEFT);
// $email = "dnynet" . $num . "@gmail.com";
// // Update data pelanggan
// // $stmt = $pdo->prepare("UPDATE pelanggan SET email = :email WHERE id = :id AND email = :old_email");
// // $stmt->bindParam(':email', $email);
// // $stmt->bindParam(':id', $dataambil['id']);
// // $stmt->bindParam(':old_email', $dataambil['email']);
// // $stmt->execute();
// echo $dataambil['id'] . " => " . $dataambil['email'] . " Jadi => " . $email . "<br>";
// $no++;
// }
// } catch (PDOException $e) {
// error_log('Database Error: ' . $e->getMessage());
// echo "Database error occurred: " . $e->getMessage();
// } catch (Exception $e) {
// error_log('General Error: ' . $e->getMessage());
// echo "An error occurred: " . $e->getMessage();
// }
try {
// Menggunakan SUBSTRING dengan indeks yang benar untuk SQL
$sqlData = "SELECT id, email, nama FROM v_tagihan WHERE id_data_server = '12' AND status = 'buat' AND SUBSTRING(email, 1, 6) = 'dnynet'";
$stmtData = $pdo->query($sqlData);
$no = 1;
while ($dataambil = $stmtData->fetch(PDO::FETCH_ASSOC)) {
$num = str_pad($no, 4, '0', STR_PAD_LEFT);
$email = "dnynet" . $num . "@gmail.com";
// Update kolom menjadi NULL
$stmt = $pdo->prepare("UPDATE tagihan SET transaction_id = NULL, transaction_link = NULL, transaction_status = NULL WHERE id = :idtag");
$stmt->bindParam(':idtag', $dataambil['id']);
$stmt->execute();
echo $dataambil['id'] . " Email => " . $dataambil['email'] . " Nama => " . $dataambil['nama'] . "<br>";
$no++;
}
} catch (PDOException $e) {
error_log('Database Error: ' . $e->getMessage());
echo "Database error occurred: " . $e->getMessage();
} catch (Exception $e) {
error_log('General Error: ' . $e->getMessage());
echo "An error occurred: " . $e->getMessage();
}
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_FILES['file']) && $_FILES['file']['error'] === UPLOAD_ERR_OK) {
$uploadDir = '../img/user/';
$fileExt = ".".pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$fileName = "bilspro_".date('YmdHis').$fileExt;
$uploadFile = $uploadDir . $fileName;
$formId = $_POST['formId'];
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
// Menyimpan nama file dalam variabel session
if (!isset($_SESSION['uploaded_files'])) {
$_SESSION['uploaded_files'] = [];
}
$_SESSION['uploaded_files'][$formId] = $fileName;
echo 'File successfully uploaded.';
} else {
echo 'Error uploading file.';
}
} else {
echo 'No file uploaded or upload error.';
}
} else {
echo 'Invalid request method.';
}
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB