-
Notifications
You must be signed in to change notification settings - Fork 0
/
peminjaman.php
102 lines (94 loc) · 3.79 KB
/
peminjaman.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
//berkas sistem
require_once './app/config.php';
require_once './app/database.php';
require_once './app/fungsi.php';
//fungsi
_isLogin();
_isLevel([1]);
//konfigurasi halaman
$limit = 5;
$offset = filter_input(INPUT_GET, 'o', FILTER_SANITIZE_NUMBER_INT);
if (empty($offset)) {
$offset = 0;
}
//pencarian
$cari = filter_input(INPUT_POST, 'cari', FILTER_SANITIZE_STRING);
$clear = filter_input(INPUT_GET, 'c', FILTER_SANITIZE_STRING);
if (!empty($cari)) {
$katacari = filter_input(INPUT_POST, 'katacari', FILTER_SANITIZE_STRING);
$_SESSION['cari'] = TRUE;
$_SESSION['katacari'] = $katacari;
}
if ($clear != null) {
unset($_SESSION['cari']);
unset($_SESSION['katacari']);
}
if (isset($_SESSION['cari']) == TRUE) {
$katacari = $_SESSION['katacari'];
$peminjaman = db_peminjaman_get_all_by_cari($db_conn, $limit, $offset, $katacari);
$total = db_peminjaman_count_by_cari($db_conn, $katacari);
} else {
$peminjaman = db_peminjaman_get_all($db_conn, $limit, $offset);
$total = db_peminjaman_count($db_conn);
}
$no = $offset + 1;
$jumlah_data_semua = mysqli_num_rows($total);
$jumlah_data_per_halaman = mysqli_num_rows($peminjaman);
?>
<html>
<head>
<title>Data Peminjaman Inventaris</title>
</head>
<body>
<p><a href="./index.php">Home</a> > Peminjaman Inventaris</p>
<p><a href="./peminjaman_tambah.php">Tambah data Peminjaman Inventaris</a></p>
<form action="./peminjaman.php" method="post">
<input type="text" name="katacari" minlength="3" required placeholder="Cari nama peminjaman"><input type="submit" name="cari" value="Cari">
</form>
<?php if (isset($_SESSION['cari']) == true) : ?>
<p>Mencari data <?= $_SESSION['katacari'] ?>, <a href="./peminjaman.php?c=1">Hapus pencarian</a></p>
<?php endif; ?>
<?php if ($jumlah_data_per_halaman < 1) : ?>
<p><b>Data peminjaman barang tidak ditemukan.</b></p>
<?php else : ?>
<table border="1">
<tr>
<th>No.</th>
<th>Kode Peminjaman</th>
<th>Nama Peminjam</th>
<th>Tanggal Pinjam</th>
<th>Tanggal Kembali</th>
<th>Status Peminjaman</th>
<th>Nama Petugas</th>
<th>Aksi</th>
</tr>
<?php foreach ($peminjaman as $data) : ?>
<tr>
<td><?= $no ?></td>
<td><?= $data['id_peminjaman'] ?></td>
<td><?= $data['nama_pegawai'] ?></td>
<td><?= _tanggal_indo($data['tanggal_pinjam']) ?></td>
<td><?= _tanggal_indo($data['tanggal_kembali']) ?></td>
<td><?= _status_peminjaman_nama($data['status_peminjaman']) ?></td>
<td><?= $data['nama'] ?></td>
<td>
<a href="./peminjaman_detail.php?id=<?= $data['id_peminjaman'] ?>">DETAIL</a>
<a href="./peminjaman_hapus.php?id=<?= $data['id_peminjaman'] ?>">HAPUS</a>
</td>
</tr>
<?php $no++ ?>
<?php endforeach; ?>
</table>
<p>Total data : <?= $jumlah_data_semua ?> Item</p>
<p>
<?php if ($offset > 0) : ?>
<a href="./peminjaman.php?o=<?= $offset - $limit ?>">Sebelumnya</a>
<?php endif; ?>
<?php if (($offset + $limit) < $jumlah_data_semua) : ?>
<a href="./peminjaman.php?o=<?= $offset + $limit ?>">Selanjutnya</a>
<?php endif; ?>
</p>
<?php endif; ?>
</body>
</html>