Mengubah tampilan show KJPP dan Create/Edit KJPP

This commit is contained in:
2024-09-30 13:04:50 +07:00
parent fde570f8d6
commit 6558d8348b
5 changed files with 85 additions and 46 deletions

View File

@@ -62,6 +62,9 @@ class KJPPController extends Controller
Storage::copy('public/test/default.pdf', 'public/uploads_pdf/' . $filename); Storage::copy('public/test/default.pdf', 'public/uploads_pdf/' . $filename);
} }
$validated['ijin_usaha_id'] = json_encode($request->input('ijin_usaha_id'));
$validated['jenis_aset_id'] = json_encode($request->input('jenis_aset_id'));
// Tambahkan nama file ke data yang divalidasi // Tambahkan nama file ke data yang divalidasi
$validated['attachment'] = $filename; $validated['attachment'] = $filename;

View File

@@ -32,8 +32,10 @@ class KJPPRequest extends FormRequest
'nomor_hp_pic_admin' => 'required|numeric|digits_between:10,15', 'nomor_hp_pic_admin' => 'required|numeric|digits_between:10,15',
'nama_pic_marketing' => 'required|string|not_regex:/^\d+$/|max:255', 'nama_pic_marketing' => 'required|string|not_regex:/^\d+$/|max:255',
'nomor_hp_pic_marketing' => 'required|numeric|digits_between:10,15', 'nomor_hp_pic_marketing' => 'required|numeric|digits_between:10,15',
'ijin_usaha_id' => 'nullable', 'ijin_usaha_id' => 'required|array',
'jenis_aset_id' => 'nullable', 'ijin_usaha_id.*' => 'exists:ijin_usaha,code',
'jenis_aset_id' => 'required|array',
'jenis_aset_id.*' => 'exists:jenis_jaminan,code',
'attachment' => 'nullable|mimes:pdf|max:1024' 'attachment' => 'nullable|mimes:pdf|max:1024'
]; ];
@@ -54,14 +56,6 @@ class KJPPRequest extends FormRequest
return true; return true;
} }
public function prepareForValidation(): void
{
$this->merge([
'ijin_usaha_id' => json_encode($this->ijin_usaha_id),
'jenis_aset_id' => json_encode($this->jenis_aset_id)
]);
}
public function messages(): array public function messages(): array
{ {
return [ return [
@@ -106,6 +100,10 @@ class KJPPRequest extends FormRequest
'nomor_hp_pic_marketing.required' => 'Nomor HP PIC Marketing Wajib diisi!', 'nomor_hp_pic_marketing.required' => 'Nomor HP PIC Marketing Wajib diisi!',
'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!', 'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!',
'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!', 'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!',
'ijin_usaha_id.required' => 'Ijin Usaha Wajib diisi!',
'ijin_usaha_id.min' => 'Ijin Usaha Wajib diisi minimal satu atau lebih!',
'jenis_aset_id.required' => 'Jenis Aset Wajib diisi!',
'jenis_aset_id.min' => 'Jenis Aset Wajib diisi minimal satu atau lebih!',
'attachment.mimes' => 'Attachment harus berformat pdf!', 'attachment.mimes' => 'Attachment harus berformat pdf!',
'attachment.max' => 'Attachment berukuran maksimum 1 MB!', 'attachment.max' => 'Attachment berukuran maksimum 1 MB!',
]; ];

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('kjpp', function (Blueprint $table) {
$table->string('ijin_usaha_id')->change();
$table->string('jenis_aset_id')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('kjpp', function (Blueprint $table) {
$table->string('ijin_usaha_id')->nullable()->change();
$table->string('jenis_aset_id')->nullable()->change();
});
}
};

View File

@@ -51,7 +51,7 @@
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Jenis Kantor</label> <label class="form-label max-w-56">Jenis Kantor</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<select class="input tomselect @error('jenis_kantor') border-danger @enderror" <select id="jenis_kantor" class="select w-full @error('jenis_kantor') border-danger @enderror"
name="jenis_kantor"> name="jenis_kantor">
<option value="">Pilih Jenis Kantor</option> <option value="">Pilih Jenis Kantor</option>
@if (isset($branch)) @if (isset($branch))
@@ -78,7 +78,8 @@
</div> </div>
<label class="form-label max-w-56">Nomor Ijin Usaha</label> <label class="form-label max-w-56">Nomor Ijin Usaha</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<select class="input tomselect @error('nomor_ijin_usaha') border-danger @enderror" <select id="nomor_ijin_usaha"
class="select w-full @error('nomor_ijin_usaha') border-danger @enderror"
name="nomor_ijin_usaha"> name="nomor_ijin_usaha">
<option value="">Pilih Nomor Ijin Usaha</option> <option value="">Pilih Nomor Ijin Usaha</option>
@if (isset($ijin_usaha)) @if (isset($ijin_usaha))
@@ -357,10 +358,10 @@
</option> </option>
@endforeach @endforeach
</select> </select>
@error('ijin_usaha_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div> </div>
@error('ijin_usaha_id')
<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"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56"> <label class="form-label max-w-56">
@@ -378,6 +379,9 @@
</option> </option>
@endforeach @endforeach
</select> </select>
@error('jenis_aset_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div> </div>
</div> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">

View File

@@ -149,45 +149,49 @@
Ijin Usaha Ijin Usaha
</label> </label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<select name="ijin_usaha_id[]" multiple="multiple" class="input tomselect w-full" disabled> @if (isset($kjpp->ijin_usaha_id))
<option value="">Pilih Ijin Usaha</option> <div class="flex flex-row space-x-4 text-gray-600 font-medium text-sm gap-1">
@foreach ($ijin_usahas as $row) @foreach (json_decode($kjpp->ijin_usaha_id, true) as $ijin_code)
@if (isset($kjpp->ijin_usaha_id)) @php
<option value="{{ $row->code }}" $ijin_usaha = $ijin_usahas->firstWhere('code', $ijin_code);
{{ in_array($row->code, old('ijin_usaha_id', json_decode($kjpp->ijin_usaha_id, true))) ? 'selected' : '' }}> @endphp
{{ $row->name }} @if ($ijin_usaha)
</option> <div
@else class="flex flex-row space-x-4 text-white font-medium text-sm badge badge-dark dark-mode:badge dark-mode:text-gray-600">
<option value="{{ $row->code }}" {{ $ijin_usaha->name }}
{{ in_array($row->code, old('ijin_usaha_id', [])) ? 'selected' : '' }}> </div>
{{ $row->name }} @endif
</option> @endforeach
@endif </div>
@endforeach @else
</select> <div class="flex flex-row space-x-4 text-white font-medium text-sm dark-mode:text-gray-600">No
business license
selected.</div>
@endif
</div> </div>
</div> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56"> <label class="form-label max-w-56">
Pengalaman (Jenis Aset) Pengalaman (Jenis Aset)
</label> </label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full gap-1">
<select name="jenis_aset_id[]" multiple="multiple" class="input tomselect w-full" disabled> @if (isset($kjpp->jenis_aset_id))
<option value="">Pilih Jenis Aset</option> @foreach (json_decode($kjpp->jenis_aset_id, true) as $aset_code)
@foreach ($jenis_jaminan as $row) @php
@if (isset($kjpp->jenis_aset_id)) $jenis_aset = $jenis_jaminan->firstWhere('code', $aset_code);
<option value="{{ $row->code }}" @endphp
{{ in_array($row->code, old('jenis_aset_id', json_decode($kjpp->jenis_aset_id, true))) ? 'selected' : '' }}> @if ($jenis_aset)
{{ $row->name }} <span
</option> class="flex flex-row space-x-4 text-white font-medium text-sm badge badge-dark dark-mode:badge dark-mode:text-gray-600">
@else {{ $jenis_aset->name }}
<option value="{{ $row->code }}" </span>
{{ in_array($row->code, old('jenis_aset_id', [])) ? 'selected' : '' }}>
{{ $row->name }}
</option>
@endif @endif
@endforeach @endforeach
</select> @else
<span class="flex flex-row space-x-4 text-white font-medium text-sm dark-mode:text-gray-600">
No asset type selected.
</span>
@endif
</div> </div>
</div> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">