From ebf0a934ea06060566a0f8a1cafe2168f9d7f062 Mon Sep 17 00:00:00 2001 From: Andy Chaerudin Date: Thu, 24 Oct 2024 12:34:00 +0700 Subject: [PATCH] add feature Registrasi Final tanpa SPK permohonan.dokumen --- .../Controllers/RegistrasiFinalController.php | 268 ++++++++++++++++++ module.json | 9 + .../views/registrasifinal/edit.blade.php | 106 +++++++ .../views/registrasifinal/index.blade.php | 158 +++++++++++ .../views/registrasifinal/js/editjs.blade.php | 153 ++++++++++ .../views/registrasifinal/show.blade.php | 242 ++++++++++++++++ routes/breadcrumbs.php | 13 + routes/registrasi.php | 12 + 8 files changed, 961 insertions(+) create mode 100644 app/Http/Controllers/RegistrasiFinalController.php create mode 100644 resources/views/registrasifinal/edit.blade.php create mode 100644 resources/views/registrasifinal/index.blade.php create mode 100644 resources/views/registrasifinal/js/editjs.blade.php create mode 100644 resources/views/registrasifinal/show.blade.php diff --git a/app/Http/Controllers/RegistrasiFinalController.php b/app/Http/Controllers/RegistrasiFinalController.php new file mode 100644 index 0000000..2561079 --- /dev/null +++ b/app/Http/Controllers/RegistrasiFinalController.php @@ -0,0 +1,268 @@ +user) || !$this->user->can('debitur.view')) { + //abort(403, 'Sorry! You are not allowed to view users.'); + } + + // Retrieve data from the database + $query =PenawaranTender::query() + ->select('penawaran.*', 'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name') + ->leftJoin('tujuan_penilaian_kjpp', 'tujuan_penilaian_kjpp.id','=','penawaran.tujuan_penilaian_kjpp_id') + ->where('penawaran.status','=','spk') + ->withCount('penawarandetails'); + + // Apply search filter if provided + if ($request->has('search') && !empty($request->get('search'))) { + $search = $request->get('search'); + $query->where(function ($q) use ($search) { + $q->where('nomor_registrasi', 'LIKE', '%' . $search . '%'); + $q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%'); + + $q->orWhere('status', 'LIKE', '%' . $search . '%'); + }); + } + + // Apply sorting if provided + if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) { + $order = $request->get('sortOrder'); + $column = $request->get('sortField'); + $query->orderBy($column, $order); + } + + // Get the total count of records + $totalRecords = $query->count(); + + // Apply pagination if provided + if ($request->has('page') && $request->has('size')) { + $page = $request->get('page'); + $size = $request->get('size'); + $offset = ($page - 1) * $size; // Calculate the offset + + $query->skip($offset)->take($size); + } + + // Get the filtered count of records + $filteredRecords = $query->count(); + + // Get the data for the current page + //$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get(); + $data = $query->get(); + // dd($data); + $i=0; + foreach($data as $obj) + { + if($obj->tanggal_penilaian_sebelumnya) + { + $data[$i]->tanggal_penilaian_sebelumnya = Carbon::parse($obj->tanggal_penilaian_sebelumnya)->format('d F Y H:i:s'); + } + + if($obj->biaya_kjpp_sebelumnya) + { + $data[$i]->biaya_kjpp_sebelumnya = formatRupiah($obj->biaya_kjpp_sebelumnya); + + } + + // date_range + if($obj->start_date && $obj->end_date) + { + $data[$i]->date_range = Carbon::parse($obj->start_date)->format('d M Y').' - '.Carbon::parse($obj->end_date)->format('d M Y'); + + } + + $i++; + } + + + // Calculate the page count + $pageCount = ceil($totalRecords / $request->get('size')); + + // Calculate the current page number + $currentPage = 0 + 1; + + // Return the response data as a JSON object + return response()->json([ + 'draw' => $request->get('draw'), + 'recordsTotal' => $totalRecords, + 'recordsFiltered' => $filteredRecords, + 'pageCount' => $pageCount, + 'page' => $currentPage, + 'totalCount' => $totalRecords, + 'data' => $data + ]); + } + + public function show($id) + { + $permohonan = Permohonan::find($id); + return view('lpj::registrasifinal.show', compact('id','permohonan')); + } + + public function edit($id) + { + return view('lpj::registrasifinal.edit', compact('id')); + } + + public function setData(Request $request): JsonResponse + { + $data = array(); + $datas = array(); + + if (request()->ajax()) { + $id = $request->id; + $datas = Permohonan::find($id); + + if ($datas) { + $penawaran=null; + $regions=null; + $regions=Regions::pluck('name', 'id'); + $penawaran = PenawaranTender::where('nomor_registrasi','=',$datas->nomor_registrasi)->first(); + + $penawaranString = ""; + if($penawaran->status) + { + $penawaranString = convertSlug($penawaran->status); + $penawaran->status = $penawaranString; + } + + $data['status'] = 'success'; + $data['regions'] = $regions; + $data['penawaran'] = $penawaran; + $data['datas'] = $datas; + $data['message']['message_success'] = array("data successfully found"); + } else { + $data['status'] = 'error'; + $data['datas'] = null; + $data['message']['message_data'] = array("data not found"); + } + } else { + $data['status'] = 'error'; + $data['message']['message_ajax'] = array("no ajax request"); + } + + return response()->json($data); + } + + public function update(Request $request, $id): JsonResponse + { + // init + $data = array(); + $dataPermohonan = array(); + $dataPenawaran = array(); + + if (request()->ajax()) { + $validator = RegistrasiFinalController::rulesEditnya($request, $id); + + if ($validator['fails']) { + $data['message'] = $validator['errors']; + $data['status'] = 'error'; + } + else + { + DB::beginTransaction(); + try { + + // update table permohonan => status (registrasi-final), region_id, keterangan, authorized_at, authorized_status, authorized_by + // update table penawaran => status (registrasi-final) + $dataPermohonan = [ + 'status' => 'registrasi-final', + 'region_id' => $request->region, + 'keterangan' => $request->catatan, + 'authorized_at' => now(), + 'authorized_status' =>1, + 'authorized_by' => Auth::id() + ]; + + $dataPenawaran = ['status' => 'registrasi-final']; + + + $permohonan = Permohonan::find($id); + $penawaran = PenawaranTender::where('nomor_registrasi','=',$permohonan->nomor_registrasi)->first(); + + $permohonan->update($dataPermohonan); + $penawaran->update($dataPenawaran); + // + DB::commit(); + + $data['status'] = 'success'; + $data['message']['message_success'] = array('Regitrasi Final '.$permohonan->nomor_registrasi.' successfully'); + } catch (Exception $e) { + DB::rollBack(); + $data['status'] = 'error'; + $data['message']['message_try_catch'] = array('Regitrasi Final '.$permohonan->nomor_registrasi.' failed.'); + } + } + + } else { + $data['status'] = 'error'; + $data['message']['message_ajax'] = array("no ajax request"); + } + + return response()->json($data); + + } + + public function rulesEditnya($request, $id) + { + $validate_catatan=''; + + $validateIt = [ + // 'name' diambil dari definisi parameter yang di kirim pada POST Data + 'region' => 'required', + 'catatan' => 'required', + ]; + + $messageIt = [ + 'region.required' => 'Silahkan pilih Region', + 'catatan.required' => 'Silahkan isi Catatan' + ]; + + $validator = Validator::make($request->all(), $validateIt, $messageIt); + + $data['fails'] = $validator->fails(); + $data['errors'] = $validator->errors(); + + return $data; + } + + } diff --git a/module.json b/module.json index 5e17b0d..6ab8ec6 100644 --- a/module.json +++ b/module.json @@ -91,6 +91,15 @@ } ] }, + { + "title": "Registrasi Final", + "path": "registrasifinal", + "icon": "ki-filled ki-file-added text-lg", + "classes": "", + "attributes": [], + "permission": "", + "roles": ["administrator", "admin"] + }, { "title": "Pembatalan", "path": "", diff --git a/resources/views/registrasifinal/edit.blade.php b/resources/views/registrasifinal/edit.blade.php new file mode 100644 index 0000000..ddaead8 --- /dev/null +++ b/resources/views/registrasifinal/edit.blade.php @@ -0,0 +1,106 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render(request()->route()->getName()) }} +@endsection +@php + // $route = Route::currentRouteName(); + // dd($route); + $route = explode('.', Route::currentRouteName()); +@endphp + +@section('content') +
+ +
+ + @method('PUT') + @csrf +
+
+

+ Tambah Registrasi Final +

+ +
+
+
+

+ Nomor Register Permohonan: +

+ + + +
+ +
+

+ Kode Penawaran: +

+ + + +
+ +
+

+ Status Penawaran: +

+ + + +
+ +
+
+ +
+ + +
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
+@endsection +@include('lpj::registrasifinal.js.editjs') diff --git a/resources/views/registrasifinal/index.blade.php b/resources/views/registrasifinal/index.blade.php new file mode 100644 index 0000000..4e50882 --- /dev/null +++ b/resources/views/registrasifinal/index.blade.php @@ -0,0 +1,158 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render('registrasifinal') }} +@endsection + +@section('content') +
+
+
+

+ Daftar Registrasi Final +

+
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + +
+ + + Nomor Registrasi + + + Kode Penawaran + + + Tanggal Penawaran + + + Tujuan Penilaian + + + KJPP Data + + + Status + + Action
+
+ +
+
+
+@endsection + +@push('scripts') + + +@endpush + diff --git a/resources/views/registrasifinal/js/editjs.blade.php b/resources/views/registrasifinal/js/editjs.blade.php new file mode 100644 index 0000000..9464649 --- /dev/null +++ b/resources/views/registrasifinal/js/editjs.blade.php @@ -0,0 +1,153 @@ +@push('scripts') + @include('lpj::assetsku.includenya') + +@endpush diff --git a/resources/views/registrasifinal/show.blade.php b/resources/views/registrasifinal/show.blade.php new file mode 100644 index 0000000..040d1e4 --- /dev/null +++ b/resources/views/registrasifinal/show.blade.php @@ -0,0 +1,242 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render(request()->route()->getName()) }} +@endsection +@php + // $route = Route::currentRouteName(); + // dd($route); registrasi.show + $route = explode('.', Route::currentRouteName()); +@endphp +@section('content') +
+
+
+

+ Data Permohonan +

+ + +
+
+
+

+ Nomor Register Permohonan: +

+ + {{ $permohonan->nomor_registrasi }} + +
+ +
+

