Commit 6e8849e4 by Triyah Fatmawati

Add registrasi kelompok

parent 8262df37
......@@ -19,6 +19,7 @@
use Illuminate\Support\Facades\Log;
use RealRashid\SweetAlert\Facades\Alert;
use Str;
use function PHPUnit\Framework\isEmpty;
class RegistrasiController extends Controller
{
......@@ -79,7 +80,7 @@ public function group_kegiatan(Request $request){
'instansi' => 'required|string',
'jabatan' => 'required|string',
'alamat' => 'required|string',
'kodepos' => 'required|string',
'kode_pos' => 'required|string',
'kota' => 'required|string',
'nik' => 'required|unique:registrasi,nik'
];
......@@ -109,7 +110,7 @@ public function preview(Request $request){
'instansi' => 'required|string',
'jabatan' => 'required|string',
'alamat' => 'required|string',
'kodepos' => 'required|string',
'kode_pos' => 'required|string',
'kota' => 'required|string',
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
......@@ -194,10 +195,12 @@ public function preview(Request $request){
}
}
else{
$kegiatan = Kegiatan::select('id', 'nama', 'harga')->where('id', $request->kegiatan[0])->first();
$hargaKonferensi = null;
$kegiatanpeserta[] = [
'id_kegiatan' => $request->kegiatan0[0],
'id_kegiatan' => $request->kegiatan[0],
'id_konferensi' => null,
'nama_kegiatan' => $kegiatan->nama
];
}
......@@ -209,6 +212,7 @@ public function preview(Request $request){
'hargaKonferensi' => $hargaKonferensi,
'totalHarga' => $totalHarga,
'anggota' => $request->anggota ?? [],
'kegiatan_anggota' => $request->kegiatan_anggota
];
return view('preview', $data)->with('success', 'Data saved successfully');
......@@ -225,7 +229,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);
......@@ -234,7 +238,7 @@ public function store(Request $request) {
$anggota = json_decode($request->anggota, true);
$tglRegistrasi = $request->tglRegistrasi;
// $totalHargas = $request->totalHarga;
$kegiatan_anggota = json_decode($request->kegiatan_anggota);
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
$jumlahKeg = count($kegiatanpeserta);
......@@ -246,18 +250,42 @@ public function store(Request $request) {
$anggota[$key]['created_at'] = Carbon::now()->toDateTimeString();
$anggota[$key]['updated_at'] = Carbon::now()->toDateTimeString();
}
// dd($anggota, $kegiatanpeserta);
Anggota::query()->insert($anggota);
//inisial harga
$konvensi = Kegiatan::find($konaspi['id']);
$konv = $konvensi->toArray();
$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){
// dd($kegiatanpeserta, $keg, $jumlahPeserta);
$arrayKeg = $keg;
if(isset($arrayKeg['anggota']['key'])){
......@@ -273,9 +301,8 @@ public function store(Request $request) {
'id_konferensi' => $keg['id_konferensi'],
'id_anggota' => $idPeserta
];
// 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();
......@@ -288,42 +315,38 @@ public function store(Request $request) {
'hargakon' => $konferensi->harga,
'namakeg' => $kegkonaspi->nama
];
// dd($kegPeserta);
}
else{
$kegPeserta = null;
}
}
// dd($kegPeserta);
$multipartData = [
'noid' => $registrasi['kode_registrasi'],
'nama' => $registrasi['nama'],
'tagihan' => $totalHarga
];
// dd($kegPeserta, $multipartData);
$registrasi->save();
// ditutup sementara
// $generatedVa = $this->generateVa($multipartData);
// $arrResponse = json_decode($generatedVa, true);
// $registrasi['status_va'] = $arrResponse['BTNresponse'];
$registrasi['status_va'] = 'status_vA';
$generatedVa = $this->generateVa($multipartData);
$arrResponse = json_decode($generatedVa, true);
$registrasi['status_va'] = $arrResponse['BTNresponse'];
$registrasi['tagihan'] = $totalHarga;
// $registrasi['nomor_va'] = $arrResponse['BTNVirtualAccount'];
$registrasi['nomor_va'] = $registrasi['kode_registrasi'];
$registrasi['nomor_va'] = $arrResponse['BTNVirtualAccount'];
$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();
......@@ -346,34 +369,31 @@ public function store(Request $request) {
Log::error($e);
DB::rollBack();
dd($e);
return redirect()->route('user.create')
->with('error', 'Data failed to save');
}
}
// 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 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();
......
......@@ -71,25 +71,30 @@
Convention
</td>
<td class="text-center">Rp {{$konaspi['harga']??'param'}}</td>
<td class="text-center">1</td>
<td class="text-right">Rp {{$konaspi['harga']??'param'}}</td>
<td class="text-center">{{ ($jumlah_peserta != 0) ? $jumlah_peserta : 1 }}</td>
<td class="text-right">Rp {{ $totalHarga }}</td>
</tr>
@if (isset($hargaKonferensi))
@foreach ($hargaKonferensi as $kon)
@if (isset($kegiatanpeserta))
@foreach ($kegiatanpeserta as $kon)
@php
$subtotal = $subtotal + $kon['hargakon'];
// $subtotal = $subtotal + $kon['hargakon'];
@endphp
<tr>
<td>{{$no}}</td>
<td>
{{$kon['namakeg']}} <br> Konferensi : <b> {{$kon['namakon']??'param'}} </b>
</td>
{{-- <td class="text-center">Rp {{$kon['hargakon']??'param'}}</td> --}}
<td class="text-center">-</td>
<td class="text-center">1</td>
{{-- <td class="text-right">Rp {{$kon['hargakon']??'param'}}</td> --}}
<td class="text-right">-</td>
</tr>
@if ($kon['id_konferensi'])
<tr>
<td>{{$no}}</td>
<td>
{{$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>
<td class="text-center">1</td>
{{-- <td class="text-right">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-right">-</td>
</tr>
@endif
@php
$i++;
$no++;
......@@ -118,13 +123,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>
......
......@@ -109,11 +109,11 @@
<label id="login-error" class="error" for="alamat" style="color: red">{{$errors->first('alamat')}}</label>
@endif
</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>
<input type="number" id="kodepos" name="kodepos" class="form-control number" required="true" placeholder="" value="{{ old('kodepos')}}">
@if ($errors->has('kodepos'))
<label id="login-error" class="error" for="kodepos" style="color: red">{{$errors->first('kodepos')}}</label>
<input type="number" id="kode_pos" name="kode_pos" class="form-control number" required="true" placeholder="" value="{{ old('kode_pos')}}">
@if ($errors->has('kode_pos'))
<label id="login-error" class="error" for="kode_pos" style="color: red">{{$errors->first('kode_pos')}}</label>
@endif
{{-- <div class="invalid-feedback">Isikan Kode Pos yg sesuai</div> --}}
</div>
......
......@@ -81,7 +81,7 @@
Convention
</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>
</tr>
@if (isset($kegiatanpeserta))
......@@ -89,20 +89,22 @@
{{-- @php
$subtotal = $subtotal + $kon['hargakon'];
@endphp --}}
<tr>
<td>{{$no}}</td>
<td>
{{$kon['nama_kegiatan']}} <br> Konferensi : <b> {{$kon['nama_konferensi']}} </b>
@isset($kon['anggota']['nama'])
@if ($kon['id_konferensi'])
<tr>
<td>{{$no}}</td>
<td>
{{$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>
<td class="text-center">1</td>
{{-- <td class="text-right">Rp {{$kon['hargakon']}}</td> --}}
<td class="text-right">-</td>
</tr>
@endisset
</td>
{{-- <td class="text-center">Rp {{$kon['hargakon']}}</td> --}}
<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
$i++;
$no++;
......@@ -160,7 +162,7 @@
<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> --}}
{{-- <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>
......
......@@ -154,7 +154,8 @@
<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) }}">
<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 class="btn btn-danger btn-icon icon-left"><i class="fas fa-times"></i> Cancel</button>
</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