<?php 
include 'header.php';
include '../koneksi/koneksi.php';
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Master Produk - UMKM Galeri 3D</title>
<style>
body {
    background: #f3f4f6;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}
.container {
  	max-width: 1200px;
    margin: 5px auto;
    padding: 0 30px;
}
.btn-success {
    margin-top: 15px;
    padding: 10px 18px;
    font-weight: 600;
}
</style>
</head>
<body>

<div class="container">
    <h2 style="width:100%; border-bottom:3px solid gray; font-size:30px; margin-bottom: 20px; padding-bottom: 10px;"><b>Master Produk</b></h2>

    <table class="table table-striped">
        <thead>
            <tr>
                <th>No</th>
                <th>Produk</th>
                <th>Gambar</th>
				<th>Stok</th>
                <th>Harga</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php 
            $result = mysqli_query($conn, "SELECT * FROM produk");
            $no = 1;
            while ($row = mysqli_fetch_assoc($result)) {
            ?>
                <tr>
                    <td><?= $no; ?></td>
                    <td>
						<strong><?= $row['kode_produk']; ?></strong><br>
						<span style="color: #555;"><?= $row['nama']; ?></span>
					</td>

                    <td><img src="../image/produk/<?= $row['image']; ?>" width="80"></td>
                    <td><?= $row['stok']; ?></td>
                    <td>
                        <div style="line-height: 1.3;">
                            <strong>Rp <?= number_format($row['harga'], 0, ',', '.'); ?></strong><br>
                            <small style="color: #888;">Diskon: Rp <?= number_format($row['diskon'], 0, ',', '.'); ?></small>
                        </div>
                    </td>
                    <td>
                        <a href="edit_produk.php?kode=<?= $row['kode_produk']; ?>" class="btn btn-warning btn-sm" title="Edit">
                            <i class="glyphicon glyphicon-edit"></i>
                        </a>
                        <a href="proses/del_produk.php?kode=<?= $row['kode_produk']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Yakin ingin menghapus data ini?')" title="Hapus">
                            <i class="glyphicon glyphicon-trash"></i>
                        </a>
                        <a href="bom.php?kode=<?= $row['kode_produk']; ?>" class="btn btn-primary btn-sm" title="Lihat BOM">
                            <i class="glyphicon glyphicon-eye-open"></i>
                        </a>
                    </td>
                </tr> 
            <?php
            $no++; 
            }
            ?>
        </tbody>
    </table>

    <a href="tm_produk.php" class="btn btn-success">
        <i class="glyphicon glyphicon-plus-sign"></i> Tambah Produk
    </a>
</div>

</body>
</html>