+ Pemohon: +

+ + {{ $permohonan->user->nik }} | {{ $permohonan->user->name }} | {{ $permohonan->user->branch->name }} + +
+ +
+

+ Tujan Permohonan: +

+ + {{ $permohonan->tujuanPenilaian->name }} + +
+ +
+
+ +
+
+

+ Detail Debutur +

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ Name + + {{ $permohonan->debiture->name ?? "" }} +
+ Email + + {{ $permohonan->debiture->email ?? "" }} +
+ Phone + + {{ $permohonan->debiture->phone ?? "" }} +
+ Address + + {{ $permohonan->debiture->address ?? "" }} +
+   + + {{ $permohonan->debiture->village->name ?? "" }}, {{ $permohonan->debiture->district->name ?? "" }}, {{ $permohonan->debiture->city->name ?? "" }}, {{ $permohonan->debiture->province->name ?? "" }} - {{ $permohonan->debiture->village->postal_code ?? "" }} +
+
+
+ + + + + + + + + + + + + + + + + +
+ Cabang + + {{ $permohonan->debiture->branch->name ?? "" }} +
+ CIF + + {{ $permohonan->debiture->cif ?? "" }} +
+ Nomor Rekening + + {{ $permohonan->debiture->nomor_rekening ?? "" }} +
+ NPWP + + {{ $permohonan->debiture->npwp ?? "" }} +
+
+
+
+
+ +
+
+

+ Data Jaminan +

+
+
+ @foreach($permohonan->debiture->documents as $dokumen) +
+ + +
+ @endforeach +
+
+
+ +@endsection diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php index 562b021..39a97be 100644 --- a/routes/breadcrumbs.php +++ b/routes/breadcrumbs.php @@ -515,6 +515,19 @@ Breadcrumbs::for('otorisasitender.penawaran.show', function (BreadcrumbTrail $tr $trail->push('Detail Data Otorisasi Penawaran'); }); // andy add Otorisasi Tender +// andy add registrasi final +Breadcrumbs::for('registrasifinal', function (BreadcrumbTrail $trail) { + $trail->push('Registrasi Final', route('registrasifinal.index')); +}); +Breadcrumbs::for('registrasifinal.show', function (BreadcrumbTrail $trail) { + $trail->parent('registrasifinal'); + $trail->push('Detail Registrasi Final'); +}); +Breadcrumbs::for('registrasifinal.edit', function (BreadcrumbTrail $trail) { + $trail->parent('registrasifinal'); + $trail->push('Tambah registrasifinal'); +}); +// andy add registrasi final Breadcrumbs::for('otorisator.pelaporan.index', function (BreadcrumbTrail $trail) { diff --git a/routes/registrasi.php b/routes/registrasi.php index b205ce1..f8b3893 100644 --- a/routes/registrasi.php +++ b/routes/registrasi.php @@ -4,6 +4,7 @@ use Modules\Lpj\Http\Controllers\RegistrasiController; use Modules\Lpj\Http\Controllers\ProsesPenawaranController; use Modules\Lpj\Http\Controllers\ProsesPenawaranUlangController; use Modules\Lpj\Http\Controllers\OtorisasiPenawaranController; +use Modules\Lpj\Http\Controllers\RegistrasiFinalController; Route::middleware(['auth'])->group(function () { @@ -83,5 +84,16 @@ Route::middleware(['auth'])->group(function () { }); }); + + Route::controller(RegistrasiFinalController::class)->group(function(){ + Route::get('/registrasifinal', 'index')->name('registrasifinal.index'); + Route::get('/registrasifinal/datatables', 'dataForDatatables')->name('registrasifinal.datatables'); + Route::get('/registrasifinal/{registrasifinal}', 'show')->name('registrasifinal.show'); + + Route::post('registrasifinal/setData', 'setData')->name('registrasifinal.setData'); + + Route::get('/registrasifinal/{registrasifinal}/edit', 'edit')->name('registrasifinal.edit'); + Route::put('/registrasifinal/{registrasifinal}', 'update')->name('registrasifinal.update'); + }); });