Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- pages/produk.php -->
- <div class="container-fluid">
- <!-- Page Heading -->
- <div class="d-sm-flex align-items-center justify-content-between mb-4">
- <h1 class="h3 mb-0 text-gray-800">Kategori Buku</h1>
- </div>
- <?php tampilPesan(); ?>
- <div class="row"> <!-- start row untuk tabel -->
- <div class="col-xl-12 col-md-12 mb-12">
- <table class="table table-striped" id="tabel_kategori">
- <thead>
- <tr>
- <th>ID Produk</th>
- <th>Nama Produk</th>
- <th>Stok</th>
- <th>Aksi</th>
- </tr>
- </thead>
- <tbody>
- <?php // mengambil data untuk ditampilkan di tabel
- $sql = "SELECT *
- FROM produk
- ORDER BY prod_id DESC";
- $stmt = $conn->query($sql);
- while ($row = $stmt->fetch(PDO::FETCH_OBJ)):
- ?>
- <tr>
- <td><?= $row->prod_id; ?></td>
- <td><?= $row->prod_nama; ?></td>
- <td><?= $row->prod_stok; ?></td>
- <td>
- <a href="proses/add-cart.php?id=<?= $row->prod_id; ?>" data-remote="false" class="btn btn-info btn-sm" >Beli</a>
- <?php if(batasiTampilan([1,9])): ?>
- <a href="?p=kategori&id=<?= $row->Kode_Kategori; ?>" class="btn btn-sm btn-warning">Edit</a>
- <a href="proses/kategori-proses.php?id=<?= $row->Kode_Kategori; ?>" class="btn btn-sm btn-danger confirm">Hapus</a>
- <?php endif; ?>
- </td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
- </div>
- </div> <!-- end row untuk tabel -->
- <!-- /.container-fluid -->
- </div>
- <!-- Modal -->
- <div id="myModal" class="modal fade" role="dialog">
- <div class="modal-dialog">
- <!-- Modal content-->
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title">Detail Kategori</h4>
- <button type="button" class="close" data-dismiss="modal">×</button>
- </div>
- <div class="modal-body">
- <p>Some text in the modal.</p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- $(document).ready(function() {
- $('#tabel_kategori').DataTable({
- "language": {
- "url": "http://localhost/pwd2019/perpustakaan/vendor/datatables/Indonesian.json"
- }
- });
- });
- $('a.confirm').bind('click',function(e) {
- var baris = $(this).parents('tr');
- e.preventDefault();
- var url = $(this).attr('href');
- Swal.fire({
- title: 'Anda yakin untuk menghapus?',
- text: "Data yang sudah dihapus tidak dapat dikembalikan lagi.",
- type: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: 'Ya, saya yakin',
- cancelButtonText: 'Tidak, saya khilaf'
- }).then((result) => {
- if (result.value) {
- $.get(url).done(function(response) {
- Swal.fire('Data berhasil dihapus').then((result) => {
- baris.remove();
- });
- });
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement