Upload New File

parent aea31da6
<?php
session_start();
include('../config.php');
include('function.php');
// include("../common/dbconfig.php");
include("template/header.php");
include("../common/function.php");
open_page("Tiket");
if(! isset($_SESSION['is_login']))
{
header('location:../index.php');
}
if (!isset($_SESSION["username"])){
// echo "<script>alert('Login terlebih dahulu');window.location='../index.php';</script>";
// exit;
echo "Anda harus login dulu <br><a href='../index.php'>Klik disini</a>";
exit;
}
$role = $_SESSION["role"];
if($role != "admin"){
echo "<script>alert('Anda bukan admin');window.location='../index.php';</script>";
exit;
}
$id_akun = $_SESSION["id_akun"];
$nama = $_SESSION["nama"];
$username = $_SESSION["username"];
$query = "SELECT t_tiketsdia.id ,t_tiketsdia.kode_tiket, destinasi.nama_destinasi, pt_trans.nama_transp, t_tiketsdia.harga
FROM pt_trans INNER JOIN (destinasi INNER JOIN t_tiketsdia ON destinasi.id_destinasi = t_tiketsdia.t_destinasi) ON pt_trans.id_transp = t_tiketsdia.t_kendaraan;
";
$data = mysqli_query($koneksi,$query);
if(isset($_POST["tambah"]))
{
if(tambahtiket($_POST) > 0 )
{
echo
"
<script>
alert('Berhasil ditambahkan');
document.location.href = 'tiket_admin.php';
</script>
";
} else {
echo
"
<script>
alert('Gagal ditambahkan');
document.location.href = 'tiket_admin.php';
</script>
";
}
}
?>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Tiket</h2>
</div>
</div>
</section>
<!-- End Breadcrumbs -->
<div class="container">
<button type="button" class="btn btn-primary mt-3" data-toggle="modal" data-target="#exampleModal">
Tambah Data
</button>
<a href="exportdatatiket.php">
<button type="button" class="btn btn-secondary mt-3">
Cetak Data Tiket
</button>
</a>
<table class="table table-bordered mt-3 mb-2">
<thead class="thead-dark">
<tr align="center">
<th scope="col" rowspan="2">Kode Tiket</th>
<th scope="col" rowspan="2">Tujuan Destinasi</th>
<th scope="col" rowspan="2">Kendaraan</th>
<th scope="col" rowspan="2">Harga</th>
<th scope="col">Option</th>
</tr>
</thead>
<?php
while($tiket = mysqli_fetch_array($data)) { ?>
<tr>
<td align="center"><?= $tiket['kode_tiket'] ?></td>
<td align="center"><?= $tiket['nama_destinasi'] ?></td>
<td align="center"><?= $tiket['nama_transp'] ?></td>
<td>Rp. <?= $tiket['harga'] ?></td>
<td>
<a href="ubahtiket.php?id=<?= $tiket['id'];?>" class="badge badge-success">Ubah</a>
<a href="hapustiket.php?id=<?= $tiket['id'];?>" onclick="return confirm('Apakah Anda sudah yakin ?');" class="badge badge-danger">Hapus</a>
</td>
</tr>
<?php } ?>
</table>
<!-- Modal tambah-->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<?php
$query2 = "SELECT pt_trans.id_transp, pt_trans.nama_transp FROM pt_trans";
$ubah1 = mysqli_query($koneksi,$query2);
$query3 = "SELECT destinasi.id_destinasi, destinasi.nama_destinasi FROM destinasi";
$ubah2 = mysqli_query($koneksi,$query3);
?>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h2>Tambah Tiket</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<form action="" method="POST" enctype="multipart/form-data">
</div>
<form>
<div class="form-group">
<label for="t_destinasi">Tujuan Destinasi</label>
<select class="form-control" name="t_destinasi">
<?php while($kendaraan = mysqli_fetch_array($ubah2)) { ?>
<option value="<?=$kendaraan['id_destinasi']?>"><?=$kendaraan['nama_destinasi']?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="t_kendaraan">Kendaraan</label>
<select class="form-control" name="t_kendaraan">
<?php while($kendaraan = mysqli_fetch_array($ubah1)) { ?>
<option value="<?=$kendaraan['id_transp']?>"><?=$kendaraan['nama_transp']?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="harga">Harga Tiket</label>
<input type="text" autocomplete="off" name="harga" class="form-control" placeholder="Masukkan harga tiket">
</div>
<button type="submit" class="btn btn-primary" name="tambah">Tambah</button>
</form>
</div>
</div>
</div>
</div>
<!-- End Modal tambah-->
</div>
<?php
include("template/footer.php")
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment