Pisah server penyimpanan dan update payment gateway
This commit is contained in:
@@ -287,6 +287,8 @@ if (isset($_POST['ganerate'])) {
|
||||
$lainnya = '0';
|
||||
$totalAmount = number_format($invi['total_list']);
|
||||
$terbilang = terbilang($invi['total_list']).' rupiah';
|
||||
|
||||
$filename = 'INV-'.$customerName.'-' . $invoiceNumber . '.pdf';
|
||||
|
||||
// Membuat instance PDF
|
||||
require ("invoice/generate_invoice.php");
|
||||
@@ -305,9 +307,18 @@ if (isset($_POST['ganerate'])) {
|
||||
// Menambahkan pembuat ke PDF
|
||||
$pdf->Pembuat($Pembuat);
|
||||
// Output PDF ke browser
|
||||
$pdf->Output('F', 'invoice/inv_contoh/INV-'.$customerName.'-' . $invoiceNumber . '.pdf');
|
||||
// $pdf->Output('F', 'invoice/inv_contoh/INV-'.$customerName.'-' . $invoiceNumber . '.pdf');
|
||||
|
||||
// Upload ke minio storage
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
$pdfData = $pdf->Output('S');
|
||||
$objectPath = 'invoice_pdf/' . $filename;
|
||||
$uploadResult = uploadToMinioStorageRaw($pdfData, $objectPath);
|
||||
|
||||
$fileOpen = 'https://storage.manjapro.net/files/' . $objectPath;
|
||||
|
||||
echo '<script type="text/javascript">window.open("invoice/inv_contoh/INV-'.$customerName.'-' . $invoiceNumber . '.pdf", "_blank")</script>';
|
||||
// echo '<script type="text/javascript">window.open("invoice/inv_contoh/INV-'.$customerName.'-' . $invoiceNumber . '.pdf", "_blank")</script>';
|
||||
echo '<script type="text/javascript">window.open("'. $fileOpen . '", "_blank")</script>';
|
||||
// // sweetAlert("Data berhasil di simpan", "success");
|
||||
}
|
||||
?>
|
||||
+2
-2
@@ -167,7 +167,7 @@ function loadMoreData(searchTerm = '', startDate = '', endDate = '', idS = <?php
|
||||
<td class="hide-on-mobile">${truncatedData.keterangan} ${truncatedData.nama ? `(${truncatedData.nama})` : ''}</td>
|
||||
<td class="hide-on-mobile">
|
||||
${truncatedData.pemasukan ? 'Rp. ' + Number(truncatedData.pemasukan).toLocaleString() : ''}
|
||||
${truncatedData.bukti_pembayaran ? `<img src="img/user/${truncatedData.bukti_pembayaran}" height="35px" class="thumbnail ml-3" data-toggle="modal" data-target="#imageModal" data-fullsize="img/user/${truncatedData.bukti_pembayaran}">` : ''}
|
||||
${truncatedData.bukti_pembayaran ? `<img src="https://storage.manjapro.net/files/user/${truncatedData.bukti_pembayaran}" height="35px" class="thumbnail ml-3" data-toggle="modal" data-target="#imageModal" data-fullsize="https://storage.manjapro.net/files/user/${truncatedData.bukti_pembayaran}">` : ''}
|
||||
</td>
|
||||
<td class="hide-on-mobile hide-on-tablet">${truncatedData.pengeluaran ? 'Rp. ' + Number(truncatedData.pengeluaran).toLocaleString() : ''}</td>
|
||||
<td class="hide-on-mobile hide-on-tablet">${truncatedData.metode_pembayaran}</td>
|
||||
@@ -185,7 +185,7 @@ function loadMoreData(searchTerm = '', startDate = '', endDate = '', idS = <?php
|
||||
<th>Kas Masuk</th>
|
||||
<td>
|
||||
${truncatedData.pemasukan ? 'Rp. ' + Number(truncatedData.pemasukan).toLocaleString() : ''}
|
||||
${truncatedData.bukti_pembayaran ? `<img src="img/user/${truncatedData.bukti_pembayaran}" height="35px" class="thumbnail ml-3" data-toggle="modal" data-target="#imageModal" data-fullsize="img/user/${truncatedData.bukti_pembayaran}">` : ''}
|
||||
${truncatedData.bukti_pembayaran ? `<img src="https://storage.manjapro.net/files/user/${truncatedData.bukti_pembayaran}" height="35px" class="thumbnail ml-3" data-toggle="modal" data-target="#imageModal" data-fullsize="https://storage.manjapro.net/files/user/${truncatedData.bukti_pembayaran}">` : ''}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="hide-on-laptop">
|
||||
|
||||
@@ -165,7 +165,7 @@ if (isset($_POST['kirim'])) {
|
||||
$sk1 = !empty($sk) ? " AND status_koneksi = :sk" : "";
|
||||
$mt1 = !empty($mt) ? " AND id_master_topologi = :mt" : "";
|
||||
|
||||
$target_dir = "https://manjapro.net/img/user/";
|
||||
$target_dir = "https://storage.manjapro.net/files/user/";
|
||||
$SQL = "WHERE id_data_server IN ($idsv)" . $sp1 . $sk1 . $mt1;
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php if($SvId == 2 || $_SESSION['user'] == 1 ) { ?>
|
||||
<?php if($SvId == 2 || $_SESSION['user'] == 1 || $SvId == 12) { ?>
|
||||
|
||||
<?php
|
||||
$stmt3 = $pdo->prepare("SELECT * FROM master_template_pesan WHERE id = :id");
|
||||
|
||||
+29
-42
@@ -199,38 +199,6 @@ $datakonpensasi = ($data[0]['konpensasi'] == 0) ? $data[0]['jumlah_konpensasi']
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$gambarKwitansi = 'img/'.$result['backround_kwitansi']; // Pastikan variabel
|
||||
$tanggalbayar = $_POST['formatted_datetime'];
|
||||
|
||||
// $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, 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, 'Dengan Nomor Layanan', $black);
|
||||
// imagestring($img, 5, 200, 150, ': '.$user, $black);
|
||||
// imagestring($img, 4, 30, 175, 'Sejumlah Uang', $black);
|
||||
// imagestring($img, 4, 200, 175, ': '.terbilang($nominal).' rupiah', $black);
|
||||
// imagestring($img, 4, 30, 200, 'Untuk Pembayaran', $black);
|
||||
// imagestring($img, 4, 200, 200, ':', $black);
|
||||
// imagestring($img, 5, 100, 225, $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);
|
||||
// // Simpan file ke direktori 'invoice'
|
||||
// $invoicePath = 'invoice/'.$invoice;
|
||||
|
||||
|
||||
$img = imagecreatefrompng($gambarKwitansi);
|
||||
// Buat beberapa warna
|
||||
@@ -288,12 +256,19 @@ $datakonpensasi = ($data[0]['konpensasi'] == 0) ? $data[0]['jumlah_konpensasi']
|
||||
// Simpan file ke direktori 'invoice'
|
||||
$invoicePath = 'invoice/'.$invoice;
|
||||
|
||||
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
ob_start();
|
||||
imagepng($img);
|
||||
$imageData = ob_get_clean();
|
||||
|
||||
if (!imagepng($img, $invoicePath)) {
|
||||
echo "<br>".$invoicePath;
|
||||
die('Gagal menyimpan gambar.');
|
||||
} else {
|
||||
|
||||
// Upload file ke Minio
|
||||
$responMinio = uploadToMinioStorageRaw($imageData,$invoicePath);
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
//Get Mikrotik Setting
|
||||
@@ -373,25 +348,37 @@ $datakonpensasi = ($data[0]['konpensasi'] == 0) ? $data[0]['jumlah_konpensasi']
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
// --- KIRIM CUSTOM ----
|
||||
// if (in_array($data[0]['id_data_server'], [2, 3, 4, 5, 6, 8, 9])) {
|
||||
// $nomor = explode(',', $data[0]['nomor_whatsapp'] . ',6282130888937');
|
||||
// } else {
|
||||
// $nomor = explode(',', $data[0]['nomor_whatsapp']);
|
||||
// }
|
||||
// Cari Payment Gateway
|
||||
$stmt = $pdo->prepare("SELECT payment_gateway, apikey_payment_gateway, url_payment_gateway, status_payment_gateway
|
||||
FROM data_server WHERE id = :id_data");
|
||||
$stmt->bindParam(':id_data', $data[0]['id_data_server'], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$paygw = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($paygw['apikey_payment_gateway'])
|
||||
&& $paygw['status_payment_gateway'] === 'ACTIVE'
|
||||
&& $paygw['payment_gateway'] == 'flip'
|
||||
&& !empty($data[0]['transaction_id'])) {
|
||||
|
||||
require 'payment/flip/Flip/Transaction.php';
|
||||
$flip = new FlipPaymentGateway($paygw['apikey_payment_gateway'], $paygw['url_payment_gateway']);
|
||||
$response = $flip->editBill($data[0]['transaction_id'], 'INACTIVE', $data[0]['keterangan'], $data[0]['verifikasi_tagihan']);
|
||||
}
|
||||
// nanti jangan lupa ubah yang keterangan jadi transaction_title
|
||||
|
||||
|
||||
$nomor = explode(',', $data[0]['nomor_whatsapp']);
|
||||
// Kirim Pesan WhatsApp
|
||||
$Url = baseurl($invoicePath);
|
||||
// $Url = baseurl($invoicePath);
|
||||
|
||||
$Url = $responMinio;
|
||||
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Create_Pesan($data[0]['id_data_server'],$idtag,'Pesan Melunasi Tagihan','tag');
|
||||
$Pesan = $APIwa->Get_Pesan();
|
||||
$APIwa->Send_Pesan($data[0]['id_data_server'],['sendMediaFromUrl','Pesan Melunasi Tagihan'],$nomor,$Pesan,$Url);
|
||||
// echo $Pesan;
|
||||
// echo $Pesan;
|
||||
sweetAlert("Pembayaran tagihan berhasil", "success", "?".encrypt_url('tagihan_detail_lunas|' . $idtag));
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -110,6 +110,9 @@ if (isset($_POST['tambah'])) {
|
||||
// Calculate billing details
|
||||
$limit_tag = $_POST['tanggal'];
|
||||
$keterangan = "Tagihan Layanan Internet bulan " . formatIndo($limit_tag, 'F Y');
|
||||
|
||||
$keteranganName = ucwords(strtolower(preg_replace('/[^a-zA-Z\s]/', '', $pelanggan['nama'])));
|
||||
$keteranganFlip = "Tagihan bulan " . formatIndo($limit_tag, 'F Y') . " (a.n " . $keteranganName . ")";
|
||||
$status = 'pending';
|
||||
|
||||
// Payment gateway processing
|
||||
@@ -122,7 +125,7 @@ if (isset($_POST['tambah'])) {
|
||||
if (!empty($paygw['apikey_payment_gateway']) && $paygw['status_payment_gateway'] === 'ACTIVE' && $paygw['payment_gateway'] == 'flip') {
|
||||
require 'payment/flip/Flip/Transaction.php';
|
||||
$flip = new FlipPaymentGateway($paygw['apikey_payment_gateway'], $paygw['url_payment_gateway']);
|
||||
$response = $flip->createBill($keterangan, $total_desimal, $pelanggan['email'], $pelanggan['nama'], $pelanggan['nomor_whatsapp'], $pelanggan['alamat']);
|
||||
$response = $flip->createBill($keteranganFlip, $total_desimal, $pelanggan['email'], $pelanggan['nama'], $pelanggan['nomor_whatsapp'], $pelanggan['alamat']);
|
||||
|
||||
if (isset($response['link_id'])) {
|
||||
$transaction_id = $response['link_id'];
|
||||
|
||||
@@ -266,7 +266,7 @@ $paygw = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$tagihan = $data[0]['nominal_tagihan'] - $jumlahkon ;
|
||||
} else {
|
||||
$konpensasi = $_POST['potongan'];
|
||||
$jumhari = date('t');
|
||||
$jumhari = 30;
|
||||
$jumlahkon = $data[0]['nominal_tagihan'] / $jumhari * $konpensasi;
|
||||
$tagihan = $data[0]['nominal_tagihan'] - $jumlahkon ;
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ if ($data[0]['konpensasi'] == 0) {
|
||||
<div class="col-md-6">
|
||||
<center>
|
||||
<h6>Bukti Pembayaran</h6><hr>
|
||||
<img src="img/user/<?php echo $data[0]['bukti_pembayaran']; ?>" height="400px"><br>
|
||||
<img src="https://storage.manjapro.net/files/user/<?php echo $data[0]['bukti_pembayaran']; ?>" height="400px"><br>
|
||||
<h6>Kwitansi Lunas</h6><hr>
|
||||
<img src="invoice/<?php echo $data[0]['img_invoice']; ?>" width="100%">
|
||||
<img src="https://storage.manjapro.net/files/invoice/<?php echo $data[0]['img_invoice']; ?>" width="100%">
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
@@ -240,7 +240,7 @@ if ($data[0]['konpensasi'] == 0) {
|
||||
|
||||
if (isset($_POST['kirim'])) {
|
||||
$Nomor = array($data[0]['nomor_whatsapp']);
|
||||
$Url = baseurl('invoice/'.$data[0]['img_invoice']);
|
||||
$Url = 'https://storage.manjapro.net/files/invoice/' . $data[0]['img_invoice'];
|
||||
$Pesan = "Kwitansi Pembayaran bulan ".formatIndo($data[0]['tanggal_bayar'], 'F Y');
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Send_Pesan($data[0]['id_data_server'],'sendMediaFromUrl',$Nomor,$Pesan,$Url);
|
||||
@@ -284,10 +284,16 @@ if (isset($_POST['thermal'])) {
|
||||
|
||||
$pdf->dataItems($items, $data[0]['tanggal_bayar'], formatIndo($data[0]['limit_pembayaran'], 'F Y'));
|
||||
|
||||
$outputPath = "invoice/thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
$pdf->Output('F', $outputPath);
|
||||
// $outputPath = "invoice/thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
// $pdf->Output('F', $outputPath);
|
||||
|
||||
echo '<script type="text/javascript">window.open("' . $outputPath . '", "_blank")</script>';
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
$pdfData = $pdf->Output('S');
|
||||
$objectPath = "invoice_thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
$uploadResult = uploadToMinioStorageRaw($pdfData, $objectPath);
|
||||
$fileOpen = 'https://storage.manjapro.net/files/' . $objectPath;
|
||||
|
||||
echo '<script type="text/javascript">window.open("' . $fileOpen . '", "_blank")</script>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -162,9 +162,15 @@ if (isset($_POST['thermal'])) {
|
||||
|
||||
$pdf->dataItems($items, $data[0]['tanggal_bayar'], formatIndo($data[0]['limit_pembayaran'], 'F Y'));
|
||||
|
||||
$outputPath = "invoice/thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
$pdf->Output('F', $outputPath);
|
||||
// $outputPath = "invoice/thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
// $pdf->Output('F', $outputPath);
|
||||
|
||||
echo '<script type="text/javascript">window.open("' . $outputPath . '", "_blank")</script>';
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
$pdfData = $pdf->Output('S');
|
||||
$objectPath = "invoice_thermal/INV-" . preg_replace("/[^a-zA-Z0-9]/", "_", $data[0]['nama']) . "-" . $data[0]['tanggal_bayar'] . ".pdf";
|
||||
$uploadResult = uploadToMinioStorageRaw($pdfData, $objectPath);
|
||||
$fileOpen = 'https://storage.manjapro.net/files/' . $objectPath;
|
||||
|
||||
echo '<script type="text/javascript">window.open("' . $fileOpen . '", "_blank")</script>';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -117,11 +117,11 @@ $data = $stmt->fetchAll();
|
||||
<div class="col-md-6">
|
||||
<?php if($data[0]['status'] == 4 OR $data[0]['status'] == 5) { ?>
|
||||
<h6>Foto Sebelum Perbaikan</h6><br>
|
||||
<img src="img/user/<?php echo $data[0]['img_sebelum']; ?>" width="100%">
|
||||
<img src="https://storage.manjapro.net/files/user/<?php echo $data[0]['img_sebelum']; ?>" width="100%">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h6>Foto Setelah Perbaikan</h6><br>
|
||||
<img src="img/user/<?php echo $data[0]['img_selesai']; ?>" width="100%">
|
||||
<img src="https://storage.manjapro.net/files/user/<?php echo $data[0]['img_selesai']; ?>" width="100%">
|
||||
<!-- Sebelum di perbaikai -->
|
||||
<?php } if($data[0]['status'] == 2) { ?>
|
||||
<label>Foto sebelum di perbaikan</label>
|
||||
|
||||
+190
-7
@@ -92,6 +92,19 @@ if (!isValidLong($long)) {
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group m-1" id="group-dropdown6">
|
||||
<?php
|
||||
// Tanggal di Tambahkan 1 Bulan agar di jalankan cronjib sesuai..
|
||||
$baseTanggal = !empty($isi['mulai_pembayaran']) ? $isi['mulai_pembayaran'] : date('Y-m-d');
|
||||
$date = new DateTime($baseTanggal);
|
||||
$date->modify('+1 month');
|
||||
$mulaiBayar = $date->format('Y-m-d');
|
||||
$mulaiBayarFormatted = date('d-m-Y', strtotime($mulaiBayar));
|
||||
|
||||
?>
|
||||
<label>Mulai Bayar Tagihan</label>
|
||||
<input type="text" id="formTgl" class="form-control" name="mulai_pembayaran" value="<?php echo $mulaiBayarFormatted; ?>">
|
||||
</div>
|
||||
<div class="form-group m-1" id="group-dropdown3">
|
||||
<label>Marketing Area / Penagih</label>
|
||||
<select id="dropdown3" class="form-control select2bs4" required="required" name="idm" data-id="<?php echo $isi['id_marketing']; ?>">
|
||||
@@ -254,7 +267,12 @@ if (!isValidLong($long)) {
|
||||
<?php } if($isi['status'] == 'sampah' && in_array("Aktivasi", $json_array[2]['sub_menu'])) { ?>
|
||||
<button type="submit" class="btn btn-primary btn-sm m-1" name="aktifkan">Aktifkan Status Pelanggan</button>
|
||||
<button type="submit" class="btn btn-danger btn-sm m-1" name="hapus">Hapus Permanen</button>
|
||||
|
||||
|
||||
<?php } if ($isi['status'] == 'aktif' && $_SESSION['user'] == 1) {?>
|
||||
<button type="submit" class="btn btn-success btn-sm m-1" name="berita_acara_pemasangan">Buat Berita Acara Pemasangan</button>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -334,6 +352,12 @@ if (isset($_POST['aktivasi'])) {
|
||||
$serialnumber = str_replace(' ', '', $serialnumber);
|
||||
$serialnumber = preg_replace('/[^A-Za-z0-9]/', '', $serialnumber);
|
||||
$serialnumber = strtoupper($serialnumber);
|
||||
|
||||
// DI kurangi 1 bulan agar cronjob berjalan sesuai harapan
|
||||
$Formatted = date('Y-m-d', strtotime($_POST['mulai_pembayaran']));
|
||||
$date1 = new DateTime($Formatted);
|
||||
$date1->modify('-1 month');
|
||||
$mulaiBayarFix = $date1->format('Y-m-d');
|
||||
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Create_Pesan($isi['id_data_server'], $isi['id'], 'Pesan Aktivasi');
|
||||
@@ -368,7 +392,8 @@ if (isset($_POST['aktivasi'])) {
|
||||
user_hotspot = :user_hotspot,
|
||||
kode_unik_tagihan = :kodeuser,
|
||||
time_start = :time_start,
|
||||
serial_number = :serial_number
|
||||
serial_number = :serial_number,
|
||||
mulai_pembayaran = :mulai_pembayaran
|
||||
WHERE id = :id");
|
||||
$stmt->execute([
|
||||
':id_setting_mikrotik' => $_POST['ism'],
|
||||
@@ -380,6 +405,7 @@ if (isset($_POST['aktivasi'])) {
|
||||
'kodeuser' => $kodeuser,
|
||||
'time_start' => $time_start,
|
||||
'serial_number' => $serialnumber,
|
||||
'mulai_pembayaran' => $mulaiBayarFix,
|
||||
'id' => $isi['id']
|
||||
]);
|
||||
|
||||
@@ -402,6 +428,135 @@ if (isset($_POST['aktivasi'])) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['berita_acara_pemasangan'])) {
|
||||
try {
|
||||
require('controller/surat_pdf/BA_Template.php');
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM v_pelanggan WHERE id = :id");
|
||||
$stmt->execute(['id' => $page[1]]);
|
||||
$userData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM profile_tagihan WHERE id = :id");
|
||||
$stmt->execute(['id' => $isi['id_profile_tagihan']]);
|
||||
$tagData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
$hargaDasar = $userData['nominal_tagihan'] + ($userData['nominal_tagihan'] / 100 * 11);
|
||||
$hargaPaket = substr($hargaDasar, 0, -3) . '000';
|
||||
$limit = $tagData['limit_tagihan'] - 1;
|
||||
|
||||
$langganan = $userData['time_start'];
|
||||
// $mulaiLangganan = $langganan . ' WIB';
|
||||
$mulaiLangganan = $langganan . ' WIB';
|
||||
|
||||
$tanggal = new DateTime($userData['mulai_pembayaran']);
|
||||
$tanggal->modify('+1 month');
|
||||
$tanggalNow = $tanggal->format('Y-m-d');
|
||||
|
||||
|
||||
$startPay = formatIndo($tanggalNow, 'F Y');
|
||||
$freeWifi = formatIndo($langganan) . ' hingga 01 ' . $startPay; // 26 Oktober 2025 hingga 01 Desember 2025
|
||||
// Data dari POST (contoh simulasi)
|
||||
$data = [
|
||||
'template_name' => 'ba_pemasangan',
|
||||
'header' => [
|
||||
'nama_perusahaan' => 'PT. LINTAS JARINGAN NUSANTARA',
|
||||
'kantor' => 'KANTOR LAYANAN CIKEMBAR',
|
||||
'telp' => '+62 812-1161-0233',
|
||||
'email' => 'info@rjn-net.id',
|
||||
'website' => 'www.rjn-net.id',
|
||||
'imglogo' => 'controller/surat_pdf/logo.png'
|
||||
],
|
||||
|
||||
'body' => [
|
||||
'bodyHead' => [
|
||||
'parameter' => ['PT Lintas Jaringan Nusantara Kantor Layanan Cikembar']
|
||||
],
|
||||
|
||||
'bodyData' => [
|
||||
'Nomor Layanan' => $userData['akun'],
|
||||
'Nama Pelanggan' => ucwords(strtolower($userData['nama'])),
|
||||
'Nomor NIK / KTP' => $userData['nik'],
|
||||
'Nomor WhatsApp' => $userData['nomor_whatsapp'],
|
||||
'Alamat Rumah' => $userData['alamat'],
|
||||
'Kordinat Rumah' => $userData['latitude'] . ', ' . $userData['longitude'],
|
||||
'Wilayah / ID Area' => $userData['nama_topologi'],
|
||||
'Nama Paket iNet' => $userData['nama_paket'],
|
||||
'Tagihan Internet' => 'Rp. ' . number_format($hargaPaket) . ' (sudah termasuk PPN 11%)',
|
||||
'Jatuh Tempo' => 'Setiap Bulan Tanggal ' . $limit,
|
||||
'Nomor WA Penagih' => $userData['nomor_marketing'] . ' (' . $userData['nama_marketing'] . ')',
|
||||
'Status Berlangganan' => ucwords($userData['status']),
|
||||
'Terdaftar Sejak' => $mulaiLangganan,
|
||||
'Status Alat' => 'Dipinjamkan (alat dalam rumah tanggung jawab pelanggan)',
|
||||
'Kode Seri' => $userData['serial_number'],
|
||||
'Status Pembayaran' => 'Via Transfer'
|
||||
],
|
||||
|
||||
'bodyNote' => [
|
||||
[
|
||||
'judul' => 'CATATAN PENTING',
|
||||
'parameter' => [
|
||||
'Rp. 150.000',
|
||||
$startPay,
|
||||
$freeWifi,
|
||||
$startPay
|
||||
]
|
||||
],
|
||||
[
|
||||
'judul' => 'CARA PEMBAYARAN',
|
||||
'parameter' => [$startPay]
|
||||
],
|
||||
[
|
||||
'judul' => 'LAYANAN PELANGGAN',
|
||||
'parameter' => [$userData['akun']]
|
||||
],
|
||||
[
|
||||
'judul' => 'TENTANG KAMI',
|
||||
'parameter' => []
|
||||
]
|
||||
],
|
||||
|
||||
'bodyTTD' => [
|
||||
'nama' => 'PT. LINTAS JARINGAN NUSANTARA',
|
||||
'jabatan' => 'Admin Kantor Layanan Cikembar',
|
||||
'imgttd' => 'ttd_admin.png'
|
||||
]
|
||||
],
|
||||
'footer' => [
|
||||
'parameter' => []
|
||||
]
|
||||
];
|
||||
|
||||
// Gabung data + template
|
||||
$result = mergeTemplateWithData($data);
|
||||
|
||||
// Buat PDF
|
||||
$pdf = new BA_Template($result);
|
||||
$pdf->BodyContent();
|
||||
|
||||
// Simpan file PDF
|
||||
// $pdfPath = 'berita_acara/pemasangan/BA-Pemasangan-' . ucwords(strtolower($userData['nama'])) . '-' . $userData['akun'] . '.pdf';
|
||||
// $pdf->Output('F', $pdfPath);
|
||||
|
||||
$objectPath = 'berita_acara/BA-Pemasangan-' . ucwords(strtolower($userData['nama'])) . '-' . $userData['akun'] . '.pdf';
|
||||
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
$pdfData = $pdf->Output('S');
|
||||
// $objectPath = 'berita_acara/' . $filename;
|
||||
$uploadResult = uploadToMinioStorageRaw($pdfData, $objectPath);
|
||||
|
||||
$fileOpen = 'https://storage.manjapro.net/files/' . $objectPath;
|
||||
|
||||
// Tampilkan ke tab baru
|
||||
echo '<script type="text/javascript">window.open("' . $fileOpen . '", "_blank");</script>';
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo '<script>alert("Terjadi kesalahan: ' . $e->getMessage() . '");</script>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Buat Berita Acara Pengambilan Alat di Rumah pelanggan OFF
|
||||
if (isset($_POST['berita_acara'])) {
|
||||
try {
|
||||
@@ -437,11 +592,18 @@ if (isset($_POST['berita_acara'])) {
|
||||
$pdf->AddBeritaAcara($isi['akun'], $isi['nomor_whatsapp'], $isi['nama'], $isi['alamat']);
|
||||
|
||||
// Output PDF ke file
|
||||
$pdfFile = 'berita_acara/BA-pengambilan-alat-' . $isi['nama'] . '-' . $isi['akun'] . '.pdf';
|
||||
$pdf->Output('F', $pdfFile);
|
||||
$objectPath = 'berita_acara/BA-Pengambilan-Alat-' . $isi['nama'] . '-' . $isi['akun'] . '.pdf';
|
||||
// $pdf->Output('F', $objectPath);
|
||||
|
||||
require 'controller/uploadMinioFiles.php';
|
||||
$pdfData = $pdf->Output('S');
|
||||
// $objectPath = 'berita_acara/' . $filename;
|
||||
$uploadResult = uploadToMinioStorageRaw($pdfData, $objectPath);
|
||||
|
||||
$fileOpen = 'https://storage.manjapro.net/files/' . $objectPath;
|
||||
|
||||
// Tampilkan PDF di tab baru
|
||||
echo '<script type="text/javascript">window.open("' . $pdfFile . '", "_blank")</script>';
|
||||
echo '<script type="text/javascript">window.open("' . $fileOpen . '", "_blank")</script>';
|
||||
|
||||
} catch (Exception $e) {
|
||||
sweetAlert("Error: ' . $e->getMessage() . '", "error");
|
||||
@@ -517,6 +679,12 @@ if (isset($_POST['ubah'])) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DI kurangi 1 bulan agar cronjob berjalan sesuai harapan
|
||||
$Formatted = date('Y-m-d', strtotime($_POST['mulai_pembayaran']));
|
||||
$date1 = new DateTime($Formatted);
|
||||
$date1->modify('-1 month');
|
||||
$mulaiBayarFix = $date1->format('Y-m-d');
|
||||
|
||||
$SQL = "UPDATE pelanggan SET
|
||||
id_data_server = :id_data_server,
|
||||
@@ -541,7 +709,8 @@ if (isset($_POST['ubah'])) {
|
||||
foto_rumah = :foto_rumah,
|
||||
foto_onu = :foto_onu,
|
||||
foto_test = :foto_test,
|
||||
serial_number = :serial_number
|
||||
serial_number = :serial_number,
|
||||
mulai_pembayaran = :mulai_pembayaran
|
||||
WHERE id = :id";
|
||||
|
||||
try {
|
||||
@@ -570,10 +739,12 @@ if (isset($_POST['ubah'])) {
|
||||
':foto_onu' => $fotoonu1,
|
||||
':foto_test' => $fototes1,
|
||||
':serial_number' => $serialnumber,
|
||||
':mulai_pembayaran' => $mulaiBayarFix,
|
||||
':id' => $page[1]
|
||||
]);
|
||||
|
||||
|
||||
sweetAlert("Data pelanggan " . $logubahpaket . "berhasil diubah", "success");
|
||||
sweetAlert("Data pelanggan " . $logubahpaket . "berhasil diubah ", "success");
|
||||
} catch (PDOException $e) {
|
||||
// Handle error appropriately
|
||||
sweetAlert("Error: " . $e->getMessage(), "error");
|
||||
@@ -731,4 +902,16 @@ $_SESSION['uploaded_files']['rmh'.$isi['id']] = $isi['foto_rumah'];
|
||||
$_SESSION['uploaded_files']['onu'.$isi['id']] = $isi['foto_onu'];
|
||||
$_SESSION['uploaded_files']['tes'.$isi['id']] = $isi['foto_test'];
|
||||
?>
|
||||
<script type="text/javascript" src="dist/js/mapsFormCustom.js"></script>
|
||||
<script type="text/javascript" src="dist/js/mapsFormCustom.js"></script>
|
||||
<!-- Tambahkan library Flatpickr -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/id.js"></script>
|
||||
|
||||
<script>
|
||||
flatpickr("#formTgl", {
|
||||
dateFormat: "d-m-Y", // format tampilan
|
||||
locale: "id", // pakai bahasa Indonesia
|
||||
allowInput: true // bisa diketik manual juga
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user