79 lines
2.6 KiB
PHP
79 lines
2.6 KiB
PHP
<?php
|
|
include '../template/template1.php';
|
|
include '../template/header.php';
|
|
include '../template/sidebar.php';
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
<div class="pagetitle">
|
|
<h1>Daftar Produk</h1>
|
|
<nav>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="../index.php">Home</a></li>
|
|
<li class="breadcrumb-item active">Produk</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="card mt-2">
|
|
<div class="card-body">
|
|
<a href="tambah.php" class="btn btn-primary mb-3 mt-3">Tambah Produk</a>
|
|
|
|
<table class="table datatable">
|
|
<thead>
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Nama Produk</th>
|
|
<th>Kategori</th>
|
|
<th>Stok</th>
|
|
<th>Harga</th>
|
|
<th>Gambar</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$no = 1;
|
|
$result = mysqli_query($conn, "SELECT * FROM produk");
|
|
while ($row = mysqli_fetch_assoc($result)) :
|
|
?>
|
|
<tr>
|
|
<td><?= $no++; ?></td>
|
|
<td><?= $row['nama_produk']; ?></td>
|
|
<td><?= $row['kategori']; ?></td>
|
|
<td><?= $row['stok']; ?> <?= $row['satuan']; ?></td>
|
|
<td>Rp <?= number_format($row['harga_jual'], 0, ',', '.'); ?></td>
|
|
<td><img src="<?= $base_url; ?>/assets/img/produk/<?= $row['gambar']; ?>" width="70"></td>
|
|
<td>
|
|
<a href="edit.php?id=<?= $row['id_produk']; ?>" class="btn btn-warning btn-sm">Edit</a>
|
|
<button class="btn btn-danger btn-sm" onclick="hapusProduk(<?= $row['id_produk']; ?>)">Hapus</button>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php include '../template/footer.php'; ?>
|
|
<?php include '../template/template2.php'; ?>
|
|
|
|
<script>
|
|
function hapusProduk(id) {
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: 'Produk ini akan dihapus secara permanen!',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#3085d6',
|
|
confirmButtonText: 'Ya, hapus!',
|
|
cancelButtonText: 'Batal'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = 'hapus.php?id=' + id;
|
|
}
|
|
});
|
|
}
|
|
</script>
|