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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php include 'koneksi.php'; ?>
<?php include 'common/header.php'; ?>
<h3><span class="glyphicon glyphicon-shopping-cart"></span> Daftar Menu </h3>
<button style="margin-bottom:20px" data-toggle="modal" data-target="#myModal" class="btn btn-warning col-md-2"><span class="glyphicon glyphicon-plus"></span>Tambah Menu</button>
<br/>
<br/>
<?php
$per_hal = 10;
$jumlah_record = mysql_query("SELECT COUNT(*) from menu");
$jum = mysql_result($jumlah_record, 0);
$halaman = ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
?>
<div class="col-md-12">
<table class="col-md-2">
<tr>
<td>Jumlah Record</td>
<td><?php echo $jum; ?></td>
</tr>
<tr>
<td>Jumlah Halaman</td>
<td><?php echo $halaman; ?></td>
</tr>
</table>
</div>
<form action="cari.php" method="get">
<div class="input-group col-md-5 col-md-offset-7">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-search"></span></span>
<input type="text" class="form-control" placeholder="Cari menu di sini .." aria-describedby="basic-addon1" name="cari">
</div>
</form>
<br/>
<table class="table table-hover">
<tr>
<th class="col-md-1">No</th>
<th class="col-md-3">Gambar</th>
<th class="col-md-2">Nama Barang</th>
<th class="col-md-2">Harga</th>
<th class="col-md-2"> Kategori </th>
<!-- <th class="col-md-1">Sisa</th> -->
<th class="col-md-3">Opsi</th>
</tr>
<?php
if (isset($_GET['cari'])) {
$cari = mysql_real_escape_string($_GET['cari']);
$menu = mysql_query("select * from menu where nama like '$cari' or kategori_id like '$cari'");
} else {
$menu = mysql_query("select * from menu limit $start, $per_hal");
}
$no = 1;
while ($b = mysql_fetch_array($menu)) {
?>
<tr>
<td><?php echo $no++ ?></td>
<td>
<img class="img-responsive" src="picture/<?php echo $b['gambar']; ?>" width="150" height="100">
</td>
<td><?php echo $b['nama'] ?></td>
<td>Rp.<?php echo number_format($b['harga']) ?>,-</td>
<td><?php
if ($b['kategori_id'] == 1) {
echo 'Makanan';
} else if ($b['kategori_id'] == 2) {
echo 'Minuman';
}
?>
</td>
<td>
<a href="detail.php?id=<?php echo $b['id_menu']; ?>" class="btn btn-success"><span class="glyphicon glyphicon-eye-open"> </span></a>
<a href="edit.php?id=<?php echo $b['id_menu']; ?>" class="btn btn-info"><span class="glyphicon glyphicon-edit"></span></a>
<a onclick="if (confirm('Apakah anda yakin ingin menghapus data ini ??')) {
location.href = 'delete.php?id=<?php echo $b['id_menu']; ?>'
}" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
<?php
}
?>
</table>
<ul class="pagination">
<?php
for ($x = 1; $x <= $halaman; $x++) {
?>
<li><a href="?page=<?php echo $x ?>"><?php echo $x ?></a></li>
<?php
}
?>
</ul>
<!-- modal input -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Tambah Menu</h4>
</div>
<div class="modal-body">
<form action="tambah_proses.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label> Gambar </label>
<input type="file" name="gambar" class="form-control">
</div>
<div class="form-group">
<label>Nama</label>
<input name="nama" type="text" class="form-control" placeholder="Nama Menu .."/>
</div>
<div class="form-group">
<label>Harga</label>
<input name="harga" type="text" class="form-control" placeholder="Harga Jual per porsi"/>
</div>
<div class="form-groups">
<label>Kategori</label>
<input name="kategori" type="radio" value="1"> Makanan
<input name="kategori" type="radio" value="2"> Minuman
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</form>
</div>
</div>
</div>
<?php
include 'common/footer.php';
?>