-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_historiuser.php
47 lines (44 loc) · 1.73 KB
/
select_historiuser.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
<?php
require "koneksi.php";
$respon = array();
if(isset ($_GET["id"])){
$id = $_GET['id'];
$qry = "SELECT tb_rental.`ID`, tb_dtrental.`ID_kendaraan`, tb_kendaraan.`nama_kendaraan`, tb_kendaraan.`no_plat`, tb_rental.`tgl_sewa`, tb_rental.`tgl_kembali`,
tb_profiluser.`nama_belakang`, tb_status_rental.`status_rental`
FROM tb_dtrental
INNER JOIN tb_rental ON tb_dtrental.`ID_rental`=tb_rental.`ID`
INNER JOIN tb_status_rental ON tb_dtrental.`status`=tb_status_rental.`ID`
INNER JOIN tb_kendaraan ON tb_dtrental.`ID_kendaraan`=tb_kendaraan.`ID`
INNER JOIN tb_profiluser ON tb_rental.`ID_user`=tb_profiluser.`ID_user`
WHERE tb_rental.`status`=1 && tb_rental.`ID_user`='$id';";
$result = mysqli_query($link, $qry);
if(mysqli_num_rows($result) > 0){
$respon["booking"] = array();
while ($row = mysqli_fetch_array($result)){
if($row["tgl_sewa"] < $_SERVER['REQUEST_TIME']){
$booking = array();
$booking["ID_rental"] = $row["ID"];
$booking["ID_kendaraan"] = $row["ID_kendaraan"];
$booking["nama_kendaraan"] = $row["nama_kendaraan"];
$booking["no_plat"] = $row["no_plat"];
$booking["tgl_sewa"] = $row["tgl_sewa"];
$booking["tgl_kembali"] = $row["tgl_kembali"];
$booking["status_rental"] = $row["status_rental"];
array_push($respon["booking"], $booking);
}
$respon["sukses"] = 1;
$respon["pesan"] = "Booking";
echo json_encode($respon);
}
//$result = mysqli_fetch_array($result);
} else {
$respon["sukses"] = 0;
$respon["pesan"] = "Tidak ada Kendaraan1";
echo json_encode ($respon);
}
} else {
$respon["sukses"] = 0;
$respon["pesan"] = "Required field's is missing";
echo json_encode ($respon);
}
?>