Commit 8262df37 by Triyah Fatmawati

Store Registrasi Kelompok

parent 8c72dafd
...@@ -132,6 +132,8 @@ public function preview(Request $request){ ...@@ -132,6 +132,8 @@ public function preview(Request $request){
if(!is_null($request->data_registrasi)){ if(!is_null($request->data_registrasi)){
$registrasi = json_decode(decrypt($request->data_registrasi), true); $registrasi = json_decode(decrypt($request->data_registrasi), true);
$registrasi['kode_registrasi'] = $kode_registrasi;
$registrasi['urutan'] = $urutan;
} }
else{ else{
$registrasi = [ $registrasi = [
...@@ -215,7 +217,7 @@ public function preview(Request $request){ ...@@ -215,7 +217,7 @@ public function preview(Request $request){
catch(Exception $e){ catch(Exception $e){
Log::error($e); Log::error($e);
DB::rollBack(); DB::rollBack();
dd($e);
return redirect()->back() return redirect()->back()
->with('error', 'Data failed to save'); ->with('error', 'Data failed to save');
} }
...@@ -223,7 +225,7 @@ public function preview(Request $request){ ...@@ -223,7 +225,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);
...@@ -232,22 +234,30 @@ public function store(Request $request) { ...@@ -232,22 +234,30 @@ 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;
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
$jumlahKeg = count($kegiatanpeserta);
//anggota
foreach($anggota as $key => $item){ foreach($anggota as $key => $item){
$anggota[$key]['id'] = Str::uuid()->toString(); $anggota[$key]['id'] = Str::uuid()->toString();
$anggota[$key]['id_registrasi'] = $id_registrasi;
$anggota[$key]['created_at'] = Carbon::now()->toDateTimeString();
$anggota[$key]['updated_at'] = Carbon::now()->toDateTimeString();
} }
// Anggota::query()->insert($anggota); // dd($anggota, $kegiatanpeserta);
Anggota::query()->insert($anggota);
// $registrasi = Registrasi::query()->create($registrasi);
// $id_registrasi = $registrasi->id;
$id_registrasi = '$registrasi->id';
$jumlahKeg = count($kegiatanpeserta);
//inisial harga //inisial harga
$konvensi = Kegiatan::find($konaspi['id']); $konvensi = Kegiatan::find($konaspi['id']);
$konv = $konvensi->toArray(); $konv = $konvensi->toArray();
$totalHarga = (int) $konvensi->harga; $jumlahPeserta = count($anggota);
$totalHarga = ((int) $konvensi->harga) * $jumlahPeserta;
// dd($kegiatanpeserta, $totalHarga, $anggota, $registrasi['kode_registrasi']);
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'])){
...@@ -262,10 +272,10 @@ public function store(Request $request) { ...@@ -262,10 +272,10 @@ public function store(Request $request) {
'id_kegiatan' => $keg['id_kegiatan'], 'id_kegiatan' => $keg['id_kegiatan'],
'id_konferensi' => $keg['id_konferensi'], 'id_konferensi' => $keg['id_konferensi'],
'id_anggota' => $idPeserta 'id_anggota' => $idPeserta
// 'id_anggota' =>
]; ];
dd($kegpeserta); // 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();
...@@ -278,39 +288,42 @@ public function store(Request $request) { ...@@ -278,39 +288,42 @@ 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(''); // 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->tagihan = $totalHarga; $registrasi['status_va'] = 'status_vA';
$registrasi->nomor_va = $arrResponse['BTNVirtualAccount']; $registrasi['tagihan'] = $totalHarga;
// $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'){
// DB::rollBack();
// Log::error('---');
// Log::error($multipartData);
// Log::error($arrResponse['BTNresponse']);
// Log::error('---');
if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){ // return redirect()->route('user.create')
DB::rollBack(); // ->with('error', 'Data failed to save');
Log::error('---'); // }
Log::error($multipartData);
Log::error($arrResponse['BTNresponse']);
Log::error('---');
return redirect()->route('user.create')
->with('error', 'Data failed to save');
}
DB::commit(); DB::commit();
...@@ -320,9 +333,11 @@ public function store(Request $request) { ...@@ -320,9 +333,11 @@ public function store(Request $request) {
'konaspi' => $konv, 'konaspi' => $konv,
'hargaKonferensi' => $kegPeserta, 'hargaKonferensi' => $kegPeserta,
'totalHarga' => $totalHarga, 'totalHarga' => $totalHarga,
'jumlah_peserta' => $jumlahPeserta,
'kegiatanpeserta' => $kegiatanpeserta
]; ];
SendMail::dispatch($data, 'email.invoice', $data['registrasi']->email, 'registrasi', 'email_regis_sent_at'); SendMail::dispatch($data, 'email.invoice', $data['registrasi']['email'], 'registrasi', 'email_regis_sent_at');
return view('invoice', $data)->with('success', 'Data saved successfully'); return view('invoice', $data)->with('success', 'Data saved successfully');
...@@ -338,26 +353,27 @@ public function store(Request $request) { ...@@ -338,26 +353,27 @@ public function store(Request $request) {
} }
} }
private function generateVa($multipartData) // ditutup sementara
{ // private function generateVa($multipartData)
$client = new Client(); // {
$options = [ // $client = new Client();
'form_params' => [ // $options = [
// 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O', // 'form_params' => [
'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/', // // 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
'noid' => $multipartData['noid'], // 'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/',
'nama' => $multipartData['nama'], // 'noid' => $multipartData['noid'],
'tagihan' => $multipartData['tagihan'], // 'nama' => $multipartData['nama'],
'flag' => 'F', // 'tagihan' => $multipartData['tagihan'],
'expired_date' => '2024-08-01T23:59:59+07:00', // 'flag' => 'F',
'deskripsi' => 'pembayaran konaspi' // 'expired_date' => '2024-08-01T23:59:59+07:00',
] // '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();
......
...@@ -81,18 +81,21 @@ ...@@ -81,18 +81,21 @@
Convention Convention
</td> </td>
<td class="text-center">Rp {{$konaspi['harga']}}</td> <td class="text-center">Rp {{$konaspi['harga']}}</td>
<td class="text-center">1</td> <td class="text-center">{{ $jumlah_peserta }}</td>
<td class="text-right">Rp {{$konaspi['harga']}}</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> <tr>
<td>{{$no}}</td> <td>{{$no}}</td>
<td> <td>
{{$kon['namakeg']}} <br> Konferensi : <b> {{$kon['namakon']}} </b> {{$kon['nama_kegiatan']}} <br> Konferensi : <b> {{$kon['nama_konferensi']}} </b>
@isset($kon['anggota']['nama'])
<br>Anggota : <b>{{ $kon['anggota']['nama'] }}</b>
@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>
...@@ -129,13 +132,13 @@ ...@@ -129,13 +132,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>
......
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