162 lines
5.0 KiB
PHP
162 lines
5.0 KiB
PHP
<?php
|
|
session_start();
|
|
include '../config.php';
|
|
|
|
if (!isset($_SESSION['status_login']) || !$_SESSION['status_login']) {
|
|
echo "<script>alert('Harap login terlebih dahulu.');window.close();</script>";
|
|
exit;
|
|
}
|
|
|
|
$id_pembeli = $_SESSION['id_pembeli'];
|
|
$id_order = isset($_GET['id_order']) ? intval($_GET['id_order']) : null;
|
|
|
|
if (!$id_order) {
|
|
echo "<script>alert('Pesanan tidak ditemukan!');window.close();</script>";
|
|
exit;
|
|
}
|
|
|
|
// Ambil data pesanan
|
|
$query_order = mysqli_query($conn, "SELECT * FROM orders WHERE id_pembeli = '$id_pembeli' AND id_order = '$id_order'");
|
|
$order = mysqli_fetch_assoc($query_order);
|
|
|
|
// Jika pesanan tidak ditemukan
|
|
if (!$order) {
|
|
echo "<script>alert('Pesanan tidak ditemukan!');window.close();</script>";
|
|
exit;
|
|
}
|
|
|
|
// Ambil detail pesanan
|
|
$query_details = mysqli_query($conn, "SELECT * FROM order_details WHERE id_order = '$id_order'");
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Cetak Nota Pesanan</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
text-align: center;
|
|
margin: 20px;
|
|
background-color: #f9f9f9;
|
|
}
|
|
.container {
|
|
width: 90%;
|
|
max-width: 800px;
|
|
background: white;
|
|
padding: 20px;
|
|
margin: auto;
|
|
border-radius: 10px;
|
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h2 {
|
|
margin-bottom: 10px;
|
|
}
|
|
.info {
|
|
text-align: left;
|
|
margin-bottom: 15px;
|
|
}
|
|
.info p {
|
|
margin: 5px 0;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-top: 15px;
|
|
}
|
|
th, td {
|
|
padding: 12px;
|
|
text-align: center;
|
|
border: 1px solid #ddd;
|
|
}
|
|
th {
|
|
background-color: #343a40;
|
|
color: white;
|
|
}
|
|
tr:nth-child(even) {
|
|
background-color: #f8f9fa;
|
|
}
|
|
.total {
|
|
font-size: 18px;
|
|
font-weight: bold;
|
|
color: #28a745;
|
|
margin-top: 20px;
|
|
}
|
|
.print-button {
|
|
margin-top: 15px;
|
|
padding: 10px 15px;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
border-radius: 5px;
|
|
}
|
|
.btn-primary {
|
|
background-color: #007bff;
|
|
color: white;
|
|
}
|
|
.btn-danger {
|
|
background-color: #dc3545;
|
|
color: white;
|
|
}
|
|
@media print {
|
|
.print-button {
|
|
display: none;
|
|
}
|
|
.container {
|
|
box-shadow: none;
|
|
border: none;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body onload="window.print()">
|
|
|
|
<div class="container">
|
|
<h2>Nota Pesanan</h2>
|
|
|
|
<div class="info">
|
|
<p><strong>ID Pesanan:</strong> <?php echo $order['id_order']; ?></p>
|
|
<p><strong>Tanggal Pesanan:</strong> <?php echo date('d-m-Y H:i', strtotime($order['tanggal_order'])); ?></p>
|
|
<p><strong>Status:</strong> <?php echo ucfirst($order['status_order']); ?></p>
|
|
</div>
|
|
|
|
<h3>Detail Pesanan</h3>
|
|
<div class="table-responsive">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Nama Produk</th>
|
|
<th>Jumlah</th>
|
|
<th>Harga</th>
|
|
<th>Potong</th>
|
|
<th>Total</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php while ($detail = mysqli_fetch_assoc($query_details)): ?>
|
|
<?php
|
|
$product_id = $detail['id_produk'];
|
|
$query_product = mysqli_query($conn, "SELECT nama_produk FROM produk WHERE id_produk = '$product_id'");
|
|
$product = mysqli_fetch_assoc($query_product);
|
|
?>
|
|
<tr>
|
|
<td><?php echo $product['nama_produk'] ?? 'Produk Tidak Ditemukan'; ?></td>
|
|
<td><?php echo $detail['jumlah']; ?></td>
|
|
<td>Rp<?php echo number_format($detail['harga'], 0, ',', '.'); ?></td>
|
|
<td><?php echo number_format($detail['potong'], 0, ',', '.'); ?></td>
|
|
<td class="text-success"><strong>Rp<?php echo number_format(($detail['jumlah'] * $detail['harga']), 0, ',', '.'); ?></strong></td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p class="total">Total Pembayaran: Rp<?php echo number_format($order['total_harga'], 0, ',', '.'); ?></p>
|
|
|
|
<button class="print-button btn-primary" onclick="window.print()">Cetak</button>
|
|
<button class="print-button btn-danger" onclick="window.close()">Tutup</button>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|