Commit 6e8849e4 by Triyah Fatmawati

Add registrasi kelompok

parent 8262df37
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use RealRashid\SweetAlert\Facades\Alert; use RealRashid\SweetAlert\Facades\Alert;
use Str; use Str;
use function PHPUnit\Framework\isEmpty;
class RegistrasiController extends Controller class RegistrasiController extends Controller
{ {
...@@ -79,7 +80,7 @@ public function group_kegiatan(Request $request){ ...@@ -79,7 +80,7 @@ public function group_kegiatan(Request $request){
'instansi' => 'required|string', 'instansi' => 'required|string',
'jabatan' => 'required|string', 'jabatan' => 'required|string',
'alamat' => 'required|string', 'alamat' => 'required|string',
'kodepos' => 'required|string', 'kode_pos' => 'required|string',
'kota' => 'required|string', 'kota' => 'required|string',
'nik' => 'required|unique:registrasi,nik' 'nik' => 'required|unique:registrasi,nik'
]; ];
...@@ -109,7 +110,7 @@ public function preview(Request $request){ ...@@ -109,7 +110,7 @@ public function preview(Request $request){
'instansi' => 'required|string', 'instansi' => 'required|string',
'jabatan' => 'required|string', 'jabatan' => 'required|string',
'alamat' => 'required|string', 'alamat' => 'required|string',
'kodepos' => 'required|string', 'kode_pos' => 'required|string',
'kota' => 'required|string', 'kota' => 'required|string',
]; ];
$request->validate($rules, ValidationRule::getErrorMessage($rules)); $request->validate($rules, ValidationRule::getErrorMessage($rules));
...@@ -194,10 +195,12 @@ public function preview(Request $request){ ...@@ -194,10 +195,12 @@ public function preview(Request $request){
} }
} }
else{ else{
$kegiatan = Kegiatan::select('id', 'nama', 'harga')->where('id', $request->kegiatan[0])->first();
$hargaKonferensi = null; $hargaKonferensi = null;
$kegiatanpeserta[] = [ $kegiatanpeserta[] = [
'id_kegiatan' => $request->kegiatan0[0], 'id_kegiatan' => $request->kegiatan[0],
'id_konferensi' => null, 'id_konferensi' => null,
'nama_kegiatan' => $kegiatan->nama
]; ];
} }
...@@ -209,6 +212,7 @@ public function preview(Request $request){ ...@@ -209,6 +212,7 @@ public function preview(Request $request){
'hargaKonferensi' => $hargaKonferensi, 'hargaKonferensi' => $hargaKonferensi,
'totalHarga' => $totalHarga, 'totalHarga' => $totalHarga,
'anggota' => $request->anggota ?? [], 'anggota' => $request->anggota ?? [],
'kegiatan_anggota' => $request->kegiatan_anggota
]; ];
return view('preview', $data)->with('success', 'Data saved successfully'); return view('preview', $data)->with('success', 'Data saved successfully');
...@@ -225,7 +229,7 @@ public function preview(Request $request){ ...@@ -225,7 +229,7 @@ public function preview(Request $request){
public function store(Request $request) { public function store(Request $request) {
DB::beginTransaction(); DB::beginTransaction();
// dd($request);
try{ try{
$registrasi = json_decode($request->registrasi, true); $registrasi = json_decode($request->registrasi, true);
$kegiatanpeserta = json_decode($request->kegiatanpeserta, true); $kegiatanpeserta = json_decode($request->kegiatanpeserta, true);
...@@ -234,7 +238,7 @@ public function store(Request $request) { ...@@ -234,7 +238,7 @@ public function store(Request $request) {
$anggota = json_decode($request->anggota, true); $anggota = json_decode($request->anggota, true);
$tglRegistrasi = $request->tglRegistrasi; $tglRegistrasi = $request->tglRegistrasi;
// $totalHargas = $request->totalHarga; // $totalHargas = $request->totalHarga;
$kegiatan_anggota = json_decode($request->kegiatan_anggota);
$registrasi = Registrasi::query()->create($registrasi); $registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id; $id_registrasi = $registrasi->id;
$jumlahKeg = count($kegiatanpeserta); $jumlahKeg = count($kegiatanpeserta);
...@@ -246,18 +250,42 @@ public function store(Request $request) { ...@@ -246,18 +250,42 @@ public function store(Request $request) {
$anggota[$key]['created_at'] = Carbon::now()->toDateTimeString(); $anggota[$key]['created_at'] = Carbon::now()->toDateTimeString();
$anggota[$key]['updated_at'] = Carbon::now()->toDateTimeString(); $anggota[$key]['updated_at'] = Carbon::now()->toDateTimeString();
} }
// dd($anggota, $kegiatanpeserta);
Anggota::query()->insert($anggota); Anggota::query()->insert($anggota);
//inisial harga //inisial harga
$konvensi = Kegiatan::find($konaspi['id']); $konvensi = Kegiatan::find($konaspi['id']);
$konv = $konvensi->toArray(); $konv = $konvensi->toArray();
$jumlahPeserta = count($anggota); $jumlahPeserta = count($anggota);
$totalHarga = ((int) $konvensi->harga) * $jumlahPeserta;
// dd($kegiatanpeserta, $totalHarga, $anggota, $registrasi['kode_registrasi']); if($jumlahPeserta > 0){
$totalHarga = ((int) $konvensi->harga) * $jumlahPeserta;
}
else{
$totalHarga = ((int) $konvensi->harga);
}
if(!isEmpty($anggota) && !is_null($kegiatan_anggota)){
$anggotaIndices = array_keys($anggota);
$kegiatanAnggotaValues = array_values($kegiatan_anggota);
$konvensi_anggota = array_values(array_diff($anggotaIndices, $kegiatanAnggotaValues));
if($konvensi_anggota){
foreach ($konvensi_anggota as $key => $value) {
$convention_only = [
'id_registrasi' => $anggota[$value]['id_registrasi'],
'id_kegiatan' => $konv['id'],
'id_konferensi' => null,
'id_anggota' => $anggota[$value]['id']
];
KegiatanPeserta::query()->create($convention_only);
}
}
}
foreach($kegiatanpeserta as $keg){ foreach($kegiatanpeserta as $keg){
// dd($kegiatanpeserta, $keg, $jumlahPeserta);
$arrayKeg = $keg; $arrayKeg = $keg;
if(isset($arrayKeg['anggota']['key'])){ if(isset($arrayKeg['anggota']['key'])){
...@@ -273,9 +301,8 @@ public function store(Request $request) { ...@@ -273,9 +301,8 @@ public function store(Request $request) {
'id_konferensi' => $keg['id_konferensi'], 'id_konferensi' => $keg['id_konferensi'],
'id_anggota' => $idPeserta 'id_anggota' => $idPeserta
]; ];
// dd($kegpeserta, $kegiatanpeserta);
KegiatanPeserta::query()->create($kegpeserta); KegiatanPeserta::query()->create($kegpeserta);
// dd($kegpeserta, $kegiatanpeserta);
if($keg['id_kegiatan'] != '498633a9-082c-4a4a-9dbd-e20b678ec15e'){ if($keg['id_kegiatan'] != '498633a9-082c-4a4a-9dbd-e20b678ec15e'){
$konferensi = Konferensi::query()->where('id', $keg['id_konferensi'])->first(); $konferensi = Konferensi::query()->where('id', $keg['id_konferensi'])->first();
...@@ -288,42 +315,38 @@ public function store(Request $request) { ...@@ -288,42 +315,38 @@ public function store(Request $request) {
'hargakon' => $konferensi->harga, 'hargakon' => $konferensi->harga,
'namakeg' => $kegkonaspi->nama 'namakeg' => $kegkonaspi->nama
]; ];
// dd($kegPeserta);
} }
else{ else{
$kegPeserta = null; $kegPeserta = null;
} }
} }
// dd($kegPeserta);
$multipartData = [ $multipartData = [
'noid' => $registrasi['kode_registrasi'], 'noid' => $registrasi['kode_registrasi'],
'nama' => $registrasi['nama'], 'nama' => $registrasi['nama'],
'tagihan' => $totalHarga 'tagihan' => $totalHarga
]; ];
// dd($kegPeserta, $multipartData);
$registrasi->save(); $registrasi->save();
// ditutup sementara
// $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['status_va'] = 'status_vA';
$registrasi['tagihan'] = $totalHarga; $registrasi['tagihan'] = $totalHarga;
// $registrasi['nomor_va'] = $arrResponse['BTNVirtualAccount']; $registrasi['nomor_va'] = $arrResponse['BTNVirtualAccount'];
$registrasi['nomor_va'] = $registrasi['kode_registrasi'];
$registrasi->save(); $registrasi->save();
// ditutup sementara if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){
// if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){ DB::rollBack();
// DB::rollBack(); Log::error('---');
// Log::error('---'); Log::error($multipartData);
// Log::error($multipartData); Log::error($arrResponse['BTNresponse']);
// Log::error($arrResponse['BTNresponse']); Log::error('---');
// Log::error('---');
// return redirect()->route('user.create') return redirect()->route('user.create')
// ->with('error', 'Data failed to save'); ->with('error', 'Data failed to save');
// } }
DB::commit(); DB::commit();
...@@ -346,34 +369,31 @@ public function store(Request $request) { ...@@ -346,34 +369,31 @@ public function store(Request $request) {
Log::error($e); Log::error($e);
DB::rollBack(); DB::rollBack();
dd($e);
return redirect()->route('user.create') return redirect()->route('user.create')
->with('error', 'Data failed to save'); ->with('error', 'Data failed to save');
} }
} }
// ditutup sementara private function generateVa($multipartData)
// private function generateVa($multipartData) {
// { $client = new Client();
// $client = new Client(); $options = [
// $options = [ 'form_params' => [
// 'form_params' => [ // 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
// // 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O', 'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/',
// 'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/', 'noid' => $multipartData['noid'],
// 'noid' => $multipartData['noid'], 'nama' => $multipartData['nama'],
// 'nama' => $multipartData['nama'], 'tagihan' => $multipartData['tagihan'],
// 'tagihan' => $multipartData['tagihan'], 'flag' => 'F',
// 'flag' => 'F', 'expired_date' => '2024-08-01T23:59:59+07:00',
// 'expired_date' => '2024-08-01T23:59:59+07:00', 'deskripsi' => 'pembayaran konaspi'
// 'deskripsi' => 'pembayaran konaspi' ]
// ] ];
// ];
$response = $client->request('POST', 'https://neosidata.unesa.ac.id/btn_v2/create', $options);
// $response = $client->request('POST', 'https://neosidata.unesa.ac.id/btn_v2/create', $options);
return $response->getBody()->getContents();
// return $response->getBody()->getContents(); }
// }
private function getDataUniv(){ private function getDataUniv(){
$client = new Client(); $client = new Client();
......
...@@ -71,25 +71,30 @@ ...@@ -71,25 +71,30 @@
Convention Convention
</td> </td>
<td class="text-center">Rp {{$konaspi['harga']??'param'}}</td> <td class="text-center">Rp {{$konaspi['harga']??'param'}}</td>
<td class="text-center">1</td> <td class="text-center">{{ ($jumlah_peserta != 0) ? $jumlah_peserta : 1 }}</td>
<td class="text-right">Rp {{$konaspi['harga']??'param'}}</td> <td class="text-right">Rp {{ $totalHarga }}</td>
</tr> </tr>
@if (isset($hargaKonferensi)) @if (isset($kegiatanpeserta))
@foreach ($hargaKonferensi as $kon) @foreach ($kegiatanpeserta as $kon)
@php @php
$subtotal = $subtotal + $kon['hargakon']; // $subtotal = $subtotal + $kon['hargakon'];
@endphp @endphp
<tr> @if ($kon['id_konferensi'])
<td>{{$no}}</td> <tr>
<td> <td>{{$no}}</td>
{{$kon['namakeg']}} <br> Konferensi : <b> {{$kon['namakon']??'param'}} </b> <td>
</td> {{$kon['nama_kegiatan']}} <br> Konferensi : <b> {{$kon['nama_konferensi']}} </b>
{{-- <td class="text-center">Rp {{$kon['hargakon']??'param'}}</td> --}} @isset($kon['anggota']['nama'])
<td class="text-center">-</td> <br>Anggota : <b>{{ $kon['anggota']['nama'] }}</b>
<td class="text-center">1</td> @endisset
{{-- <td class="text-right">Rp {{$kon['hargakon']??'param'}}</td> --}} </td>
<td class="text-right">-</td> {{-- <td class="text-center">Rp {{$kon['hargakon']}}</td> --}}
</tr> <td class="text-center">-</td>
<td class="text-center">1</td>
{{-- <td class="text-right">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-right">-</td>
</tr>
@endif
@php @php
$i++; $i++;
$no++; $no++;
...@@ -118,13 +123,13 @@ ...@@ -118,13 +123,13 @@
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Subtotal</div> <div class="invoice-detail-name">Subtotal</div>
{{-- <div class="invoice-detail-value">Rp {{$subtotal}}</div> --}} {{-- <div class="invoice-detail-value">Rp {{$subtotal}}</div> --}}
<div class="invoice-detail-value">Rp {{$initialharga}}</div> <div class="invoice-detail-value">Rp {{$totalHarga}}</div>
</div> </div>
<hr class="mt-2 mb-2"> <hr class="mt-2 mb-2">
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Total</div> <div class="invoice-detail-name">Total</div>
{{-- <div class="invoice-detail-value invoice-detail-value-lg">Rp {{$subtotal}}</div> --}} {{-- <div class="invoice-detail-value invoice-detail-value-lg">Rp {{$subtotal}}</div> --}}
<div class="invoice-detail-value invoice-detail-value-lg">Rp {{$initialharga}}</div> <div class="invoice-detail-value invoice-detail-value-lg">Rp {{$totalHarga}}</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -109,11 +109,11 @@ ...@@ -109,11 +109,11 @@
<label id="login-error" class="error" for="alamat" style="color: red">{{$errors->first('alamat')}}</label> <label id="login-error" class="error" for="alamat" style="color: red">{{$errors->first('alamat')}}</label>
@endif @endif
</div> </div>
<div class="form-group" @if ($errors->has('kodepos')) has-error @endif> <div class="form-group" @if ($errors->has('kode_pos')) has-error @endif>
<label>Kode Pos</label> <label>Kode Pos</label>
<input type="number" id="kodepos" name="kodepos" class="form-control number" required="true" placeholder="" value="{{ old('kodepos')}}"> <input type="number" id="kode_pos" name="kode_pos" class="form-control number" required="true" placeholder="" value="{{ old('kode_pos')}}">
@if ($errors->has('kodepos')) @if ($errors->has('kode_pos'))
<label id="login-error" class="error" for="kodepos" style="color: red">{{$errors->first('kodepos')}}</label> <label id="login-error" class="error" for="kode_pos" style="color: red">{{$errors->first('kode_pos')}}</label>
@endif @endif
{{-- <div class="invalid-feedback">Isikan Kode Pos yg sesuai</div> --}} {{-- <div class="invalid-feedback">Isikan Kode Pos yg sesuai</div> --}}
</div> </div>
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
Convention Convention
</td> </td>
<td class="text-center">Rp {{$konaspi['harga']}}</td> <td class="text-center">Rp {{$konaspi['harga']}}</td>
<td class="text-center">{{ $jumlah_peserta }}</td> <td class="text-center">{{ ($jumlah_peserta != 0) ? $jumlah_peserta : 1 }}</td>
<td class="text-right">Rp {{ $totalHarga }}</td> <td class="text-right">Rp {{ $totalHarga }}</td>
</tr> </tr>
@if (isset($kegiatanpeserta)) @if (isset($kegiatanpeserta))
...@@ -89,20 +89,22 @@ ...@@ -89,20 +89,22 @@
{{-- @php {{-- @php
$subtotal = $subtotal + $kon['hargakon']; $subtotal = $subtotal + $kon['hargakon'];
@endphp --}} @endphp --}}
<tr> @if ($kon['id_konferensi'])
<td>{{$no}}</td> <tr>
<td> <td>{{$no}}</td>
{{$kon['nama_kegiatan']}} <br> Konferensi : <b> {{$kon['nama_konferensi']}} </b> <td>
@isset($kon['anggota']['nama']) {{$kon['nama_kegiatan']}} <br> Konferensi : <b> {{$kon['nama_konferensi']}} </b>
@isset($kon['anggota']['nama'])
<br>Anggota : <b>{{ $kon['anggota']['nama'] }}</b> <br>Anggota : <b>{{ $kon['anggota']['nama'] }}</b>
@endisset @endisset
</td> </td>
{{-- <td class="text-center">Rp {{$kon['hargakon']}}</td> --}} {{-- <td class="text-center">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-center">-</td> <td class="text-center">-</td>
<td class="text-center">1</td> <td class="text-center">1</td>
{{-- <td class="text-right">Rp {{$kon['hargakon']}}</td> --}} {{-- <td class="text-right">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-right">-</td> <td class="text-right">-</td>
</tr> </tr>
@endif
@php @php
$i++; $i++;
$no++; $no++;
...@@ -160,7 +162,7 @@ ...@@ -160,7 +162,7 @@
<input type="hidden" id="totalHarga" name="totalHarga" value="{{ json_encode($totalHarga) }}"> --}} <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 type="submit" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</button> --}}
{{-- <a href="{{route('user.create')}}" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</a> --}} {{-- <a href="{{route('user.create')}}" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Bayar</a> --}}
<a href="{{route('user.create')}}" class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i>Close</a> <a href="{{route('pre-register')}}" class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i>Close</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -154,7 +154,8 @@ ...@@ -154,7 +154,8 @@
<input type="hidden" id="konaspi" name="konaspi" value="{{ json_encode($konaspi) }}"> <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="hargaKonferensi" name="hargaKonferensi" value="{{ json_encode($hargaKonferensi) }}">
<input type="hidden" id="totalHarga" name="totalHarga" value="{{ json_encode($totalHarga) }}"> <input type="hidden" id="totalHarga" name="totalHarga" value="{{ json_encode($totalHarga) }}">
<input type="hidden" id="totalHarga" name="anggota" value="{{ json_encode($anggota) }}"> <input type="hidden" id="anggota" name="anggota" value="{{ json_encode($anggota) }}">
<input type="hidden" id="kegiatan_anggota" name="kegiatan_anggota" value="{{ json_encode($kegiatan_anggota) }}">
<button type="submit" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Daftar</button> <button type="submit" class="btn btn-primary btn-icon icon-left"><i class="fas fa-credit-card"></i> Daftar</button>
<button class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button> <button class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button>
</div> </div>
......
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