Commit 8262df37 by Triyah Fatmawati

Store Registrasi Kelompok

parent 8c72dafd
......@@ -132,6 +132,8 @@ public function preview(Request $request){
if(!is_null($request->data_registrasi)){
$registrasi = json_decode(decrypt($request->data_registrasi), true);
$registrasi['kode_registrasi'] = $kode_registrasi;
$registrasi['urutan'] = $urutan;
}
else{
$registrasi = [
......@@ -215,7 +217,7 @@ public function preview(Request $request){
catch(Exception $e){
Log::error($e);
DB::rollBack();
dd($e);
return redirect()->back()
->with('error', 'Data failed to save');
}
......@@ -223,7 +225,7 @@ public function preview(Request $request){
public function store(Request $request) {
DB::beginTransaction();
// dd($request);
try{
$registrasi = json_decode($request->registrasi, true);
$kegiatanpeserta = json_decode($request->kegiatanpeserta, true);
......@@ -232,22 +234,30 @@ public function store(Request $request) {
$anggota = json_decode($request->anggota, true);
$tglRegistrasi = $request->tglRegistrasi;
// $totalHargas = $request->totalHarga;
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
$jumlahKeg = count($kegiatanpeserta);
//anggota
foreach($anggota as $key => $item){
$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);
// $registrasi = Registrasi::query()->create($registrasi);
// $id_registrasi = $registrasi->id;
$id_registrasi = '$registrasi->id';
$jumlahKeg = count($kegiatanpeserta);
// dd($anggota, $kegiatanpeserta);
Anggota::query()->insert($anggota);
//inisial harga
$konvensi = Kegiatan::find($konaspi['id']);
$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){
// dd($kegiatanpeserta, $keg, $jumlahPeserta);
$arrayKeg = $keg;
if(isset($arrayKeg['anggota']['key'])){
......@@ -262,10 +272,10 @@ public function store(Request $request) {
'id_kegiatan' => $keg['id_kegiatan'],
'id_konferensi' => $keg['id_konferensi'],
'id_anggota' => $idPeserta
// 'id_anggota' =>
];
dd($kegpeserta);
// KegiatanPeserta::query()->create($kegpeserta);
// dd($kegpeserta, $kegiatanpeserta);
KegiatanPeserta::query()->create($kegpeserta);
// dd($kegpeserta, $kegiatanpeserta);
if($keg['id_kegiatan'] != '498633a9-082c-4a4a-9dbd-e20b678ec15e'){
$konferensi = Konferensi::query()->where('id', $keg['id_konferensi'])->first();
......@@ -278,39 +288,42 @@ public function store(Request $request) {
'hargakon' => $konferensi->harga,
'namakeg' => $kegkonaspi->nama
];
// dd($kegPeserta);
}
else{
$kegPeserta = null;
}
}
dd('');
// dd($kegPeserta);
$multipartData = [
'noid' => $registrasi['kode_registrasi'],
'nama' => $registrasi['nama'],
'tagihan' => $totalHarga
];
// dd($kegPeserta, $multipartData);
$registrasi->save();
$generatedVa = $this->generateVa($multipartData);
$arrResponse = json_decode($generatedVa, true);
$registrasi->status_va = $arrResponse['BTNresponse'];
$registrasi->tagihan = $totalHarga;
$registrasi->nomor_va = $arrResponse['BTNVirtualAccount'];
// ditutup sementara
// $generatedVa = $this->generateVa($multipartData);
// $arrResponse = json_decode($generatedVa, true);
// $registrasi['status_va'] = $arrResponse['BTNresponse'];
$registrasi['status_va'] = 'status_vA';
$registrasi['tagihan'] = $totalHarga;
// $registrasi['nomor_va'] = $arrResponse['BTNVirtualAccount'];
$registrasi['nomor_va'] = $registrasi['kode_registrasi'];
$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'){
DB::rollBack();
Log::error('---');
Log::error($multipartData);
Log::error($arrResponse['BTNresponse']);
Log::error('---');
return redirect()->route('user.create')
->with('error', 'Data failed to save');
}
// return redirect()->route('user.create')
// ->with('error', 'Data failed to save');
// }
DB::commit();
......@@ -320,9 +333,11 @@ public function store(Request $request) {
'konaspi' => $konv,
'hargaKonferensi' => $kegPeserta,
'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');
......@@ -337,27 +352,28 @@ public function store(Request $request) {
->with('error', 'Data failed to save');
}
}
private function generateVa($multipartData)
{
$client = new Client();
$options = [
'form_params' => [
// 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/',
'noid' => $multipartData['noid'],
'nama' => $multipartData['nama'],
'tagihan' => $multipartData['tagihan'],
'flag' => 'F',
'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);
return $response->getBody()->getContents();
}
// ditutup sementara
// private function generateVa($multipartData)
// {
// $client = new Client();
// $options = [
// 'form_params' => [
// // 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
// 'credential' => '$1$OkLGZt6i$FzuqzUwZ8nNS/xbzyPN/R/',
// 'noid' => $multipartData['noid'],
// 'nama' => $multipartData['nama'],
// 'tagihan' => $multipartData['tagihan'],
// 'flag' => 'F',
// '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);
// return $response->getBody()->getContents();
// }
private function getDataUniv(){
$client = new Client();
......
......@@ -81,18 +81,21 @@
Convention
</td>
<td class="text-center">Rp {{$konaspi['harga']}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$konaspi['harga']}}</td>
<td class="text-center">{{ $jumlah_peserta }}</td>
<td class="text-right">Rp {{ $totalHarga }}</td>
</tr>
@if (isset($hargaKonferensi))
@foreach ($hargaKonferensi as $kon)
@php
@if (isset($kegiatanpeserta))
@foreach ($kegiatanpeserta as $kon)
{{-- @php
$subtotal = $subtotal + $kon['hargakon'];
@endphp
@endphp --}}
<tr>
<td>{{$no}}</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 class="text-center">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-center">-</td>
......@@ -129,13 +132,13 @@
<div class="invoice-detail-item">
<div class="invoice-detail-name">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>
<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 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>
......
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