Commit 30feb5bd by Palti Sinaga

h-1

parents 9f287095 1606b1ac
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Feedback;
use App\Homestay;
use App\ListBook;
use App\RequestHomestay;
use App\Room;
use App\Transaksi;
use Illuminate\Http\Request;
......@@ -48,7 +49,145 @@ class CustomerController extends Controller
//Memperbaharui pesanan
public function updatePesanan($id){
$data = Transaksi::find($id);
//$time = explode('-', $request['tanggal']);
$tanggalMulai = explode('-',$data->tanggal_mulai);
$tanggalBerakhir = explode('-',$data->tanggal_berakhir);
$lamaMenginap = $tanggalBerakhir[2] - $tanggalMulai[2];
//dd($lamaMenginap);
return view('adminlte::layouts.customers.UpdatePemesanan')->with('data',$data)->with('lama_menginap',$lamaMenginap);
}
//Menimpan pesanan yang baru
public function perbaharui(Request $request,$id){
$dataTransaksi = DB::table('transaksi')
->select('transaksi.*')
->where('transaksi.id','=',$id)
->get();
$dataHomestay = DB::table('homestay')
->join('kamar','homestay.id','=','kamar.id_homestay')
->select('kamar.*','homestay.harga','homestay.jumlah_kamar')
->where('homestay.id','=',$dataTransaksi[0]->id_homestay)
->get();
$homestayJumlahKamar = DB::table('homestay')
->select('homestay.jumlah_kamar')
->where('homestay.id','=',$dataTransaksi[0]->id_homestay)
->get();
$dataBookingMulai = DB::table('daftar_book')
->select('daftar_book.*')
->where('daftar_book.tanggal_mulai','=',$request['tanggal'])
->get();
$tanggal_baru = explode('-', $request['tanggal']);
$tanggal_baru[2] +=$request['lama_menginap'];
$tanggal = join('-',$tanggal_baru);
$dataBookingBerakhir = DB::table('daftar_book')
->select('daftar_book.*')
->where('daftar_book.tanggal_berakhir','=',$tanggal)
->get();
//dd($dataTransaksi[0],$dataHomestay[0],$dataPemilik[0],$homestayJumlahKamar[0],$dataBookingBerakhir[0],$dataBookingMulai[0]);
if($dataHomestay[0]->jumlah_kamar < $request['jumlah_kamar']){
return redirect('updatepesanan/',$id)->with('message','Maaf Jumalh kamar tidak sesuai');
}else {
if ($dataBookingMulai->count() > 0) {
$currentJumlahKamar = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingMulai[0]->jumlah_kamar;
if ($currentJumlahKamar < $request['jumlah_kamar']) {
return redirect()->action('GuestController@detailhomestay', ['id' => $request['id']])->with('message', 'Maaf Anda Tidak Bisa Melakukan Pembookingan di karenakan kamar yang tersisa tidak sesuai dengan permintaan anda!');
}
} else {
if ($dataBookingBerakhir->count() > 0) {
$currentJumlahKamar2 = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingBerakhir[0]->jumlah_kamar;
if ($currentJumlahKamar2 < $request['jumlah_kamar']) {
return redirect()->action('GuestController@detailhomestay', ['id' => $request['id']])->with('message', 'Maaf Anda Tidak Bisa Melakukan Pembookingan di karenakan kamar yang tersisa tidak sesuai dengan permintaan anda!');
}
}
}
$time = explode('-', $request['tanggal']);
if ($time[1] == 2) {
$time[2] += $request['lama_menginap'];
if ($time[2] > 28) {
$time[2] = 0;
$time[2] += $request['lama_menginap'];
$time[2] -= 1;
$time[1] += 1;
if ($time[1] > 12) {
$time[1] = 1;
}
}
} else {
if ($time[1] % 2 == 1) {
$time[2] += $request['lama_menginap'];
if ($time[2] > 31) {
if ($request['lama_menginap'] != 1) {
$time[2] = 0;
$time[2] += $request['lama_menginap'];
$time[1] += 1;
}
}
//$time[2] -=1;
} else {
$time[2] += $request['lama_menginap'];
if ($time[2] > 30) {
if ($request['lama_menginap'] != 1) {
$time[2] = 0;
$time[2] += $request['lama_menginap'];
$time[1] += 1;
}
//$time[2] -=1;
}
}
$baru = join('-', $time);
$transaksi = Transaksi::find($id);
$transaksi->tanggal_mulai = $request['tanggal'];
$transaksi->tanggal_berakhir = $baru;
$transaksi->jumlah_kamar = $request['jumlah_kamar'];
$dafBook = ListBook::where('id_transaksi',$id)->get();
/*DB::table('daftar_book')
->where('daftar_book.id_transaksi','=',$id)
->get();*/
$lb = ListBook::find($dafBook[0]->id);
//dd($lb);
$lb->jumlah_kamar = $request['jumlah_kamar'];
$lb->tanggal_mulai = $request['tanggal'];
$lb->tanggal_berakhir = $baru;
//dd($dafBook[0]);
$transaksi->update();
$lb->update();
return redirect('customerHistory');
}
}
}
//Pemberian/Pengiriman Feedback
......@@ -230,101 +369,105 @@ class CustomerController extends Controller
->where('daftar_book.tanggal_berakhir','=',$request['tanggal'])
->get();
if($dataBookingMulai->count() > 0){
$currentJumlahKamar = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingMulai[0]->jumlah_kamar;
if($currentJumlahKamar < $request['jumlah_kamar']){
return redirect()->action('GuestController@detailhomestay',['id'=>$request['id']])->with('message', 'Maaf Anda Tidak Bisa Melakukan Pembookingan di karenakan kamar yang tersisa tidak sesuai dengan permintaan anda!');
}
if($dataHomestay[0]->jumlah_kamar < $request['jumlah_kamar']){
return redirect('detailhomestay/',$dataHomestay[0]->id)->with('message','Maaf Jumalh kamar tidak sesuai');
}else{
if($dataBookingBerakhir->count() > 0){
$currentJumlahKamar2 = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingBerakhir[0]->jumlah_kamar;
if($currentJumlahKamar2 < $request['jumlah_kamar']){
if($dataBookingMulai->count() > 0){
$currentJumlahKamar = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingMulai[0]->jumlah_kamar;
if($currentJumlahKamar < $request['jumlah_kamar']){
return redirect()->action('GuestController@detailhomestay',['id'=>$request['id']])->with('message', 'Maaf Anda Tidak Bisa Melakukan Pembookingan di karenakan kamar yang tersisa tidak sesuai dengan permintaan anda!');
}
}
}
$time = explode('-', $request['tanggal']);
if ($time[1]==2){
$time[2] += $request['jumlah_hari'];
if ($time[2]>28){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[2] -=1;
$time[1] +=1;
if($time[1]>12){
$time[1] = 1;
}else{
if($dataBookingBerakhir->count() > 0){
$currentJumlahKamar2 = $homestayJumlahKamar[0]->jumlah_kamar - $dataBookingBerakhir[0]->jumlah_kamar;
if($currentJumlahKamar2 < $request['jumlah_kamar']){
return redirect()->action('GuestController@detailhomestay',['id'=>$request['id']])->with('message', 'Maaf Anda Tidak Bisa Melakukan Pembookingan di karenakan kamar yang tersisa tidak sesuai dengan permintaan anda!');
}
}
}
}else{
if($time[1]%2==1){
$time = explode('-', $request['tanggal']);
if ($time[1]==2){
$time[2] += $request['jumlah_hari'];
if($time[2]>31){
if($request['jumlah_hari']!=1){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[1] +=1;
if ($time[2]>28){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[2] -=1;
$time[1] +=1;
if($time[1]>12){
$time[1] = 1;
}
}
//$time[2] -=1;
}else{
$time[2] += $request['jumlah_hari'];
if($time[2]>30){
if($request['jumlah_hari']!=1){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[1] +=1;
if($time[1]%2==1){
$time[2] += $request['jumlah_hari'];
if($time[2]>31){
if($request['jumlah_hari']!=1){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[1] +=1;
}
}
//$time[2] -=1;
}else{
$time[2] += $request['jumlah_hari'];
if($time[2]>30){
if($request['jumlah_hari']!=1){
$time[2] = 0;
$time[2] += $request['jumlah_hari'];
$time[1] +=1;
}
}
//$time[2] -=1;
}
//$time[2] -=1;
}
$baru = join('-',$time);
$trans = new Transaksi();
$trans->id_pelanggan = $dataPelanggan[0]->id;
$trans->id_homestay = $request['id'];
$trans->tanggal_mulai = $request['tanggal'];
$trans->tanggal_berakhir = $baru;
$trans->jumlah_kamar =$request['jumlah_kamar'];
$trans->lama_menginap = $request['jumlah_hari'];
$trans->total_pembayaran = $request['jumlah_kamar'] * $dataHomestay[0]->harga;
$trans->status = 0;
$trans->save();
$dataTrans = DB::table('transaksi')
->select('transaksi.id')
->where('transaksi.tanggal_mulai','=',$request['tanggal'])
->where('transaksi.tanggal_berakhir','=',$baru)
->get();
//Insert Table Daftar Booking
$lb->homestay = $request['id'];
$lb->id_transaksi = $dataTrans[0]->id;
$lb->nama_pemesan = $dataPelanggan[0]->nama;
$lb->jumlah_kamar = $request['jumlah_kamar'];
$lb->tanggal_mulai = $request['tanggal'] ;
$lb->tanggal_berakhir = $baru;
//Save
$lb->save();
$text = "Ada Pesanan Kamari dari Sdr/i : ";
$pesan = $text . ' ' .$dataPelanggan[0]->nama;
//$pesan = $text + $dataPelanggan[0]->nama;
//$pesan +=" dengan jumlah kamar"+ ;
Nexmo::message()->send([
'to' => $dataPemilik[0]->no_telepon,
'from' => 'ASDASD',
'text' => $pesan
]);
return redirect('customerHistory');
}
$baru = join('-',$time);
$trans = new Transaksi();
$trans->id_pelanggan = $dataPelanggan[0]->id;
$trans->id_homestay = $request['id'];
$trans->tanggal_mulai = $request['tanggal'];
$trans->tanggal_berakhir = $baru;
$trans->jumlah_kamar =$request['jumlah_kamar'];
$trans->lama_menginap = $request['jumlah_hari'];
$trans->total_pembayaran = $request['jumlah_kamar'] * $dataHomestay[0]->harga;
$trans->status = 0;
$trans->save();
$dataTrans = DB::table('transaksi')
->select('transaksi.id')
->where('transaksi.tanggal_mulai','=',$request['tanggal'])
->where('transaksi.tanggal_berakhir','=',$baru)
->get();
//Insert Table Daftar Booking
$lb->homestay = $request['id'];
$lb->id_transaksi = $dataTrans[0]->id;
$lb->nama_pemesan = $dataPelanggan[0]->nama;
$lb->jumlah_kamar = $request['jumlah_kamar'];
$lb->tanggal_mulai = $request['tanggal'] ;
$lb->tanggal_berakhir = $baru;
//Save
$lb->save();
$text = "Ada Pesanan Kamari dari Sdr/i : ";
$pesan = $text . ' ' .$dataPelanggan[0]->nama;
//$pesan = $text + $dataPelanggan[0]->nama;
//$pesan +=" dengan jumlah kamar"+ ;
Nexmo::message()->send([
'to' => $dataPemilik[0]->no_telepon,
'from' => 'ASDASD',
'text' => $pesan
]);
return redirect('customerHistory');
}
public function dataValidation($id){
......
......@@ -89,7 +89,7 @@ class OwnerController extends Controller
public function updateProfil(Request $request,$id){
$owner = Owner::where('id',$id)->first();
$user = User::where('name',$owner->nama)->first();
//dd($owner->id_akun);
if($request['nama']==""){
$user->name = $owner->nama;
}else{
......@@ -104,11 +104,13 @@ class OwnerController extends Controller
if($request->file('picture')==null){
$owner->foto = $owner->foto;
$user->foto = $user->foto;
}else{
$file = $request->file('picture');
$fileName = $file->getClientOriginalName();
$request->file('picture')->move("img/",$fileName);
$owner->foto = $fileName;
$user->foto = $fileName;
}
$user->update();
......
......@@ -3,17 +3,17 @@
@section('main-content')
<div class="cuisines agileits w3layouts" style="padding-top: 50px; margin-top: 80px; margin-bottom: 100px;">
<div class="container">
<form class="form-horizontal" action="{{url('upload/'.$data->id)}}" method="post" enctype="multipart/form-data">
<form class="form-horizontal" action="{{url('perbaharui/'.$data->id)}}" method="post">
<input type="hidden" name="_method" value="PUT">
{{csrf_field()}}
<label>Tanggal Mulai</label>
<input type="text" name="tanggal_mulai" value="{{$data->tanggal_mulai}}" id="noTelepon" class="form-control">
<label>Tanggal Berakhir</label>
<input type="text" name="tanggal_berakhir" value="{{$data->tanggal_berakhir}}" class="form-control" >
<input type="text" name="tanggal" value="{{$data->tanggal_mulai}}" id="noTelepon" class="form-control">
<label>Lama Menginap</label>
<input type="text" name="lama_menginap" value="{{$lama_menginap}}" class="form-control" >
<label>Jumlah Kamar</label>
<input type="text" name="jumlah_kamar" value="{{$data->jumlah_kamar}}" class="form-control">
<div class="form-group" align="right">
<input type="submit" class="btn btn-primary" value="simpan">
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</form>
</div>
......
......@@ -58,6 +58,7 @@
<img src="/img/{{ $a->bukti_pembayaran }}" style="width: 100px" alt="User Image" onclick="document.getElementById('modal').style.display='block'"/>
@endif
<img src="/img/{{ $a->bukti_pembayaran }}" style="width: 100px" alt="Tidak Ada Gambar" onclick="document.getElementById('modal').style.display='block'"/>
</td>
......
......@@ -55,7 +55,7 @@
<div class="input-group-addon">
<i class="fa fa-dollar"></i>
</div>
<input type="text" class="form-control" value="{{$data->pekerjaan}}" placeholder="pekerjaan" name=""/>
<input type="text" class="form-control" value="{{$data->pekerjaan}}" name="pekerjaan"/>
</div>
</div>
......@@ -65,7 +65,7 @@
<div class="input-group-addon">
<i class="fa fa-dollar"></i>
</div>
<input type="Number" class="form-control" value="{{$data->no_telepon}}" placeholder="noTelepon" name=""/>
<input type="Number" class="form-control" value="{{$data->no_telepon}}" placeholder="noTelepon" name="noTelepon"/>
</div>
</div>
......@@ -75,14 +75,14 @@
<div class="input-group-addon">
<i class="fa fa-dollar"></i>
</div>
<input type="Number" class="form-control" value="{{$data->no_rekening}}" placeholder="noRekening" name=""/>
<input type="Number" class="form-control" value="{{$data->no_rekening}}" placeholder="noRekening" name="noRekening"/>
</div>
</div>
<div class="form-group">
<label>Foto </label>
<div class="input-group">
<input type="file" value="Browse" name="foto" id="picture" >
<input type="file" value="Browse" name="picture" id="picture" >
</div>
</div>
......
......@@ -11,7 +11,7 @@
<span class="logo-lg" style="font-size: 17px;"><b>SI </b>Pemesanan Homestay </span>
</a>
@elseif(Auth::user()->role=="Owner")
<a href="{{ url('/pesanan') }}" class="logo">
<a href="{{ url('/') }}" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>SI</b>PH</span>
<!-- logo for regular state and mobile devices -->
......
......@@ -88,6 +88,7 @@ Route::post('daftar','GuestController@registerStore');
Route::group(['middleware' => 'customer'], function () {
Route::get('updatepesanan/{id}','CustomerController@updatePesanan');
Route::put('perbaharui/{id}','CustomerController@perbaharui');
Route::put('batalkan/{id}','CustomerController@cancelPemesanan');
Route::put('upload/{id}','CustomerController@upload');
Route::get('customerHistory','CustomerController@history');
......
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