TIF_NGANJUK_E41212035/cetak_bukti_donasi.php

79 lines
2.0 KiB
PHP

<?php
require_once(__DIR__ . '/vendor/tecnickcom/tcpdf/tcpdf.php'); // Sesuaikan path
include 'config/database.php';
if (!isset($_GET['donasi_id'])) {
die("ID donasi tidak ditemukan.");
}
$donasi_id = intval($_GET['donasi_id']);
// Ambil data donasi berdasarkan ID
$query = "SELECT * FROM donasi WHERE donasi_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $donasi_id);
$stmt->execute();
$result = $stmt->get_result();
$donasi = $result->fetch_assoc();
if (!$donasi) {
die("Data donasi tidak ditemukan.");
}
// Ambil data profil masjid
$query_profil = "SELECT * FROM profil LIMIT 1";
$result_profil = $conn->query($query_profil);
$profil = $result_profil->fetch_assoc();
$conn->close();
// Inisialisasi TCPDF
$pdf = new TCPDF();
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->AddPage();
// Judul
$pdf->SetFont('helvetica', 'B', 16);
$pdf->Cell(0, 10, strtoupper($profil['profil_nama']), 0, 1, 'C');
$pdf->SetFont('helvetica', '', 12);
$pdf->Cell(0, 10, $profil['profil_alamatlengkap'], 0, 1, 'C');
$pdf->Ln(5);
// Garis
$pdf->SetLineWidth(0.5);
$pdf->Line(10, 30, 200, 30);
$pdf->Ln(10);
// Detail Donasi
$pdf->SetFont('helvetica', 'B', 14);
$pdf->Cell(0, 10, "Bukti Donasi", 0, 1, 'C');
$pdf->Ln(5);
$pdf->SetFont('helvetica', '', 12);
$pdf->Cell(50, 10, "Nama Donatur:", 0, 0);
$pdf->Cell(100, 10, $donasi['donasi_nama'], 0, 1);
$pdf->Cell(50, 10, "Jumlah Donasi:", 0, 0);
$pdf->Cell(100, 10, "Rp " . number_format($donasi['donasi_jumlah'], 0, ',', '.'), 0, 1);
$pdf->Cell(50, 10, "Metode Pembayaran:", 0, 0);
$pdf->Cell(100, 10, $donasi['donasi_metode'], 0, 1);
$pdf->Cell(50, 10, "Keterangan:", 0, 0);
$pdf->Cell(100, 10, $donasi['donasi_keterangan'], 0, 1);
$pdf->Cell(50, 10, "Tanggal Donasi:", 0, 0);
$pdf->Cell(100, 10, date('d-m-Y'), 0, 1);
$pdf->Ln(10);
// Tanda tangan
$pdf->Cell(0, 10, "Terima kasih atas donasi Anda.", 0, 1, 'C');
$pdf->Ln(15);
$pdf->Cell(0, 10, "____________________", 0, 1, 'C');
$pdf->Cell(0, 10, "Pengurus Masjid", 0, 1, 'C');
// Output PDF
$pdf->Output();
?>