Commit 4f1d49ba by Palti Sinaga

asdf

parents 6b2ef92c 195321b6
...@@ -35,37 +35,121 @@ class GuestController extends Controller ...@@ -35,37 +35,121 @@ class GuestController extends Controller
return view('welcome'); 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){ public function cari(Request $request){
$data = Homestay::all(); $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; $i = 0;
//Melakukan Looping pengecekan Homestay yang avilable
foreach ($data as $a){ foreach ($data as $a){
$book_start = DB::table('daftar_book') $tm = explode('-',$request['tanggal_mulai']);
->select('daftar_book.*') $ts = explode('-',$request['tanggal_selesai']);
->where('daftar_book.tanggal_mulai','=',$request['tanggal_mulai']) $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');
}
}
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(); ->get();
}
}
}else{
$book_finish = DB::table('daftar_book') $currentKamar = null;
->select('daftar_book.*')
->where('daftar_book.tanggal_berakhir','=',$request['tanggal_selesai']) //$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(); ->get();
if($book_start->count() > 0){ if ($dataKamarHomestay[$l][0]->homestay == $a->id){
dd($book_start); $currentKamar = ($a->jumlah_kamar - $dataKamarHomestay[$l][0]->jumlah_kamar) - $currentKamar;
//dd($book_start[0]->jumlah_kamar);
}else{ }else{
if($book_finish->count() > 0){ $currentKamar = $a->jumlah_kamar;
}
}
//dd($dataKamarHomestay[1][0]->homestay);
}else{
if($request['jumlah_Tamu'] > $request['jumlah_kamar'] * 2){ //dd($dataKamarHomestay);
dd('ngak bisa'); // echo $currentKamar;
}else{ //dd('asd');
if($request['jumlah_kamar'] <= $currentKamar){
if($request['jumlah_Tamu'] <= ($request['jumlah_kamar']*2)*2){
$dataHomestay[$i] = DB::table('homestay') $dataHomestay[$i] = DB::table('homestay')
->where('homestay.id','=',$a->id) ->where('homestay.id','=',$a->id)
->get(); ->get();
...@@ -74,20 +158,26 @@ class GuestController extends Controller ...@@ -74,20 +158,26 @@ class GuestController extends Controller
} }
$i++; $i++;
} }
// $j=0;
// //dd($dataHomestay[1][0]->nama_homestay);//,$dataHomestay[1]->nama_homestay,$dataHomestay[2]->nama_homestay); //dd($dataHomestay);
// foreach ($dataHomestay as $b){
// echo $b[0]->nama_homestay; if($dataHomestay == null){
// //echo $j; dd('salah');
//// if($j==1){ return redirect('')->with('message','Jumlah Kamar yang Avilable tidak mencukupi');
//// dd($b[0]); }
//// } if($dataHomestay[0] == null){
// echo '<br>'; return redirect('')->with('message','Jumlah Kamar yang Avilable tidak mencukupi');
// $j++; dd('salah');
// } }
//dd('benar');
return view('searchhomestay')->with('data',$dataHomestay); 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($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']); //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 @@ ...@@ -22,10 +22,10 @@
<div class="col-md-4 col-sm-4 details-grid details-grid-2 agileits w3layouts "> <div class="col-md-4 col-sm-4 details-grid details-grid-2 agileits w3layouts ">
<div class="details-grid2 agileits w3layouts"> <div class="details-grid2 agileits w3layouts">
<div class="details-grid-image 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>
<div class="details-grid-info agileits w3layouts"> <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>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -93,7 +93,7 @@ Route::group(['middleware' => 'owner'], function () { ...@@ -93,7 +93,7 @@ Route::group(['middleware' => 'owner'], function () {
Route::get('pesanan/{id}','OwnerController@pesanan'); Route::get('pesanan/{id}','OwnerController@pesanan');
Route::resource('pdf','PDFController@showPDF'); Route::resource('pdf','PDFController@showPDF');
}); });
Route::get('homestay/{id}/{tm}/{lm}/{ts}/{jt}/{jk}','GuestController@homestay');
Route::get('cari','GuestController@cari'); Route::get('cari','GuestController@cari');
Route::get('detailhomestay/{id}','GuestController@detailhomestay'); Route::get('detailhomestay/{id}','GuestController@detailhomestay');
Route::get('daftar','GuestController@register'); 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