Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['cari'])) {
- $cari = $_POST['cari'];
- } else {
- $cari = "";
- }
- ?>
- <!---<link href="../../assets/css/bootstrap.min.css" rel="stylesheet">--->
- <div class="row">
- <div class="col-md-12">
- <div class="page-header">
- <h4>
- <i class="glyphicon glyphicon-briefcase"></i> Data Alokasi Supir
- <div class="pull-right btn-tambah">
- <form class="form-inline" method="POST" action="index.php">
- <div class="form-group">
- <div class="input-group">
- <div class="input-group-addon">
- <i class="glyphicon glyphicon-search"></i>
- </div>
- <input type="text" class="form-control" name="cari" placeholder="Cari ..." autocomplete="off" value="<?php echo $cari; ?>">
- </div>
- </div>
- <a class="btn btn-info" href="?page=tambah">
- <i class="glyphicon glyphicon-plus"></i> Tambah
- </a>
- </form>
- </div>
- </h4>
- </div>
- <?php
- if (empty($_GET['alert'])) {
- echo "";
- } elseif ($_GET['alert'] == 1) {
- echo "<div class='alert alert-danger alert-dismissible' role='alert'>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- <strong><i class='glyphicon glyphicon-alert'></i> Gagal!</strong> Terjadi kesalahan.
- </div>";
- } elseif ($_GET['alert'] == 2) {
- echo "<div class='alert alert-success alert-dismissible' role='alert'>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil disimpan.
- </div>";
- } elseif ($_GET['alert'] == 3) {
- echo "<div class='alert alert-success alert-dismissible' role='alert'>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil diubah.
- </div>";
- } elseif ($_GET['alert'] == 4) {
- echo "<div class='alert alert-success alert-dismissible' role='alert'>
- <button type='button' class='close' data-dismiss='alert' aria-label='Close'>
- <span aria-hidden='true'>×</span>
- </button>
- <strong><i class='glyphicon glyphicon-ok-circle'></i> Sukses!</strong> Data Alokasi Supir berhasil dihapus.
- </div>";
- }
- ?>
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Data Alokasi Supir</h3>
- </div>
- <div class="panel-body">
- <div class="table-responsive">
- <table class="table table-striped table-hover">
- <thead>
- <tr>
- <th>No.</th>
- <th>Nama</th>
- <th>No. Polisi</th>
- <th>Jenis Kendaraan</th>
- <th>Tipe Kendaraan</th>
- <th>Keterangan</th>
- <th>Aksi</th>
- </tr>
- </thead>
- <tbody>
- <?php
- /* Pagination */
- $batas = 5;
- if (isset($cari)) {
- $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,
- trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol and a.nama LIKE '%$cari%' OR b.nopol LIKE '%$cari%'")
- or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
- } else {
- $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,
- trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol ")
- or die('Ada kesalahan pada query jumlah_record: '.mysqli_error($db));
- }
- $jumlah = mysqli_num_rows($jumlah_record);
- $halaman = ceil($jumlah / $batas);
- $page = (isset($_GET['hal'])) ? (int)$_GET['hal'] : 1;
- $mulai = ($page - 1) * $batas;
- /*-------------------------------------------------------------------*/
- $no = 1;
- if (isset($cari)) {
- $query = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
- 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")
- or die('Ada kesalahan pada query Alokasi Supir: '.mysqli_error($db));
- } else {
- $query = mysqli_query($db, "SELECT c.kode,a.nip,a.nama,b.nopol,b.jenis,b.tipe,b.ket,c.cabang FROM karyawan a,
- trasportasi b, supir c WHERE c.nip=a.nip and c.nopol=b.nopol
- ORDER BY a.nama DESC LIMIT $mulai, $batas")
- or die('Ada kesalahan pada query Alokasi Supir: '.mysqli_error($db));
- }
- while ($data = mysqli_fetch_assoc($query)) {
- //$hrg=number_format($data['harga'],0,",",".");
- echo "<tr>
- <td width='50'>$no</td>
- <td width='60'>$data[nama]</td>
- <td width='50'>$data[nopol]</td>
- <td width='50'>$data[jenis]</td>
- <td width='50'>$data[tipe]</td>
- <td width='50'>$data[ket]</td>
- <td width='100'>
- <div class=''>
- <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]'>
- <i class='glyphicon glyphicon-edit'></i>
- </a>";
- ?>
- <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']; ?>?');">
- <i class="glyphicon glyphicon-trash"></i>
- </a>
- <?php
- echo "
- </div>
- </td>
- </tr>";
- $no++;
- }
- ?>
- </tbody>
- </table>
- <?php
- if (empty($_GET['hal'])) {
- $halaman_aktif = '1';
- } else {
- $halaman_aktif = $_GET['hal'];
- }
- ?>
- <a>
- Halaman <?php echo $halaman_aktif; ?> dari <?php echo $halaman; ?> |
- Total <?php echo $jumlah; ?> data
- </a>
- <nav>
- <ul class="pagination pull-right">
- <!-- Button untuk halaman sebelumnya -->
- <?php
- if ($halaman_aktif<='1') { ?>
- <li class="disabled">
- <a href="" aria-label="Previous">
- <span aria-hidden="true">«</span>
- </a>
- </li>
- <?php
- } else { ?>
- <li>
- <a href="" aria-label="Previous">
- <span aria-hidden="true">«</span>
- </a>
- </li>
- <?php
- }
- ?>
- <!-- Link halaman 1 2 3 ... -->
- <?php
- for($x=1; $x<=$halaman; $x++) { ?>
- <li class="">
- <a href=""><?php echo $x ?></a>
- </li>
- <?php
- }
- ?>
- <!-- Button untuk halaman selanjutnya -->
- <?php
- if ($halaman_aktif>=$halaman) { ?>
- <li class="disabled">
- <a href="" aria-label="Next">
- <span aria-hidden="true">»</span>
- </a>
- </li>
- <?php
- } else { ?>
- <li>
- <a href="" aria-label="Next">
- <span aria-hidden="true">»</span>
- </a>
- </li>
- <?php
- }
- ?>
- </ul>
- </nav>
- </div>
- </div>
- </div> <!-- /.panel -->
- </div> <!-- /.col -->
- </div> <!-- /.row -->
Advertisement
Add Comment
Please, Sign In to add comment