Add remaining project files (exclude ignored folders)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# Please fill in the URLrewrite rules or custom Apache config here
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
const { exec } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
// Jalur ke executable PHP
|
||||
const phpExecutablePath = '/www/server/php/74/bin/php'; // Jalur yang sesuai dengan sistem Anda
|
||||
|
||||
// Daftar jalur ke file PHP
|
||||
const phpScriptPaths = [
|
||||
path.join(__dirname, 'load_pesan.php'),
|
||||
path.join(__dirname, 'create_link_flip.php')
|
||||
];
|
||||
|
||||
// Fungsi untuk menjalankan file PHP
|
||||
function runPhpScripts() {
|
||||
phpScriptPaths.forEach((phpScriptPath) => {
|
||||
console.log(`Running command: ${phpExecutablePath} ${phpScriptPath}`);
|
||||
exec(`${phpExecutablePath} ${phpScriptPath}`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error executing PHP script ${phpScriptPath}: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(`PHP script ${phpScriptPath} stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Jalankan PHP scripts segera dan kemudian setiap 5 detik
|
||||
runPhpScripts();
|
||||
setInterval(runPhpScripts, 5000);
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// include "../config/connect.php";
|
||||
// require_once '../config/routeros_api.class.php';
|
||||
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Konfigurasi MikroTik
|
||||
$ip = '103.242.106.56';
|
||||
$username = 'billdnynet2742';
|
||||
$password = 'syif@2011@reth@2012';
|
||||
$port = '8727';
|
||||
$board_id = 'S9QL-XRJ5';
|
||||
|
||||
// // Konfigurasi MikroTik
|
||||
// $ip = '103.26.176.81';
|
||||
// $username = 'ccnet0304api';
|
||||
// $password = 'ccnet0304api';
|
||||
// $port = '4426';
|
||||
// $board_id = 'ABMS-YBP77';
|
||||
|
||||
if ($API->connect2($ip, $username, $password, $port)) {
|
||||
|
||||
// === PPPoE Active ===
|
||||
$pppoe_data = $API->comm("/ppp/active/print");
|
||||
$pppoe_active = [];
|
||||
|
||||
foreach ($pppoe_data as $item) {
|
||||
$name = $item['name'] ?? '';
|
||||
$address = $item['address'] ?? '';
|
||||
if ($name && $address) {
|
||||
$pppoe_active[] = "{$name}_{$address}";
|
||||
}
|
||||
}
|
||||
|
||||
// === Hotspot Users (bukan active) ===
|
||||
$hotspot_users = $API->comm("/ip/hotspot/user/print");
|
||||
$hotspot_active = [];
|
||||
|
||||
foreach ($hotspot_users as $item) {
|
||||
$user = $item['name'] ?? '';
|
||||
$comment = $item['comment'] ?? '';
|
||||
|
||||
if ($user && $comment && strpos($comment, 'Login.') === 0) {
|
||||
$clean_comment = substr($comment, strlen('Login.'));
|
||||
$hotspot_active[] = "{$user}_{$clean_comment}";
|
||||
}
|
||||
}
|
||||
|
||||
// === System Resource ===
|
||||
$sys = $API->comm("/system/resource/print");
|
||||
$board_name = $sys[0]['board-name'] ?? '';
|
||||
$uptime = $sys[0]['uptime'] ?? '';
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
// === Final Output ===
|
||||
$response = [
|
||||
'pppoe_active' => implode('|', $pppoe_active),
|
||||
'hotspot_active' => implode('|', $hotspot_active),
|
||||
'board_name' => $board_name,
|
||||
'uptime' => $uptime
|
||||
];
|
||||
|
||||
// Pastikan $pdo tersedia
|
||||
if (!isset($pdo)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Koneksi database gagal']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Simpan ke DB
|
||||
try {
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE setting_mikrotik SET pppa = :pppa, hsa = :hsa, uptime = :ut, board_name = :bm, status = 'Connected' WHERE LEFT(board_id, 9) = :id");
|
||||
$stmt->execute([
|
||||
':pppa' => $response['pppoe_active'],
|
||||
':hsa' => $response['hotspot_active'],
|
||||
':ut' => $response['uptime'],
|
||||
':bm' => $response['board_name'],
|
||||
':id' => $board_id
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'DB Error: ' . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
// echo json_encode($response, JSON_PRETTY_PRINT);
|
||||
|
||||
} else {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Tidak dapat terhubung ke RouterOS'
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// include "../config/connect.php";
|
||||
// require_once '../config/routeros_api.class.php';
|
||||
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Konfigurasi MikroTik
|
||||
$ip = '103.188.169.125';
|
||||
$username = 'apirjn';
|
||||
$password = '@APIRJN123';
|
||||
$port = '6644';
|
||||
|
||||
if ($API->connect2($ip, $username, $password, $port)) {
|
||||
|
||||
// === PPPoE Active ===
|
||||
$pppoe_data = $API->comm("/ppp/active/print");
|
||||
$pppoe_active = [];
|
||||
|
||||
foreach ($pppoe_data as $item) {
|
||||
$name = $item['name'] ?? '';
|
||||
$address = $item['address'] ?? '';
|
||||
if ($name && $address) {
|
||||
$pppoe_active[] = "{$name}_{$address}";
|
||||
}
|
||||
}
|
||||
|
||||
// === Hotspot Users (bukan active) ===
|
||||
$hotspot_users = $API->comm("/ip/hotspot/user/print");
|
||||
$hotspot_active = [];
|
||||
|
||||
foreach ($hotspot_users as $item) {
|
||||
$user = $item['name'] ?? '';
|
||||
$comment = $item['comment'] ?? '';
|
||||
|
||||
if ($user && $comment && strpos($comment, 'Login.') === 0) {
|
||||
$clean_comment = substr($comment, strlen('Login.'));
|
||||
$hotspot_active[] = "{$user}_{$clean_comment}";
|
||||
}
|
||||
}
|
||||
|
||||
// === System Resource ===
|
||||
$sys = $API->comm("/system/resource/print");
|
||||
$board_name = $sys[0]['board-name'] ?? '';
|
||||
$uptime = $sys[0]['uptime'] ?? '';
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
// === Final Output ===
|
||||
$response = [
|
||||
'pppoe_active' => implode('|', $pppoe_active),
|
||||
'hotspot_active' => implode('|', $hotspot_active),
|
||||
'board_name' => $board_name,
|
||||
'uptime' => $uptime
|
||||
];
|
||||
|
||||
// Pastikan $pdo tersedia
|
||||
if (!isset($pdo)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Koneksi database gagal']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Simpan ke DB
|
||||
try {
|
||||
$board_id = '03FK-Q7XE1';
|
||||
$stmt = $pdo->prepare("UPDATE setting_mikrotik SET pppa = :pppa, hsa = :hsa, uptime = :ut, board_name = :bm, status = 'Connected' WHERE board_id = :id");
|
||||
$stmt->execute([
|
||||
':pppa' => $response['pppoe_active'],
|
||||
':hsa' => $response['hotspot_active'],
|
||||
':ut' => $response['uptime'],
|
||||
':bm' => $response['board_name'],
|
||||
':id' => $board_id
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'DB Error: ' . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
// echo json_encode($response, JSON_PRETTY_PRINT);
|
||||
|
||||
} else {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Tidak dapat terhubung ke RouterOS'
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Include necessary files
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
// include "../config/connect.php";
|
||||
// include "../config/routeros_api.class.php";
|
||||
|
||||
// Get parameters from command line arguments
|
||||
$m_ip = $argv[1]; // IP address
|
||||
$m_user = $argv[2]; // Username
|
||||
$m_pass = $argv[3]; // Password
|
||||
$m_port = $argv[4]; // Port
|
||||
$idsm = $argv[5]; // Mikrotik setting ID
|
||||
|
||||
// Create new RouterosAPI instance
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Connect to the router API
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
echo "\n<b>Connected to Router: {$m_ip}</b>\n";
|
||||
|
||||
// Query vouchers that need to be checked
|
||||
$ambilv1 = $pdo->prepare("SELECT id, create_time, voucher, durasi FROM v_load_cek_voucher WHERE id_setting_mikrotik = :idsm AND status_cek IS NULL LIMIT 75");
|
||||
$ambilv1->execute([':idsm' => $idsm]);
|
||||
|
||||
while ($cekv1 = $ambilv1->fetch(PDO::FETCH_ASSOC)) {
|
||||
$iddatav1 = $cekv1['id'];
|
||||
$datav1 = $cekv1['voucher'];
|
||||
$durasi = $cekv1['durasi'];
|
||||
|
||||
// Convert the 'durasi' to a valid DateInterval format
|
||||
$inter = convertDurationToInterval($durasi);
|
||||
if (!$inter) {
|
||||
echo "Invalid duration format: $durasi.\n";
|
||||
continue; // Skip this voucher if the duration is invalid
|
||||
}
|
||||
|
||||
// Check if the voucher exists in the hotspot users
|
||||
$cek = $API->comm('/ip/hotspot/user/print', ["?name" => $datav1]);
|
||||
|
||||
if ($cek) {
|
||||
// If voucher exists, check the comment
|
||||
if (isset($cek[0]['comment']) && $cek[0]['comment'] != '') {
|
||||
$activetime = processCommentDate($cek[0]['comment']);
|
||||
$Tgl = new DateTime($activetime);
|
||||
$Tgl->add($inter);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo "{$datav1} comment->{$cek[0]['comment']} active->{$activetime} exp->{$exp} => Exists\n";
|
||||
|
||||
// Update the database with active and expired time
|
||||
updateVoucher($pdo, $iddatav1, $activetime, $exp);
|
||||
} else {
|
||||
// Mark the voucher as checked
|
||||
markVoucherChecked($pdo, $iddatav1);
|
||||
}
|
||||
} else {
|
||||
// If voucher does not exist, calculate expiration time based on creation date
|
||||
$aktif = $cekv1['create_time'];
|
||||
$Tgl = new DateTime($aktif);
|
||||
$Tgl->add($inter);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo "{$datav1} active->{$aktif} exp->{$exp} => Does not exist\n";
|
||||
|
||||
// Update the database with active and expired time
|
||||
updateVoucher($pdo, $iddatav1, $aktif, $exp);
|
||||
}
|
||||
|
||||
echo "{$cekv1['voucher']}\n";
|
||||
}
|
||||
} else {
|
||||
echo "Unable to connect to router: {$m_ip}\n";
|
||||
}
|
||||
|
||||
// Disconnect the API session
|
||||
$API->disconnect();
|
||||
|
||||
// Function to convert duration string to DateInterval
|
||||
function convertDurationToInterval($durasi) {
|
||||
if (substr($durasi, -1) == 'H') {
|
||||
return new DateInterval("PT" . rtrim($durasi, 'H') . "H"); // For hours
|
||||
} elseif (substr($durasi, -1) == 'D') {
|
||||
return new DateInterval("P" . rtrim($durasi, 'D') . "D"); // For days
|
||||
} elseif (substr($durasi, -1) == 'M') {
|
||||
return new DateInterval("PT" . rtrim($durasi, 'M') . "M"); // For minutes
|
||||
} else {
|
||||
return false; // Invalid duration format
|
||||
}
|
||||
}
|
||||
|
||||
// Function to process the comment and extract valid activation time
|
||||
function processCommentDate($comment) {
|
||||
$modifiedDateTime = substr($comment, 6);
|
||||
if (substr($modifiedDateTime, 0, 4) == date('Y')) {
|
||||
return $modifiedDateTime;
|
||||
} else {
|
||||
$date = date_create_from_format("M/d/Y H:i:s", $modifiedDateTime);
|
||||
if ($date !== false) {
|
||||
return date_format($date, "Y-m-d H:i:s");
|
||||
} else {
|
||||
echo "Invalid date format: {$modifiedDateTime}\n";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to update the voucher in the database
|
||||
function updateVoucher($pdo, $iddatav1, $activetime, $exp) {
|
||||
$updateQuery = "UPDATE ganerate_voucher SET active_time = :activetime, expaired_time = :exp WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([
|
||||
':activetime' => $activetime,
|
||||
':exp' => $exp,
|
||||
':id' => $iddatav1
|
||||
]);
|
||||
}
|
||||
|
||||
// Function to mark voucher as checked in the database
|
||||
function markVoucherChecked($pdo, $iddatav1) {
|
||||
$updateQuery = "UPDATE ganerate_voucher SET status_cek = '1' WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([':id' => $iddatav1]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
// Aktifkan pelaporan kesalahan untuk pengembangan
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1); // Menampilkan kesalahan untuk pengembangan
|
||||
|
||||
function sanitizeString($input) {
|
||||
$str01 = preg_replace('/[^a-zA-Z0-9\s]/', ' ', $input);
|
||||
$str02 = preg_replace('/\s+/', ' ', $str01);
|
||||
$str03 = trim($str02); // Perbaiki penamaan variabel di sini
|
||||
return $str03;
|
||||
}
|
||||
|
||||
include "../config/connect.php";
|
||||
|
||||
try {
|
||||
$sqlData = "SELECT id, apikey_payment_gateway,url_payment_gateway FROM data_server WHERE status_payment_gateway = 'ACTIVE' AND apikey_payment_gateway != '' AND tokenkey_payment_gateway != '' AND url_payment_gateway != ''";
|
||||
$stmtData = $pdo->query($sqlData);
|
||||
|
||||
while ($dataambil = $stmtData->fetch(PDO::FETCH_ASSOC)) {
|
||||
$idds = $dataambil['id'];
|
||||
|
||||
$apiKey = $dataambil['apikey_payment_gateway'];
|
||||
$apiUrl = $dataambil['url_payment_gateway'];
|
||||
|
||||
$sqlProfil = "SELECT id, kirim_tagihan FROM profile_tagihan WHERE id_data_server = :id_data_server";
|
||||
$stmtProfil = $pdo->prepare($sqlProfil);
|
||||
$stmtProfil->bindParam(':id_data_server', $idds, PDO::PARAM_INT);
|
||||
$stmtProfil->execute();
|
||||
|
||||
while ($dataprofil = $stmtProfil->fetch(PDO::FETCH_ASSOC)) {
|
||||
$sql = "SELECT * FROM v_tagihan WHERE id_data_server = :idds AND id_profile_tagihan = :idpt AND status = 'buat' AND transaction_id IS NULL AND transaction_link IS NULL AND transaction_status IS NULL AND verifikasi_tagihan > 1000 AND RIGHT(email, 10) = '@gmail.com'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([':idds' => $idds, ':idpt' => $dataprofil['id']]);
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
echo $dataprofil['id'];
|
||||
// Pastikan $data['limit_pembayaran'] ada dan tidak kosong
|
||||
if ($data && isset($data['limit_pembayaran'])) {
|
||||
$day = str_pad($dataprofil['kirim_tagihan'], 2, '0', STR_PAD_LEFT);
|
||||
$cekkirim = substr($data['limit_pembayaran'], 0, 8) . $day;
|
||||
|
||||
// Pastikan format tanggal valid
|
||||
try {
|
||||
$date = new DateTime($cekkirim);
|
||||
$date->modify('-1 day');
|
||||
$cektanggal = $date->format('Y-m-d');
|
||||
$sekarang = date('Y-m-d');
|
||||
|
||||
if ($sekarang == $cektanggal) {
|
||||
// Kode untuk meng-create link payment gateway
|
||||
require '../payment/flip/Flip/Transaction.php';
|
||||
$flip = new FlipPaymentGateway($apiKey, $apiUrl);
|
||||
|
||||
$response = $flip->createBill(
|
||||
sanitizeString($data['keterangan']),
|
||||
sanitizeString($data['verifikasi_tagihan']),
|
||||
$data['email'],
|
||||
sanitizeString($data['nama']),
|
||||
sanitizeString($data['nomor_whatsapp']),
|
||||
sanitizeString($data['alamat'])
|
||||
);
|
||||
|
||||
if (!empty($response['link_id']) && !empty($response['link_url']) && !empty($response['status'])) {
|
||||
$transaction_id = $response['link_id'];
|
||||
$transaction_link = $response['link_url'];
|
||||
$transaction_status = $response['status'];
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE tagihan SET transaction_id = :transaction_id, transaction_link = :transaction_link, transaction_status = :transaction_status WHERE id = :idtag");
|
||||
$stmt->bindParam(':transaction_id', $transaction_id);
|
||||
$stmt->bindParam(':transaction_link', $transaction_link);
|
||||
$stmt->bindParam(':transaction_status', $transaction_status);
|
||||
$stmt->bindParam(':idtag', $data['id']);
|
||||
$stmt->execute();
|
||||
echo " =>Success ".$data['nama'].", SV :".$data['nama_server'];
|
||||
} else {
|
||||
echo " =>Error ".$data['nama'].", SV :".$data['nama_server'];
|
||||
print_r($response);
|
||||
}
|
||||
} else {
|
||||
echo "No Data";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Tanggal tidak valid: " . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
echo "Data tidak ditemukan";
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "../config/connect.php";
|
||||
|
||||
try {
|
||||
// Ambil tahun dari query string, jika tidak ada gunakan tahun saat ini
|
||||
$tahun = isset($_GET['year']) && is_numeric($_GET['year']) ? (int)$_GET['year'] : (int)date('Y');
|
||||
$sqldata = isset($_GET['i']) ? trim($_GET['i']) : '';
|
||||
$sqlid = isset($_GET['d']) ? trim($_GET['d']) : '';
|
||||
|
||||
// Menentukan filter tambahan berdasarkan input
|
||||
$sqlkar = ($sqlid === 'all' || $sqlid === '') ? '' : "AND id_penyelesai_tiket = :id_penyelesai";
|
||||
|
||||
// Menyiapkan query SQL
|
||||
$query = "
|
||||
SELECT
|
||||
SUM(jumlah_tiket) AS jumlah_tiket,
|
||||
CASE WHEN COUNT(waktu) > 0 THEN SUM(rata_rata_sebelum) / COUNT(waktu) / 60 ELSE 0 END AS rata_rata_sebelum,
|
||||
CASE WHEN COUNT(waktu) > 0 THEN SUM(rata_rata_sesudah) / COUNT(waktu) / 60 ELSE 0 END AS rata_rata_sesudah,
|
||||
SUM(tiket_jalur) AS tiket_jalur,
|
||||
SUM(tiket_lain) AS tiket_lain,
|
||||
SUM(bobot) AS bobot,
|
||||
waktu
|
||||
FROM
|
||||
v_akumulasi_kinerja_by_tiket
|
||||
WHERE
|
||||
SUBSTRING(waktu, 1, 4) = :tahun
|
||||
$sqldata
|
||||
$sqlkar
|
||||
GROUP BY
|
||||
waktu
|
||||
";
|
||||
|
||||
// Persiapan dan eksekusi query
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->bindParam(':tahun', $tahun, PDO::PARAM_INT);
|
||||
if (!empty($sqlkar)) {
|
||||
$stmt->bindParam(':id_penyelesai', $sqlid, PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
$jumbulan = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Inisialisasi array untuk menyimpan data bulanan
|
||||
$jumTiket = array_fill(0, 12, 0);
|
||||
$rata2sebelum = array_fill(0, 12, 0);
|
||||
$rata2sesudah = array_fill(0, 12, 0);
|
||||
$tiketJalur = array_fill(0, 12, 0);
|
||||
$tiketLain = array_fill(0, 12, 0);
|
||||
$bobot = array_fill(0, 12, 0);
|
||||
$bulan = [];
|
||||
|
||||
// Mengisi data ke dalam array berdasarkan bulan
|
||||
foreach ($jumbulan as $row) {
|
||||
$monthIndex = (int)date('n', strtotime($row['waktu'])) - 1; // Bulan ke indeks array (0-11)
|
||||
$jumTiket[$monthIndex] = (int)$row['jumlah_tiket'];
|
||||
$rata2sebelum[$monthIndex] = '-'.(float)$row['rata_rata_sebelum'];
|
||||
$rata2sesudah[$monthIndex] = '-'.(float)$row['rata_rata_sesudah'];
|
||||
$tiketJalur[$monthIndex] = (int)$row['tiket_jalur'];
|
||||
$tiketLain[$monthIndex] = (int)$row['tiket_lain'];
|
||||
$bobot[$monthIndex] = (int)$row['bobot'];
|
||||
}
|
||||
|
||||
// Buat array bulan untuk label
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
$bulan[] = sprintf('%s-%02d', $tahun, $i + 1); // format Y-m
|
||||
}
|
||||
|
||||
// Mengemas data menjadi array untuk JSON
|
||||
$data = [
|
||||
'bulan' => $bulan, // data bulan yang ditampilkan di label
|
||||
'jumlah' => $jumTiket,
|
||||
'createToProses' => $rata2sebelum,
|
||||
'prosesToClose' => $rata2sesudah,
|
||||
'tiketJalur' => $tiketJalur,
|
||||
'tiketLain' => $tiketLain,
|
||||
'bobot' => $bobot
|
||||
];
|
||||
|
||||
// Mengirimkan data sebagai JSON
|
||||
echo json_encode($data);
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Jika terjadi kesalahan, kirim pesan error sebagai JSON
|
||||
http_response_code(500); // Kirim kode status HTTP 500
|
||||
echo json_encode(['error' => 'Terjadi kesalahan pada server.', 'details' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "../config/connect.php";
|
||||
|
||||
// Ambil tahun dan bulan dari query string, jika tidak ada gunakan tahun dan bulan saat ini
|
||||
$tahun = date('Y');
|
||||
$bulan = isset($_GET['m']) ? $_GET['m'] : date('m');
|
||||
$id = isset($_GET['i']) ? $_GET['i'] : '6258';
|
||||
|
||||
// Mengambil data dari database berdasarkan tahun dan bulan
|
||||
$stmt = $pdo->prepare("SELECT * FROM monitoring_pelanggan WHERE id_pelanggan = :id AND YEAR(waktu) = :tahun AND MONTH(waktu) = :bulan");
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':tahun', $tahun);
|
||||
$stmt->bindParam(':bulan', $bulan);
|
||||
$stmt->execute();
|
||||
$monitor = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Memeriksa apakah data ditemukan
|
||||
if (!empty($monitor)) {
|
||||
$status = [];
|
||||
$waktu = [];
|
||||
|
||||
$status[] = 4;
|
||||
$waktu[] = date('Y-'.$bulan.'-01 00:00:01');
|
||||
|
||||
$days = date('d') - 1; // Mendapatkan jumlah hari dalam bulan
|
||||
|
||||
// Saya ingin data per harinya ada sesuai dengan status hari sebelumnya
|
||||
for ($day = 2; $day <= $days; $day++) {
|
||||
$wak = date('Y-'.$bulan.'-'.str_pad($day, 2, '0', STR_PAD_LEFT));
|
||||
$found = false;
|
||||
|
||||
foreach ($monitor as $row) {
|
||||
if (substr($row['waktu'], 0, 10) == $wak) {
|
||||
$status[] = $row['status'];
|
||||
$waktu[] = $row['waktu'];
|
||||
$found = true;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$status[] = 4; // Status default
|
||||
$waktu[] = $wak . ' 00:00:00'; // Waktu default
|
||||
$status[] = 4; // Status default
|
||||
$waktu[] = $wak . ' 09:00:00'; // Waktu default
|
||||
$status[] = 4; // Status default
|
||||
$waktu[] = $wak . ' 18:00:00'; // Waktu default
|
||||
}
|
||||
}
|
||||
|
||||
// Tambahkan status dan waktu saat ini
|
||||
$status[] = 4; // Menambahkan status sekarang
|
||||
if (date('m') == $bulan) {
|
||||
$waktu[] = date('Y-m-d H:i:s'); // Menambahkan waktu saat ini
|
||||
} else {
|
||||
$date = new DateTime('last day of previous month');
|
||||
$waktu[] = $date->format('Y-m-d 00:00:00');
|
||||
}
|
||||
|
||||
// Mengisi data ke dalam array hasil
|
||||
$data = [
|
||||
'status' => $status,
|
||||
'waktu' => $waktu,
|
||||
];
|
||||
} else {
|
||||
// Jika tidak ada data ditemukan
|
||||
$d1 = date('Y-'.$bulan.'-01 00:00:01');
|
||||
$d2 = date('Y-'.$bulan.'-t H:i:s'); // Menggunakan 't' untuk hari terakhir dalam bulan
|
||||
$data = [
|
||||
'status' => [4, 4],
|
||||
'waktu' => [$d1, $d2],
|
||||
];
|
||||
}
|
||||
|
||||
// Mengirimkan data sebagai JSON
|
||||
echo json_encode($data);
|
||||
?>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "../config/connect.php";
|
||||
|
||||
// Ambil tahun dari query string, jika tidak ada gunakan tahun saat ini
|
||||
$tahun = isset($_GET['year']) ? $_GET['year'] : date('Y');
|
||||
$sqldata = isset($_GET['s']) ? $_GET['s'] : '';
|
||||
|
||||
// Mengambil data dari database berdasarkan tahun
|
||||
$stmt = $pdo->prepare("SELECT SUM(pemasukan) AS pemasukan, SUM(pengeluaran) AS pengeluaran, SUM(saldo) AS saldo, bulan AS bulan FROM v_jumlah_transaksi_bulanan WHERE SUBSTRING(bulan, 1, 4) = :tahun $sqldata GROUP BY bulan");
|
||||
$stmt->bindParam(':tahun', $tahun, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$jumbulan = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Inisialisasi array untuk menyimpan pemasukan, pengeluaran, dan saldo
|
||||
$pemasukan = array_fill(0, 12, 0); // Inisialisasi dengan 0 untuk semua bulan
|
||||
$pengeluaran = array_fill(0, 12, 0);
|
||||
$saldo = array_fill(0, 12, 0);
|
||||
$bulan = [];
|
||||
|
||||
// Mengisi data ke dalam array
|
||||
foreach ($jumbulan as $row) {
|
||||
$monthIndex = (int) date('n', strtotime($row['bulan'])) - 1; // Ubah bulan ke indeks array (0-11)
|
||||
$pemasukan[$monthIndex] = (int) $row['pemasukan'];
|
||||
$pengeluaran[$monthIndex] = (int) $row['pengeluaran'];
|
||||
$saldo[$monthIndex] = (int) $row['saldo'];
|
||||
}
|
||||
|
||||
// Buat array bulan untuk label
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
$bulan[] = sprintf('%s-%02d', $tahun, $i + 1); // format Y-m
|
||||
}
|
||||
|
||||
// Mengemas data menjadi array untuk JSON
|
||||
$data = [
|
||||
'bulan' => $bulan, // data bulan yang ditampilkan di label
|
||||
'pemasukan' => $pemasukan,
|
||||
'pengeluaran' => $pengeluaran,
|
||||
'saldo' => $saldo
|
||||
];
|
||||
|
||||
// Mengirimkan data sebagai JSON
|
||||
echo json_encode($data);
|
||||
?>
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"apps": [
|
||||
{
|
||||
"name": "bilspro",
|
||||
"script": "./autoload.js",
|
||||
"instances": 1,
|
||||
"autorestart": true,
|
||||
"watch": false,
|
||||
"max_memory_restart": "1G",
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"env_production": {
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
include "../config/connect.php";
|
||||
|
||||
try {
|
||||
// Ambil data user
|
||||
$stmt = $pdo->prepare("SELECT id, nama, password FROM user_akses");
|
||||
$stmt->execute();
|
||||
|
||||
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo $data['id'] . " " . $data['nama'] . " " . $data['password'] . "<br>";
|
||||
|
||||
// Hash password
|
||||
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
|
||||
// Update password yang sudah di-hash
|
||||
$updateStmt = $pdo->prepare("UPDATE user_akses SET password = :password WHERE id = :id");
|
||||
$updateStmt->bindParam(':password', $hashedPassword);
|
||||
$updateStmt->bindParam(':id', $data['id']);
|
||||
$updateStmt->execute();
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Tangani kesalahan
|
||||
echo "Terjadi kesalahan: " . $e->getMessage();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
// include "../config/connect.php";
|
||||
// Ambil data dari tabel setting_mikrotik
|
||||
$stmt = $pdo->prepare("SELECT id, hsa FROM setting_mikrotik WHERE hsa != ''");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
$id = $row['id'];
|
||||
$hsa = $row['hsa'];
|
||||
|
||||
// Ambil data pelanggan berdasarkan id_setting_mikrotik
|
||||
$stmtPel = $pdo->prepare("SELECT id, voucher, durasi FROM v_ganerate_voucher WHERE id_setting_mikrotik = :id AND active_time IS NULL");
|
||||
$stmtPel->bindValue(':id', $id);
|
||||
$stmtPel->execute();
|
||||
$pel = $stmtPel->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Proses setiap data voucher
|
||||
foreach ($pel as $key) {
|
||||
$voucher = $key['voucher'];
|
||||
$durasi = $key['durasi'];
|
||||
|
||||
if (preg_match("/" . preg_quote($voucher, '/') . "/i", $hsa)) {
|
||||
// Cari nama awalan dan ambil bagian data setelahnya
|
||||
$cari00 = stristr($hsa, $voucher);
|
||||
// Ambil data hingga tanda '|'
|
||||
$cari02 = strtok($cari00, "|");
|
||||
// Rubah ke array
|
||||
$data = explode("_", $cari02);
|
||||
|
||||
// Pastikan ada cukup elemen di $data
|
||||
if (count($data) < 2) {
|
||||
continue; // Lewati jika tidak ada cukup data
|
||||
}
|
||||
|
||||
// Hapus titik dan periksa format tanggal
|
||||
$modifiedDateTime = str_replace('.', ' ', trim($data[1]));
|
||||
echo "Voucher: " . $data[0] . "<br>";
|
||||
|
||||
if (substr($modifiedDateTime, 0, 4) == date('Y')) {
|
||||
$activetime = $modifiedDateTime;
|
||||
} else {
|
||||
$date = date_create_from_format("M/d/Y H:i:s", $modifiedDateTime);
|
||||
if ($date !== false) {
|
||||
$activetime = date_format($date, "Y-m-d H:i:s");
|
||||
} else {
|
||||
echo "Format tanggal tidak valid: $modifiedDateTime<br>";
|
||||
continue; // Lewati iterasi jika format tidak valid
|
||||
}
|
||||
}
|
||||
|
||||
echo "Aktif => " . $activetime . "<br>";
|
||||
|
||||
if (substr($durasi, -1) == 'H') {
|
||||
$inter = "PT" . $durasi; // Untuk durasi dalam jam
|
||||
} elseif (substr($durasi, -1) == 'D') {
|
||||
$inter = "P" . $durasi; // Untuk durasi dalam hari
|
||||
} elseif(substr($durasi, -1) == 'M') {
|
||||
$inter = "P" . $durasi;
|
||||
} else {
|
||||
// Tangani kasus jika format durasi tidak valid
|
||||
echo "Format durasi tidak valid.<br>";
|
||||
$inter = null; // Atau tentukan nilai default
|
||||
}
|
||||
|
||||
// Menggunakan DateInterval untuk menambahkan durasi
|
||||
$Tgl = new DateTime($activetime);
|
||||
$interval = new DateInterval($inter); // Durasi dalam jam
|
||||
$Tgl->add($interval);
|
||||
$Expaired = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo "Expaired => " . $Expaired . "<br>";
|
||||
|
||||
$stmtUpdate = $pdo->prepare("UPDATE ganerate_voucher SET active_time = :active_time, expaired_time = :expaired_time WHERE id = :idgen");
|
||||
$stmtUpdate->execute([
|
||||
':active_time' => $activetime,
|
||||
':expaired_time' => $Expaired,
|
||||
':idgen' => $key['id']
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "No data found.<br>";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,50 @@
|
||||
SV_Cikembar_Utama Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_BojongKerta Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_Permata_Sampora Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_Kingnet_Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_CC-Net_Cipicung Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_Nusaina_Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_Diamond Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_22P Net Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01SV_Nettizen_Segaranten Data pelanggan tidak ada
|
||||
2025-07-05 14:09:01SV-DNY-Net-1 Data pelanggan tidak ada
|
||||
2025-07-05 14:49:01SV_NTA_2_Pasawahan Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_NTA_1 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV-Cicukang Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO-Bumdes-Mekarmanah Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO-Pak-Kholiq Data pelanggan tidak ada
|
||||
2025-07-05 14:54:01RO-Dendrit-Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
LJN.NS.CSR.NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
IVVINET-CBD Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01QONNET Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01Mikrotik_X86 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Mikrotik_BSW_1 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Mikrotik_Alea Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
STANG Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
UNIX-NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
BTR CIEMAS Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_NTA_2_TBL Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
MULYANAJAYA Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
PERWASIM.NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_MELDINA Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_LIPPY Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_Asep Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
BATUNUNGGAL Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
PADINET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RAGILNET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_Sukasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_Wargasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
LJN_AGUNG Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RNET-CMS Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
DCN-GB-CCR Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01coba Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
412NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
brf Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
BMSNET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
purabaya Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
DCN-CO-GX4 Data pelanggan tidak ada
|
||||
2025-07-05 14:39:01MIKROTIK GX4 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO - Netborhood Wifi Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV-DNY-Net-2 Data pelanggan tidak ada
|
||||
2025-07-05 14:49:01DNY-Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/whatsapp_api.php";
|
||||
|
||||
// include "../config/connect.php";
|
||||
// include "../config/whatsapp_api.php";
|
||||
|
||||
// Ambil data dari tabel setting_mikrotik
|
||||
$stmt = $pdo->prepare("SELECT id, pppa, id_data_server, nama FROM setting_mikrotik ");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
$mik = $row['nama'];
|
||||
|
||||
// Kirim Pesan Koneksi Off ke Pelanggan
|
||||
// Berdasarkan data server yang mengaktifkan pesan tersebut dan sesuai interval nya
|
||||
|
||||
$stmtSV = $pdo->prepare("SELECT status_koneksi_off, interval_koneksi_off FROM data_server WHERE id = :idserver");
|
||||
$stmtSV->bindValue(':idserver', $row['id_data_server']);
|
||||
$stmtSV->execute();
|
||||
$SV = $stmtSV->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($SV['status_koneksi_off'] === 'Aktif' && !empty($SV['interval_koneksi_off'])) {
|
||||
// Konversi interval koneksi off ke integer
|
||||
$intervalMenit = (int)$SV['interval_koneksi_off'];
|
||||
|
||||
// Hitung batas waktu berdasarkan interval
|
||||
$batasWaktu = date('Y-m-d H:i:s', strtotime("-$intervalMenit minutes"));
|
||||
|
||||
// Siapkan dan eksekusi query untuk mengambil pelanggan
|
||||
$stmtInt = $pdo->prepare("SELECT id, id_data_server, nomor_whatsapp FROM pelanggan WHERE pesan_off = '0' AND status = 'aktif' AND id_setting_mikrotik = :id AND time_update < :batasWaktu");
|
||||
$stmtInt->bindValue(':id', $row['id']);
|
||||
$stmtInt->bindValue(':batasWaktu', $batasWaktu);
|
||||
$stmtInt->execute();
|
||||
$Intv = $stmtInt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($Intv) {
|
||||
foreach ($Intv as $Val) {
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Create_Pesan($Val['id_data_server'], $Val['id'], 'pesan_koneksi_off');
|
||||
$Pesan = $APIwa->Get_Pesan();
|
||||
$APIwa->Send_Pesan($Val['id_data_server'], 'sendMessage', [$Val['nomor_whatsapp']], $Pesan);
|
||||
|
||||
$stmtInt = $pdo->prepare("UPDATE pelanggan SET pesan_off = '1' WHERE id = :id");
|
||||
$stmtInt->bindValue(':id', $Val['id']);
|
||||
$stmtInt->execute();
|
||||
|
||||
echo $mik." Pesan ke => ".$Val['nomor_whatsapp']." => ".$batasWaktu."\n";
|
||||
}
|
||||
} else {
|
||||
echo $mik." Data pelanggan tidak ada\n".$batasWaktu;
|
||||
}
|
||||
} else {
|
||||
echo $mik." Status koneksi tidak aktif atau interval tidak tersedia.\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "No data found.\n";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
Successfully started background process for IP: 103.26.176.93
|
||||
Started parallel processes for checking vouchers. => 2025-07-05 15:09:02
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
|
||||
// Include necessary files
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
// include "../config/connect.php";
|
||||
// include "../config/routeros_api.class.php";
|
||||
|
||||
// Fetch data from the database
|
||||
$query = "SELECT * FROM v_load_api_cek_voucher";
|
||||
$set1 = $pdo->query($query);
|
||||
|
||||
if ($set1->rowCount() > 0) {
|
||||
$processes = [];
|
||||
|
||||
while ($pset = $set1->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Get connection details for the router
|
||||
$m_ip = $pset['ip_address'];
|
||||
$m_user = $pset['username'];
|
||||
$m_pass = $pset['password'];
|
||||
$m_port = $pset['port_api'];
|
||||
$idsm = $pset['id_setting_mikrotik'];
|
||||
|
||||
// Prepare the command for each router
|
||||
$command = "php /www/wwwroot/bilspro/load/check_voucher.php {$m_ip} {$m_user} {$m_pass} {$m_port} {$idsm} > /dev/null 2>&1 &";
|
||||
|
||||
// Execute the command in background
|
||||
exec($command, $output, $return_var);
|
||||
|
||||
// Check if there was an issue with exec
|
||||
if ($return_var !== 0) {
|
||||
echo "Error executing command for IP: {$m_ip}\n";
|
||||
} else {
|
||||
echo "Successfully started background process for IP: {$m_ip}\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "Started parallel processes for checking vouchers. => ". date('Y-m-d H:i:s');
|
||||
} else {
|
||||
// Reset status_cek to NULL
|
||||
$updateQuery = "UPDATE ganerate_voucher SET status_cek = NULL WHERE status_cek = '1'";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
if ($stmt->execute()) {
|
||||
echo "Update ALL to NULL successful\n";
|
||||
} else {
|
||||
echo "Error updating status_cek to NULL\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
// Aktifkan pelaporan kesalahan untuk pengembangan
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0); // Tampilkan kesalahan saat pengembangan
|
||||
|
||||
// Menghubungkan ke database
|
||||
include "../config/connect.php";
|
||||
include "../config/tanggal_indo.php";
|
||||
include "../config/routeros_api.class.php";
|
||||
include "../config/whatsapp_api.php";
|
||||
|
||||
try {
|
||||
// Ambil semua apiKey_whatsapp yang tidak kosong
|
||||
$sqlData = "SELECT api_key FROM v_key_load_pesan";
|
||||
$stmtData = $pdo->query($sqlData);
|
||||
|
||||
// Loop melalui setiap apiKey_whatsapp
|
||||
while ($dataambil = $stmtData->fetch(PDO::FETCH_ASSOC)) {
|
||||
$keyapi = $dataambil['api_key'];
|
||||
|
||||
// Ambil pesan dengan status 'PENDING' dan api_key sesuai
|
||||
$sql = "SELECT * FROM v_master_pesan WHERE api_key = :apiKey AND status ='PENDING' ";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([':apiKey' => $keyapi]);
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if($data) {
|
||||
$jenis = $data['jenis_pesan'];
|
||||
$apiurl = $data['api_url'];
|
||||
|
||||
// Siapkan data untuk dikirim berdasarkan jenis pesan
|
||||
$datapost = '';
|
||||
if ($jenis == "sendMessage") {
|
||||
$datapost = http_build_query([
|
||||
'apiKey' => $data['api_key'],
|
||||
'phone' => $data['nomor'],
|
||||
'message' => $data['pesan']
|
||||
]);
|
||||
} elseif ($jenis == "sendMediaFromUrl") {
|
||||
$datapost = http_build_query([
|
||||
'apiKey' => $data['api_key'],
|
||||
'phone' => $data['nomor'],
|
||||
'url_file' => $data['url_file'],
|
||||
'as_document' => '0',
|
||||
'caption' => $data['pesan']
|
||||
]);
|
||||
} else {
|
||||
continue; // Skip jika jenis tidak dikenali
|
||||
}
|
||||
|
||||
// echo $datapost;
|
||||
// echo $datapost;
|
||||
|
||||
// Inisialisasi cURL
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $apiurl . $jenis,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $datapost,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Content-Length: ' . strlen($datapost)
|
||||
),
|
||||
));
|
||||
|
||||
// Eksekusi cURL dan tangani kesalahan
|
||||
$response = curl_exec($curl);
|
||||
if (curl_errno($curl)) {
|
||||
error_log('cURL Error: ' . curl_error($curl));
|
||||
curl_close($curl);
|
||||
continue; // Skip ke data berikutnya jika ada error
|
||||
}
|
||||
curl_close($curl);
|
||||
|
||||
// Decode respons JSON
|
||||
$rdata = json_decode($response);
|
||||
// print_r($rdata)."<br>";
|
||||
|
||||
// Periksa apakah respons valid
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
error_log('JSON Decode Error: ' . json_last_error_msg());
|
||||
$rdata = (object) ['code' => '200', 'results' => (object) []]; // Anda bisa menyesuaikan ini jika perlu
|
||||
}
|
||||
|
||||
// Update status berdasarkan respons
|
||||
// $status = (isset($rdata->code) && $rdata->code === '200') ? 'TERKIRIM' : 'GAGAL';
|
||||
if($rdata->code == 200){
|
||||
$status = 'TERKIRIM';
|
||||
} else {
|
||||
$status = 'GAGAL';
|
||||
}
|
||||
|
||||
echo $rdata->code; // Mengakses 'code' dengan benar
|
||||
echo " ".$status;
|
||||
|
||||
|
||||
// Update status di database
|
||||
$updateStmt = $pdo->prepare("UPDATE master_pesan SET status = :status WHERE id = :id");
|
||||
$updateStmt->execute([
|
||||
':status' => $status,
|
||||
':id' => $data['id']
|
||||
]);
|
||||
}
|
||||
}
|
||||
// Ambil data tagihan yang status transaksinya SUCCESSFUL
|
||||
$datetime = date('Y-m-d H:i:s', time() - 60); // waktu 60 detik yang lalu
|
||||
$stmt = $pdo->prepare("SELECT * FROM v_tagihan_flip_lunas WHERE last_mikrotik_connect > :datetime");
|
||||
$stmt->execute(['datetime' => $datetime]);
|
||||
$tagihan = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
// Pastikan data tagihan ditemukan
|
||||
if ($tagihan) {
|
||||
|
||||
// Ambil detail tagihan
|
||||
$user = $tagihan['akun'];
|
||||
$idtag = $tagihan['id'];
|
||||
$nama = $tagihan['nama']; // Contoh nama
|
||||
$nominal = $tagihan['verifikasi_tagihan']; // Contoh nominal
|
||||
$keterangan = 'Pembayaran ' . $tagihan['keterangan']; // Contoh keterangan
|
||||
$invoice = 'kwitansi_' . date('Ymd') . $idtag . '.png'; // Nama file output
|
||||
$paketint = $tagihan['nama_paket'];
|
||||
$jumtagihan = 'Rp. '.number_format($tagihan['jumlah_tagihan'], 0, ',', '.');
|
||||
$ppn = 'Rp. '.number_format($tagihan['ppn'], 0, ',', '.');
|
||||
$subsidi = 'Rp. '.number_format($tagihan['kode_unik'], 0, ',', '.');
|
||||
$tanggal = $tagihan['tanggal_bayar'];
|
||||
$metode = "API Payment";
|
||||
$kodeunik = $tagihan['kode_unik'];
|
||||
|
||||
// Buat gambar dari file PNG yang ada
|
||||
$stmt = $pdo->prepare("SELECT backround_kwitansi, kabupaten FROM data_server WHERE id = :id");
|
||||
$stmt->bindParam(':id', $tagihan['id_data_server'], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$gambarKwitansi = '../img/' . $result['backround_kwitansi']; // Pastikan variabel gambar ada
|
||||
|
||||
// Membuat gambar dari file PNG
|
||||
$img = imagecreatefrompng($gambarKwitansi);
|
||||
// Buat beberapa warna
|
||||
$white = imagecolorallocate($img, 245, 245, 245);
|
||||
$black = imagecolorallocate($img, 0, 0, 0);
|
||||
$orange = imagecolorallocate($img, 0, 0, 128);
|
||||
$fontPath = '../dist/X_10x20_LE.gdf';
|
||||
$font = imageloadfont($fontPath);
|
||||
$line = '_____________________________________________________________________________________';
|
||||
|
||||
// Menambahkan teks ke gambar
|
||||
// imagestring($img, $font, 320, 30, 'KWITANSI PEMBAYARAN', $black);
|
||||
// imagestring($img, 5, 650, 52, 'No. ' . date('Ymd') . $idtag, $black);
|
||||
// imagestring($img, 2, 650, 67, 'Tanggal pembayaran', $black);
|
||||
// imagestring($img, 2, 650, 82, formatIndo(date('Y-m-d'), 'd F Y'), $black);
|
||||
// imagestring($img, 5, 20, 91, $line, $orange);
|
||||
// imagestring($img, 5, 20, 95, $line, $orange);
|
||||
// imagestring($img, 4, 30, 125, 'Telah Diterima Dari', $black);
|
||||
// imagestring($img, 5, 200, 125, ': ' . $nama, $black);
|
||||
// imagestring($img, 4, 30, 150, 'Sejumlah Uang', $black);
|
||||
// imagestring($img, 4, 200, 150, ': ' . terbilang($nominal) . ' rupiah', $black);
|
||||
// imagestring($img, 4, 30, 175, 'Untuk Pembayaran', $black);
|
||||
// imagestring($img, 4, 200, 175, ':', $black);
|
||||
// imagestring($img, 5, 100, 200, $keterangan, $black);
|
||||
// imagestring($img, 5, 20, 245, $line, $orange);
|
||||
// imagestring($img, 5, 50, 280, '___________________________', $orange);
|
||||
// imagestring($img, $font, 70, 300, 'Nominal : Rp. ' . number_format($nominal, 0, ',', '.'), $black);
|
||||
// imagestring($img, 5, 50, 310, '___________________________', $orange);
|
||||
// imagestring($img, 4, 535, 280, $result['kabupaten'] . ', ' . formatIndo(date('Y-m-d'), 'd F Y'), $black);
|
||||
|
||||
$img = imagecreatefrompng($gambarKwitansi);
|
||||
// Buat beberapa warna
|
||||
$white = imagecolorallocate($img, 245, 245, 245);
|
||||
$black = imagecolorallocate($img, 0, 0, 0);
|
||||
$orange = imagecolorallocate($img, 0, 0, 128);
|
||||
$fontPath = '../dist/X_10x20_LE.gdf';
|
||||
$font = imageloadfont($fontPath);
|
||||
$line = '_____________________________________________________________________________________';
|
||||
imagestring($img, $font, 320, 30, 'KWITANSI PEMBAYARAN', $black);
|
||||
imagestring($img, 3, 580, 30, 'No Faktur', $black);
|
||||
imagestring($img, 3, 670, 30, ': '.date('Ymd').$idtag, $black);
|
||||
imagestring($img, 3, 580, 50, 'Tanggal', $black);
|
||||
imagestring($img, 3, 670, 50, ': '.formatIndo(date('Y-m-d'), 'd F Y'), $black);
|
||||
imagestring($img, 3, 580, 70, 'No Pelanggan', $black);
|
||||
imagestring($img, 3, 670, 70, ': '.$user, $black);
|
||||
imagestring($img, 5, 20, 81, $line, $orange);
|
||||
imagestring($img, 5, 20, 85, $line, $orange);
|
||||
imagestring($img, 4, 30, 110, 'Telah Diterima Dari', $black);
|
||||
imagestring($img, 5, 200, 110, ': '.$nama, $black);
|
||||
imagestring($img, 4, 30, 135, 'Sejumlah Uang', $black);
|
||||
imagestring($img, 4, 200, 135, ': '.terbilang($nominal).' rupiah', $black);
|
||||
imagestring($img, 4, 30, 160, 'Untuk Pembayaran', $black);
|
||||
imagestring($img, 4, 200, 160, ': '. $keterangan, $black);
|
||||
imagestring($img, 5, 20, 175, $line, $orange);
|
||||
imagestring($img, 4, 30, 190, 'NO', $black);
|
||||
imagestring($img, 4, 70, 190, 'KETERANGAN', $black);
|
||||
imagestring($img, 4, 620, 190, 'NOMINAL', $black);
|
||||
imagestring($img, 5, 20, 195, $line, $orange);
|
||||
|
||||
imagestring($img, 4, 30, 215, '1', $black);
|
||||
imagestring($img, 4, 70, 215, $paketint, $black);
|
||||
imagestring($img, 4, 620, 215, $jumtagihan, $black);
|
||||
|
||||
if($tagihan['ppn'] != 0 ) {
|
||||
imagestring($img, 4, 30, 235, '2', $black);
|
||||
imagestring($img, 4, 70, 235, 'PPN 11%', $black);
|
||||
imagestring($img, 4, 620, 235, $ppn, $black);
|
||||
}
|
||||
|
||||
if($tagihan['kode_unik'] != 0 ) {
|
||||
imagestring($img, 4, 30, 255, '3', $black);
|
||||
imagestring($img, 4, 70, 255, 'Subsidi', $black);
|
||||
imagestring($img, 4, 620, 255, $subsidi, $black);
|
||||
}
|
||||
|
||||
imagestring($img, 5, 20, 265, $line, $orange);
|
||||
imagestring($img, 4, 550, 290, 'TOTAL', $black);
|
||||
imagestring($img, 4, 620, 290, 'Rp. '.number_format($nominal, 0, ',', '.'), $black);
|
||||
imagestring($img, 5, 550, 300, '__________________________ ', $orange);
|
||||
|
||||
imagestring($img, 5, 50, 320, '______________________________', $orange);
|
||||
imagestring($img, $font, 70, 340, 'Terbilang : Rp. '.number_format($nominal, 0, ',', '.'), $black);
|
||||
imagestring($img, 5, 50, 350, '______________________________', $orange);
|
||||
// Simpan file ke direktori 'invoice'
|
||||
$invoicePath = 'invoice/'.$invoice;
|
||||
|
||||
// echo $invoicePath;
|
||||
// Simpan file ke direktori 'invoice'
|
||||
$invoicePath = '../invoice/' . $invoice;
|
||||
if (!imagepng($img, $invoicePath)) {
|
||||
// echo "<br>" . $invoicePath;
|
||||
die('Gagal menyimpan gambar.');
|
||||
} else {
|
||||
imagedestroy($img); // Hancurkan gambar setelah disimpan
|
||||
|
||||
// Ambil pengaturan Mikrotik
|
||||
$Mikro = $pdo->prepare("SELECT ip_address, port_api, username, password FROM setting_mikrotik WHERE id = :idset");
|
||||
$Mikro->bindParam(':idset', $tagihan['id_setting_mikrotik'], PDO::PARAM_INT);
|
||||
$Mikro->execute();
|
||||
$Mikrot = $Mikro->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Ambil detail koneksi
|
||||
$m_ip = $Mikrot[0]['ip_address'];
|
||||
$m_user = $Mikrot[0]['username'];
|
||||
$m_pass = $Mikrot[0]['password'];
|
||||
$m_port = $Mikrot[0]['port_api'];
|
||||
|
||||
// Ambil akun pelanggan
|
||||
$hsakun = $tagihan['user_hotspot'];
|
||||
|
||||
// Koneksi ke API Mikrotik
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
// Memproses berdasarkan jenis layanan
|
||||
if ($tagihan['jenis_layanan'] == 'Hotspot') {
|
||||
|
||||
$statuskas = "Pendapatan Hotspot";
|
||||
|
||||
$arrIDh = $API->comm("/ip/hotspot/user/getall", [
|
||||
".proplist" => ".id",
|
||||
"?name" => $hsakun,
|
||||
]);
|
||||
|
||||
if (!empty($arrIDh)) {
|
||||
$API->comm("/ip/hotspot/user/set", [
|
||||
".id" => $arrIDh[0][".id"],
|
||||
"disabled" => "false",
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
|
||||
$statuskas = "Pendapatan PPPOE";
|
||||
|
||||
$arrID = $API->comm("/ppp/secret/getall", [
|
||||
".proplist" => ".id",
|
||||
"?name" => $user,
|
||||
]);
|
||||
|
||||
if (!empty($arrID)) {
|
||||
$API->comm("/ppp/secret/set", [
|
||||
".id" => $arrID[0][".id"],
|
||||
"disabled" => "false",
|
||||
]);
|
||||
}
|
||||
}
|
||||
// Update status pelanggan menjadi aktif
|
||||
$stmt = $pdo->prepare("UPDATE pelanggan SET status = 'aktif' WHERE id = :idpel");
|
||||
$stmt->bindParam(':idpel', $tagihan['id_pelanggan'], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
// Update status tagihan dan simpan bukti pembayaran
|
||||
$stmt = $pdo->prepare("UPDATE tagihan SET img_invoice = :inv, status = 'lunas' WHERE id = :idtag");
|
||||
$stmt->bindParam(':inv', $invoice);
|
||||
$stmt->bindParam(':idtag', $idtag, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
// Cek transaksi dengan id tagihan
|
||||
$stmt = $pdo->prepare("SELECT id_tagihan FROM transaksi WHERE id_tagihan = :id");
|
||||
$stmt->bindParam(':id', $idtag, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$tagid = $stmt->fetchColumn();
|
||||
if ($tagid === false) {
|
||||
// Jika tidak ada, insert data transaksi baru
|
||||
$sql = "INSERT INTO transaksi (id_data_server, id_tagihan, id_user_akses, start_time, keterangan, pemasukan, metode_pembayaran, status) VALUES (:idds, :idtag, :idua, :start_time, :keterangan, :pemasukan, :metode, :status)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->bindParam(':idds', $tagihan['id_data_server'], PDO::PARAM_INT);
|
||||
$stmt->bindParam(':idtag', $idtag, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':idua', $tagihan['id_marketing'], PDO::PARAM_INT);
|
||||
$stmt->bindParam(':start_time', $tanggal);
|
||||
$stmt->bindParam(':keterangan', $tagihan['keterangan']);
|
||||
$stmt->bindParam(':pemasukan', $tagihan['verifikasi_tagihan']);
|
||||
$stmt->bindParam(':metode', $metode);
|
||||
$stmt->bindParam(':status', $statuskas);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
// Kirim Pesan WhatsApp
|
||||
$nomor = explode(',', $tagihan['nomor_whatsapp']);
|
||||
$Url = 'http://bilspro.com/invoice/' . $invoice;
|
||||
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Create_Pesan($tagihan['id_data_server'], $idtag, 'pesan_melunasi_tagihan', 'tag');
|
||||
$Pesan = $APIwa->Get_Pesan();
|
||||
$APIwa->Send_Pesan($tagihan['id_data_server'], 'sendMediaFromUrl', $nomor, $Pesan, $Url);
|
||||
}
|
||||
}
|
||||
echo "Flip Lunas" . $tagihan['nama'];
|
||||
} else {
|
||||
echo "Tidak ADA DATA yang lunas";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
error_log('Database Error: ' . $e->getMessage());
|
||||
echo "Database error occurred."; // Tampilkan pesan kesalahan
|
||||
} catch (Exception $e) {
|
||||
error_log('General Error: ' . $e->getMessage());
|
||||
echo "An error occurred."; // Tampilkan pesan kesalahan umum
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
|
||||
// Include necessary files
|
||||
// include "/www/wwwroot/bilspro/config/connect.php";
|
||||
// include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
|
||||
include "../config/connect.php";
|
||||
include "../config/routeros_api.class.php";
|
||||
|
||||
// Fetch data from the database
|
||||
$query = "SELECT * FROM v_load_api_cek_voucher";
|
||||
$set1 = $pdo->query($query);
|
||||
|
||||
if ($set1->rowCount() > 0) {
|
||||
|
||||
while ($pset = $set1->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Get connection details for the router
|
||||
$m_ip = $pset['ip_address'];
|
||||
$m_user = $pset['username'];
|
||||
$m_pass = $pset['password'];
|
||||
$m_port = $pset['port_api'];
|
||||
$idsm = $pset['id_setting_mikrotik'];
|
||||
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Connect to the router API
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
echo "\n<b>" . $pset['username'] . "</b>\n";
|
||||
|
||||
// Query vouchers that need to be checked
|
||||
$ambilv1 = $pdo->prepare("SELECT id, create_time, voucher, durasi FROM v_load_cek_voucher WHERE id_setting_mikrotik = :idsm AND status_cek IS NULL LIMIT 15");
|
||||
$ambilv1->execute([':idsm' => $idsm]);
|
||||
|
||||
while ($cekv1 = $ambilv1->fetch(PDO::FETCH_ASSOC)) {
|
||||
$iddatav1 = $cekv1['id'];
|
||||
$datav1 = $cekv1['voucher'];
|
||||
$durasi = $cekv1['durasi'];
|
||||
|
||||
// Convert the 'durasi' to a valid DateInterval format
|
||||
if (substr($durasi, -1) == 'H') {
|
||||
$inter = "PT" . rtrim($durasi, 'H') . "H"; // For hours
|
||||
} elseif (substr($durasi, -1) == 'D') {
|
||||
$inter = "P" . rtrim($durasi, 'D') . "D"; // For days
|
||||
} elseif (substr($durasi, -1) == 'M') {
|
||||
$inter = "PT" . rtrim($durasi, 'M') . "M"; // For minutes
|
||||
} else {
|
||||
echo "Invalid duration format: $durasi.\n";
|
||||
continue; // Skip this voucher if the duration is invalid
|
||||
}
|
||||
|
||||
// Check if the voucher exists in the hotspot users
|
||||
$cek = $API->comm('/ip/hotspot/user/print', array("?name" => $datav1));
|
||||
|
||||
if ($cek) {
|
||||
// If voucher exists, check the comment
|
||||
if (isset($cek[0]['comment']) && $cek[0]['comment'] != '') {
|
||||
$modifiedDateTime = substr($cek[0]['comment'], 6);
|
||||
if (substr($modifiedDateTime, 0, 4) == date('Y')) {
|
||||
$activetime = $modifiedDateTime;
|
||||
} else {
|
||||
$date = date_create_from_format("M/d/Y H:i:s", $modifiedDateTime);
|
||||
if ($date !== false) {
|
||||
$activetime = date_format($date, "Y-m-d H:i:s");
|
||||
} else {
|
||||
echo "Format tanggal tidak valid: $modifiedDateTime\n";
|
||||
continue; // Skip iteration if the format is invalid
|
||||
}
|
||||
}
|
||||
$Tgl = new DateTime($activetime);
|
||||
$interval = new DateInterval($inter); // Add the duration (in the correct format)
|
||||
$Tgl->add($interval);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo $datav1 . " comment->" . $cek[0]['comment'] . " active->" . $activetime . " exp->" . $exp . " => Exists\n";
|
||||
|
||||
// Update the database using prepared statement
|
||||
$updateQuery = "UPDATE ganerate_voucher SET active_time = :activetime, expaired_time = :exp WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([
|
||||
':activetime' => $activetime,
|
||||
':exp' => $exp,
|
||||
':id' => $iddatav1
|
||||
]);
|
||||
} else {
|
||||
// Mark the voucher as checked in the database
|
||||
$updateQuery = "UPDATE ganerate_voucher SET status_cek = '1' WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([':id' => $iddatav1]);
|
||||
}
|
||||
} else {
|
||||
// If voucher does not exist, calculate expiration time
|
||||
$aktif = $cekv1['create_time'];
|
||||
$date1 = date_create($aktif);
|
||||
|
||||
// Ensure that the duration is numeric and valid
|
||||
if (!empty($durasi) && is_numeric(rtrim($durasi, 'HDM'))) {
|
||||
// Calculate expiration date using DateTime and DateInterval
|
||||
try {
|
||||
$Tgl = new DateTime($aktif);
|
||||
$interval = new DateInterval($inter); // Add the duration (in the correct format)
|
||||
$Tgl->add($interval);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo $datav1 . " active->" . $aktif . " exp->" . $exp . " => " . $iddatav1 . " => Does not exist\n";
|
||||
|
||||
// Update the database using prepared statement
|
||||
$updateQuery = "UPDATE ganerate_voucher SET active_time = :aktif, expaired_time = :exp WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([
|
||||
':aktif' => $aktif,
|
||||
':exp' => $exp,
|
||||
':id' => $iddatav1
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo "Error processing duration for voucher $datav1: " . $e->getMessage() . "\n";
|
||||
}
|
||||
} else {
|
||||
// Handle case if 'durasi' is not valid or not numeric
|
||||
echo "Invalid or missing 'durasi' value for voucher $datav1.\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo $cekv1['voucher'] . "\n";
|
||||
}
|
||||
} else {
|
||||
// If unable to connect to the router
|
||||
echo "Unable to connect to router: " . $m_ip . "\n";
|
||||
}
|
||||
|
||||
// Disconnect the API session
|
||||
$API->disconnect();
|
||||
}
|
||||
} else {
|
||||
// Reset status_cek to NULL
|
||||
$updateQuery = "UPDATE ganerate_voucher SET status_cek = NULL WHERE status_cek = '1'";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
if ($stmt->execute()) {
|
||||
echo "Update ALL to NULL successful\n";
|
||||
} else {
|
||||
echo "Error updating status_cek to NULL\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "../config/connect.php";
|
||||
|
||||
$id = isset($_GET['i']) ? $_GET['i'] : '';
|
||||
$sqlwh = base64_decode($id);
|
||||
// Mengambil data dari database berdasarkan id_data_server
|
||||
$stmt = $pdo->prepare("SELECT * FROM v_data_maps $sqlwh ORDER BY status_koneksi");
|
||||
$stmt->execute();
|
||||
$monitor = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmtodp = $pdo->prepare("SELECT * FROM master_topologi $sqlwh");
|
||||
$stmtodp->execute();
|
||||
$master = $stmtodp->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Memeriksa apakah data ditemukan
|
||||
if (!empty($monitor) || !empty($master)) {
|
||||
$data = []; // Array untuk menampung hasil
|
||||
|
||||
// Mengisi data dari master_topologi
|
||||
foreach ($master as $odp) {
|
||||
list($lat, $lng) = explode(", ", $odp['titik_koordinat']);
|
||||
|
||||
$data[] = [
|
||||
'nama' => $odp['nama'],
|
||||
'latitude' => floatval($lat),
|
||||
'longitude' => floatval($lng),
|
||||
'icon' => 'dist/img/ODP.png',
|
||||
'content' => '<b>' . $odp['nama'] . '</b>'
|
||||
];
|
||||
}
|
||||
|
||||
// Mengisi data ke dalam array hasil dari monitor
|
||||
foreach ($monitor as $row) {
|
||||
$data[] = [
|
||||
'nama' => $row['nama'],
|
||||
'latitude' => floatval($row['latitude']),
|
||||
'longitude' => floatval($row['longitude']),
|
||||
'icon' => ($row['status'] == 'aktif') ?
|
||||
(($row['status_koneksi'] == 'On') ? 'dist/img/ON.png' : 'dist/img/OF.png') :
|
||||
(($row['status_koneksi'] == 'On') ? 'dist/img/ON1.png' : 'dist/img/OF1.png'),
|
||||
'content' => 'User_Id: <b>' . $row['akun'] . '</b><br>User: <b>' . $row['nama'] . '</b><br>login_at: ' . $row['last_on'] . '<br>last_logout: ' . $row['last_off'] . '<br>Status: ' . ($row['status_koneksi'] == 'On' ? 'Connect / '.$row['status'] : 'Disconnect / '.$row['status'])
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// Format data untuk output
|
||||
$result = array_map(function($item) {
|
||||
return [
|
||||
'lat' => $item['latitude'],
|
||||
'lng' => $item['longitude'],
|
||||
'title' => $item['nama'],
|
||||
'icon' => $item['icon'],
|
||||
'content' => $item['content']
|
||||
];
|
||||
}, $data);
|
||||
|
||||
// Mengirimkan data sebagai JSON
|
||||
echo json_encode($result);
|
||||
} else {
|
||||
// Jika tidak ada data, kembalikan array kosong
|
||||
echo json_encode([]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
include "../config/connect.php";
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Ambil data dari permintaan POST
|
||||
$postData = file_get_contents('php://input');
|
||||
$data = json_decode($postData);
|
||||
|
||||
$id = $data->id;
|
||||
$pppa = $data->pppa;
|
||||
$hsa = $data->hsa;
|
||||
$ut = $data->ut;
|
||||
$bm = $data->bm;
|
||||
$times = date('Y-m-d H:i:s');
|
||||
$data2 = $id."\n".$pppa."\n".$hsa."\n".$ut."\n".$bm;
|
||||
|
||||
$koneksi->query("UPDATE setting SET pppa='$pppa', hsa='$hsa', uptime_mikrotik='$ut', device_mikrotik='$bm', status_mikrotik='Connected', last_update_time='$times' WHERE serial_number='$id'");
|
||||
|
||||
if($pppa != "")
|
||||
{
|
||||
//UPDATE PPPOE
|
||||
$am = $koneksi->query("SELECT pppoe FROM pelanggan JOIN setting ON pelanggan.IdSetting=setting.IdSetting WHERE serial_number = '$id'");
|
||||
while($pc = $am->fetch_assoc())
|
||||
{
|
||||
echo $pc['pppoe']."<br>";
|
||||
if(preg_match("/$pc[pppoe]/i", $pppa)==1)
|
||||
{
|
||||
//cari nama awalan
|
||||
$cari00 = stristr($pppa, $pc['pppoe']);
|
||||
//ambil sampai akhir tanda |
|
||||
$cari02 = strtok($cari00, "|");
|
||||
//rubah ke array
|
||||
$data = explode("_",$cari02);
|
||||
//ambil data ip address
|
||||
$ipadd = $data[1];
|
||||
//update data pelanggan
|
||||
$koneksi->query("UPDATE pelanggan SET StatusKon = 'On', IpAddress = '$ipadd', TimeUpdate = '$times' WHERE pppoe = '$pc[pppoe]'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$koneksi->query("UPDATE pelanggan SET StatusKon = 'Off' WHERE pppoe = '$pc[pppoe]'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($hsa != "")
|
||||
{
|
||||
//UPDATE HOTSPOT
|
||||
$amhs = $koneksi->query("SELECT Voucher,DurasiVoucher FROM genvoucher
|
||||
INNER JOIN setting ON genvoucher.IdSetting=setting.IdSetting
|
||||
INNER JOIN paketvoucher ON genvoucher.IdVoucher=paketvoucher.IdVoucher
|
||||
WHERE serial_number = '$id' AND Aktif = ''");
|
||||
while($pchs = $amhs->fetch_assoc())
|
||||
{
|
||||
if(preg_match("/$pchs[Voucher]/i", $hsa)==1)
|
||||
{
|
||||
//cari nama awalan
|
||||
$cari0 = stristr($hsa, $pchs['Voucher']);
|
||||
//ambil sampai akhir tanda |
|
||||
$cari2 = strtok($cari0, "|");
|
||||
//rubah ke array
|
||||
$datahs = explode("_",$cari2);
|
||||
//ambil data waktu aktif
|
||||
$timeactive = str_replace("."," ",$datahs[1]);
|
||||
//cek format tanggal IF Y-m-d
|
||||
if(substr($timeactive,0,4) == date('Y'))
|
||||
{
|
||||
$activetime = $timeactive;
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = date_create_from_format("M/d/Y H:i:s",$timeactive);
|
||||
$activetime = date_format($date,"Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
$date1 = date_create($activetime);
|
||||
date_add($date1, date_interval_create_from_date_string($pchs['DurasiVoucher']));
|
||||
$exptime = date_format($date1, 'Y-m-d H:i:s');
|
||||
$koneksi->query("UPDATE genvoucher SET Aktif = '$activetime', Expaired = '$exptime', StaVoucher='0' WHERE Voucher = '$pchs[Voucher]'");
|
||||
|
||||
echo $pchs['Voucher']." => ".$activetime." => ".$exptime."<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
//CEK IF Update Aktif Kosong OR Aktif Terisi.
|
||||
//$koneksi->query("UPDATE genvoucher SET StaVoucher = '1' WHERE Voucher = '$pchs[Voucher]' ");
|
||||
}
|
||||
}
|
||||
}
|
||||
file_put_contents('apimik-log.log',$data);
|
||||
}
|
||||
|
||||
?>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"systemParams": "linux-x64-83",
|
||||
"modulesFolders": [],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [],
|
||||
"lockfileEntries": {},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "bilspro",
|
||||
"version": "1.0.0",
|
||||
"description": "A Node.js application that runs a PHP script periodically.",
|
||||
"main": "autoload.js",
|
||||
"scripts": {
|
||||
"start": "node autoload.js",
|
||||
"test": "echo \"No tests specified\" && exit 0"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Your Name",
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
include "../config/connect.php";
|
||||
include "../config/whatsapp_api.php";
|
||||
|
||||
$no = 1;
|
||||
$tanggalHariIni = date('Y-m-d');
|
||||
$sql = "SELECT * FROM data_server WHERE id != :id AND expaired_date >= :tanggal ORDER BY expaired_date DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':id' => 1,
|
||||
':tanggal' => $tanggalHariIni
|
||||
]);
|
||||
|
||||
while ($server = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo $no . ' => ' . $server['nama_server'] . '<br>';
|
||||
$no++;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
SV_Cikembar_Utama =><br>
|
||||
SV_BojongKerta =><br>
|
||||
SV_Permata_Sampora =><br>
|
||||
SV_Kingnet_Cibadak =><br>
|
||||
SV_CC-Net_Cipicung =><br>
|
||||
SV_Nusaina_Cibadak =><br>
|
||||
SV_Diamond Net =><br>
|
||||
SV_22P Net Cibadak =><br>
|
||||
SV_Nettizen_Segaranten =><br>
|
||||
SV-DNY-Net-1 =><br>
|
||||
SV_NTA_2_Pasawahan =><br>
|
||||
SV_NTA_1 =><br>
|
||||
SV-Cicukang =><br>
|
||||
RO-Bumdes-Mekarmanah =><br>
|
||||
RO-Pak-Kholiq =><br>
|
||||
RO-Dendrit-Net =><br>
|
||||
LJN.NS.CSR.NET =><br>
|
||||
IVVINET-CBD =><br>
|
||||
QONNET =><br>
|
||||
Mikrotik_X86 =><br>
|
||||
Mikrotik_BSW_1 =><br>
|
||||
Mikrotik_Alea =><br>
|
||||
STANG =><br>
|
||||
UNIX-NET =><br>
|
||||
SV_NTA_2_TBL =><br>
|
||||
MULYANAJAYA =><br>
|
||||
PERWASIM.NET =><br>
|
||||
RO_MELDINA =><br>
|
||||
RO_LIPPY =><br>
|
||||
RO_Asep =><br>
|
||||
BATUNUNGGAL =><br>
|
||||
PADINET =><br>
|
||||
RAGILNET =><br>
|
||||
RO_Sukasari =><br>
|
||||
RO_Wargasari =><br>
|
||||
LJN_AGUNG =><br>
|
||||
RNET-CMS =><br>
|
||||
DCN-GB-CCR =><br>
|
||||
412NET =><br>
|
||||
brf =><br>
|
||||
BMSNET =><br>
|
||||
purabaya =><br>
|
||||
DCN-CO-GX4 =><br>
|
||||
MIKROTIK GX4 =><br>
|
||||
RO - Netborhood Wifi =><br>
|
||||
Neglasari =><br>
|
||||
SV-DNY-Net-2 =><br>
|
||||
DNY-Neglasari =><br>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
// Ambil data dari tabel setting_mikrotik
|
||||
$stmt = $pdo->prepare("SELECT id, pppa, id_data_server, nama FROM setting_mikrotik WHERE pppa != ''");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
$id = $row['id'];
|
||||
|
||||
$pppa = substr($row['pppa'],0,-1);
|
||||
|
||||
$entries = explode('|', $pppa);
|
||||
// Buat array hasil dari $pppa
|
||||
$result = [];
|
||||
foreach ($entries as $entry) {
|
||||
// Pecah setiap entry berdasarkan '_'
|
||||
list($akun, $ip_address) = explode('_', $entry);
|
||||
$result[] = [
|
||||
'akun' => $akun,
|
||||
'ip_address' => $ip_address
|
||||
];
|
||||
}
|
||||
// Ambil data akun dari database
|
||||
$dataakun = [];
|
||||
$stmtPel = $pdo->prepare("SELECT id, akun FROM pelanggan WHERE id_setting_mikrotik = :id");
|
||||
$stmtPel->bindValue(':id', $id, PDO::PARAM_INT); // Pastikan parameter tipe aman
|
||||
$stmtPel->execute();
|
||||
$pelanggan = $stmtPel->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Iterasi data pelanggan
|
||||
foreach ($pelanggan as $key) {
|
||||
if (isset($key['akun'], $key['id'])) { // Pastikan kedua kunci ada
|
||||
$dataakun[] = [
|
||||
"akun" => $key['akun'],
|
||||
"id" => $key['id']
|
||||
];
|
||||
}
|
||||
}
|
||||
// Ambil hanya daftar akun dari $dataakun
|
||||
$akunDataakun = array_column($dataakun, 'akun');
|
||||
|
||||
// Cari akun yang ada di $result tetapi tidak ada di $dataakun
|
||||
$akunTidakAdaDiDataakun = array_filter($result, function ($item) use ($akunDataakun) {
|
||||
return !in_array($item['akun'], $akunDataakun);
|
||||
});
|
||||
|
||||
// Hasil akhir
|
||||
$hasil = [
|
||||
'akun_unmanage' => $akunTidakAdaDiDataakun
|
||||
];
|
||||
|
||||
$ppp_unmanage = json_encode($hasil);
|
||||
|
||||
$updateStmt = $pdo->prepare("UPDATE setting_mikrotik SET ppp_unmanage = :ppp_unmanage WHERE id = :id");
|
||||
$updateStmt->execute([':ppp_unmanage' => $ppp_unmanage, ':id' => $id]);
|
||||
|
||||
|
||||
|
||||
|
||||
// Ambil semua akun pelanggan dalam satu query
|
||||
$stmtPel = $pdo->prepare("SELECT id, akun FROM pelanggan WHERE id_setting_mikrotik = :id");
|
||||
$stmtPel->bindValue(':id', $id);
|
||||
$stmtPel->execute();
|
||||
$pelanggan = $stmtPel->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$time = date('Y-m-d H:i:s');
|
||||
$updates = [];
|
||||
$updateStatusOff = [];
|
||||
|
||||
foreach ($pelanggan as $key) {
|
||||
$akun = $key['akun'];
|
||||
$idakun = $key['id'];
|
||||
|
||||
// Cek apakah akun ada dalam pppa
|
||||
if (strpos($pppa, $akun) !== false) {
|
||||
// Cari nama awalan dan ambil bagian data setelahnya
|
||||
$cari00 = stristr($pppa, $akun);
|
||||
// Ambil data hingga tanda '|'
|
||||
$cari02 = strtok($cari00, "|");
|
||||
// Rubah ke array
|
||||
$data = explode("_", $cari02);
|
||||
|
||||
if (count($data) === 2) {
|
||||
$ipadd = $data[1];
|
||||
|
||||
// Siapkan data untuk update
|
||||
$updates[] = [
|
||||
'id' => $idakun,
|
||||
'status' => 'On',
|
||||
'ip_address' => $ipadd,
|
||||
'time' => $time,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$updateStatusOff[] = $idakun;
|
||||
}
|
||||
}
|
||||
echo $row['nama'] . " =><br>\n";
|
||||
|
||||
// Update status koneksi yang 'On' sekaligus
|
||||
if (!empty($updates)) {
|
||||
$updateQuery = "UPDATE pelanggan SET status_koneksi = CASE id ";
|
||||
foreach ($updates as $update) {
|
||||
$updateQuery .= "WHEN {$update['id']} THEN 'On' ";
|
||||
}
|
||||
$updateQuery .= "END, ip_address = CASE id ";
|
||||
foreach ($updates as $update) {
|
||||
$updateQuery .= "WHEN {$update['id']} THEN '{$update['ip_address']}' ";
|
||||
}
|
||||
$updateQuery .= "END, time_update = '{$time}' WHERE id IN (" . implode(',', array_column($updates, 'id')) . ")";
|
||||
$pdo->exec($updateQuery);
|
||||
}
|
||||
|
||||
// Update status koneksi yang 'Off'
|
||||
if (!empty($updateStatusOff)) {
|
||||
$updateOffQuery = "UPDATE pelanggan SET status_koneksi = 'Off' WHERE id IN ('" . implode("', '", $updateStatusOff) . "')";
|
||||
$pdo->exec($updateOffQuery);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
echo "No data found.\n";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8'); // pastikan output bisa dibaca oleh Swal
|
||||
|
||||
$idServer = intval($_GET['id']);
|
||||
$stmt = $pdo->prepare("SELECT id, pppa, id_data_server, nama FROM setting_mikrotik WHERE pppa != '' AND id_data_server = :idserver");
|
||||
$stmt->execute([':idserver' => $idServer]);
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$caseParts = [];
|
||||
$whereTuples = [];
|
||||
$bindValues = [];
|
||||
$mikrotikCount = [];
|
||||
$mikrotikNama = [];
|
||||
|
||||
foreach ($rows as $rowIndex => $row) {
|
||||
$id_setting = $row['id'];
|
||||
$id_data_server = $row['id_data_server'];
|
||||
$pppa = rtrim($row['pppa'], '|');
|
||||
$entries = explode('|', $pppa);
|
||||
$mikrotikNama[$id_setting] = $row['nama'];
|
||||
|
||||
foreach ($entries as $entryIndex => $entry) {
|
||||
$parts = explode('_', $entry);
|
||||
if (count($parts) !== 2) continue;
|
||||
|
||||
list($akun, $ip_address) = $parts;
|
||||
$key = $rowIndex . '_' . $entryIndex;
|
||||
|
||||
$caseParts[] = "WHEN akun = :akun_$key AND id_data_server = :server_$key THEN :setting_$key";
|
||||
$whereTuples[] = "(:akun_$key, :server_$key)";
|
||||
$bindValues[":akun_$key"] = $akun;
|
||||
$bindValues[":server_$key"] = $id_data_server;
|
||||
$bindValues[":setting_$key"] = $id_setting;
|
||||
|
||||
if (!isset($mikrotikCount[$id_setting])) {
|
||||
$mikrotikCount[$id_setting] = 0;
|
||||
}
|
||||
$mikrotikCount[$id_setting]++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($caseParts)) {
|
||||
$sql = "
|
||||
UPDATE pelanggan
|
||||
SET id_setting_mikrotik = CASE
|
||||
" . implode("\n", $caseParts) . "
|
||||
END
|
||||
WHERE (akun, id_data_server) IN (" . implode(", ", $whereTuples) . ")
|
||||
";
|
||||
|
||||
$stmtUpdate = $pdo->prepare($sql);
|
||||
$stmtUpdate->execute($bindValues);
|
||||
|
||||
echo "<b>✅ Sinkronisasi Berhasil</b><br>";
|
||||
foreach ($mikrotikCount as $id_mikrotik => $jumlah) {
|
||||
$nama = $mikrotikNama[$id_mikrotik] ?? 'Tidak diketahui';
|
||||
echo "<b>$nama</b>: $jumlah akun diperbarui</br>";
|
||||
}
|
||||
} else {
|
||||
echo "<b>⚠️ Tidak ada data yang perlu disinkronkan.</b>";
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
$id_data_server = '12';
|
||||
|
||||
$stmt = $pdo->prepare("SELECT id, nama_server, nama, nominal_tagihan, limit_pembayaran FROM v_tagihan WHERE id_data_server = :id_data_server AND status = 'buat'");
|
||||
$stmt->bindParam(':id_data_server', $id_data_server);
|
||||
$stmt->execute();
|
||||
$profiletag = $stmt->fetchAll();
|
||||
|
||||
foreach ($profiletag as $profile) {
|
||||
|
||||
$konpensasi = '2';
|
||||
$jumhari = date('t');
|
||||
$jumlahkon = $profile['nominal_tagihan'] / $jumhari * $konpensasi;
|
||||
$tagihan = $profile['nominal_tagihan'] - $jumlahkon;
|
||||
|
||||
$nominal_tagihan = $tagihan;
|
||||
$jumlah_tagihan = $tagihan;
|
||||
$ppn_amount = $jumlah_tagihan / 100 * 11;
|
||||
$total_tagihan = round($jumlah_tagihan + $ppn_amount);
|
||||
$kode_unik = 0;
|
||||
$verifikasi_tagihan = round($total_tagihan + $kode_unik);
|
||||
|
||||
echo $profile['nama_server'] . ' , ' . $profile['nama'] . ' , ' . $profile['nominal_tagihan'] . ' , ' . $jumlah_tagihan . ' , ' . $profile['limit_pembayaran'] . "<br>";
|
||||
|
||||
// // Gunakan prepare di luar loop jika ingin optimal, tapi untuk contoh ini oke
|
||||
// $stmt = $pdo->prepare("UPDATE tagihan SET
|
||||
// konpensasi = :konpensasi,
|
||||
// jumlah_konpensasi = :jumlahkon,
|
||||
// jumlah_tagihan = :jumlah_tagihan,
|
||||
// ppn = :ppn,
|
||||
// total_tagihan = :total_tagihan,
|
||||
// verifikasi_tagihan = :verifikasi_tagihan,
|
||||
// kode_unik = :kode_unik
|
||||
// WHERE id = :idtag");
|
||||
|
||||
// $stmt->bindParam(':jumlahkon', $jumlahkon);
|
||||
// $stmt->bindParam(':jumlah_tagihan', $jumlah_tagihan);
|
||||
// $stmt->bindParam(':ppn', $ppn_amount);
|
||||
// $stmt->bindParam(':total_tagihan', $total_tagihan);
|
||||
// $stmt->bindParam(':verifikasi_tagihan', $verifikasi_tagihan);
|
||||
// $stmt->bindParam(':konpensasi', $konpensasi);
|
||||
// $stmt->bindParam(':kode_unik', $kode_unik);
|
||||
// $stmt->bindParam(':idtag', $profile['id']); // ← perbaikan di sini
|
||||
// $stmt->execute();
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
// include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
include "../config/connect.php";
|
||||
// Ambil data dari tabel setting_mikrotik
|
||||
$stmt = $pdo->prepare("SELECT id, pppa, id_data_server, nama FROM setting_mikrotik WHERE pppa != ''");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
$id = $row['id'];
|
||||
$pppa = substr($row['pppa'],0,-1);
|
||||
|
||||
$entries = explode('|', $pppa);
|
||||
// Buat array hasil dari $pppa
|
||||
$result = [];
|
||||
foreach ($entries as $entry) {
|
||||
// Pecah setiap entry berdasarkan '_'
|
||||
list($akun, $ip_address) = explode('_', $entry);
|
||||
$result[] = [
|
||||
'akun' => $akun,
|
||||
'ip_address' => $ip_address
|
||||
];
|
||||
}
|
||||
// Ambil data akun dari database
|
||||
$dataakun = [];
|
||||
$stmtPel = $pdo->prepare("SELECT id, akun FROM pelanggan WHERE id_setting_mikrotik = :id");
|
||||
$stmtPel->bindValue(':id', $id, PDO::PARAM_INT); // Pastikan parameter tipe aman
|
||||
$stmtPel->execute();
|
||||
$pelanggan = $stmtPel->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Iterasi data pelanggan
|
||||
foreach ($pelanggan as $key) {
|
||||
if (isset($key['akun'], $key['id'])) { // Pastikan kedua kunci ada
|
||||
$dataakun[] = [
|
||||
"akun" => $key['akun'],
|
||||
"id" => $key['id']
|
||||
];
|
||||
}
|
||||
}
|
||||
// Ambil hanya daftar akun dari $dataakun
|
||||
$akunDataakun = array_column($dataakun, 'akun');
|
||||
|
||||
// Cari akun yang ada di $result tetapi tidak ada di $dataakun
|
||||
$akunTidakAdaDiDataakun = array_filter($result, function ($item) use ($akunDataakun) {
|
||||
return !in_array($item['akun'], $akunDataakun);
|
||||
});
|
||||
|
||||
// Hasil akhir
|
||||
$hasil = [
|
||||
'akun_unmanage' => $akunTidakAdaDiDataakun
|
||||
];
|
||||
|
||||
$ppp_unmanage = json_encode($hasil);
|
||||
|
||||
$updateStmt = $pdo->prepare("UPDATE setting_mikrotik SET ppp_unmanage = :ppp_unmanage WHERE id = :id");
|
||||
$updateStmt->execute([':ppp_unmanage' => $ppp_unmanage, ':id' => $id]);
|
||||
|
||||
// Output hasil
|
||||
// echo "<pre>";
|
||||
// print_r($hasil);
|
||||
|
||||
|
||||
|
||||
// $dataakun = [];
|
||||
// // Ambil semua akun pelanggan dalam satu query
|
||||
// $stmtPel = $pdo->prepare("SELECT id, akun FROM pelanggan WHERE id_setting_mikrotik = :id");
|
||||
// $stmtPel->bindValue(':id', $id);
|
||||
// $stmtPel->execute();
|
||||
// $pelanggan = $stmtPel->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// foreach ($pelanggan as $key) {
|
||||
// $dataakun[] = array("akun" => $key['akun'], "id" => $key['id']);
|
||||
// }
|
||||
|
||||
// $time = date('Y-m-d H:i:s');
|
||||
// $updates = [];
|
||||
// $updateStatusOff = [];
|
||||
|
||||
// foreach ($pelanggan as $key) {
|
||||
// $akun = $key['akun'];
|
||||
// $idakun = $key['id'];
|
||||
|
||||
// // Cek apakah akun ada dalam pppa
|
||||
// if (strpos($pppa, $akun) !== false) {
|
||||
// // Cari nama awalan dan ambil bagian data setelahnya
|
||||
// $cari00 = stristr($pppa, $akun);
|
||||
// // Ambil data hingga tanda '|'
|
||||
// $cari02 = strtok($cari00, "|");
|
||||
// // Rubah ke array
|
||||
// $data = explode("_", $cari02);
|
||||
|
||||
// if (count($data) === 2) {
|
||||
// $ipadd = $data[1];
|
||||
|
||||
// // Siapkan data untuk update
|
||||
// $updates[] = [
|
||||
// 'id' => $idakun,
|
||||
// 'status' => 'On',
|
||||
// 'ip_address' => $ipadd,
|
||||
// 'time' => $time,
|
||||
// ];
|
||||
// }
|
||||
// } else {
|
||||
// $updateStatusOff[] = $idakun;
|
||||
// }
|
||||
// }
|
||||
// echo $row['nama'] . " =><br>\n";
|
||||
|
||||
// // Update status koneksi yang 'On' sekaligus
|
||||
// if (!empty($updates)) {
|
||||
// $updateQuery = "UPDATE pelanggan SET status_koneksi = CASE id ";
|
||||
// foreach ($updates as $update) {
|
||||
// $updateQuery .= "WHEN {$update['id']} THEN 'On' ";
|
||||
// }
|
||||
// $updateQuery .= "END, ip_address = CASE id ";
|
||||
// foreach ($updates as $update) {
|
||||
// $updateQuery .= "WHEN {$update['id']} THEN '{$update['ip_address']}' ";
|
||||
// }
|
||||
// $updateQuery .= "END, time_update = '{$time}' WHERE id IN (" . implode(',', array_column($updates, 'id')) . ")";
|
||||
// $pdo->exec($updateQuery);
|
||||
// }
|
||||
|
||||
// // Update status koneksi yang 'Off'
|
||||
// if (!empty($updateStatusOff)) {
|
||||
// $updateOffQuery = "UPDATE pelanggan SET status_koneksi = 'Off' WHERE id IN ('" . implode("', '", $updateStatusOff) . "')";
|
||||
// $pdo->exec($updateOffQuery);
|
||||
// }
|
||||
|
||||
}
|
||||
} else {
|
||||
echo "No data found.\n";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
Tidak perlu update untuk ID: 2 Rp.200,000<br>Harga khusus untuk ID: 3 Rp.250,000<br>Tidak perlu update untuk ID: 4 Rp.300,000<br>Tidak perlu update untuk ID: 5 Rp.300,000<br>Tidak perlu update untuk ID: 6 Rp.200,000<br>Harga khusus untuk ID: 7 Rp.200,000<br>Tidak perlu update untuk ID: 8 Rp.200,000<br>Tidak perlu update untuk ID: 9 Rp.200,000<br>Tidak perlu update untuk ID: 10 Rp.200,000<br>Harga harus diupdate untuk ID Data Server: 12 Rp.750,000<br>Tidak perlu update untuk ID: 13 Rp.750,000<br>Tidak perlu update untuk ID: 14 Rp.450,000<br>Tidak perlu update untuk ID: 15 Rp.450,000<br>Tidak perlu update untuk ID: 16 Rp.300,000<br>Harga khusus untuk ID: 17 Rp.300,000<br>Tidak perlu update untuk ID: 18 Rp.300,000<br>Tidak perlu update untuk ID: 19 Rp.450,000<br>Tidak perlu update untuk ID: 20 Rp.200,000<br>Tidak perlu update untuk ID: 21 Rp.300,000<br>Tidak perlu update untuk ID: 22 Rp.300,000<br>Tidak perlu update untuk ID: 23 Rp.450,000<br>Tidak perlu update untuk ID: 24 Rp.200,000<br>Tidak perlu update untuk ID: 25 Rp.250,000<br>Tidak perlu update untuk ID: 26 Rp.200,000<br>Tidak perlu update untuk ID: 28 Rp.200,000<br>Tidak perlu update untuk ID: 29 Rp.300,000<br>Tidak perlu update untuk ID: 30 Rp.200,000<br>Tidak perlu update untuk ID: 31 Rp.200,000<br>Tidak perlu update untuk ID: 32 Rp.200,000<br>Tidak perlu update untuk ID: 33 Rp.200,000<br>Tidak perlu update untuk ID: 34 Rp.200,000<br>Tidak perlu update untuk ID: 35 Rp.200,000<br>Tidak perlu update untuk ID: 36 Rp.200,000<br>Tidak perlu update untuk ID: 37 Rp.300,000<br>Tidak perlu update untuk ID: 38 Rp.200,000<br>Tidak perlu update untuk ID: 39 Rp.200,000<br>Harga khusus untuk ID: 40 Rp.1,000,000<br>Tidak perlu update untuk ID: 41 Rp.200,000<br>Tidak perlu update untuk ID: 42 Rp.200,000<br>Harga khusus untuk ID: 43 Rp.100,000<br>Tidak perlu update untuk ID: 44 Rp.200,000<br>Tidak perlu update untuk ID: 45 Rp.300,000<br>Tidak perlu update untuk ID: 46 Rp.200,000<br>Tidak perlu update untuk ID: 47 Rp.200,000<br>Tidak perlu update untuk ID: 48 Rp.200,000<br>Tidak perlu update untuk ID: 49 Rp.200,000<br>Tidak perlu update untuk ID: 50 Rp.200,000<br>Tidak perlu update untuk ID: 51 Rp.200,000<br>Tidak perlu update untuk ID: 52 Rp.1,000,000<br>Tidak perlu update untuk ID: 53 Rp.200,000<br>Tidak perlu update untuk ID: 54 Rp.200,000<br>Tidak perlu update untuk ID: 55 Rp.200,000<br>Tidak perlu update untuk ID: 56 Rp.200,000<br>Tidak perlu update untuk ID: 57 Rp.200,000<br>Tidak perlu update untuk ID: 58 Rp.200,000<br>Tidak perlu update untuk ID: 59 Rp.200,000<br>Tidak perlu update untuk ID: 60 Rp.200,000<br>Tidak perlu update untuk ID: 61 Rp.300,000<br>Tidak perlu update untuk ID: 62 Rp.200,000<br>Tidak perlu update untuk ID: 63 Rp.200,000<br>Tidak perlu update untuk ID: 64 Rp.200,000<br>Tidak perlu update untuk ID: 65 Rp.200,000<br>Tidak perlu update untuk ID: 66 Rp.200,000<br>Tidak perlu update untuk ID: 67 Rp.200,000<br>Harga khusus untuk ID: 68 Rp.200,000<br>Harga khusus untuk ID: 69 Rp.200,000<br>Tidak perlu update untuk ID: 70 Rp.200,000<br>Tidak perlu update untuk ID: 71 Rp.200,000<br>Tidak perlu update untuk ID: 72 Rp.200,000<br>Tidak perlu update untuk ID: 73 Rp.200,000<br>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
try {
|
||||
// Ambil data user dari view
|
||||
$stmt = $pdo->prepare("SELECT * FROM v_jumlah_data_server");
|
||||
$stmt->execute();
|
||||
|
||||
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($data['status_sewa'] == 'normal') {
|
||||
// Tentukan harga berdasarkan jumlah user_aktif
|
||||
if ($data['user_aktif'] <= 200) {
|
||||
$harga_user = 200000;
|
||||
} elseif ($data['user_aktif'] > 200 && $data['user_aktif'] <= 500) {
|
||||
$harga_user = 300000;
|
||||
} elseif ($data['user_aktif'] > 500 && $data['user_aktif'] <= 800) {
|
||||
$harga_user = 450000;
|
||||
} elseif ($data['user_aktif'] > 800 && $data['user_aktif'] <= 1200) {
|
||||
$harga_user = 750000;
|
||||
} elseif ($data['user_aktif'] > 1200 && $data['user_aktif'] <= 1600) {
|
||||
$harga_user = 1000000;
|
||||
} else {
|
||||
$harga_user = 1500000; // Harga default jika user_aktif lebih dari 1600
|
||||
}
|
||||
|
||||
// Tentukan harga berdasarkan jumlah_agen
|
||||
if ($data['jumlah_agen'] <= 15) {
|
||||
$harga_agen = 200000;
|
||||
} elseif ($data['jumlah_agen'] > 15 && $data['jumlah_agen'] <= 30) {
|
||||
$harga_agen = 300000;
|
||||
} elseif ($data['jumlah_agen'] > 30 && $data['jumlah_agen'] <= 60) {
|
||||
$harga_agen = 450000;
|
||||
} elseif ($data['jumlah_agen'] > 60 && $data['jumlah_agen'] <= 90) {
|
||||
$harga_agen = 750000;
|
||||
} elseif ($data['jumlah_agen'] > 90 && $data['jumlah_agen'] <= 130) {
|
||||
$harga_agen = 1000000;
|
||||
} else {
|
||||
$harga_agen = 1500000; // Harga default jika jumlah_agen lebih dari 130
|
||||
}
|
||||
|
||||
// Gunakan harga tertinggi di antara harga_user dan harga_agen
|
||||
$harga = max($harga_user, $harga_agen);
|
||||
|
||||
// Bandingkan harga yang dihitung dengan harga di database
|
||||
if ($data['harga_sewa'] < $harga) {
|
||||
// Update harga di database (uncomment saat digunakan di produksi)
|
||||
$updateStmt = $pdo->prepare("UPDATE data_server SET harga_sewa = :harga WHERE id = :id");
|
||||
$updateStmt->execute([':harga' => $harga, ':id' => $data['id']]);
|
||||
echo "Harga harus diupdate untuk ID Data Server: " . $data['id'] . " Rp." . number_format($harga) . "<br>";
|
||||
} else {
|
||||
echo "Tidak perlu update untuk ID: " . $data['id'] . " Rp." . number_format($data['harga_sewa']) . "<br>";
|
||||
}
|
||||
} else {
|
||||
// Jika status_sewa bukan 'normal', gunakan harga khusus
|
||||
echo "Harga khusus untuk ID: " . $data['id'] . " Rp." . number_format($data['harga_sewa']) . "<br>";
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Tangani kesalahan koneksi atau query
|
||||
echo "Terjadi kesalahan: " . $e->getMessage();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
// Ambil data dari tabel setting_mikrotik
|
||||
$stmt = $pdo->prepare("SELECT id, pppa, id_data_server FROM setting_mikrotik WHERE pppa != '' AND id IN (12,73)");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Menyimpan bagian CASE dan nilai parameter binding
|
||||
$caseParts = [];
|
||||
$whereTuples = [];
|
||||
$bindValues = [];
|
||||
|
||||
foreach ($rows as $rowIndex => $row) {
|
||||
$id_setting = $row['id'];
|
||||
$id_data_server = $row['id_data_server'];
|
||||
$pppa = rtrim($row['pppa'], '|');
|
||||
$entries = explode('|', $pppa);
|
||||
|
||||
foreach ($entries as $entryIndex => $entry) {
|
||||
$parts = explode('_', $entry);
|
||||
if (count($parts) !== 2) continue;
|
||||
|
||||
list($akun, $ip_address) = $parts;
|
||||
|
||||
// Buat key unik agar tidak tabrakan
|
||||
$key = $rowIndex . '_' . $entryIndex;
|
||||
|
||||
// Tambahkan ke bagian CASE
|
||||
$caseParts[] = "WHEN akun = :akun_$key AND id_data_server = :server_$key THEN :setting_$key";
|
||||
|
||||
// Tambahkan ke bagian WHERE IN
|
||||
$whereTuples[] = "(:akun_$key, :server_$key)";
|
||||
|
||||
// Bind parameter
|
||||
$bindValues[":akun_$key"] = $akun;
|
||||
$bindValues[":server_$key"] = $id_data_server;
|
||||
$bindValues[":setting_$key"] = $id_setting;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<pre>";
|
||||
echo $sql . "\n";
|
||||
print_r($bindValues);
|
||||
echo "</pre>";
|
||||
|
||||
|
||||
if (!empty($caseParts)) {
|
||||
$sql = "
|
||||
UPDATE pelanggan
|
||||
SET id_setting_mikrotik = CASE
|
||||
" . implode("\n", $caseParts) . "
|
||||
END
|
||||
WHERE (akun, id_data_server) IN (" . implode(", ", $whereTuples) . ")
|
||||
";
|
||||
|
||||
$stmtUpdate = $pdo->prepare($sql);
|
||||
$stmtUpdate->execute($bindValues);
|
||||
|
||||
echo "Update berhasil.";
|
||||
} else {
|
||||
echo "Tidak ada data yang perlu diupdate.";
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user