diff --git a/app/Exports/JenisLaporanExport.php b/app/Exports/JenisLaporanExport.php new file mode 100644 index 0000000..c647ee6 --- /dev/null +++ b/app/Exports/JenisLaporanExport.php @@ -0,0 +1,46 @@ +id, + $row->code, + $row->name, + $row->created_at + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Code', + 'Name', + 'Created At' + ]; + } + + public function columnFormats(): array + { + return [ + 'A' => NumberFormat::FORMAT_NUMBER, + 'D' => NumberFormat::FORMAT_DATE_DATETIME + ]; + } +} diff --git a/app/Http/Controllers/JenisLaporanController.php b/app/Http/Controllers/JenisLaporanController.php new file mode 100644 index 0000000..ed93164 --- /dev/null +++ b/app/Http/Controllers/JenisLaporanController.php @@ -0,0 +1,174 @@ +validated(); + + if ($validate) { + try { + JenisLaporan::create($validate); + return redirect() + ->route('basicdata.jenis_laporan.index') + ->with('success', 'Jenis Laporan created successfully'); + } catch (Throwable $e) { + return redirect() + ->route('basicdata.jenis_laporan.create') + ->with('success', 'Failed to create Jenis Laporan: ' . $e); + } + } + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // return view('lpj::show'); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $jenisLaporan = JenisLaporan::find($id); + return view('lpj::jenis_laporan.create', compact('jenisLaporan')); + } + + /** + * Update the specified resource in storage. + */ + public function update(JenisLaporanRequest $request, $id) + { + $validate = $request->validated(); + + if ($validate) { + try { + $jenisLaporan = JenisLaporan::find($id); + $jenisLaporan->update($validate); + return redirect() + ->route('basicdata.jenis_laporan.index') + ->with('success', 'Jenis Laporan updated successfully'); + } catch (Throwable $e) { + return redirect() + ->route('basicdata.jenis_laporan.edit', $id) + ->with('success', 'Failed to update Jenis Laporan: ' . $e); + } + } + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + try { + // Delete from database + $jenisLaporan = JenisLaporan::find($id); + $jenisLaporan->delete(); + + echo json_encode(['success' => true, 'message' => 'Jenis Laporan deleted successfully']); + } catch (Throwable $e) { + echo json_encode(['success' => false, 'message' => 'Failed to delete jenis Laporan']); + } + } + + public function dataForDatatables(Request $request) + { + if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) { + //abort(403, 'Sorry! You are not allowed to view users.'); + } + + // Retrieve data from the database + $query = JenisLaporan::query(); + + // 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('code', 'LIKE', "%$search%"); + $q->orWhere('name', '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->get(); + + // 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 export() + { + return Excel::download(new JenisLaporanExport, 'jenis_laporan.xlsx'); + } +} diff --git a/app/Http/Requests/JenisLaporanRequest.php b/app/Http/Requests/JenisLaporanRequest.php new file mode 100644 index 0000000..76babb0 --- /dev/null +++ b/app/Http/Requests/JenisLaporanRequest.php @@ -0,0 +1,46 @@ + 'required|max:5', + 'name' => 'required|max:255', + ]; + + if ($this->method() == 'PUT') { + $rules['code'] = 'required|max:5|unique:jenis_laporan,code,' . $this->id; + } else { + $rules['code'] = 'required|max:5|unique:jenis_laporan,code'; + } + + return $rules; + } + + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return true; + } + + public function messages(): array + { + return [ + 'code.required' => 'Kode Jenis Laporan Wajib diisi!', + 'code.max' => 'Kode Jenis Laporan maksimum 5 huruf!', + 'code.unique' => 'Kode Jenis Laporan tidak boleh sama!', + 'name.required' => 'Nama Jenis Laporan Wajib diisi!', + 'name.max' => 'Nama Jenis Laporan Wajib diisi!' + ]; + } +} diff --git a/app/Models/JenisLaporan.php b/app/Models/JenisLaporan.php new file mode 100644 index 0000000..13e248e --- /dev/null +++ b/app/Models/JenisLaporan.php @@ -0,0 +1,22 @@ +id(); + $table->string('code'); + $table->string('nama_kjpp_sebelumnya'); + $table->string('biaya_kjpp_sebelumnya'); + $table->datetime('tanggal_penilaian_sebelumnya'); + $table->string('nomor_registrasi'); + $table->foreignId('tujuan_penilaian_kjpp_id')->constrained('tujuan_penilaian_kjpp'); + $table->foreignId('jenis_laporan_id')->constrained('jenis_laporan'); + $table->date('start_date'); + $table->date('end_date'); + $table->text('catatan'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('penawaran'); + } +}; diff --git a/database/migrations/2024_09_26_034446_create_tujuan_penilaian_kjpp_table.php b/database/migrations/2024_09_26_034446_create_tujuan_penilaian_kjpp_table.php new file mode 100644 index 0000000..7f300c6 --- /dev/null +++ b/database/migrations/2024_09_26_034446_create_tujuan_penilaian_kjpp_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('code')->unique()->index(); + $table->string('name'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tujuan_penilaian_kjpp'); + } +}; diff --git a/database/migrations/2024_09_26_041326_create_jenis_laporan_table.php b/database/migrations/2024_09_26_041326_create_jenis_laporan_table.php new file mode 100644 index 0000000..f47da7a --- /dev/null +++ b/database/migrations/2024_09_26_041326_create_jenis_laporan_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('code')->unique()->index(); + $table->string('name'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('jenis_laporan'); + } +}; diff --git a/database/migrations/2024_09_26_043449_create_persetujuan_penawaran_table.php b/database/migrations/2024_09_26_043449_create_persetujuan_penawaran_table.php new file mode 100644 index 0000000..025fb96 --- /dev/null +++ b/database/migrations/2024_09_26_043449_create_persetujuan_penawaran_table.php @@ -0,0 +1,43 @@ +id(); + $table->foreignId('penawaran_id')->constrained('penawaran'); + $table->string('nomor_proposal_penawaran'); + $table->date('tanggal_proposal_penawaran'); + $table->string('biaya_final'); + $table->datetime('sls_resume'); + $table->datetime('sla_final'); + $table->string('catatan'); + $table->string('attachment'); + $table->foreignId('region_id')->constrained('regions'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('persetujuan_penawaran'); + } +}; diff --git a/database/migrations/2024_09_26_043525_create_detail_penawaran_table.php b/database/migrations/2024_09_26_043525_create_detail_penawaran_table.php new file mode 100644 index 0000000..6a185db --- /dev/null +++ b/database/migrations/2024_09_26_043525_create_detail_penawaran_table.php @@ -0,0 +1,39 @@ +id(); + $table->foreignId('kjpp_rekanan_id')->constrained('kjpp'); + $table->foreignId('penawaran_id')->constrained('penawaran'); + $table->string('biaya_penawaran'); + $table->string('attachment'); + $table->string('dokumen_persetujuan'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('detail_penawaran'); + } +}; diff --git a/module.json b/module.json index 9060084..1a3cf44 100644 --- a/module.json +++ b/module.json @@ -156,6 +156,14 @@ "permission": "", "roles": [] }, + { + "title": "Jenis Laporan", + "path": "basicdata.jenis_laporan", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] + }, { "title": "Jenis Dokumen", "path": "basicdata.jenis-dokumen", @@ -235,22 +243,6 @@ "attributes": [], "permission": "", "roles": [] - }, - { - "title": "KJPP", - "path": "basicdata.kjpp", - "classes": "", - "attributes": [], - "permission": "", - "roles": [] - }, - { - "title": "Ijin Usaha", - "path": "basicdata.ijin_usaha", - "classes": "", - "attributes": [], - "permission": "", - "roles": [] } ] } diff --git a/resources/views/jenis_laporan/create.blade.php b/resources/views/jenis_laporan/create.blade.php new file mode 100644 index 0000000..64d0bb4 --- /dev/null +++ b/resources/views/jenis_laporan/create.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render(request()->route()->getName()) }} +@endsection + +@section('content') +
+ @if (isset($jenisLaporan->id)) +
+ + @method('PUT') + @else + + @endif + @csrf +
+
+

