16 lines
3.5 KiB
PHP
16 lines
3.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
@date_default_timezone_set('Asia/Jakarta');
|
|
function e(string $value): string { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); }
|
|
function rupiah(float $value): string { return 'Rp ' . number_format($value, 0, ',', '.'); }
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('SELECT * FROM print_orders WHERE id = :id LIMIT 1');
|
|
$stmt->execute([':id' => max(0, (int)($_GET['id'] ?? 0))]);
|
|
$order = $stmt->fetch();
|
|
if (!$order) { http_response_code(404); echo 'Invoice tidak ditemukan.'; exit; }
|
|
$subtotal = (float)$order['quantity'] * (float)$order['unit_price'];
|
|
$total = max(0, $subtotal - (float)$order['discount']);
|
|
$remaining = max(0, $total - (float)$order['paid_amount']);
|
|
?>
|
|
<!doctype html><html lang="id"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Invoice <?= e($order['invoice_no']) ?> — Kenanga Kreasindo</title><meta name="description" content="Invoice Kenanga Kreasindo."><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"><link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>"></head><body class="print-body"><main class="print-sheet"><div class="print-actions"><a class="btn btn-outline-dark btn-sm" href="order_detail.php?id=<?= (int)$order['id'] ?>">← Detail</a><button class="btn btn-dark btn-sm" onclick="window.print()">Print / Save PDF</button></div><section class="doc-card"><header class="doc-header"><div><h1>Kenanga Kreasindo</h1><p>Perum BCL Jln Kenanga Raya · kenangakreasindo@gmail.com</p></div><div class="doc-number"><span>Invoice No</span><strong><?= e($order['invoice_no']) ?></strong><small><?= e(date('d M Y', strtotime($order['created_at']))) ?></small></div></header><div class="row g-3 mb-4"><div class="col-6"><div class="doc-box"><span>Company / Customer</span><strong><?= e($order['customer_name']) ?></strong><small><?= e($order['customer_phone']) ?></small></div></div><div class="col-6"><div class="doc-box"><span>Project</span><strong><?= e($order['project_name']) ?></strong><small>Order: <?= e($order['order_no']) ?></small></div></div></div><table class="table invoice-table"><thead><tr><th>Item</th><th>Category</th><th class="text-end">Qty</th><th class="text-end">Disc</th><th class="text-end">Price/Unit</th><th class="text-end">Amount</th></tr></thead><tbody><tr><td><?= e($order['project_name']) ?></td><td><?= e($order['category']) ?></td><td class="text-end"><?= (int)$order['quantity'] ?></td><td class="text-end"><?= e(rupiah((float)$order['discount'])) ?></td><td class="text-end"><?= e(rupiah((float)$order['unit_price'])) ?></td><td class="text-end"><?= e(rupiah($total)) ?></td></tr></tbody></table><div class="row justify-content-end"><div class="col-md-5"><div class="total-box"><div><span>Subtotal</span><strong><?= e(rupiah($subtotal)) ?></strong></div><div><span>Disc</span><strong><?= e(rupiah((float)$order['discount'])) ?></strong></div><div><span>Total</span><strong><?= e(rupiah($total)) ?></strong></div><div><span>Paid</span><strong><?= e(rupiah((float)$order['paid_amount'])) ?></strong></div><div class="remaining"><span>Remaining payment</span><strong><?= e(rupiah($remaining)) ?></strong></div></div></div></div><div class="payment-box"><strong>Informasi Pembayaran</strong><p>Transfer ke rekening resmi Kenanga Kreasindo. Nomor rekening dapat diisi pada iterasi berikutnya sesuai rekening aktif.</p></div><div class="signature-row"><div>Received</div><div>Kenanga Kreasindo</div><div>Customer</div></div></section></main></body></html>
|