Update Banyak
This commit is contained in:
+60
-12
@@ -1,33 +1,81 @@
|
||||
// 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, 'load_tagihan_flip.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);
|
||||
|
||||
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
|
||||
const phpExecutablePath = '/www/server/php/74/bin/php';
|
||||
|
||||
// Daftar jalur ke file PHP
|
||||
const phpScriptPaths = [
|
||||
path.join(__dirname, 'load_pesan.php'),
|
||||
path.join(__dirname, 'create_link_flip.php')
|
||||
path.join(__dirname, 'load_tagihan_flip.php'),
|
||||
path.join(__dirname, 'create_link_flip.php'),
|
||||
path.join(__dirname, 'load_tagihan_paydisini.php'),
|
||||
];
|
||||
|
||||
// Fungsi untuk menjalankan file PHP
|
||||
function runPhpScripts() {
|
||||
phpScriptPaths.forEach((phpScriptPath) => {
|
||||
// Fungsi untuk menjalankan 1 file PHP (Promise)
|
||||
function runPhpScript(phpScriptPath) {
|
||||
return new Promise((resolve) => {
|
||||
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) {
|
||||
} else if (stderr) {
|
||||
console.error(`PHP script ${phpScriptPath} stderr: ${stderr}`);
|
||||
return;
|
||||
} else {
|
||||
console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
}
|
||||
console.log(`PHP script ${phpScriptPath} output: ${stdout}`);
|
||||
resolve(); // tetap resolve biar lanjut meskipun error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Jalankan PHP scripts segera dan kemudian setiap 5 detik
|
||||
// Fungsi utama
|
||||
async function runPhpScripts() {
|
||||
// Jalankan semua script secara paralel
|
||||
await Promise.all(phpScriptPaths.map(runPhpScript));
|
||||
|
||||
// Random delay 5–15 detik
|
||||
const nextDelay = Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000;
|
||||
console.log(`Next run in ${nextDelay / 1000} seconds\n`);
|
||||
|
||||
// Jalankan lagi setelah delay
|
||||
setTimeout(runPhpScripts, nextDelay);
|
||||
}
|
||||
|
||||
// Jalankan pertama kali
|
||||
runPhpScripts();
|
||||
setInterval(runPhpScripts, 5000);
|
||||
@@ -0,0 +1 @@
|
||||
{"status":"error","message":"Tidak dapat terhubung ke RouterOS"}
|
||||
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@ $API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Konfigurasi MikroTik
|
||||
$ip = '103.188.169.125';
|
||||
$ip = '103.155.198.185';
|
||||
$username = 'apirjn';
|
||||
$password = '@APIRJN123';
|
||||
$port = '6644';
|
||||
@@ -83,7 +83,7 @@ if ($API->connect2($ip, $username, $password, $port)) {
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
// echo json_encode($response, JSON_PRETTY_PRINT);
|
||||
echo json_encode($response, JSON_PRETTY_PRINT);
|
||||
|
||||
} else {
|
||||
echo json_encode([
|
||||
|
||||
+94
-58
@@ -1,96 +1,132 @@
|
||||
<?php
|
||||
// Aktifkan pelaporan kesalahan untuk pengembangan
|
||||
// Aktifkan error log (minimalis)
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1); // Menampilkan kesalahan untuk pengembangan
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/../logs/create_link_flip.log');
|
||||
|
||||
// Fungsi sanitasi string
|
||||
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;
|
||||
return trim($str02);
|
||||
}
|
||||
|
||||
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 != ''";
|
||||
$linkCreated = false; // Penanda apakah ada link yang berhasil dibuat
|
||||
|
||||
// Ambil semua server dengan payment gateway aktif
|
||||
$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'];
|
||||
|
||||
$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";
|
||||
// Ambil hanya 1 profile_tagihan untuk server ini
|
||||
$sqlProfil = "SELECT id, kirim_tagihan
|
||||
FROM profile_tagihan
|
||||
WHERE id_data_server = :id_data_server
|
||||
LIMIT 1";
|
||||
$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'";
|
||||
if ($dataprofil = $stmtProfil->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Ambil hanya 1 tagihan yang valid
|
||||
$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'
|
||||
ORDER BY id ASC
|
||||
LIMIT 1";
|
||||
$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;
|
||||
$stmt->execute([
|
||||
':idds' => $idds,
|
||||
':idpt' => $dataprofil['id']
|
||||
]);
|
||||
|
||||
// Pastikan format tanggal valid
|
||||
if ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
try {
|
||||
$date = new DateTime($cekkirim);
|
||||
$date->modify('-1 day');
|
||||
$cektanggal = $date->format('Y-m-d');
|
||||
$sekarang = date('Y-m-d');
|
||||
if (!empty($data['limit_pembayaran'])) {
|
||||
$day = str_pad($dataprofil['kirim_tagihan'], 2, '0', STR_PAD_LEFT);
|
||||
$cekkirim = substr($data['limit_pembayaran'], 0, 8) . $day;
|
||||
|
||||
if ($sekarang == $cektanggal) {
|
||||
// Kode untuk meng-create link payment gateway
|
||||
require '../payment/flip/Flip/Transaction.php';
|
||||
$flip = new FlipPaymentGateway($apiKey, $apiUrl);
|
||||
$date = new DateTime($cekkirim);
|
||||
$date->modify('-1 day');
|
||||
$cektanggal = $date->format('Y-m-d');
|
||||
$sekarang = date('Y-m-d');
|
||||
|
||||
$response = $flip->createBill(
|
||||
sanitizeString($data['keterangan']),
|
||||
sanitizeString($data['verifikasi_tagihan']),
|
||||
$data['email'],
|
||||
sanitizeString($data['nama']),
|
||||
sanitizeString($data['nomor_whatsapp']),
|
||||
sanitizeString($data['alamat'])
|
||||
);
|
||||
if ($sekarang === $cektanggal) {
|
||||
// Buat link payment gateway
|
||||
require '../payment/flip/Flip/Transaction.php';
|
||||
$flip = new FlipPaymentGateway($apiKey, $apiUrl);
|
||||
|
||||
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'];
|
||||
$response = $flip->createBill(
|
||||
sanitizeString($data['keterangan']),
|
||||
sanitizeString($data['verifikasi_tagihan']),
|
||||
$data['email'],
|
||||
sanitizeString($data['nama']),
|
||||
sanitizeString($data['nomor_whatsapp']),
|
||||
sanitizeString($data['alamat'])
|
||||
);
|
||||
|
||||
$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);
|
||||
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'];
|
||||
|
||||
$update = $pdo->prepare("UPDATE tagihan
|
||||
SET transaction_id = :transaction_id,
|
||||
transaction_link = :transaction_link,
|
||||
transaction_status = :transaction_status
|
||||
WHERE id = :idtag");
|
||||
$update->execute([
|
||||
':transaction_id' => $transaction_id,
|
||||
':transaction_link' => $transaction_link,
|
||||
':transaction_status' => $transaction_status,
|
||||
':idtag' => $data['id']
|
||||
]);
|
||||
|
||||
echo "[SUCCESS] {$data['nama']} ({$data['id']}) link dibuat.\n";
|
||||
$linkCreated = true; // Set penanda ada link dibuat
|
||||
} else {
|
||||
error_log("[ERROR] Flip API gagal untuk tagihan ID {$data['id']}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "No Data";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Tanggal tidak valid: " . $e->getMessage();
|
||||
error_log("[EXCEPTION] {$e->getMessage()} untuk tagihan ID {$data['id']}");
|
||||
}
|
||||
} else {
|
||||
echo "Data tidak ditemukan";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Jika tidak ada satupun link yang dibuat
|
||||
if (!$linkCreated) {
|
||||
// error_log("[INFO] Tidak ada tagihan yang perlu dibuat link Flip.");
|
||||
echo "[INFO] Tidak ada tagihan yang perlu dibuat link.\n";
|
||||
}
|
||||
|
||||
echo "[DONE] Proses selesai pada " . date('Y-m-d H:i:s') . "\n";
|
||||
} catch (PDOException $e) {
|
||||
error_log('Database Error: ' . $e->getMessage());
|
||||
echo "Database error occurred: " . $e->getMessage();
|
||||
error_log('[DB ERROR] ' . $e->getMessage());
|
||||
echo "[DB ERROR] " . $e->getMessage();
|
||||
} catch (Exception $e) {
|
||||
error_log('General Error: ' . $e->getMessage());
|
||||
echo "An error occurred: " . $e->getMessage();
|
||||
error_log('[GENERAL ERROR] ' . $e->getMessage());
|
||||
echo "[ERROR] " . $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
// Ambil summary
|
||||
$stmt = $pdo->query("SELECT * FROM v_summary_transaksi_agen_bulanan");
|
||||
$summary = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Ambil detail
|
||||
$stmt = $pdo->query("SELECT * FROM v_detail_agen_pascabayar");
|
||||
$detail = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Ubah jadi keyed array
|
||||
function toKeyedArray($rows) {
|
||||
$out = [];
|
||||
foreach ($rows as $r) {
|
||||
$key = $r['id_agen_voucher'].'-'.$r['id_data_server'].'-'.$r['generate_time'];
|
||||
$out[$key] = $r;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
$summaryArr = toKeyedArray($summary);
|
||||
$detailArr = toKeyedArray($detail);
|
||||
|
||||
// Gabungkan semua key
|
||||
$allKeys = array_unique(array_merge(array_keys($summaryArr), array_keys($detailArr)));
|
||||
|
||||
$diffs = [];
|
||||
$same = [];
|
||||
|
||||
foreach ($allKeys as $key) {
|
||||
$rowSummary = $summaryArr[$key] ?? null;
|
||||
$rowDetail = $detailArr[$key] ?? null;
|
||||
|
||||
if (!$rowSummary || !$rowDetail) {
|
||||
$diffs[$key] = [
|
||||
'missing_in' => !$rowSummary ? 'summary' : 'detail'
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Bandingkan kolom satu per satu
|
||||
$rowDiff = [];
|
||||
foreach ($rowSummary as $col => $valSummary) {
|
||||
$valDetail = $rowDetail[$col] ?? null;
|
||||
|
||||
// Normalisasi null jadi 0
|
||||
$valSummaryNorm = ($valSummary === null || $valSummary === '') ? 0 : $valSummary;
|
||||
$valDetailNorm = ($valDetail === null || $valDetail === '') ? 0 : $valDetail;
|
||||
|
||||
if (trim((string)$valSummaryNorm) !== trim((string)$valDetailNorm)) {
|
||||
$rowDiff[$col] = [
|
||||
'summary' => $valSummary,
|
||||
'detail' => $valDetail
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($rowDiff) {
|
||||
$diffs[$key] = $rowDiff;
|
||||
} else {
|
||||
$same[$key] = $rowSummary;
|
||||
}
|
||||
}
|
||||
|
||||
// Hasil
|
||||
echo "<h3>✅ Data Sama: ".count($same)."</h3>";
|
||||
// echo "<pre>".json_encode($same, JSON_PRETTY_PRINT)."</pre>";
|
||||
|
||||
echo "<h3>⚠️ Data Berbeda / Hilang: ".count($diffs)."</h3>";
|
||||
echo "<pre>".json_encode($diffs, JSON_PRETTY_PRINT)."</pre>";
|
||||
@@ -0,0 +1,116 @@
|
||||
[21:38:01] [OK] 103.26.176.81
|
||||
[21:38:01] [OK] 103.188.169.123
|
||||
[21:38:01] [OK] 103.26.176.85
|
||||
[21:38:01] [OK] 103.26.176.83
|
||||
[21:38:01] [OK] 103.155.198.185
|
||||
[21:38:01] [OK] 103.188.169.121
|
||||
[21:38:01] [OK] tunnel.manjapro.net
|
||||
[21:38:01] [OK] tunnel.manjapro.net
|
||||
[21:38:01] [OK] tunnel.manjapro.net
|
||||
[21:38:01] [OK] tunnel.manjapro.net
|
||||
[21:38:01] [OK] tunnel.manjapro.net
|
||||
[21:38:02] [OK] 103.188.169.127
|
||||
[21:38:02] [OK] tunnel.manjapro.net
|
||||
[21:38:02] [OK] 103.26.176.87
|
||||
[21:38:02] [OK] tunnel.manjapro.net
|
||||
[21:38:02] [OK] 157.20.128.231
|
||||
[21:38:02] [OK] tunnel.manjapro.net
|
||||
[21:38:02] [OK] 103.26.176.93
|
||||
[21:38:02] [OK] 103.155.196.145
|
||||
[21:38:02] [OK] 103.94.10.112
|
||||
[21:38:02] [OK] tunnel.manjapro.net
|
||||
[21:38:02] [OK] 103.31.233.237
|
||||
[21:38:02] [OK] 103.242.104.69
|
||||
[21:38:03] [OK] 103.18.79.171
|
||||
[21:38:03] [OK] 103.155.199.191
|
||||
[21:38:03] [OK] tunnel.manjapro.net
|
||||
[21:38:03] [OK] tunnel.manjapro.net
|
||||
[21:38:03] [OK] tunnel.manjapro.net
|
||||
[21:38:04] [OK] 103.242.106.56
|
||||
[21:38:04] [OK] tunnel.manjapro.net
|
||||
[21:38:05] [FAIL] 103.67.80.126
|
||||
[21:38:06] [OK] 103.236.190.109
|
||||
[21:38:07] [FAIL] 103.94.10.240
|
||||
[21:38:07] [FAIL] 103.94.10.240
|
||||
[21:38:07] [FAIL] 103.94.10.240
|
||||
[21:38:07] [OK] 114.141.51.12
|
||||
[21:38:08] [FAIL] infinnet.cloud
|
||||
[21:38:08] [OK] 114.141.51.12
|
||||
[21:38:08] [OK] tunnel.manjapro.net
|
||||
[21:38:10] [OK] tunnel.manjapro.net
|
||||
[21:38:10] [OK] tunnel.manjapro.net
|
||||
[21:38:10] [OK] tunnel.manjapro.net
|
||||
[21:38:11] [OK] tunnel.manjapro.net
|
||||
[21:38:11] [OK] tunnel.manjapro.net
|
||||
[21:38:11] [FAIL] infinnet.cloud
|
||||
[21:38:12] [OK] tunnel.manjapro.net
|
||||
[21:38:12] [FAIL] tunnel.bilspro.com
|
||||
[21:38:12] [FAIL] tunnel.bilspro.com
|
||||
[21:38:12] [OK] tunnel.manjapro.net
|
||||
[21:38:13] [OK] tunnel.manjapro.net
|
||||
[21:38:14] [FAIL] tunnel.bilspro.com
|
||||
[21:38:14] [FAIL] 103.10.1.5
|
||||
[21:38:15] [FAIL] 157.20.12
|
||||
[21:38:16] [FAIL] 103.103.147.225
|
||||
[21:38:17] [FAIL] 103.155.198.109
|
||||
[21:38:17] [FAIL] tunnel.bilspro.com
|
||||
[21:38:18] [FAIL] tunnel.manjapro.net
|
||||
[2025-09-21 21:38:18] Semua child selesai. Mulai update DB...
|
||||
[21:38:18] [UPDATE DB] 03FK-Q7XE1
|
||||
[21:38:18] [UPDATE DB] IDLF-SK944
|
||||
[21:38:18] [UPDATE DB] TYF0-3RP75
|
||||
[21:38:18] [UPDATE DB] 0YDS-EI1V6
|
||||
[21:38:18] [UPDATE DB] C7CU-PGT97
|
||||
[21:38:18] [UPDATE STATUS] 7FZH-WIBI8 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE DB] YHVJ-ZN9V9
|
||||
[21:38:18] [UPDATE DB] C7CU-PGT910
|
||||
[21:38:18] [UPDATE DB] MPK0-Q43P11
|
||||
[21:38:18] [UPDATE DB] S9QL-XRJ512
|
||||
[21:38:18] [UPDATE DB] HHJH-UFWL14
|
||||
[21:38:18] [UPDATE DB] 03FK-Q7XE15
|
||||
[21:38:18] [UPDATE DB] DG7B-JP4218
|
||||
[21:38:18] [UPDATE DB] XXWL-VMH419
|
||||
[21:38:18] [UPDATE DB] 03FK-Q7XE20
|
||||
[21:38:18] [UPDATE DB] C7CU-PGT922
|
||||
[21:38:18] [UPDATE DB] 8FHL-TXVS23
|
||||
[21:38:18] [UPDATE DB] Q23C-IE2524
|
||||
[21:38:18] [UPDATE DB] Q4D5-ATUM25
|
||||
[21:38:18] [UPDATE DB] HHJH-UFWL28
|
||||
[21:38:18] [UPDATE DB] 11P4-SII029
|
||||
[21:38:18] [UPDATE DB] CUAA-CD2K30
|
||||
[21:38:18] [UPDATE DB] S1Z8-TK6932
|
||||
[21:38:18] [UPDATE DB] H67G-R4AK33
|
||||
[21:38:18] [UPDATE STATUS] 9RV7-3W5U34 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE DB] 32PA-DAZ435
|
||||
[21:38:18] [UPDATE STATUS] LJQ6-KDDJ37 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE DB] 0TW0-J74U38
|
||||
[21:38:18] [UPDATE DB] L7TJ-IF2G39
|
||||
[21:38:18] [UPDATE DB] RWDJ-NXBZ40
|
||||
[21:38:18] [UPDATE DB] A26W-ART341
|
||||
[21:38:18] [UPDATE STATUS] RE5H-G12Y42 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE STATUS] 03FK-Q7XE43 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE STATUS] Q96U-20UZ44 (Disconnected -> Disconnected)
|
||||
[21:38:18] [UPDATE DB] D3TU-JN5745
|
||||
[21:38:18] [UPDATE DB] 7SDF-17X546
|
||||
[21:38:18] [UPDATE DB] HMAZ-3HSX51
|
||||
[21:38:18] [UPDATE STATUS] PQJB-HG8V53 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE STATUS] PMA9-QC7654 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE STATUS] 7ZCI-NFCI62 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE STATUS] 0E73-PABK63 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE DB] 4MZF-SFTR65
|
||||
[21:38:19] [UPDATE DB] PJC8-K0EG66
|
||||
[21:38:19] [UPDATE STATUS] 351D-5NCH67 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE STATUS] A0S7-K2IC69 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE DB] G9Z1-HRLY70
|
||||
[21:38:19] [UPDATE STATUS] C7CU-PGT972 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE DB] 66AU-Z7I573
|
||||
[21:38:19] [UPDATE DB] ABMS-YBP776
|
||||
[21:38:19] [UPDATE DB] C7CU-PGT977
|
||||
[21:38:19] [UPDATE DB] C7CU-PGT978
|
||||
[21:38:19] [UPDATE DB] HHJH-UFWL81
|
||||
[21:38:19] [UPDATE DB] 83
|
||||
[21:38:19] [UPDATE STATUS] RNS6-DB3N84 (Disconnected -> Disconnected)
|
||||
[21:38:19] [UPDATE DB] C7CU-PGT987
|
||||
[21:38:19] [UPDATE DB] ZMVC-KAFH88
|
||||
[2025-09-21 21:38:19] Update DB selesai. OK: 56, FAIL: 1
|
||||
[2025-09-21 21:38:19] Lama eksekusi: 17.58 detik
|
||||
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
$start_time = microtime(true);
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
die("Script ini hanya bisa dijalankan lewat CLI.\n");
|
||||
}
|
||||
|
||||
ini_set('max_execution_time', 0);
|
||||
date_default_timezone_set('Asia/Jakarta');
|
||||
|
||||
require "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
// ---------------- Config ----------------
|
||||
$max_processes = 10;
|
||||
$timeout_api = 3;
|
||||
$tmpDir = sys_get_temp_dir() . '/mt_results';
|
||||
|
||||
if (!is_dir($tmpDir)) {
|
||||
@mkdir($tmpDir, 0770, true);
|
||||
}
|
||||
|
||||
// Ambil daftar perangkat
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
$sqlList = "
|
||||
SELECT DISTINCT ip_address, port_api, username, password, board_id
|
||||
FROM setting_mikrotik";
|
||||
$stmt = $pdo->prepare($sqlList);
|
||||
$stmt->execute();
|
||||
$mikrotiks = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$pdo = null;
|
||||
|
||||
if (empty($mikrotiks)) {
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Tidak ada data MikroTik.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Fork parallel
|
||||
$child_pids = [];
|
||||
$outfiles = [];
|
||||
|
||||
foreach ($mikrotiks as $data) {
|
||||
while (count($child_pids) >= $max_processes) {
|
||||
foreach ($child_pids as $key => $pid) {
|
||||
if (pcntl_waitpid($pid, $status, WNOHANG) > 0) {
|
||||
unset($child_pids[$key]);
|
||||
}
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
$safeId = preg_replace('~[^A-Za-z0-9_\-]~', '_', substr($data['board_id'], 0, 64));
|
||||
$outfile = $tmpDir . "/mt_" . $safeId . "_" . microtime(true) . "_" . mt_rand(1000,9999) . ".json";
|
||||
$outfiles[] = $outfile;
|
||||
|
||||
$pid = pcntl_fork();
|
||||
if ($pid == -1) {
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Gagal fork.\n";
|
||||
continue;
|
||||
} elseif ($pid) {
|
||||
$child_pids[] = $pid;
|
||||
} else {
|
||||
process_mikrotik_child($data, $timeout_api, $outfile);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($child_pids as $pid) {
|
||||
pcntl_waitpid($pid, $status);
|
||||
}
|
||||
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Semua child selesai. Mulai update DB...\n";
|
||||
|
||||
// Update DB
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
$updateSql = "
|
||||
UPDATE setting_mikrotik
|
||||
SET pppa = :pppa,
|
||||
hsa = :hsa,
|
||||
uptime = :ut,
|
||||
board_name = :bm,
|
||||
status = :st
|
||||
WHERE board_id = :id
|
||||
";
|
||||
$statusOnlySql = "
|
||||
UPDATE setting_mikrotik
|
||||
SET status = :st
|
||||
WHERE board_id = :id
|
||||
";
|
||||
|
||||
$updateStmt = $pdo->prepare($updateSql);
|
||||
$statusOnlyStmt = $pdo->prepare($statusOnlySql);
|
||||
|
||||
$execWithRetry = function($stmt, $params) use (&$pdo, $updateSql, $statusOnlySql, &$updateStmt, &$statusOnlyStmt) {
|
||||
try {
|
||||
$stmt->execute($params);
|
||||
return true;
|
||||
} catch (PDOException $e) {
|
||||
$msg = $e->getMessage();
|
||||
if (stripos($msg, '2006 MySQL server has gone away') !== false) {
|
||||
$pdo = null;
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
$updateStmt = $pdo->prepare($updateSql);
|
||||
$statusOnlyStmt = $pdo->prepare($statusOnlySql);
|
||||
$stmt = (isset($params[':pppa']) ? $updateStmt : $statusOnlyStmt);
|
||||
$stmt->execute($params);
|
||||
return true;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
};
|
||||
|
||||
$updated = 0;
|
||||
$failed = 0;
|
||||
|
||||
foreach ($outfiles as $file) {
|
||||
if (!is_file($file)) continue;
|
||||
|
||||
$json = file_get_contents($file);
|
||||
@unlink($file);
|
||||
|
||||
$row = json_decode($json, true);
|
||||
if (!$row || !isset($row['board_id'], $row['status'])) {
|
||||
$failed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$paramsStatus = [
|
||||
':st' => $row['status'],
|
||||
':id' => $row['board_id'],
|
||||
];
|
||||
|
||||
// Cek data lama untuk log perbandingan
|
||||
$cekStmt = $pdo->prepare("SELECT pppa,hsa,uptime,board_name,status FROM setting_mikrotik WHERE board_id = :id");
|
||||
$cekStmt->execute([':id' => $row['board_id']]);
|
||||
$current = $cekStmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row['status'] === 'Connected') {
|
||||
$params = [
|
||||
':pppa' => $row['pppa'] ?? '',
|
||||
':hsa' => $row['hsa'] ?? '',
|
||||
':ut' => $row['uptime'] ?? '',
|
||||
':bm' => $row['board_name'] ?? '',
|
||||
':st' => 'Connected',
|
||||
':id' => $row['board_id'],
|
||||
];
|
||||
try {
|
||||
$execWithRetry($updateStmt, $params);
|
||||
$updated++;
|
||||
|
||||
echo "[" . date('H:i:s') . "] [UPDATE DB] {$row['board_id']} \n ";
|
||||
// echo "OLD: " . json_encode($current, JSON_UNESCAPED_UNICODE) . "\n NEW: " . json_encode($params, JSON_UNESCAPED_UNICODE) . "\n";
|
||||
} catch (PDOException $e) {
|
||||
echo "[" . date('H:i:s') . "] [DB ERROR] {$row['board_id']} - " . $e->getMessage() . "\n";
|
||||
$failed++;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$execWithRetry($statusOnlyStmt, $paramsStatus);
|
||||
$updated++;
|
||||
echo "[" . date('H:i:s') . "] [UPDATE STATUS] {$row['board_id']} ({$current['status']} -> {$row['status']})\n";
|
||||
} catch (PDOException $e) {
|
||||
echo "[" . date('H:i:s') . "] [DB ERROR] {$row['board_id']} - " . $e->getMessage() . "\n";
|
||||
$failed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Update DB selesai. OK: {$updated}, FAIL: {$failed}\n";
|
||||
|
||||
$end_time = microtime(true);
|
||||
$duration = $end_time - $start_time;
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Lama eksekusi: " . number_format($duration, 2) . " detik\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
// ================================
|
||||
// CHILD: konek RouterOS & tulis file hasil
|
||||
// ================================
|
||||
function process_mikrotik_child(array $data, int $timeout_api, string $outfile): void
|
||||
{
|
||||
$ip = $data['ip_address'];
|
||||
$username = $data['username'];
|
||||
$password = $data['password'];
|
||||
$port = $data['port_api'];
|
||||
$board_id = $data['board_id'];
|
||||
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
$API->timeout = $timeout_api;
|
||||
|
||||
$result = [
|
||||
'board_id' => $board_id,
|
||||
'status' => 'Disconnected',
|
||||
'pppa' => '',
|
||||
'hsa' => '',
|
||||
'board_name' => '',
|
||||
'uptime' => '',
|
||||
'ip' => $ip,
|
||||
];
|
||||
|
||||
if ($API->connect2($ip, $username, $password, $port)) {
|
||||
$pppoe_active = [];
|
||||
$pppoe_data = $API->comm("/ppp/active/print");
|
||||
if (is_array($pppoe_data)) {
|
||||
foreach ($pppoe_data as $item) {
|
||||
$name = $item['name'] ?? '';
|
||||
$addr = $item['address'] ?? '';
|
||||
if ($name !== '' && $addr !== '') {
|
||||
$pppoe_active[] = "{$name}_{$addr}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hotspot_active = [];
|
||||
$hotspot_users = $API->comm("/ip/hotspot/user/print");
|
||||
if (is_array($hotspot_users)) {
|
||||
foreach ($hotspot_users as $item) {
|
||||
$user = $item['name'] ?? '';
|
||||
$comment = $item['comment'] ?? '';
|
||||
if ($user !== '' && strpos($comment, 'Login.') === 0) {
|
||||
$hotspot_active[] = "{$user}_" . substr($comment, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sys = $API->comm("/system/resource/print");
|
||||
$board_name = '';
|
||||
$uptime = '';
|
||||
if (is_array($sys) && !empty($sys[0])) {
|
||||
$board_name = $sys[0]['board-name'] ?? '';
|
||||
$uptime = $sys[0]['uptime'] ?? '';
|
||||
}
|
||||
|
||||
$API->disconnect();
|
||||
|
||||
$result['status'] = 'Connected';
|
||||
$result['pppa'] = implode('|', $pppoe_active);
|
||||
$result['hsa'] = implode('|', $hotspot_active);
|
||||
$result['board_name'] = $board_name;
|
||||
$result['uptime'] = $uptime;
|
||||
|
||||
echo "[" . date('H:i:s') . "] [OK] {$ip}\n";
|
||||
} else {
|
||||
echo "[" . date('H:i:s') . "] [FAIL] {$ip}\n";
|
||||
}
|
||||
|
||||
file_put_contents($outfile, json_encode($result, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[2025-09-21 21:36:01] Tidak ada remote expired.
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
include "/www/wwwroot/bilspro/controller/remoteModem.php";
|
||||
|
||||
// Kurangi 30 menit dari waktu sekarang
|
||||
$date = date('Y-m-d H:i:s', strtotime('-20 minutes'));
|
||||
|
||||
$stmt = $pdo->prepare("SELECT id_setting_mikrotik, remote_port
|
||||
FROM log_remote
|
||||
WHERE aktif_time <= :date
|
||||
LIMIT 1");
|
||||
$stmt->execute([':date' => $date]);
|
||||
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($data) {
|
||||
// Tutup remote yang sudah expired
|
||||
$remote = new RemoteModem($pdo);
|
||||
$result = $remote->remote_close($data['id_setting_mikrotik'], $data['remote_port']);
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Remote port " . $data['remote_port'] . " berhasil ditutup.\n";
|
||||
} else {
|
||||
// Tidak ada yang perlu dihapus
|
||||
echo "[" . date('Y-m-d H:i:s') . "] Tidak ada remote expired.\n";
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[2025-09-20 23:50:02] 0 data telah dihapus. Data tersisa sejak 2025-08-01 00:00:00 sampai sekarang.
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
// Ambil tanggal awal bulan -1 (bulan sebelumnya)
|
||||
$date = date('Y-m-01 00:00:00', strtotime('-1 month'));
|
||||
|
||||
// Jalankan query DELETE
|
||||
$stmt = $pdo->prepare("DELETE FROM monitoring_pelanggan
|
||||
WHERE waktu < :date");
|
||||
$stmt->execute([':date' => $date]);
|
||||
|
||||
// Ambil jumlah data yang dihapus
|
||||
$delete = $stmt->rowCount();
|
||||
|
||||
// Tampilkan hasil
|
||||
echo "[" . date('Y-m-d H:i:s') . "] " . $delete . " data telah dihapus. Data tersisa sejak " . $date . " sampai sekarang.\n";
|
||||
@@ -0,0 +1 @@
|
||||
2025-09-21 21:30:06 ✅ Summary updated, rows affected: 1474
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
|
||||
try {
|
||||
// Update / replace summary table
|
||||
$sql = "
|
||||
REPLACE INTO summary_transaksi_agen_bulanan
|
||||
|
||||
SELECT
|
||||
a.id_agen_voucher AS id_agen_voucher,
|
||||
a.id_data_server AS id_data_server,
|
||||
SUBSTR(a.generate_time, 1, 7) AS generate_time,
|
||||
SUM(a.debet) AS debet,
|
||||
SUM(a.kredit) AS kredit,
|
||||
(SUM(COALESCE(a.kredit, 0)) - SUM(COALESCE(a.debet, 0))) AS saldo,
|
||||
COUNT(DISTINCT (CASE WHEN (a.kredit IS NOT NULL) THEN a.id END)) AS jumlah_voucher,
|
||||
COUNT(DISTINCT (CASE WHEN (c.active_time IS NULL) THEN c.id END)) AS jumlah_voucher_belum_aktif,
|
||||
COUNT(DISTINCT (CASE WHEN (c.expaired_time > NOW()) THEN c.id END)) AS jumlah_voucher_aktif,
|
||||
COUNT(DISTINCT (CASE WHEN (c.expaired_time < NOW()) THEN c.id END)) AS jumlah_voucher_expaired
|
||||
FROM
|
||||
transaksi_agen_voucher a
|
||||
JOIN agen_voucher b ON (a.id_agen_voucher = b.id)
|
||||
LEFT JOIN ganerate_voucher c ON (a.id_ganerate_voucher = c.id)
|
||||
WHERE
|
||||
b.jenis_agen = 'Pascabayar'
|
||||
AND a.generate_time < DATE_FORMAT(CURDATE(), '%Y-%m-01')
|
||||
GROUP BY
|
||||
SUBSTR(a.generate_time, 1, 7),
|
||||
a.id_agen_voucher
|
||||
";
|
||||
|
||||
$affected = $pdo->exec($sql);
|
||||
echo date('Y-m-d H:i:s') . " ✅ Summary updated, rows affected: {$affected}\n";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo date('Y-m-d H:i:s') . " ❌ Error: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Voucher: CCU7DPArBx5nR<br>Aktif => 2025-09-21 21:38:11<br>Expaired => 2025-09-28 21:38:11<br>
|
||||
+23
-15
@@ -1,23 +1,23 @@
|
||||
SV_Cikembar_Utama Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_BojongKerta Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_Permata_Sampora Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_Kingnet_Cibadak Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_CC-Net_Cipicung Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_Nusaina_Cibadak Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_Diamond Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:09:01SV_BojongKerta Data pelanggan tidak ada
|
||||
2025-09-21 21:09:01RO Bima Net Data pelanggan tidak ada
|
||||
2025-09-21 21:09:01SV_Kingnet_Cibadak Data pelanggan tidak ada
|
||||
2025-09-21 21:09:01SV_CC-Net_Cipicung Data pelanggan tidak ada
|
||||
2025-09-21 21:09:01SV_Nusaina_Cibadak Data pelanggan tidak ada
|
||||
2025-09-21 21:09:01SV_Diamond Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_22P Net Cibadak Data pelanggan tidak ada
|
||||
2025-07-15 01:58:01SV_Nettizen_Segaranten Data pelanggan tidak ada
|
||||
2025-07-15 01:28:01SV-DNY-Net-1 Data pelanggan tidak ada
|
||||
2025-07-15 02:08:01SV_NTA_2_Pasawahan Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:09:01SV_Nettizen_Segaranten Data pelanggan tidak ada
|
||||
2025-09-21 20:39:01SV-DNY-Net-1 Data pelanggan tidak ada
|
||||
2025-09-21 21:19:01SV_NTA_2_PSW_1 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-15 02:13:01RO-Dendrit-Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:24: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-15 01:58:02QONNET Data pelanggan tidak ada
|
||||
2025-07-15 01:58:02Mikrotik_X86 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:09:01QONNET Data pelanggan tidak ada
|
||||
2025-09-21 21:09: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.
|
||||
@@ -37,14 +37,22 @@ 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-15 01:58:02coba Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:09: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-15 01:58:02MIKROTIK GX4 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:09: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-15 02:08:02DNY-Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-09-21 21:19:01DNY-Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_TTO Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
AP - NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
GAS NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_NTA_2_PSW_2 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
chr tencent Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
DamarisNet Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Triunsa Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Mikrotik GR 3 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
|
||||
+23
-1
@@ -1 +1,23 @@
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV-DNY-Net-1<br>Successfully started background process for IP: nsn.my.id SV_22P Net Cibadak<br>Successfully started background process for IP: nsn.my.id RO-Bumdes-Mekarmanah<br>Successfully started background process for IP: 103.242.104.69 RO-Dendrit-Net<br>Successfully started background process for IP: 103.26.176.93 LJN.NS.CSR.NET<br>Successfully started background process for IP: 103.155.198.109 RO_Asep<br>Successfully started background process for IP: 103.155.199.191 PERWASIM-NETWORK<br>Successfully started background process for IP: tunnel.manjapro.net SV_NTA_2_Pasawahan<br>Successfully started background process for IP: tunnel.manjapro.net SV-Cicukang<br>Successfully started background process for IP: tunnel.manjapro.net SV_NTA_1<br>Successfully started background process for IP: 103.94.10.112 STANG<br>Successfully started background process for IP: 157.20.128.231 QONNET<br>Successfully started background process for IP: 114.141.51.12 BMSNET<br>Successfully started background process for IP: 114.141.51.12 purabaya<br>Successfully started background process for IP: nsn.my.id SV_Cikembar_Utama<br>Successfully started background process for IP: tunnel.bilspro.com RO_Sukasari<br>Successfully started background process for IP: tunnel.bilspro.com Mikrotik_X86<br>Successfully started background process for IP: 103.155.196.145 UNIX-NET<br>Successfully started background process for IP: nsn.my.id SV_Diamond Net<br>Successfully started background process for IP: 103.26.176.81 SV_CC-Net_Cipicung<br>Successfully started background process for IP: 103.242.105.199 SV-DNY-Net-2<br>Started parallel processes for checking vouchers. => 2025-07-15 02:00:02
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV-DNY-Net-1
|
||||
Successfully started background process for IP: 103.188.169.123 SV_22P Net Cibadak
|
||||
Successfully started background process for IP: tunnel.manjapro.net RO-Bumdes-Mekarmanah
|
||||
Successfully started background process for IP: 103.242.104.69 RO-Dendrit-Net
|
||||
Successfully started background process for IP: 103.26.176.93 LJN.NS.CSR.NET
|
||||
Successfully started background process for IP: tunnel.manjapro.net RO_Asep
|
||||
Successfully started background process for IP: 103.155.199.191 PERWASIM-NETWORK
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV_NTA_2_PSW_1
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV-Cicukang
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV_NTA_1
|
||||
Successfully started background process for IP: 103.94.10.112 STANG
|
||||
Successfully started background process for IP: 157.20.128.231 QONNET
|
||||
Successfully started background process for IP: 114.141.51.12 BMSNET
|
||||
Successfully started background process for IP: 114.141.51.12 purabaya
|
||||
Successfully started background process for IP: 103.155.198.185 SV_Cikembar_Utama
|
||||
Successfully started background process for IP: 103.155.196.145 UNIX-NET
|
||||
Successfully started background process for IP: 103.26.176.81 SV_CC-Net_Cipicung
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV-DNY-Net-2
|
||||
Successfully started background process for IP: tunnel.manjapro.net Mikrotik_X86
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV_NTA_2_PSW_2
|
||||
Successfully started background process for IP: tunnel.manjapro.net Triunsa
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV_Diamond Net
|
||||
Started parallel processes for checking vouchers. => 2025-09-21 21:30:01
|
||||
@@ -34,9 +34,9 @@ if ($set1->rowCount() > 0) {
|
||||
|
||||
// Check if there was an issue with exec
|
||||
if ($return_var !== 0) {
|
||||
echo "Error executing command for IP: {$m_ip}<br>";
|
||||
echo "Error executing command for IP: {$m_ip}\n";
|
||||
} else {
|
||||
echo "Successfully started background process for IP: {$m_ip} {$nama}<br>";
|
||||
echo "Successfully started background process for IP: {$m_ip} {$nama}\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+132
-315
@@ -1,341 +1,158 @@
|
||||
<?php
|
||||
// Aktifkan pelaporan kesalahan untuk pengembangan
|
||||
// Aktifkan error log
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0); // Tampilkan kesalahan saat pengembangan
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/../logs/load_pesan.log');
|
||||
|
||||
// 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);
|
||||
$apiKeys = $stmtData->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
// Loop melalui setiap apiKey_whatsapp
|
||||
while ($dataambil = $stmtData->fetch(PDO::FETCH_ASSOC)) {
|
||||
$keyapi = $dataambil['api_key'];
|
||||
if (!empty($apiKeys)) {
|
||||
foreach ($apiKeys as $keyapi) {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// 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);
|
||||
// --- CEK LOG APIKEY ---
|
||||
$sql1 = "SELECT chat_count, update_time
|
||||
FROM chat_log_apikey
|
||||
WHERE apikey_whatsapp = :apiKey
|
||||
LIMIT 1";
|
||||
$stmt = $pdo->prepare($sql1);
|
||||
$stmt->execute([':apiKey' => $keyapi]);
|
||||
$log = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if($data) {
|
||||
$jenis = $data['jenis_pesan'];
|
||||
$apiurl = $data['api_url'];
|
||||
$chatCount = $log ? (int)$log['chat_count'] : 0;
|
||||
$updateTime = $log ? strtotime($log['update_time']) : 0;
|
||||
$now = time();
|
||||
|
||||
// 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",
|
||||
]);
|
||||
}
|
||||
// Kalau sudah lebih dari 200, cek jeda 10 menit
|
||||
if ($chatCount >= 200) {
|
||||
if ($now < $updateTime + (10 * 60)) {
|
||||
// Masih dalam masa jeda, skip API key ini
|
||||
$pdo->commit();
|
||||
echo "[PAUSE] API {$keyapi} ditunda sampai " . date('Y-m-d H:i:s', $updateTime + 300) . "\n";
|
||||
continue;
|
||||
} else {
|
||||
|
||||
$statuskas = "Pendapatan PPPOE";
|
||||
|
||||
$arrID = $API->comm("/ppp/secret/getall", [
|
||||
".proplist" => ".id",
|
||||
"?name" => $user,
|
||||
// Reset counter karena sudah lewat 10 menit
|
||||
$chatCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// --- AMBIL PESAN PENDING ---
|
||||
$sql = "
|
||||
SELECT * FROM master_pesan
|
||||
WHERE api_key = :apiKey AND status = 'PENDING'
|
||||
ORDER BY id ASC
|
||||
LIMIT 1
|
||||
FOR UPDATE
|
||||
";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([':apiKey' => $keyapi]);
|
||||
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($data) {
|
||||
// Lock pesan jadi PROCESSING
|
||||
$updateProcessing = $pdo->prepare("
|
||||
UPDATE master_pesan
|
||||
SET status = 'PROCESSING'
|
||||
WHERE id = :id AND status = 'PENDING'
|
||||
");
|
||||
$updateProcessing->execute([':id' => $data['id']]);
|
||||
$pdo->commit();
|
||||
|
||||
// --- KIRIM PESAN ---
|
||||
$jenis = $data['jenis_pesan'];
|
||||
$apiurl = $data['api_url'];
|
||||
$datapost = '';
|
||||
|
||||
if ($jenis === "sendMessage") {
|
||||
$datapost = http_build_query([
|
||||
'apiKey' => $data['api_key'],
|
||||
'phone' => $data['nomor'],
|
||||
'message' => $data['pesan']
|
||||
]);
|
||||
|
||||
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();
|
||||
} 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 {
|
||||
error_log("[INVALID JENIS] Jenis pesan tidak valid: {$jenis} untuk ID {$data['id']}");
|
||||
$pdo->prepare("UPDATE master_pesan SET status = 'GAGAL' WHERE id = :id")
|
||||
->execute([':id' => $data['id']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Kirim Pesan WhatsApp
|
||||
$nomor = explode(',', $tagihan['nomor_whatsapp']);
|
||||
$Url = 'https://manjapro.net/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);
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $apiurl . $jenis,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $datapost,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Content-Length: ' . strlen($datapost)
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (curl_errno($curl) || $httpCode >= 400) {
|
||||
error_log("[CURL ERROR] ID {$data['id']}: " . curl_error($curl));
|
||||
$status = 'GAGAL';
|
||||
} else {
|
||||
$rdata = json_decode($response, true);
|
||||
$status = ($rdata && $rdata['code'] == 200) ? 'TERKIRIM' : 'GAGAL';
|
||||
}
|
||||
curl_close($curl);
|
||||
|
||||
// Update status pesan
|
||||
$pdo->prepare("UPDATE master_pesan SET status = :status WHERE id = :id")
|
||||
->execute([':status' => $status, ':id' => $data['id']]);
|
||||
|
||||
// Update log apikey
|
||||
$newCount = ($status === 'TERKIRIM') ? $chatCount + 1 : $chatCount;
|
||||
$sqlLog = "
|
||||
INSERT INTO chat_log_apikey (apikey_whatsapp, chat_count, update_time)
|
||||
VALUES (:apiKey, :chatCount, NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
chat_count = :chatCount,
|
||||
update_time = NOW()
|
||||
";
|
||||
$pdo->prepare($sqlLog)->execute([
|
||||
':apiKey' => $keyapi,
|
||||
':chatCount' => $newCount
|
||||
]);
|
||||
|
||||
echo "[{$status}] ID {$data['id']} untuk API {$keyapi}, count={$newCount}\n";
|
||||
|
||||
} else {
|
||||
$pdo->commit();
|
||||
// tidak ada pesan untuk API key ini
|
||||
}
|
||||
}
|
||||
echo "Flip Lunas" . $tagihan['nama'];
|
||||
} else {
|
||||
echo "Tidak ADA DATA yang lunas";
|
||||
echo "[INFO] Tidak ada API Key aktif untuk Whatsapp Gateway\n";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
error_log('Database Error: ' . $e->getMessage());
|
||||
echo "Database error occurred."; // Tampilkan pesan kesalahan
|
||||
$pdo->rollBack();
|
||||
error_log("[DB ERROR] " . $e->getMessage());
|
||||
echo "[DB ERROR] " . $e->getMessage() . "\n";
|
||||
} catch (Exception $e) {
|
||||
error_log('General Error: ' . $e->getMessage());
|
||||
echo "An error occurred."; // Tampilkan pesan kesalahan umum
|
||||
$pdo->rollBack();
|
||||
error_log("[GENERAL ERROR] " . $e->getMessage());
|
||||
echo "[ERROR] " . $e->getMessage() . "\n";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
// Aktifkan error log
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/../logs/load_tagihan_flip.log');
|
||||
|
||||
include "../config/connect.php";
|
||||
include "../config/routeros_api.class.php";
|
||||
include "../config/tanggal_indo.php";
|
||||
include "../config/whatsapp_api.php";
|
||||
|
||||
try {
|
||||
// Ambil data tagihan sukses maksimal 5
|
||||
$datetime = date('Y-m-d H:i:s', time() - 60);
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT * FROM v_tagihan_flip_lunas
|
||||
WHERE last_mikrotik_connect > :datetime
|
||||
LIMIT 5
|
||||
");
|
||||
$stmt->execute(['datetime' => $datetime]);
|
||||
$tagihans = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($tagihans) {
|
||||
foreach ($tagihans as $tagihan) {
|
||||
try {
|
||||
$user = $tagihan['akun'];
|
||||
$idtag = $tagihan['id'];
|
||||
$nama = $tagihan['nama'];
|
||||
$nominal = $tagihan['verifikasi_tagihan'];
|
||||
$keterangan = 'Pembayaran ' . $tagihan['keterangan'];
|
||||
$invoice = 'kwitansi_' . date('Ymd') . $idtag . '.png';
|
||||
$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";
|
||||
|
||||
// Ambil template kwitansi
|
||||
$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);
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception("Template kwitansi tidak ditemukan.");
|
||||
}
|
||||
|
||||
$gambarKwitansi = '../img/' . $result['backround_kwitansi'];
|
||||
if (!file_exists($gambarKwitansi)) {
|
||||
throw new Exception("File kwitansi tidak ditemukan: $gambarKwitansi");
|
||||
}
|
||||
|
||||
// Membuat gambar
|
||||
$img = imagecreatefrompng($gambarKwitansi);
|
||||
$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 = str_repeat('_', 100);
|
||||
|
||||
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')), $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, 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, 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);
|
||||
}
|
||||
|
||||
$invoicePath = '../invoice/' . $invoice;
|
||||
if (!imagepng($img, $invoicePath)) {
|
||||
throw new Exception("Gagal menyimpan kwitansi ke $invoicePath");
|
||||
}
|
||||
imagedestroy($img);
|
||||
|
||||
// Aktifkan user Mikrotik
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT ip_address, port_api, username, password
|
||||
FROM setting_mikrotik
|
||||
WHERE id = :id
|
||||
");
|
||||
$stmt->execute(['id' => $tagihan['id_setting_mikrotik']]);
|
||||
$mikrotik = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($API->connect2($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password'], $mikrotik['port_api'])) {
|
||||
if ($tagihan['jenis_layanan'] == 'Hotspot') {
|
||||
|
||||
$statuskas = "Pendapatan Hotspot";
|
||||
|
||||
$arrIDh = $API->comm("/ip/hotspot/user/getall", [
|
||||
".proplist" => ".id",
|
||||
"?name" => $tagihan['user_hotspot'],
|
||||
]);
|
||||
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 & tagihan
|
||||
$pdo->prepare("UPDATE pelanggan SET status = 'aktif' WHERE id = :id")
|
||||
->execute(['id' => $tagihan['id_pelanggan']]);
|
||||
$pdo->prepare("UPDATE tagihan SET img_invoice = :inv, status = 'lunas' WHERE id = :id")
|
||||
->execute(['inv' => $invoice, 'id' => $idtag]);
|
||||
|
||||
// Kirim WhatsApp dengan kwitansi
|
||||
$nomor = explode(',', $tagihan['nomor_whatsapp']);
|
||||
$urlInvoice = 'https://manjapro.net/invoice/' . $invoice;
|
||||
|
||||
// Cek transaksi dengan id tagihan
|
||||
$stmt = $pdo->prepare("SELECT id_tagihan FROM transaksi WHERE id_tagihan = :id AND metode_pembayaran = :metode");
|
||||
$stmt->bindParam(':id', $idtag, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':metode', $metode);
|
||||
$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();
|
||||
}
|
||||
|
||||
$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, $urlInvoice);
|
||||
|
||||
echo "[SUCCESS] Tagihan lunas: {$tagihan['nama']} ({$idtag})\n";
|
||||
} catch (Exception $e) {
|
||||
error_log("[ERROR] {$e->getMessage()} untuk tagihan ID {$tagihan['id']}");
|
||||
echo "[ERROR] {$e->getMessage()} untuk tagihan ID {$tagihan['id']}\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "[INFO] Tidak ada tagihan flip yang lunas.\n";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
error_log('[DB ERROR] ' . $e->getMessage());
|
||||
echo "[DB ERROR] " . $e->getMessage() . "\n";
|
||||
} catch (Exception $e) {
|
||||
error_log('[GENERAL ERROR] ' . $e->getMessage());
|
||||
echo "[ERROR] " . $e->getMessage() . "\n";
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
// Aktifkan error log
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/../logs/load_tagihan_paydisini.log');
|
||||
|
||||
include "../config/connect.php";
|
||||
include "../config/routeros_api.class.php";
|
||||
include "../config/tanggal_indo.php";
|
||||
include "../config/whatsapp_api.php";
|
||||
|
||||
try {
|
||||
// Ambil data tagihan sukses maksimal 5
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT a.id, a.id_tagihan, a.update_time, a.status_check,
|
||||
b.akun, b.nama, b.verifikasi_tagihan, b.keterangan,
|
||||
b.nama_paket, b.jumlah_tagihan, b.ppn, b.kode_unik,
|
||||
b.id_data_server, b.id_setting_mikrotik, b.jenis_layanan,
|
||||
b.user_hotspot, b.id_pelanggan, b.nomor_whatsapp, b.id_marketing
|
||||
FROM client_payment a
|
||||
LEFT JOIN v_tagihan b ON a.id_tagihan = b.id
|
||||
WHERE a.status = 'SUCCESS'
|
||||
AND (a.status_check IS NULL OR a.status_check IN (1,2,3))
|
||||
AND (a.status_check_time IS NULL OR a.status_check_time < NOW())
|
||||
LIMIT 5
|
||||
");
|
||||
$stmt->execute();
|
||||
$tagihans = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($tagihans) {
|
||||
foreach ($tagihans as $tagihan) {
|
||||
try {
|
||||
$user = $tagihan['akun'];
|
||||
$idtag = $tagihan['id_tagihan'];
|
||||
$nama = $tagihan['nama'];
|
||||
$nominal = $tagihan['verifikasi_tagihan'];
|
||||
$keterangan = 'Pembayaran ' . $tagihan['keterangan'];
|
||||
$invoice = 'kwitansi_' . date('Ymd') . $idtag . '.png';
|
||||
$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['update_time'];
|
||||
$metode = "API Payment";
|
||||
|
||||
// Ambil template kwitansi
|
||||
$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);
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception("Template kwitansi tidak ditemukan.");
|
||||
}
|
||||
|
||||
$gambarKwitansi = '../img/' . $result['backround_kwitansi'];
|
||||
if (!file_exists($gambarKwitansi)) {
|
||||
throw new Exception("File kwitansi tidak ditemukan: $gambarKwitansi");
|
||||
}
|
||||
|
||||
// Membuat gambar
|
||||
$img = imagecreatefrompng($gambarKwitansi);
|
||||
$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 = str_repeat('_', 100);
|
||||
|
||||
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')), $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, 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, 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);
|
||||
}
|
||||
|
||||
$invoicePath = '../invoice/' . $invoice;
|
||||
if (!imagepng($img, $invoicePath)) {
|
||||
throw new Exception("Gagal menyimpan kwitansi ke $invoicePath");
|
||||
}
|
||||
imagedestroy($img);
|
||||
|
||||
// Aktifkan user Mikrotik
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT ip_address, port_api, username, password
|
||||
FROM setting_mikrotik
|
||||
WHERE id = :id
|
||||
");
|
||||
$stmt->execute(['id' => $tagihan['id_setting_mikrotik']]);
|
||||
$mikrotik = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($API->connect2($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password'], $mikrotik['port_api'])) {
|
||||
if ($tagihan['jenis_layanan'] == 'Hotspot') {
|
||||
|
||||
$statuskas = "Pendapatan Hotspot";
|
||||
|
||||
$arrIDh = $API->comm("/ip/hotspot/user/getall", [
|
||||
".proplist" => ".id",
|
||||
"?name" => $tagihan['user_hotspot'],
|
||||
]);
|
||||
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 & tagihan
|
||||
$pdo->prepare("UPDATE pelanggan SET status = 'aktif' WHERE id = :id")
|
||||
->execute(['id' => $tagihan['id_pelanggan']]);
|
||||
$pdo->prepare("UPDATE tagihan SET img_invoice = :inv, status = 'lunas' WHERE id = :id")
|
||||
->execute(['inv' => $invoice, 'id' => $idtag]);
|
||||
$pdo->prepare("UPDATE client_payment SET status_check_time = NOW(), status_check = 27 WHERE id = :id")
|
||||
->execute(['id' => $tagihan['id']]);
|
||||
|
||||
// Kirim WhatsApp dengan kwitansi
|
||||
$nomor = explode(',', $tagihan['nomor_whatsapp']);
|
||||
$urlInvoice = 'https://manjapro.net/invoice/' . $invoice;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
$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, $urlInvoice);
|
||||
|
||||
echo "[SUCCESS] Tagihan lunas: {$tagihan['nama']} ({$idtag})\n";
|
||||
} catch (Exception $e) {
|
||||
error_log("[ERROR] {$e->getMessage()} untuk tagihan ID {$tagihan['id_tagihan']}");
|
||||
echo "[ERROR] {$e->getMessage()} untuk tagihan ID {$tagihan['id_tagihan']}\n";
|
||||
$count_check = $tagihan['status_check'] ?? 0 ;
|
||||
$check = $count_check + 1 ;
|
||||
$datetime = date('Y-m-d H:i:s', time() + 60);
|
||||
$stmt = $pdo->prepare("UPDATE client_payment
|
||||
SET status_check_time = :datetime, status_check = :check
|
||||
WHERE id = :id");
|
||||
$stmt->execute([
|
||||
'datetime' => $datetime,
|
||||
'check' => $check,
|
||||
'id' => $tagihan['id']
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "[INFO] Tidak ada tagihan paydisini yang lunas.\n";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
error_log('[DB ERROR] ' . $e->getMessage());
|
||||
echo "[DB ERROR] " . $e->getMessage() . "\n";
|
||||
} catch (Exception $e) {
|
||||
error_log('[GENERAL ERROR] ' . $e->getMessage());
|
||||
echo "[ERROR] " . $e->getMessage() . "\n";
|
||||
}
|
||||
+29
-18
@@ -1,27 +1,26 @@
|
||||
<?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
|
||||
|
||||
// Ambil data monitoring
|
||||
$stmt = $pdo->prepare("SELECT * FROM v_data_maps $sqlwh ORDER BY status_koneksi");
|
||||
$stmt->execute();
|
||||
$monitor = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Ambil data master_topologi
|
||||
$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
|
||||
$data = [];
|
||||
|
||||
// Mengisi data dari master_topologi
|
||||
// Isi data dari master_topologi
|
||||
foreach ($master as $odp) {
|
||||
list($lat, $lng) = explode(", ", $odp['titik_koordinat']);
|
||||
|
||||
$data[] = [
|
||||
'nama' => $odp['nama'],
|
||||
'latitude' => floatval($lat),
|
||||
@@ -31,21 +30,24 @@ if (!empty($monitor) || !empty($master)) {
|
||||
];
|
||||
}
|
||||
|
||||
// Mengisi data ke dalam array hasil dari monitor
|
||||
// Isi data 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'])
|
||||
'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
|
||||
// Format ulang data
|
||||
$result = array_map(function($item) {
|
||||
return [
|
||||
'lat' => $item['latitude'],
|
||||
@@ -55,11 +57,20 @@ if (!empty($monitor) || !empty($master)) {
|
||||
'content' => $item['content']
|
||||
];
|
||||
}, $data);
|
||||
|
||||
// Mengirimkan data sebagai JSON
|
||||
echo json_encode($result);
|
||||
|
||||
// Tentukan center pakai titik pertama
|
||||
$center = !empty($result) ? ['lat' => $result[0]['lat'], 'lng' => $result[0]['lng']] : null;
|
||||
|
||||
echo json_encode([
|
||||
'status' => true,
|
||||
'centerlonglat' => $center,
|
||||
'data' => $result
|
||||
]);
|
||||
} else {
|
||||
// Jika tidak ada data, kembalikan array kosong
|
||||
echo json_encode([]);
|
||||
echo json_encode([
|
||||
'status' => false,
|
||||
'centerlonglat' => null,
|
||||
'data' => []
|
||||
]);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>OCR Google Vision</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; padding: 20px; }
|
||||
#preview { max-width: 300px; margin-top: 10px; }
|
||||
textarea { width: 100%; height: 200px; margin-top: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>OCR dengan Google Vision API</h2>
|
||||
|
||||
<input type="file" id="imageUpload" accept="image/*"><br>
|
||||
<img id="preview" src=""><br>
|
||||
|
||||
<button onclick="prosesOCR()">Proses OCR</button>
|
||||
|
||||
<h3>Hasil:</h3>
|
||||
<textarea id="hasilText" readonly></textarea>
|
||||
|
||||
<!-- ... sebelumnya sama ... -->
|
||||
|
||||
<script>
|
||||
const API_KEY = 'AIzaSyDb5jNjAc-xZrjdv7oSHmlaESdG8LeDuB0'; // Pastikan valid dan aktif
|
||||
|
||||
let base64Image = '';
|
||||
|
||||
document.getElementById('imageUpload').addEventListener('change', function () {
|
||||
const file = this.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = function () {
|
||||
base64Image = reader.result.replace(/^data:image\/(png|jpeg|jpg);base64,/, "");
|
||||
document.getElementById('preview').src = reader.result;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
function prosesOCR() {
|
||||
if (!base64Image) {
|
||||
alert("Upload gambar dulu.");
|
||||
return;
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
requests: [
|
||||
{
|
||||
image: { content: base64Image },
|
||||
features: [{ type: "TEXT_DETECTION" }]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
fetch(`https://vision.googleapis.com/v1/images:annotate?key=${API_KEY}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(requestBody)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
console.log("Full response:", result); // Debug di sini
|
||||
const res = result.responses[0];
|
||||
const detections = res.fullTextAnnotation?.text || res.textAnnotations?.[0]?.description || 'Tidak ada teks terdeteksi.';
|
||||
document.getElementById('hasilText').value = detections;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
alert("❌ Gagal proses OCR. Lihat console log.");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
SV_Cikembar_Utama =><br>
|
||||
SV_BojongKerta =><br>
|
||||
SV_Permata_Sampora =><br>
|
||||
RO Bima Net =><br>
|
||||
SV_Kingnet_Cibadak =><br>
|
||||
SV_CC-Net_Cipicung =><br>
|
||||
SV_Nusaina_Cibadak =><br>
|
||||
@@ -8,7 +8,7 @@ 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_2_PSW_1 =><br>
|
||||
SV_NTA_1 =><br>
|
||||
SV-Cicukang =><br>
|
||||
RO-Bumdes-Mekarmanah =><br>
|
||||
@@ -46,3 +46,11 @@ RO - Netborhood Wifi =><br>
|
||||
Neglasari =><br>
|
||||
SV-DNY-Net-2 =><br>
|
||||
DNY-Neglasari =><br>
|
||||
RO_TTO =><br>
|
||||
AP - NET =><br>
|
||||
GAS NET =><br>
|
||||
SV_NTA_2_PSW_2 =><br>
|
||||
chr tencent =><br>
|
||||
DamarisNet =><br>
|
||||
Triunsa =><br>
|
||||
Mikrotik GR 3 =><br>
|
||||
|
||||
+141
-12
@@ -1,17 +1,146 @@
|
||||
<?php
|
||||
<?php
|
||||
// Aktifkan error reporting
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Koneksi PDO
|
||||
include "../config/connect.php"; // pastikan $pdo sudah ada
|
||||
|
||||
// Daftar id_data_server
|
||||
$idServers = [3, 2, 4, 5, 6, 8, 9, 67, 74, 75, 76];
|
||||
|
||||
// Buat placeholder dinamis
|
||||
$placeholders = implode(',', array_fill(0, count($idServers), '?'));
|
||||
|
||||
// Query select
|
||||
$sql = "SELECT id, nama, email
|
||||
FROM pelanggan
|
||||
WHERE id_data_server IN ($placeholders)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($idServers);
|
||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($results) {
|
||||
$no = 1;
|
||||
$gmailDomain = '@gmail.com';
|
||||
|
||||
foreach ($results as $row) {
|
||||
$id = $row['id'];
|
||||
$nama = $row['nama'];
|
||||
$email = trim($row['email']);
|
||||
$emailLower = strtolower($email);
|
||||
|
||||
if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL) && substr($emailLower, -strlen($gmailDomain)) === $gmailDomain) {
|
||||
// Email valid dan Gmail
|
||||
if ($email === $emailLower) {
|
||||
// Semua huruf kecil -> hitam (biarkan)
|
||||
$color = "black";
|
||||
echo "$no => $id => $nama => <span style='color:$color;'>" . htmlspecialchars($email) . "</span><br>";
|
||||
} else {
|
||||
// Ada huruf besar -> kuning (UPDATE ke lowercase)
|
||||
$color = "orange";
|
||||
// $update = $pdo->prepare("UPDATE pelanggan SET email = ? WHERE id = ?");
|
||||
// $update->execute([$emailLower, $id]);
|
||||
|
||||
echo "$no => $id => $nama => <span style='color:$color;'>" . htmlspecialchars($email) . "</span> =UPDATED> $emailLower<br>";
|
||||
}
|
||||
} else {
|
||||
// Email tidak valid -> generate baru dan UPDATE
|
||||
$namaClean = strtolower(preg_replace('/[^a-z]/i', '', $nama));
|
||||
$randomNumber = rand(1000, 9999);
|
||||
$newmail = $namaClean . $randomNumber . $gmailDomain;
|
||||
|
||||
// $update = $pdo->prepare("UPDATE pelanggan SET email = ? WHERE id = ?");
|
||||
// $update->execute([$newmail, $id]);
|
||||
|
||||
echo "$no => $id => $nama => <span style='color:red;'>" . htmlspecialchars($email) . "</span> =NEW> $newmail<br>";
|
||||
}
|
||||
|
||||
$no++;
|
||||
}
|
||||
} else {
|
||||
echo "Tidak ada data ditemukan.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
include "../controller/crudRadiusServer.php";
|
||||
|
||||
$radius = new CrudRadiusServer();
|
||||
$radius->request('add_user', 'POST', [
|
||||
'jenis' => 'Hotspot',
|
||||
'username' => 'TESTVCR',
|
||||
'password' => 'TESTVCR',
|
||||
'groupname' => 'paket-6-device-8',
|
||||
'nasgroupname' => 'server8'
|
||||
]);
|
||||
// try {
|
||||
// $bulan = '2025-08';
|
||||
// $tanggal = date('Y-m-d');
|
||||
// $metode = "API Payment";
|
||||
|
||||
// $stmt = $pdo->prepare("
|
||||
// SELECT v_tagihan.*
|
||||
// FROM v_tagihan
|
||||
// LEFT JOIN transaksi ON v_tagihan.id = transaksi.id_tagihan
|
||||
// WHERE transaksi.id_tagihan IS NULL
|
||||
// AND SUBSTRING(v_tagihan.limit_pembayaran, 1, 7) = :bulan
|
||||
// AND v_tagihan.status = 'lunas'
|
||||
// ");
|
||||
// $stmt->bindParam(':bulan', $bulan);
|
||||
// $stmt->execute();
|
||||
|
||||
// $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// if (!$results) {
|
||||
// echo "Tidak ada tagihan lunas tanpa transaksi di bulan $bulan.<br>";
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// echo "Memproses " . count($results) . " tagihan lunas tanpa transaksi...<br>";
|
||||
|
||||
// foreach ($results as $index => $tagihan) {
|
||||
// $idtag = $tagihan['id'];
|
||||
// $cek = $pdo->prepare("SELECT id_tagihan FROM transaksi WHERE id_tagihan = :idtag");
|
||||
// $cek->bindParam(':idtag', $idtag, PDO::PARAM_INT);
|
||||
// $cek->execute();
|
||||
|
||||
// if ($cek->fetchColumn() === false) {
|
||||
// $statuskas = $tagihan['jenis_layanan'] === 'Hotspot' ? 'Pendapatan Hotspot' : 'Pendapatan PPPOE';
|
||||
|
||||
// // $insert = $pdo->prepare("
|
||||
// // 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
|
||||
// // )
|
||||
// // ");
|
||||
// // $insert->bindParam(':idds', $tagihan['id_data_server'], PDO::PARAM_INT);
|
||||
// // $insert->bindParam(':idtag', $tagihan['id'], PDO::PARAM_INT);
|
||||
// // $insert->bindParam(':idua', $tagihan['id_marketing'], PDO::PARAM_INT);
|
||||
// // $insert->bindParam(':start_time', $tanggal);
|
||||
// // $insert->bindParam(':keterangan', $tagihan['keterangan']);
|
||||
// // $insert->bindParam(':pemasukan', $tagihan['verifikasi_tagihan']);
|
||||
// // $insert->bindParam(':metode', $metode);
|
||||
// // $insert->bindParam(':status', $statuskas);
|
||||
// // $insert->execute();
|
||||
|
||||
// echo "[SUKSES] Insert transaksi untuk tagihan ID: {$tagihan['id']} - {$tagihan['nama']} - {$tagihan['nama_server']}<br>";
|
||||
// } else {
|
||||
// echo "[LEWAT] Tagihan ID {$tagihan['id']} sudah ada di transaksi.<br>";
|
||||
// }
|
||||
// }
|
||||
|
||||
// } catch (PDOException $e) {
|
||||
// echo "[PDO ERROR] " . $e->getMessage() . "<br>";
|
||||
// } catch (Exception $e) {
|
||||
// echo "[ERROR] " . $e->getMessage() . "<br>";
|
||||
// }
|
||||
|
||||
|
||||
// include "../controller/crudRadiusServer.php";
|
||||
|
||||
// $radius = new CrudRadiusServer();
|
||||
// $radius->request('add_user', 'POST', [
|
||||
// 'jenis' => 'Hotspot',
|
||||
// 'username' => 'TESTVCR',
|
||||
// 'password' => 'TESTVCR',
|
||||
// 'groupname' => 'paket-6-device-8',
|
||||
// 'nasgroupname' => 'server8'
|
||||
// ]);
|
||||
|
||||
|
||||
// $radius->request('add_user', 'POST', [
|
||||
@@ -133,7 +262,7 @@ $radius->request('add_user', 'POST', [
|
||||
// // $updateStatusOff[] = $idakun;
|
||||
// // }
|
||||
// // }
|
||||
// // echo $row['nama'] . " =><br>\n";
|
||||
// // echo $row['nama'] . " =><br><br>";
|
||||
|
||||
// // // Update status koneksi yang 'On' sekaligus
|
||||
// // if (!empty($updates)) {
|
||||
@@ -157,6 +286,6 @@ $radius->request('add_user', 'POST', [
|
||||
|
||||
// }
|
||||
// } else {
|
||||
// echo "No data found.\n";
|
||||
// echo "No data found.<br>";
|
||||
// }
|
||||
// ?>
|
||||
|
||||
@@ -1 +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>Tidak perlu update untuk ID: 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>2399 data pesan sebelum 3 hari terakhir berhasil dihapus.<br>
|
||||
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>Tidak perlu update untuk ID: 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.300,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>Harga khusus untuk ID: 74 Rp.0<br>Harga khusus untuk ID: 75 Rp.0<br>Harga khusus untuk ID: 76 Rp.0<br>Tidak perlu update untuk ID: 77 Rp.200,000<br>Harga khusus untuk ID: 78 Rp.200,000<br>Harga khusus untuk ID: 79 Rp.200,000<br>339 data pesan sebelum 3 hari terakhir berhasil dihapus.<br>
|
||||
@@ -24,15 +24,15 @@ try {
|
||||
}
|
||||
|
||||
// Tentukan harga berdasarkan jumlah_agen
|
||||
if ($data['jumlah_agen'] <= 15) {
|
||||
if ($data['jumlah_agen'] <= 30) {
|
||||
$harga_agen = 200000;
|
||||
} elseif ($data['jumlah_agen'] > 15 && $data['jumlah_agen'] <= 30) {
|
||||
} elseif ($data['jumlah_agen'] > 30 && $data['jumlah_agen'] <= 70) {
|
||||
$harga_agen = 300000;
|
||||
} elseif ($data['jumlah_agen'] > 30 && $data['jumlah_agen'] <= 60) {
|
||||
} elseif ($data['jumlah_agen'] > 70 && $data['jumlah_agen'] <= 120) {
|
||||
$harga_agen = 450000;
|
||||
} elseif ($data['jumlah_agen'] > 60 && $data['jumlah_agen'] <= 90) {
|
||||
} elseif ($data['jumlah_agen'] > 120 && $data['jumlah_agen'] <= 180) {
|
||||
$harga_agen = 750000;
|
||||
} elseif ($data['jumlah_agen'] > 90 && $data['jumlah_agen'] <= 130) {
|
||||
} elseif ($data['jumlah_agen'] > 180 && $data['jumlah_agen'] <= 250) {
|
||||
$harga_agen = 1000000;
|
||||
} else {
|
||||
$harga_agen = 1500000; // Harga default jika jumlah_agen lebih dari 130
|
||||
|
||||
Reference in New Issue
Block a user