+ {{ isset($jenisLaporan->id) ? 'Edit' : 'Tambah' }} Jenis Laporan +

+
+ Back +
+
+
+ @if (isset($jenisLaporan->id)) +
+ +
+ + @error('code') + {{ $message }} + @enderror +
+
+ @else +
+ +
+ + @error('code') + {{ $message }} + @enderror +
+
+ @endif +
+ +
+ + @error('name') + {{ $message }} + @enderror +
+
+
+ +
+
+
+
+
+@endsection diff --git a/resources/views/jenis_laporan/index.blade.php b/resources/views/jenis_laporan/index.blade.php new file mode 100644 index 0000000..fb1f6b8 --- /dev/null +++ b/resources/views/jenis_laporan/index.blade.php @@ -0,0 +1,153 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render('basicdata.jenis_laporan') }} +@endsection + +@section('content') +
+
+
+

+ Daftar Jenis Laporan +

+ +
+
+
+ + + + + + + + + +
+ + + Kode Laporan + + + Jenis Laporan + + Action
+
+ +
+
+
+@endsection + +@push('scripts') + + + +@endpush diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php index cfea1d9..7642794 100644 --- a/routes/breadcrumbs.php +++ b/routes/breadcrumbs.php @@ -52,6 +52,21 @@ Breadcrumbs::for('basicdata.jenis-jaminan.edit', function (BreadcrumbTrail $trai $trail->push('Edit Jenis Aset'); }); +Breadcrumbs::for('basicdata.jenis_laporan', function (BreadcrumbTrail $trail) { + $trail->parent('basicdata'); + $trail->push('Jenis Laporan', route('basicdata.jenis_laporan.index')); +}); + +Breadcrumbs::for('basicdata.jenis_laporan.create', function (BreadcrumbTrail $trail) { + $trail->parent('basicdata.jenis_laporan'); + $trail->push('Tambah Jenis Laporan', route('basicdata.jenis_laporan.create')); +}); + +Breadcrumbs::for('basicdata.jenis_laporan.edit', function (BreadcrumbTrail $trail) { + $trail->parent('basicdata.jenis_laporan'); + $trail->push('Edit Jenis Laporan'); +}); + Breadcrumbs::for('basicdata.tujuan-penilaian', function (BreadcrumbTrail $trail) { $trail->parent('basicdata'); $trail->push('Tujuan Penilaian', route('basicdata.tujuan-penilaian.index')); diff --git a/routes/web.php b/routes/web.php index b6b0a73..7d51643 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,6 +13,7 @@ use Modules\Lpj\Http\Controllers\IjinUsahaController; use Modules\Lpj\Http\Controllers\JenisDokumenController; use Modules\Lpj\Http\Controllers\JenisFasilitasKreditController; use Modules\Lpj\Http\Controllers\JenisJaminanController; +use Modules\Lpj\Http\Controllers\JenisLaporanController; use Modules\Lpj\Http\Controllers\JenisLegalitasJaminanController; use Modules\Lpj\Http\Controllers\JenisPenilaianController; use Modules\Lpj\Http\Controllers\KJPPController; @@ -324,6 +325,17 @@ Route::middleware(['auth'])->group(function () { }); Route::resource('ijin_usaha', IjinUsahaController::class); + // End Activity Ijin Usaha route + + // Start Activity Jenis Laporan route + Route::name('jenis_laporan.')->prefix('jenis_laporan')->group(function () { + Route::get('datatables', [JenisLaporanController::class, 'dataForDatatables']) + ->name('datatables'); + Route::get('export', [JenisLaporanController::class, 'export'])->name('export'); + }); + + Route::resource('jenis_laporan', JenisLaporanController::class); + // End Activity Jenis Laporan route }); Route::name('permohonan.')->prefix('permohonan')->group(function () {