Tambah fitur pembatalan permohonan
- Menambahkan model, migration, dan relasi untuk tabel pembatalan permohonan. - Mengubah fungsi delete menjadi pembatalan permohonan dengan konfirmasi pengguna. - Menambahkan route baru untuk form dan proses pembatalan permohonan. - Menyediakan form input alasan dan file pendukung untuk pembatalan permohonan. - Memperbarui tampilan, fungsi controller, dan breadcrumbs terkait pembatalan permohonan.
This commit is contained in:
@@ -353,4 +353,38 @@
|
|||||||
// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan'));
|
// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan'));
|
||||||
// return $pdf->stream();
|
// return $pdf->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showPembatalan($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::with(['pembatalan','debiture'])->findOrFail($id);
|
||||||
|
return view('lpj::permohonan.pembatalan-form', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function pembatalan(Request $request)
|
||||||
|
{
|
||||||
|
// Validate the request
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'alasan_pembatalan' => 'required|string',
|
||||||
|
'file_pembatalan' => 'required|file|mimes:pdf,doc,docx|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle file upload
|
||||||
|
if ($request->hasFile('file_pembatalan')) {
|
||||||
|
$file = $request->file('file_pembatalan');
|
||||||
|
$filename = time() . '_' . $file->getClientOriginalName();
|
||||||
|
$filePath = $file->storeAs('pembatalan', $filename, 'public');
|
||||||
|
$validatedData['file_pembatalan'] = $filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add created_by
|
||||||
|
$validatedData['created_by'] = auth()->id();
|
||||||
|
|
||||||
|
// Create new PermohonanPembatalan
|
||||||
|
$pembatalan = PermohonanPembatalan::create($validatedData);
|
||||||
|
|
||||||
|
return redirect()->route('permohonan.index')->with('success', 'Pembatalan Permohonan Menunggu Approval');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,4 +159,8 @@
|
|||||||
{
|
{
|
||||||
return $this->hasMany(DokumenJaminan::class);
|
return $this->hasMany(DokumenJaminan::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pembatalan(){
|
||||||
|
return $this->hasMany(PermohonanPembatalan::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
app/Models/PermohonanPembatalan.php
Normal file
50
app/Models/PermohonanPembatalan.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
|
class PermohonanPembatalan extends Base
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $table = 'permohonan_pembatalan';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'permohonan_id',
|
||||||
|
'alasan_pembatalan',
|
||||||
|
'file_pembatalan',
|
||||||
|
'status',
|
||||||
|
'keterangan',
|
||||||
|
'authorized_at',
|
||||||
|
'authorized_status',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
'authorized_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $dates = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'authorized_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'authorized_status' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Relationship with Permohonan
|
||||||
|
public function permohonan()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Permohonan::class, 'permohonan_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function creator(){
|
||||||
|
return $this->belongsTo(User::class, 'created_by');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePermohonanPembatalansTable extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('permohonan_pembatalan', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('permohonan_id');
|
||||||
|
$table->text('alasan_pembatalan');
|
||||||
|
$table->string('file_pembatalan');
|
||||||
|
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
|
||||||
|
$table->text('keterangan')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->timestamp('authorized_at')->nullable();
|
||||||
|
$table->char('authorized_status', 1)->nullable();
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->unsignedBigInteger('created_by')->nullable();
|
||||||
|
$table->unsignedBigInteger('updated_by')->nullable();
|
||||||
|
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||||
|
$table->unsignedBigInteger('authorized_by')->nullable();
|
||||||
|
|
||||||
|
$table->foreign('permohonan_id')->references('id')->on('permohonan')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('permohonan_pembatalan');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,15 +91,15 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function deleteData(data) {
|
function deleteData(data, noReg, debitur) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Pembatalan Permohonan',
|
||||||
text: "You won't be able to revert this!",
|
text: "Yakin akan membatalkan permohonan dengan nomor " + noReg + " untuk Debitur " + debitur + "?",
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#3085d6',
|
confirmButtonColor: '#3085d6',
|
||||||
cancelButtonColor: '#d33',
|
cancelButtonColor: '#d33',
|
||||||
confirmButtonText: 'Yes, delete it!'
|
confirmButtonText: 'Yes!'
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
@@ -108,16 +108,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax(`permohonan/${data}`, {
|
window.location = `permohonan/${data}/pembatalan`;
|
||||||
type: 'DELETE'
|
|
||||||
}).then((response) => {
|
|
||||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
}).catch((error) => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -225,11 +216,14 @@
|
|||||||
actionHtml += `
|
actionHtml += `
|
||||||
<a class="btn btn-sm btn-outline btn-info" href="permohonan/${data.id}/edit" title="Edit Permohonan">
|
<a class="btn btn-sm btn-outline btn-info" href="permohonan/${data.id}/edit" title="Edit Permohonan">
|
||||||
<i class="ki-outline ki-notepad-edit"></i>
|
<i class="ki-outline ki-notepad-edit"></i>
|
||||||
</a>
|
</a>`;
|
||||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-outline btn-danger" title="Hapus Permohonan">
|
if(data.status !== 'batal') {
|
||||||
<i class="ki-outline ki-trash"></i>
|
actionHtml += `
|
||||||
</a>
|
<a onclick="deleteData(${data.id}, '${data.nomor_registrasi}','${data.debiture.name}')" class="delete btn btn-sm btn-outline btn-danger" title="Batalkan Permohonan">
|
||||||
</div>`;
|
<i class="ki-outline ki-cross-square"></i>
|
||||||
|
</a>`;
|
||||||
|
}
|
||||||
|
actionHtml += `</div>`;
|
||||||
|
|
||||||
return actionHtml;
|
return actionHtml;
|
||||||
},
|
},
|
||||||
|
|||||||
73
resources/views/permohonan/pembatalan-form.blade.php
Normal file
73
resources/views/permohonan/pembatalan-form.blade.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
@extends('layouts.main')
|
||||||
|
|
||||||
|
@section('breadcrumbs')
|
||||||
|
{{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||||
|
<div class="card pb-2.5">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">Form Pembatalan Permohonan</h3>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<a href="{{ route('permohonan.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="{{ route('permohonan.pembatalan', $permohonan) }}" method="POST" class="grid gap-5" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
|
<label class="form-label max-w-56">
|
||||||
|
Nomor Registrasi
|
||||||
|
</label>
|
||||||
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
|
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||||
|
<input type="text" class="input" value="{{ $permohonan->nomor_registrasi ?? '' }}" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
|
<label class="form-label max-w-56">
|
||||||
|
Nama Debitur
|
||||||
|
</label>
|
||||||
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
|
<input type="text" class="input" value="{{ $permohonan->debiture->name ?? '' }}" readonly>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
|
<label class="form-label max-w-56">
|
||||||
|
Alasan Pembatalan
|
||||||
|
</label>
|
||||||
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
|
<textarea class="textarea @error('alasan_pembatalan') border-danger bg-danger-light @enderror"
|
||||||
|
name="alasan_pembatalan"
|
||||||
|
rows="4">{{ old('alasan_pembatalan') }}</textarea>
|
||||||
|
@error('alasan_pembatalan')
|
||||||
|
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
|
<label class="form-label max-w-56">
|
||||||
|
Dokumen Pendukung
|
||||||
|
</label>
|
||||||
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
|
<input type="file" class="file-input @error('file_pembatalan') border-danger bg-danger-light @enderror"
|
||||||
|
name="file_pembatalan">
|
||||||
|
@error('file_pembatalan')
|
||||||
|
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button type="submit" class="btn btn-primary">Submit Pembatalan</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -298,6 +298,20 @@
|
|||||||
$trail->push('Data Permohonan');
|
$trail->push('Data Permohonan');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Breadcrumbs::for('permohonan.show-pembatalan', function (BreadcrumbTrail $trail) {
|
||||||
|
$trail->parent('permohonan.index');
|
||||||
|
$trail->push('Show Pembatalan Permohonan');
|
||||||
|
});
|
||||||
|
|
||||||
|
Breadcrumbs::for('pembatalan', function (BreadcrumbTrail $trail) {
|
||||||
|
$trail->push('Pembatalan', route('pembatalan.index'));
|
||||||
|
});
|
||||||
|
|
||||||
|
Breadcrumbs::for('pembatalan.edit', function (BreadcrumbTrail $trail) {
|
||||||
|
$trail->parent('pembatalan');
|
||||||
|
$trail->push('Show Pembatalan');
|
||||||
|
});
|
||||||
|
|
||||||
Breadcrumbs::for('basicdata.region', function (BreadcrumbTrail $trail) {
|
Breadcrumbs::for('basicdata.region', function (BreadcrumbTrail $trail) {
|
||||||
$trail->parent('basicdata');
|
$trail->parent('basicdata');
|
||||||
$trail->push('Region', route('basicdata.region.index'));
|
$trail->push('Region', route('basicdata.region.index'));
|
||||||
|
|||||||
@@ -367,6 +367,8 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::get('authorization', [PermohonanController::class, 'authorization'])->name('authorization.index');
|
Route::get('authorization', [PermohonanController::class, 'authorization'])->name('authorization.index');
|
||||||
|
Route::get('permohonan/{id}/pembatalan', [PermohonanController::class, 'showPembatalan'])->name('permohonan.show-pembatalan');
|
||||||
|
Route::post('permohonan/pembatalan', [PermohonanController::class, 'pembatalan'])->name('permohonan.pembatalan');
|
||||||
|
|
||||||
Route::resource('permohonan', PermohonanController::class);
|
Route::resource('permohonan', PermohonanController::class);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user