-
Notifications
You must be signed in to change notification settings - Fork 0
/
cari_kamar.php
209 lines (164 loc) · 10.4 KB
/
cari_kamar.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php include 'header.php'; ?>
<?php
if(isset($_SESSION['booking_kamar_status'])){
unset($_SESSION['booking_kamar_status']);
unset($_SESSION['booking_kamar']);
unset($_SESSION['booking_dari']);
unset($_SESSION['booking_sampai']);
unset($_SESSION['booking_dewasa']);
unset($_SESSION['booking_anak']);
}
?>
<!-- Breadcrumb Section Begin -->
<section class="breadcrumb-option">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb__text">
<h4>Cari kamar</h4>
<div class="breadcrumb__links">
<a href="index.php">Home</a>
<a href="kamar.php">Kamar</a>
<span>Cari Kamar</span>
</div>
</div>
</div>
</div>
<br>
<center>
<h3 class="font-weight-bold"><i class="fa fa-search"></i> Cari Kamar</h3>
</center>
<br>
<br>
<form action="cari_kamar.php" method="get">
<div class="row">
<div class="col-lg-4">
<div class="checkout__input">
<p>Tgl. Check-In<span>*</span></p>
<input type="text" class="datepicker" name="dari" id="tgl_dari" placeholder="Masukkan tanggal .." required="required" value="<?php if(isset($_GET['dari'])){ echo date('d-m-Y', strtotime($_GET['dari'])); } ?>">
</div>
</div>
<div class="col-lg-4">
<div class="checkout__input">
<p>Tgl. Check-Out<span>*</span></p>
<input type="text" class="datepicker" name="sampai" id="tgl_sampai" placeholder="Masukkan tanggal .." required="required" value="<?php if(isset($_GET['sampai'])){ echo date('d-m-Y', strtotime($_GET['sampai'])); } ?>">
</div>
</div>
<div class="col-lg-1">
<div class="checkout__input">
<p>Dewasa<span>*</span></p>
<select name="dewasa" required="required">
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "1"){ echo "selected='selected'"; } } ?> value="1">1</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "2"){ echo "selected='selected'"; } } ?> value="2">2</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "3"){ echo "selected='selected'"; } } ?> value="3">3</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "4"){ echo "selected='selected'"; } } ?> value="4">4</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "5"){ echo "selected='selected'"; } } ?> value="5">5</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "6"){ echo "selected='selected'"; } } ?> value="6">6</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "7"){ echo "selected='selected'"; } } ?> value="7">7</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "8"){ echo "selected='selected'"; } } ?> value="8">8</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "9"){ echo "selected='selected'"; } } ?> value="9">9</option>
<option <?php if(isset($_GET['dewasa'])){ if($_GET['dewasa'] == "10"){ echo "selected='selected'"; } } ?> value="10">10</option>
</select>
</div>
</div>
<div class="col-lg-1">
<div class="checkout__input">
<p>Anak<span>*</span></p>
<select name="anak" required="required">
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "0"){ echo "selected='selected'"; } } ?> value="0">0</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "1"){ echo "selected='selected'"; } } ?> value="1">1</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "2"){ echo "selected='selected'"; } } ?> value="2">2</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "3"){ echo "selected='selected'"; } } ?> value="3">3</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "4"){ echo "selected='selected'"; } } ?> value="4">4</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "5"){ echo "selected='selected'"; } } ?> value="5">5</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "6"){ echo "selected='selected'"; } } ?> value="6">6</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "7"){ echo "selected='selected'"; } } ?> value="7">7</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "8"){ echo "selected='selected'"; } } ?> value="8">8</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "9"){ echo "selected='selected'"; } } ?> value="9">9</option>
<option <?php if(isset($_GET['anak'])){ if($_GET['anak'] == "10"){ echo "selected='selected'"; } } ?> value="10">10</option>
</select>
</div>
</div>
<div class="col-lg-2">
<br>
<center><button class="site-btn mt-2">CARI KAMAR</button></center>
</div>
</div>
</form>
<br>
<?php
if(isset($_GET['dari'])){
$dari = mysqli_real_escape_string($koneksi,$_GET['dari']);
$sampai = mysqli_real_escape_string($koneksi,$_GET['sampai']);
$jumlah_tersedia = 0;
if($dari == $sampai){
echo "Tanggal salah";
}else if($sampai <= $dari){
echo "Tanggal salah";
}else{
echo "<br><br><center>";
echo "<h4><b>HASIL PENCARIAN :</b> Kamar Yang Tersedia</h4> <br><br>";
echo "</center>";
$dari = date('Y-m-d', strtotime($dari));
$sampai = date('Y-m-d', strtotime($sampai));
$kamar = mysqli_query($koneksi,"select * from kamar, kategori where kategori_id=kamar_kategori order by kamar_harga asc");
while($k = mysqli_fetch_array($kamar)){
$id_kamar = $k['kamar_id'];
$cek = mysqli_query($koneksi,"select * from invoice where invoice_kamar='$id_kamar' and (invoice_dari >= '$dari' and invoice_dari <= '$sampai' or invoice_sampai > '$dari' and invoice_sampai <= '$sampai') and (invoice_status='0' or invoice_status='1' or invoice_status='3')");
// $cek = mysqli_query($koneksi,"select * from invoice where invoice_kamar='$id_kamar' and (invoice_dari BETWEEN '$dari' and '$sampai' or invoice_sampai BETWEEN '$dari' and '$sampai') and (invoice_status='0' or invoice_status='1' or invoice_status='3')");
$c = mysqli_num_rows($cek);
// cek jika jumlah kamar lebih banyak dari yg sudah dibooking
if($k['kamar_jumlah'] > $c){
$sisa = $k['kamar_jumlah'] - $c;
$jumlah_tersedia += 1;
?>
<div class="row justify-content-center">
<div class="col-lg-2">
<?php if($k['kamar_foto1'] == ""){ ?>
<img src="gambar/sistem/kamar.png" style="width: auto;height: auto">
<?php }else{ ?>
<img src="gambar/kamar/<?php echo $k['kamar_foto1'] ?>" style="width: auto;height: auto">
<?php } ?>
</div>
<div class="col-lg-6">
<h5><?php echo $k['kamar_nama']; ?></h5>
<small class="text-muted">
<?php echo $k['kategori_nama']; ?>
|
Ranjang : <?php echo $k['kamar_ranjang']; ?>
|
Ukuran Kamar : <?php echo $k['kamar_ukuran']; ?> m2
<br>
Fasilitas :
<?php
$id_kamar = $k['kamar_id'];
$fasilitas = mysqli_query($koneksi,"select * from fasilitas_kamar,kamar_fasilitas where fk_id=kf_fasilitas and kf_kamar='$id_kamar' order by fk_nama asc");
while($f = mysqli_fetch_array($fasilitas)){
echo $f['fk_nama'].", ";
}
?>
<br>
Harga : <b><?php echo "Rp. ".number_format($k['kamar_harga']).",-"; ?></b> / mlm
</small>
<br>
Tersisa <b><?php echo $sisa; ?> Kamar</b>
<br>
<a class="site-btn py-2 px-2 mt-3" target="_blank" style="font-size: 8pt" href="kamar_detail.php?id=<?php echo $k['kamar_id']; ?>">LIHAT KAMAR</a>
</div>
</div>
<hr>
<?php
}
// echo $jumlah_tersedia;
}
if($jumlah_tersedia == "0"){
echo "<div class='alert alert-danger text-center'><b>Kamar tidak tersedia.</b> Silahkan cari tanggal atau kamar lain.</div>";
}
}
}
?>
<br>
</div>
</section>
<!-- Breadcrumb Section End -->
<?php include 'footer.php'; ?>