Ikki_wrs

double muncul

Jul 12th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['cari'])) {
  3. $cari = $_POST['cari'];
  4. } else {
  5. $cari = "";
  6. }
  7. ?>
  8. <!---<link href="../../assets/css/bootstrap.min.css" rel="stylesheet">--->
  9. <div class="row">
  10. <div class="col-md-12">
  11. <div class="page-header">
  12. <h4>
  13. <i class="glyphicon glyphicon-briefcase"></i> Data Alokasi Supir
  14.  
  15. <div class="pull-right btn-tambah">
  16. <form class="form-inline" method="POST" action="index.php">
  17. <div class="form-group">
  18. <div class="input-group">
  19. <div class="input-group-addon">
  20. <i class="glyphicon glyphicon-search"></i>
  21. </div>
  22. <input type="text" class="form-control" name="cari" placeholder="Cari ..." autocomplete="off" value="<?php echo $cari; ?>">
  23. </div>
  24. </div>
  25. <a class="btn btn-info" href="?page=tambah">
  26. <i class="glyphicon glyphicon-plus"></i> Tambah
  27. </a>
  28. </form>
  29. </div>
  30.  
  31. </h4>
  32. </div>
  33.  
  34. <?php
  35. if (empty($_GET['alert'])) {
  36. echo "";
  37. } elseif ($_GET['alert'] == 1) {
  38. echo "<div class='alert alert-danger alert-dismissible' role='alert'>
  39. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  40. <span aria-hidden='true'>&times;</span>
  41. </button>
  42. <strong><i class='glyphicon glyphicon-alert'></i> Gagal!</strong> Terjadi kesalahan.
  43. </div>";
  44. } elseif ($_GET['alert'] == 2) {
  45. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  46. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  47. <span aria-hidden='true'>&times;</span>
  48. </button>
  49. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil disimpan.
  50. </div>";
  51. } elseif ($_GET['alert'] == 3) {
  52. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  53. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  54. <span aria-hidden='true'>&times;</span>
  55. </button>
  56. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil diubah.
  57. </div>";
  58. } elseif ($_GET['alert'] == 4) {
  59. echo "<div class='alert alert-success alert-dismissible' role='alert'>
  60. <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
  61. <span aria-hidden='true'>&times;</span>
  62. </button>
  63. <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil dihapus.
  64. </div>";
  65. }
  66. ?>
  67.  
  68. <div class="panel panel-default">
  69. <div class="panel-heading">
  70. <h3 class="panel-title">Data Alokasi Supir</h3>
  71. </div>
  72. <div class="panel-body">
  73. <div class="table-responsive">
  74. <table class="table table-striped table-hover">
  75. <thead>
  76. <tr>
  77. <th>No.</th>
  78. <th>Nama</th>
  79. <th>No. Polisi</th>
  80. <th>Jenis Kendaraan</th>
  81. <th>Tipe Kendaraan</th>
  82. <th>Keterangan</th>
  83. <th>Aksi</th>
  84. </tr>
  85. </thead>
  86.  
  87. <tbody>
  88. <?php
  89. /* Pagination */
  90. $batas = 5;
  91.  
  92. if (isset($cari)) {
  93. $jumlah_record = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
  94. trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol and a.nama LIKE '%$cari%' OR b.nopol LIKE '%$cari%'")
  95. or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
  96. } else {
  97. $jumlah_record = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
  98. trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol ")
  99. or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
  100. }
  101.  
  102. $jumlah = mysqli_num_rows($jumlah_record);
  103. $halaman = ceil($jumlah / $batas);
  104. $page = (isset($_GET['hal'])) ? (int)$_GET['hal'] : 1;
  105. $mulai = ($page - 1) * $batas;
  106. /*-------------------------------------------------------------------*/
  107. $no = 1;
  108. if (isset($cari)) {
  109. $query = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
  110. trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol and a.nama LIKE '%$cari%' OR b.nopol LIKE '%$cari%' ORDER BY a.nama DESC LIMIT $mulai, $batas")
  111. or die('Ada kesalahan pada query Alokasi Supir: '.mysqli_error($db));
  112. } else {
  113. $query = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
  114. trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol
  115. ORDER BY a.nama DESC LIMIT $mulai, $batas")
  116. or die('Ada kesalahan pada query Alokasi Supir: '.mysqli_error($db));
  117. }
  118.  
  119. while ($data = mysqli_fetch_assoc($query)) {
  120. //$hrg=number_format($data['harga'],0,",",".");
  121. echo "<tr>
  122. <td width='50'>$no</td>
  123. <td width='60'>$data[nama]</td>
  124. <td width='50'>$data[nopol]</td>
  125. <td width='50'>$data[jenis]</td>
  126. <td width='50'>$data[tipe]</td>
  127. <td width='50'>$data[ket]</td>
  128. <td width='100'>
  129. <div class=''>
  130. <a data-toggle='tooltip' data-placement='top' title='Ubah' style='margin-right:5px' class='btn btn-info btn-sm' href='?page=ubah&id=$data[kode]'>
  131. <i class='glyphicon glyphicon-edit'></i>
  132. </a>";
  133. ?>
  134. <a data-toggle="tooltip" data-placement="top" title="Hapus" class="btn btn-danger btn-sm" href="proses-hapus.php?id=<?php echo $data['kode'];?>" onclick="return confirm('Anda yakin ingin menghapus BBM <?php echo $data['nama']; ?>?');">
  135. <i class="glyphicon glyphicon-trash"></i>
  136. </a>
  137. <?php
  138. echo "
  139. </div>
  140. </td>
  141. </tr>";
  142. $no++;
  143. }
  144. ?>
  145. </tbody>
  146. </table>
  147. <?php
  148. if (empty($_GET['hal'])) {
  149. $halaman_aktif = '1';
  150. } else {
  151. $halaman_aktif = $_GET['hal'];
  152. }
  153. ?>
  154.  
  155. <a>
  156. Halaman <?php echo $halaman_aktif; ?> dari <?php echo $halaman; ?> |
  157. Total <?php echo $jumlah; ?> data
  158. </a>
  159.  
  160. <nav>
  161. <ul class="pagination pull-right">
  162. <!-- Button untuk halaman sebelumnya -->
  163. <?php
  164. if ($halaman_aktif<='1') { ?>
  165. <li class="disabled">
  166. <a href="" aria-label="Previous">
  167. <span aria-hidden="true">&laquo;</span>
  168. </a>
  169. </li>
  170. <?php
  171. } else { ?>
  172. <li>
  173. <a href="" aria-label="Previous">
  174. <span aria-hidden="true">&laquo;</span>
  175. </a>
  176. </li>
  177. <?php
  178. }
  179. ?>
  180.  
  181. <!-- Link halaman 1 2 3 ... -->
  182. <?php
  183. for($x=1; $x<=$halaman; $x++) { ?>
  184. <li class="">
  185. <a href=""><?php echo $x ?></a>
  186. </li>
  187. <?php
  188. }
  189. ?>
  190.  
  191. <!-- Button untuk halaman selanjutnya -->
  192. <?php
  193. if ($halaman_aktif>=$halaman) { ?>
  194. <li class="disabled">
  195. <a href="" aria-label="Next">
  196. <span aria-hidden="true">&raquo;</span>
  197. </a>
  198. </li>
  199. <?php
  200. } else { ?>
  201. <li>
  202. <a href="" aria-label="Next">
  203. <span aria-hidden="true">&raquo;</span>
  204. </a>
  205. </li>
  206. <?php
  207. }
  208. ?>
  209. </ul>
  210. </nav>
  211. </div>
  212. </div>
  213. </div> <!-- /.panel -->
  214. </div> <!-- /.col -->
  215. </div> <!-- /.row -->
Advertisement
Add Comment
Please, Sign In to add comment