Commit 7934d8fe by Triyah Fatmawati

Add preview sebelum daftar

parent bd469041
...@@ -5,8 +5,24 @@ ...@@ -5,8 +5,24 @@
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use RealRashid\SweetAlert\Facades\Alert;
class Controller extends BaseController class Controller extends BaseController
{ {
use AuthorizesRequests, ValidatesRequests; use AuthorizesRequests, ValidatesRequests;
public function __construct()
{
$this->middleware(function($request,$next){
if (session('success')) {
Alert::success(session('success'));
}
if (session('error')) {
Alert::error(session('error'));
}
return $next($request);
});
}
} }
...@@ -14,29 +14,30 @@ ...@@ -14,29 +14,30 @@
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use RealRashid\SweetAlert\Facades\Alert;
class RegistrasiController extends Controller class RegistrasiController extends Controller
{ {
public function create(){ public function create(){
$kegiatan = Kegiatan::get(); $kegiatan = Kegiatan::orderBy('id')->get();
$konferensi = Konferensi::get(); $konferensi = Konferensi::get();
$date = Date('Y-m-d'); $date = Date('Y-m-d');
$lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi'); // $lastKode = Registrasi::query()->whereDate('created_at', $date)->max('kode_registrasi');
$nourut = sprintf("%05s", ((int) substr($lastKode, -5))+1); // $nourut = sprintf("%05s", ((int) substr($lastKode, -5))+1);
$tgldaftar = Carbon::now()->format('d-m-Y'); // $tgldaftar = Carbon::now()->format('d-m-Y');
$komponen = explode('-', $tgldaftar); // $komponen = explode('-', $tgldaftar);
$kode_registrasi = $komponen[0].$komponen[1].$nourut; // $kode_registrasi = $komponen[0].$komponen[1].$nourut;
$data = [ $data = [
'kegiatan' => $kegiatan, 'kegiatan' => $kegiatan,
'konferensi' => $konferensi, 'konferensi' => $konferensi,
// 'kode_registrasi' => $kode_registrasi // 'kode_registrasi' => $kode_registrasi
]; ];
return view('form_registrasi', $data); return view('form_registrasi', $data);
} }
public function store(Request $request) { public function preview(Request $request){
$rules = [ $rules = [
'nama' => 'required|string', 'nama' => 'required|string',
'email' => 'required|email:rfc,dns', 'email' => 'required|email:rfc,dns',
...@@ -73,11 +74,8 @@ public function store(Request $request) { ...@@ -73,11 +74,8 @@ public function store(Request $request) {
]; ];
$tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s'); $tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s');
// $kegiatan = Kegiatan::find($request->kegiatan);
// $konferensi = Konferensi::find($request->konferensi);
$konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first(); $konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first();
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
//inisial harga //inisial harga
$totalHarga = (int) $konaspi->harga; $totalHarga = (int) $konaspi->harga;
...@@ -93,7 +91,6 @@ public function store(Request $request) { ...@@ -93,7 +91,6 @@ public function store(Request $request) {
} }
$kegiatanpeserta[] = [ $kegiatanpeserta[] = [
'id_registrasi' => $id_registrasi,
'id_kegiatan' => $kegiatan[$i]['id'], 'id_kegiatan' => $kegiatan[$i]['id'],
'id_konferensi' => $daftarKonferensi[$i], 'id_konferensi' => $daftarKonferensi[$i],
'nama_kegiatan' => $kegiatan[$i]['nama'], 'nama_kegiatan' => $kegiatan[$i]['nama'],
...@@ -111,30 +108,68 @@ public function store(Request $request) { ...@@ -111,30 +108,68 @@ public function store(Request $request) {
$totalHarga += (int) $konferensi->harga; $totalHarga += (int) $konferensi->harga;
$i++; $i++;
} }
foreach($kegiatanpeserta as $keg){
KegiatanPeserta::query()->create($keg);
}
} }
else{ else{
$hargaKonferensi = null; $hargaKonferensi = null;
$kegiatanpeserta = [ $kegiatanpeserta[] = [
'id_registrasi' => $id_registrasi,
'id_kegiatan' => $request->kegiatan0[0], 'id_kegiatan' => $request->kegiatan0[0],
'id_konferensi' => null, 'id_konferensi' => null,
]; ];
KegiatanPeserta::query()->create($kegiatanpeserta); }
$data = [
'registrasi' => $registrasi,
'kegiatanpeserta' => $kegiatanpeserta,
'tglRegistrasi' => $tglRegistrasi,
'konaspi' => $konaspi,
'hargaKonferensi' => $hargaKonferensi,
'totalHarga' => $totalHarga
];
return view('invoice', $data)->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to save');
}
}
public function store(Request $request) {
DB::beginTransaction();
try{
$registrasi = json_decode($request->registrasi, true);
$kegiatanpeserta = json_decode($request->kegiatanpeserta, true);
$konaspi = json_decode($request->konaspi, true);
$hargaKonferensi = json_decode($request->hargaKonferensi, true);
$tglRegistrasi = $request->tglRegistrasi;
$totalHarga = $request->totalHarga;
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
$jumlahKeg = count($kegiatanpeserta);
foreach($kegiatanpeserta as $keg){
$kegpeserta = [
'id_registrasi' => $id_registrasi,
'id_kegiatan' => $keg['id_kegiatan'],
'id_konferensi' => $keg['id_konferensi'],
];
KegiatanPeserta::query()->create($kegpeserta);
} }
$multipartData = [ $multipartData = [
'noid' => $kode_registrasi, 'noid' => $registrasi['kode_registrasi'],
'nama' => $request->nama, 'nama' => $registrasi['nama'],
'tagihan' => $totalHarga 'tagihan' => $totalHarga
]; ];
$generatedVa = $this->generateVa($multipartData); $generatedVa = $this->generateVa($multipartData);
$arrResponse = json_decode($generatedVa, true); $arrResponse = json_decode($generatedVa, true);
$registrasi->status_va = $arrResponse['BTNresponse']; $registrasi->status_va = $arrResponse['BTNresponse'];
$registrasi->tagihan = $totalHarga; $registrasi->tagihan = $totalHarga;
...@@ -153,24 +188,14 @@ public function store(Request $request) { ...@@ -153,24 +188,14 @@ public function store(Request $request) {
DB::commit(); DB::commit();
// return redirect()->back() return redirect()->route('user.create')->with('success', 'Data saved successfully');
// ->with('success', 'Data saved successfully');
$data = [
'registrasi' => $registrasi,
'tglRegistrasi' => $tglRegistrasi,
'konaspi' => $konaspi,
'hargaKonferensi' => $hargaKonferensi
];
return view('invoice', $data)->with('success', 'Data saved successfully');
} }
catch(Exception $e){ catch(Exception $e){
Log::error($e); Log::error($e);
DB::rollBack(); DB::rollBack();
return redirect()->back() return redirect()->route('user.create')
->with('error', 'Data failed to save'); ->with('error', 'Data failed to save');
} }
} }
......
...@@ -8812,5 +8812,5 @@ ...@@ -8812,5 +8812,5 @@
"php": "^8.1" "php": "^8.1"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
@if ($i != 0) @if ($i != 0)
@if ($keg->id != "498633a9-082c-4a4a-9dbd-e20b678ec15e") @if ($keg->id != "498633a9-082c-4a4a-9dbd-e20b678ec15e")
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" id="nama-kegiatan-{{ $i }}-{{ $j }}" name="kegiatan{{ $i }}[]" value="{{ $keg->id }}" onChange="cekKegiatan('nama-kegiatan-{{ $i }}-{{ $j }}')"> <input class="form-check-input" type="radio" id="nama-kegiatan-{{ $i }}-{{ $j }}" name="kegiatan{{ $i }}[]" value="{{ $keg->id }}" onChange="cekKegiatan('nama-kegiatan-{{ $i }}-{{ $j }}')" required>
<label class="form-check-label" for="{{ $keg->nama }}">{{ $keg->nama }}</label> <label class="form-check-label" for="nama-kegiatan-{{ $i }}-{{ $j }}">{{ $keg->nama }}</label>
</div> </div>
@endif @endif
@else @else
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" id="nama-kegiatan-{{ $i }}-{{ $j }}" name="kegiatan{{ $i }}[]" value="{{ $keg->id }}" onChange="cekKegiatan('nama-kegiatan-{{ $i }}-{{ $j }}')"> <input class="form-check-input" type="radio" id="nama-kegiatan-{{ $i }}-{{ $j }}" name="kegiatan{{ $i }}[]" value="{{ $keg->id }}" onChange="cekKegiatan('nama-kegiatan-{{ $i }}-{{ $j }}')" required>
<label class="form-check-label" for="{{ $keg->nama }}">{{ $keg->nama }}</label> <label class="form-check-label" for="nama-kegiatan-{{ $i }}-{{ $j }}">{{ $keg->nama }}</label>
</div> </div>
@endif @endif
@endforeach @endforeach
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</div> </div>
</div> </div>
<form class="needs-validation" novalidate="" method="POST" action="{{ route('user.store')}}" enctype="multipart/form-data"> <form class="needs-validation" novalidate="" method="POST" action="{{ route('user.preview')}}" enctype="multipart/form-data">
<div class="section-body"> <div class="section-body">
@csrf @csrf
<div class="row"> <div class="row">
...@@ -120,14 +120,14 @@ ...@@ -120,14 +120,14 @@
</div> </div>
<hr> <hr>
<div class="card"> <div class="card">
<div class="card-body"> {{-- <div class="card-body">
{{-- <div class="form-group" @if ($errors->has('kode_registrasi')) has-error @endif> <div class="form-group" @if ($errors->has('kode_registrasi')) has-error @endif>
<label>Kode Registrasi</label> <label>Kode Registrasi</label>
<input type="text" id="kode_registrasi" name="kode_registrasi" class="form-control number" required="true" placeholder="" value="{{ $kode_registrasi }}"> <input type="text" id="kode_registrasi" name="kode_registrasi" class="form-control number" required="true" placeholder="" value="{{ $kode_registrasi }}">
@if ($errors->has('kode_registrasi')) @if ($errors->has('kode_registrasi'))
<label id="login-error" class="error" for="kode_registrasi" style="color: red">{{$errors->first('kode_registrasi')}}</label> <label id="login-error" class="error" for="kode_registrasi" style="color: red">{{$errors->first('kode_registrasi')}}</label>
@endif @endif
</div> --}} </div>
<div class="form-group" @if ($errors->has('biaya')) has-error @endif> <div class="form-group" @if ($errors->has('biaya')) has-error @endif>
<label>Biaya Pendaftaran</label> <label>Biaya Pendaftaran</label>
<input type="text" id="biaya" name="biaya" class="form-control number" required="true" placeholder="" value="{{ old('biaya')}}" disabled> <input type="text" id="biaya" name="biaya" class="form-control number" required="true" placeholder="" value="{{ old('biaya')}}" disabled>
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<label id="login-error" class="error" for="biaya" style="color: red">{{$errors->first('biaya')}}</label> <label id="login-error" class="error" for="biaya" style="color: red">{{$errors->first('biaya')}}</label>
@endif @endif
</div> </div>
</div> </div> --}}
</div> </div>
</div> </div>
</div> </div>
...@@ -197,8 +197,6 @@ function hapusKegiatan(id){ ...@@ -197,8 +197,6 @@ function hapusKegiatan(id){
$('#'+id).remove(); $('#'+id).remove();
} }
function cekHarga(){
console.log('masuk');
} }
</script> </script>
@endpush @endpush
@extends('layouts.app') @extends('layouts.app')
@section('title','Tabel Data') @section('title','Invoice')
@section('content') @section('content')
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">
<h1>Invoice</h1> <h1>Invoice</h1>
<div class="section-header-breadcrumb"> <div class="section-header-breadcrumb">
<div class="breadcrumb-item"><a href="/">Dashboard</a></div> <div class="breadcrumb-item"><a href="/">Dashboard</a></div>
<div class="breadcrumb-item"><a href="">Data Registrasi</a></div> <div class="breadcrumb-item"><a href="">Data Registrasi</a></div>
<div class="breadcrumb-item active">Invoice</div> <div class="breadcrumb-item active">Invoice</div>
</div>
</div>
<div class="section-body">
{{-- @foreach ($pengajuan as $tr) --}}
<div class="invoice">
<div class="invoice-print">
<div class="row">
<div class="col-lg-12">
<div class="invoice-title">
<h2>Invoice</h2>
<div class="invoice-number">No. Transaksi #{{$registrasi['kode_registrasi']}}</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<address>
<strong>Identitas:</strong><br>
{{$registrasi['nama']}}<br>
{{$registrasi['alamat']}}<br>
{{$registrasi['telepon']}}<br>
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Instansi:</strong><br>
{{$registrasi['instansi']}}<br>
</address>
</div>
</div>
<div class="row">
<div class="col-md-6">
<address>
<strong>Metode Pembayaran:</strong><br>
Virtual Account : <br>
{{-- {{$registrasi['email']}} --}}
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Tanggal Registrasi:</strong><br>
{{$tglRegistrasi}}<br><br>
</address>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<div class="section-title">Rincian</div>
<p class="section-lead">Rincian registrasi sudah tidak bisa diubah</p>
<div class="table-responsive">
<table class="table table-striped table-hover table-md">
<tr>
<th data-width="40">#</th>
<th>Kegiatan</th>
<th class="text-center">Harga</th>
<th class="text-center">Jumlah</th>
<th class="text-right">Total Harga</th>
</tr>
@php
$no = 2;
$initialharga = $konaspi->harga;
$subtotal = $initialharga;
$i = 0;
@endphp
<tr>
<td>1</td>
<td>
Convention
</td>
<td class="text-center">Rp {{$konaspi->harga}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$konaspi->harga}}</td>
</tr>
@if (isset($hargaKonferensi))
@foreach ($hargaKonferensi as $kon)
@php
$subtotal = $subtotal + $kon['hargakon'];
@endphp
<tr>
<td>{{$no}}</td>
<td>
{{$kon['namakeg']}} <br> Konferensi : <b> {{$kon['namakon']}} </b>
</td>
<td class="text-center">Rp {{$kon['hargakon']}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$kon['hargakon']}}</td>
</tr>
@php
$i++;
$no++;
@endphp
@endforeach
@endif
</table>
</div>
<div class="row mt-4">
<div class="col-lg-8">
<div class="section-title">Payment Method</div>
<p class="section-lead">The payment method that we provide is to make it easier for you to pay invoices.</p>
<div class="d-flex">
<div class="mr-2 bg-visa" data-width="61" data-height="38"></div>
<div class="mr-2 bg-jcb" data-width="61" data-height="38"></div>
<div class="mr-2 bg-mastercard" data-width="61" data-height="38"></div>
<div class="bg-paypal" data-width="61" data-height="38"></div>
</div>
</div>
<div class="col-lg-4 text-right">
<div class="invoice-detail-item">
<div class="invoice-detail-name">Subtotal</div>
<div class="invoice-detail-value">Rp {{$subtotal}}</div>
</div>
<hr class="mt-2 mb-2">
<div class="invoice-detail-item">
<div class="invoice-detail-name">Total</div>
<div class="invoice-detail-value invoice-detail-value-lg">Rp {{$subtotal}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="text-md-right">
<div class="float-lg-left mb-lg-0 mb-3">
<button class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</button>
<button class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button>
</div>
<button class="btn btn-warning btn-icon icon-left"><i class="fas fa-print"></i> Cetak</button>
</div>
</div> </div>
{{-- @endforeach --}}
</div> </div>
</section> <form novalidate="" method="POST" action="{{ route('user.store')}}" enctype="multipart/form-data">
@csrf
<div class="section-body">
<div class="invoice">
<div class="invoice-print">
<div class="row">
<div class="col-lg-12">
<div class="invoice-title">
<h2>Invoice</h2>
<div class="invoice-number">No. Transaksi #{{$registrasi['kode_registrasi']}}</div>
</div>
<hr>
<div class="row" style="font-size: 12pt">
<div class="col-md-6">
<address>
<strong>Identitas:</strong><br>
{{$registrasi['nama']}}<br>
{{$registrasi['alamat']}}<br>
{{$registrasi['telepon']}}<br>
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Instansi:</strong><br>
{{$registrasi['instansi']}}<br>
</address>
</div>
</div>
<div class="row" style="font-size: 12pt">
<div class="col-md-6">
<address>
<strong>Metode Pembayaran:</strong><br>
Virtual Account : {{$registrasi['kode_registrasi']}}<br>
{{-- {{$registrasi['email']}} --}}
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Tanggal Registrasi:</strong><br>
{{$tglRegistrasi}}<br><br>
</address>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12" style="font-size: 12pt">
<div class="section-title">Rincian</div>
<p class="section-lead">Rincian registrasi sudah tidak bisa diubah</p>
<div class="table-responsive">
<table class="table table-striped table-hover table-md">
<tr>
<th data-width="40">#</th>
<th>Kegiatan</th>
<th class="text-center">Harga</th>
<th class="text-center">Jumlah</th>
<th class="text-right">Total Harga</th>
</tr>
@php
$no = 2;
$initialharga = $konaspi->harga;
$subtotal = $initialharga;
$i = 0;
@endphp
<tr>
<td>1</td>
<td>
Convention
</td>
<td class="text-center">Rp {{$konaspi->harga}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$konaspi->harga}}</td>
</tr>
@if (isset($hargaKonferensi))
@foreach ($hargaKonferensi as $kon)
@php
$subtotal = $subtotal + $kon['hargakon'];
@endphp
<tr>
<td>{{$no}}</td>
<td>
{{$kon['namakeg']}} <br> Konferensi : <b> {{$kon['namakon']}} </b>
</td>
<td class="text-center">Rp {{$kon['hargakon']}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$kon['hargakon']}}</td>
</tr>
@php
$i++;
$no++;
@endphp
@endforeach
@endif
</table>
</div>
<div class="row mt-4">
<div class="col-lg-8">
<div class="section-title">Metode Pembayaran</div>
<p class="section-lead" style="font-size: 12pt">Setelah menekan tombol bayar, maka data akan tersimpan dan lakukan pembayaran tagihan menggunakan <b>Nomor Virtual Account</b> yang tertera pada <b>Invoice</b> ini</p>
{{-- <div class="d-flex">
<div class="mr-2 bg-visa" data-width="61" data-height="38"></div>
<div class="mr-2 bg-jcb" data-width="61" data-height="38"></div>
<div class="mr-2 bg-mastercard" data-width="61" data-height="38"></div>
<div class="bg-paypal" data-width="61" data-height="38"></div>
</div> --}}
</div>
<div class="col-lg-4 text-right">
<div class="invoice-detail-item">
<div class="invoice-detail-name">Subtotal</div>
<div class="invoice-detail-value">Rp {{$subtotal}}</div>
</div>
<hr class="mt-2 mb-2">
<div class="invoice-detail-item">
<div class="invoice-detail-name">Total</div>
<div class="invoice-detail-value invoice-detail-value-lg">Rp {{$subtotal}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="text-md-right">
{{-- <div class="float-lg-left mb-lg-0 mb-3">
<button class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</button>
<button class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button>
</div> --}}
{{-- <button class="btn btn-warning btn-icon icon-left"><i class="fas fa-print"></i> Cetak</button> --}}
<input type="hidden" id="registrasi" name="registrasi" value="{{ json_encode($registrasi) }}">
<input type="hidden" id="kegiatanpeserta" name="kegiatanpeserta" value="{{ json_encode($kegiatanpeserta) }}">
<input type="hidden" id="tglRegistrasi" name="tglRegistrasi" value="{{ json_encode($tglRegistrasi) }}">
<input type="hidden" id="konaspi" name="konaspi" value="{{ json_encode($konaspi) }}">
<input type="hidden" id="hargaKonferensi" name="hargaKonferensi" value="{{ json_encode($hargaKonferensi) }}">
<input type="hidden" id="totalHarga" name="totalHarga" value="{{ json_encode($totalHarga) }}">
<button type="submit" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</button>
<button class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button>
</div>
</div>
</div>
</form>
</section>
@endsection @endsection
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Route::get('/', [RegistrasiController::class,'create'])->name('user.create'); Route::get('/', [RegistrasiController::class,'create'])->name('user.create');
Route::post('/store', [RegistrasiController::class,'store'])->name('user.store'); Route::post('/store', [RegistrasiController::class,'store'])->name('user.store');
Route::get('/cekHarga', [RegistrasiController::class,'cekHarga'])->name('user.cekharga'); Route::post('/preview', [RegistrasiController::class,'preview'])->name('user.preview');
Route::get('/home', [AdminController::class,'index'])->name('admin.home'); Route::get('/home', [AdminController::class,'index'])->name('admin.home');
......
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