Commit 195321b6 by Juliper

no message

parent 50a9ce57
......@@ -35,59 +35,149 @@ class GuestController extends Controller
return view('welcome');
}
//{id}/{tm}/{lm}/{ts}/{jt}/{jk}
public function homestay($id,$tm,$lm,$ts,$jt,$jk){
$data = DB::table('homestay')
->join('pemilikhomestay','homestay.id_pemilik','=','pemilikhomestay.id')
->select('pemilikhomestay.*','homestay.*')
->where('homestay.id','=',$id)
->get();
//dd($data);
$dataKamar = DB::table('kamar')
->where('kamar.id_homestay','=',$id)
->get();
return view('adminlte::layouts.pages.detilSHomestay')->with('data',$data[0])->with('tm',$tm)->with('lm',$lm)->with('ts',$ts)->with('jt',$jt)->with('jk',$jk)->with('dataKamar',$dataKamar);
}
public function cari(Request $request){
$data = Homestay::all();
//$a = null;
//$book_start[] = null;
$dataBook = ListBook::all();
$tanggal_mulai = $request['tanggal_mulai'];
$jumlah_hari = $request['jumlah_hari'];
$tanggal_selesai = $request['tanggal_selesai'];
$jumlah_Tamu = $request['jumlah_Tamu'];
$jumlah_kamar = $request['jumlah_kamar'];
//$book_start[] = null;
$dataHomestay[] = null;
$i = 0;
//Melakukan Looping pengecekan Homestay yang avilable
foreach ($data as $a){
$book_start = DB::table('daftar_book')
->select('daftar_book.*')
->where('daftar_book.tanggal_mulai','=',$request['tanggal_mulai'])
->get();
$tm = explode('-',$request['tanggal_mulai']);
$ts = explode('-',$request['tanggal_selesai']);
$counter = 0;
$j=0;
//Mencocokkan data pesanan untuk mendapat current room avilable
foreach ($dataBook as $db){
$ldbm = explode('-',$db->tanggal_mulai);
$ldbs = explode('-',$db->tanggal_berakhir);
if($tm[1]==$ts[1]){
if($tm[1] == $ldbm[1] && $ts[1] == $ldbs[1]){
if(($tm[2] >= $ldbm[2] && $tm[2] <= $ldbs[2] ) && ($ts[2] >= $ldbm[2] && $ts[2]<= $ldbs[2]) ){
//dd('beriirisan total');
$dataCurrent[$j] = $db->id;
$counter +=1;
$j++;
echo 'beririsan';
}
else if(($tm[2] < $ldbm[2] && $tm[2] <= $ldbs[2] ) && ($ts[2] >= $ldbm[2] && $ts[2]<= $ldbs[2])){
$dataCurrent[$j] = $db->id;
$counter +=1;
$j++;
echo 'beririsan sebagian batas atas';
//dd('beririsan sebagian batas atas');
}else if(($tm[2] >= $ldbm[2] && $tm[2] <= $ldbs[2] ) && ($ts[2] >= $ldbm[2] && $ts[2] > $ldbs[2])){
$dataCurrent[$j] = $db->id;
$counter +=1;
$j++;
echo 'beririsan sebagian batas bawah';
//dd('beririsan sebagian batas bawah');
}
}
}else if($tm[1] < $ts[1]){
dd('jangan dulu');
}
$book_finish = DB::table('daftar_book')
->select('daftar_book.*')
->where('daftar_book.tanggal_berakhir','=',$request['tanggal_selesai'])
->get();
}
if($book_start->count() > 0){
dd($book_start);
//dd($book_start[0]->jumlah_kamar);
if($counter==0){
if($request['jumlah_kamar'] <= $a->jumlah_kamar){
if($request['jumlah_Tamu'] <= ($request['jumlah_kamar']*2)*2){
$dataHomestay[$i] = DB::table('homestay')
->where('homestay.id','=',$a->id)
->get();
}
}
}else{
if($book_finish->count() > 0){
}else{
if($request['jumlah_Tamu'] > $request['jumlah_kamar'] * 2){
dd('ngak bisa');
$currentKamar = null;
//$dataKamarHomestay = ListBook::find(14);
//dd($dataKamarHomestay);
//dd($dataCurrent);
for ($l = 0; $l<$counter;$l++){
// echo $dataCurrent[$l];
$dataKamarHomestay[$l] = DB::table('daftar_book')
->where('daftar_book.id','=',$dataCurrent[$l])
//->where('daftar_book.homestay','=',$a->id)
->get();
if ($dataKamarHomestay[$l][0]->homestay == $a->id){
$currentKamar = ($a->jumlah_kamar - $dataKamarHomestay[$l][0]->jumlah_kamar) - $currentKamar;
}else{
$currentKamar = $a->jumlah_kamar;
}
}
//dd($dataKamarHomestay[1][0]->homestay);
//dd($dataKamarHomestay);
// echo $currentKamar;
//dd('asd');
if($request['jumlah_kamar'] <= $currentKamar){
if($request['jumlah_Tamu'] <= ($request['jumlah_kamar']*2)*2){
$dataHomestay[$i] = DB::table('homestay')
->where('homestay.id','=',$a->id)
->get();
->where('homestay.id','=',$a->id)
->get();
}
}
}
$i++;
}
// $j=0;
// //dd($dataHomestay[1][0]->nama_homestay);//,$dataHomestay[1]->nama_homestay,$dataHomestay[2]->nama_homestay);
// foreach ($dataHomestay as $b){
// echo $b[0]->nama_homestay;
// //echo $j;
//// if($j==1){
//// dd($b[0]);
//// }
// echo '<br>';
// $j++;
// }
return view('searchhomestay')->with('data',$dataHomestay);
//dd($dataHomestay);
if($dataHomestay == null){
dd('salah');
return redirect('')->with('message','Jumlah Kamar yang Avilable tidak mencukupi');
}
if($dataHomestay[0] == null){
return redirect('')->with('message','Jumlah Kamar yang Avilable tidak mencukupi');
dd('salah');
}
//dd('benar');
return view('searchhomestay')->with('data',$dataHomestay)
->with('tm',$tanggal_mulai)
->with('lm',$jumlah_hari)
->with('ts',$tanggal_selesai)
->with('jt',$jumlah_Tamu)
->with('jk',$jumlah_kamar);
//dd($i,$book_start[0],$book_start[1],$book_start[2],$book_finish[0],$book_finish[1],$book_finish[2]);
//dd($request['tanggal_mulai'],$request['jumlah_hari'],$request['tanggal_selesai'],$request['jumlah_Tamu'],$request['jumlah_kamar']);
}
......
@extends('adminlte::layouts.master')
@section('main-content')
<!-- Banner -->
<div class="banner agileits w3layouts">
<img src="{{asset('/img/'.$data->gambar)}}" alt="Agileits W3layouts" style="max-height:500px; ">
<h1 class="wow agileits w3layouts fadeInDown">{{$data->nama_homestay}}</h1>
</div>
<!-- //Banner -->
<!-- Booking -->
<div class="details agileits w3layouts" style="margin-top: 20px; padding:0px;">
<br>
@if(Session::has('message'))
<div class="alert alert-danger">
{{ Session::get('message') }}
</div>
@endif
<div class="container">
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> {{ trans('adminlte_lang::message.someproblems') }}<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
<!-- Informations -->
<div class="cuisines agileits w3layouts">
<div class="container">
<div class="col-md-6 col-sm-6 cuisines-grids agileits w3layouts cuisines-grids-1 ">
<h3 style="margin-bottom: 10px; font-weight:10px;"> Fasilitas </h3>
<ul style="list-style-type: none;">
<p>{{$data->fasilitas}}</p>
</ul>
<img style="width: 450px; margin-top: 10px;" src="{{asset('img/line1.png')}}">
<h3 style="margin-bottom: 10px;"> Info Pemilik </h3>
<table class="table-condensed" style="font-size: 16px; margin-left: -3px; color: #777;">
<tr>
<td>Pemilik</td>
<td>:</td>
<td>{{$data->nama}}</td>
</tr>
<tr>
<td> No Telp</td>
<td>:</td>
<td>{{$data->no_telepon}}</td>
</tr>
<tr>
<td> Alamat </td>
<td>:</td>
<td>{{$data->alamat}}</td>
</tr>
<tr>
<td> No Rekening </td>
<td>:</td>
<td>{{$data->no_rekening}}</td>
</tr>
<tr>
<td> Harga </td>
<td>:</td>
<td>Rp 150.000 / hari</td>
</tr>
<tr>
<td>
<form action="{{url('')}}">
<input type="hidden" name="tanggal_mulai" value="{{$tm}}">
<input type="hidden" name="lama_menginap" value="{{$lm}}">
<input type="hidden" name="tanggal_selesai" value="{{$ts}}">
<input type="hidden" name="jumlah_tamu" value="{{$jt}}">
<input type="hidden" name="jumlah_kamar" value="{{$jk}}">
<input type="submit" value="Pesan Sekarang" class="btn-succes">
</form>
</td>
</tr>
</table>
</div>
<div class="col-md-6 col-sm-6 cuisines-grids agileits w3layouts cuisines-grids-2 ">
<img src="/img/{{$data->gambar}}" alt="Agileits W3layouts">
</div>
<!-- <div class="clearfix"></div> -->
<div class="col-md-12 col-sm-12 gallery-grids agileits w3layouts gallery-grids1">
<!--Homestay pict -->
@foreach($dataKamar as $dk)
<div class="col-md-3 col-sm-3 details-grid agileits w3layouts details-grid-1">
<div id="gambar">
<a class="example-image-link agileits w3layouts" href="/img/{{$dk->gambar}}" data-lightbox="example-set" data-title="">
<div class="grid agileits w3layouts">
<figure class="effect-apollo agileits w3layouts">
<img src="/img/{{$dk->gambar}}" alt="Agileits W3layouts" id="data">
<figcaption></figcaption>
</figure>
</div>
</a>
<!-- <img src="" alt="Agileits W3layouts" data-toggle="modal" data-target="#myModal" style="cursor: pointer;"> -->
</div>
<div class="clearfix"></div>
</div>
@endforeach
<div class="clearfix"></div>
<!--Homestay pict -->
</div>
</div>
</div>
<!-- //Informations -->
<!-- //Kritik & Saran -->
<div class="cuisines agileits w3layouts">
<div class="container">
<div class="col-md-6 col-sm-6 cuisines-grids agileits w3layouts cuisines-grids-1 ">
<h3 style="margin-bottom: 0px; font-weight:10px;"> Review Pengunjung </h3>
<img style="width: 450px; margin-top: 3px;" src="{{asset('img/line1.png')}}"><br>
DISINI REVIEW
</div>
</div>
</div>
<!-- //Informations -->
<!-- Scripts -->
<!-- Date-Picker-JavaScript -->
<script src="{{asset('js/jquery-ui.js')}}"></script>
<!-- Scripts -->
<script>
function updateDate(object) {
//$('#tanggal_selesai').datepicker({
// dateFormat: "yy-mm-dd",
//});
alert(object.value);
//var tanggal_mulai = $('#datepicker1').datepicker('getDate');
//tanggal_mulai.setDate(tanggal_mulai.getDate()+parseInt(object.value));
//$('#tanggal_selesai').datepicker('setDate',tanggal_mulai);
//alert(tanggal_mulai);
var date1 = $('#datepicker1').datepicker('getDate');
var date = new Date( Date.parse( date1 ) );
date.setDate( date.getDate() + parseInt(object.value) );
var newDate = date.toDateString();
newDate = new Date( Date.parse( newDate ) );
$('#datepicker2').datepicker("setDate",newDate);
}
</script>
@endsection
......@@ -22,10 +22,10 @@
<div class="col-md-4 col-sm-4 details-grid details-grid-2 agileits w3layouts ">
<div class="details-grid2 agileits w3layouts">
<div class="details-grid-image agileits w3layouts" >
<a href ="{{url('detailhomestay/'.$a->id)}}" ><img src="/img/{{$a->gambar}}" alt="Agileits W3layouts" ></a>
<a href ="{{url('homestay/'.$a[0]->id.'/'.$tm.'/'.$lm.'/'.$ts.'/'.$jt.'/'.$jk)}}" ><img src="/img/{{$a[0]->gambar}}" alt="Agileits W3layouts" ></a>
</div>
<div class="details-grid-info agileits w3layouts">
<a href ="{{url('detailhomestay/'.$a->id)}}" ><h4>{{$a[0]->nama_homestay}}</h4></a>
<a href ="{{url('homestay/'.$a[0]->id.'/'.$tm.'/'.$lm.'/'.$ts.'/'.$jt.'/'.$jk)}}" ><h4>{{$a[0]->nama_homestay}}</h4></a>
</div>
<div class="clearfix"></div>
</div>
......
......@@ -91,7 +91,7 @@ Route::group(['middleware' => 'owner'], function () {
Route::get('home','OwnerController@index');
Route::get('detailpesanan/{id}','OwnerController@detailpesanan');
});
Route::get('homestay/{id}/{tm}/{lm}/{ts}/{jt}/{jk}','GuestController@homestay');
Route::get('cari','GuestController@cari');
Route::get('detailhomestay/{id}','GuestController@detailhomestay');
Route::get('daftar','GuestController@register');
......
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