Merge branch 'master' into feature/senior-officer
This commit is contained in:
commit
b36f266deb
@ -4,12 +4,14 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DetailDokumenJaminan;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
@ -36,8 +38,10 @@
|
||||
$debitur = Debiture::find($id);
|
||||
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$validate['debiture_id'] = $id;
|
||||
|
||||
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||
@ -61,22 +65,54 @@
|
||||
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||
}
|
||||
|
||||
if ($request->hasFile('dokumen_jaminan')) {
|
||||
$file = $request->file('dokumen_jaminan');
|
||||
$file_name = $file->getClientOriginalName();
|
||||
$file->storeAs('public/jaminan/' . $debitur->id, $file_name);
|
||||
$validate['dokumen_jaminan'] = 'jaminan/' . $debitur->id . '/' . $file_name;
|
||||
$document = DokumenJaminan::create($validate);
|
||||
|
||||
try {
|
||||
|
||||
foreach ($request->dokumen_jaminan as $key => $value) {
|
||||
$file_name = $value->getClientOriginalName();
|
||||
|
||||
if ($file_name) {
|
||||
try {
|
||||
$file_name = $value->getClientOriginalName();
|
||||
$value->storeAs(
|
||||
'public/jaminan/' . $debitur->id . '/' . $document->id . '/',
|
||||
$file_name
|
||||
);
|
||||
|
||||
$detail = [
|
||||
'dokumen_jaminan_id' => $document->id,
|
||||
'jenis_legalitas_jaminan_id' => $request->jenis_legalitas_jaminan_id[$key],
|
||||
'dokumen_jaminan' => 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name,
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
];
|
||||
DetailDokumenJaminan::create($detail);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'error',
|
||||
'Gagal upload file dokumen jaminan '. $key. ': '. $e->getMessage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
}catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'error',
|
||||
'gg'.$e->getMessage(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
DokumenJaminan::create($validate);
|
||||
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'success',
|
||||
'Dokumen Jaminan berhasil ditambahkan',
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error','ggl'. $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
app/Http/Requests/DetailDokumenJaminanRequest.php
Normal file
43
app/Http/Requests/DetailDokumenJaminanRequest.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DokumenJaminanRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'debiture_id' => 'required|exists:debitures,id',
|
||||
'pemilik_jaminan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'jenis_legalitas_jaminan_id' => 'required',
|
||||
'dokumen_jaminan' => 'nullable|file|mimes:pdf',
|
||||
'keterangan' => 'nullable|string|max:255',
|
||||
'province_code' => 'nullable|exists:provinces,code',
|
||||
'city_code' => 'nullable|exists:cities,code',
|
||||
'district_code' => 'nullable|exists:districts,code',
|
||||
'village_code' => 'nullable|exists:villages,code',
|
||||
'name' => 'required',
|
||||
'address' => 'nullable|string',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'status' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -16,14 +16,10 @@
|
||||
'debiture_id' => 'required|exists:debitures,id',
|
||||
'pemilik_jaminan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'jenis_legalitas_jaminan_id' => 'required',
|
||||
'dokumen_jaminan' => 'nullable|file|mimes:pdf',
|
||||
'keterangan' => 'nullable|string|max:255',
|
||||
'province_code' => 'nullable|exists:provinces,code',
|
||||
'city_code' => 'nullable|exists:cities,code',
|
||||
'district_code' => 'nullable|exists:districts,code',
|
||||
'village_code' => 'nullable|exists:villages,code',
|
||||
'name' => 'required',
|
||||
'address' => 'nullable|string',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'status' => 'nullable|boolean',
|
||||
|
34
app/Models/DetailDokumenJaminan.php
Normal file
34
app/Models/DetailDokumenJaminan.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Database\Factories\DokumenJaminanFactory;
|
||||
|
||||
class DetailDokumenJaminan extends Base
|
||||
{
|
||||
protected $table = 'detail_dokumen_jaminan';
|
||||
protected $fillable = [
|
||||
'dokumen_jaminan_id',
|
||||
'jenis_legalitas_jaminan_id',
|
||||
'name',
|
||||
'dokumen_jaminan',
|
||||
'keterangan',
|
||||
|
||||
'status',
|
||||
'authorized_at',
|
||||
'authorized_status',
|
||||
'authorized_by',
|
||||
];
|
||||
|
||||
public function jenisLegalitasJaminan(){
|
||||
return $this->belongsTo(JenisLegalitasJaminan::class, 'jenis_legalitas_jaminan_id', 'id');
|
||||
}
|
||||
|
||||
public function dokumenJaminan(){
|
||||
return $this->belongsTo(DokumenJaminan::class, 'dokumen_jaminan_id', 'id');
|
||||
}
|
||||
}
|
@ -16,10 +16,6 @@
|
||||
'permohonan_id',
|
||||
'pemilik_jaminan_id',
|
||||
'jenis_jaminan_id',
|
||||
'jenis_legalitas_jaminan_id',
|
||||
'name',
|
||||
'dokumen_jaminan',
|
||||
'keterangan',
|
||||
'province_code',
|
||||
'city_code',
|
||||
'district_code',
|
||||
@ -64,10 +60,6 @@
|
||||
return $this->belongsTo(JenisJaminan::class, 'jenis_jaminan_id', 'id');
|
||||
}
|
||||
|
||||
public function jenisLegalitasJaminan(){
|
||||
return $this->belongsTo(JenisLegalitasJaminan::class, 'jenis_legalitas_jaminan_id', 'id');
|
||||
}
|
||||
|
||||
public function permohonan(){
|
||||
return $this->belongsTo(Permohonan::class, 'permohonan_id', 'id');
|
||||
}
|
||||
|
@ -18,20 +18,16 @@ use Illuminate\Support\Facades\Schema;
|
||||
{
|
||||
Schema::create('dokumen_jaminan', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->foreignIdFor(Debiture::class)->constrained('debitures')->onDelete('cascade');
|
||||
$table->foreignIdFor(Permohonan::class)->nullable()->constrained('permohonan')->onDelete('cascade');
|
||||
$table->foreignIdFor(JenisJaminan::class)->constrained('jenis_jaminan')->onDelete('cascade');
|
||||
$table->foreignIdFor(PemilikJaminan::class)->constrained('pemilik_jaminan')->onDelete('cascade');
|
||||
$table->foreignIdFor(JenisLegalitasJaminan::class)->constrained('jenis_legalitas_jaminan')->onDelete('cascade');
|
||||
$table->string('province_code')->nullable()->index();
|
||||
$table->string('city_code')->nullable()->index();
|
||||
$table->string('district_code')->nullable()->index();
|
||||
$table->string('village_code')->nullable()->index();
|
||||
$table->string('postal_code', 5)->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('dokumen_jaminan')->nullable();
|
||||
$table->string('keterangan')->nullable();
|
||||
|
||||
$table->boolean('status')->default(true)->nullable();
|
||||
$table->timestamps();
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('detail_dokumen_jaminan', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->foreignIdFor(DokumenJaminan::class)->constrained('dokumen_jaminan')->onDelete('cascade');
|
||||
$table->foreignIdFor(JenisLegalitasJaminan::class)->constrained('jenis_legalitas_jaminan')->onDelete('cascade');
|
||||
$table->string('dokumen_jaminan')->nullable();
|
||||
$table->string('keterangan')->nullable();
|
||||
|
||||
$table->boolean('status')->default(true)->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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('detail_dokumen_jaminan');
|
||||
}
|
||||
};
|
@ -73,67 +73,9 @@
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Jenis Legalitas Jaminan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="input tomselect w-full @error('branch_id') border-danger bg-danger-light @enderror" name="jenis_legalitas_jaminan_id" id="jenis_legalitas_jaminan_id">
|
||||
<option value="">Pilih Jenis Legalitas Jaminan</option>
|
||||
@foreach($jenisLegalitasJaminan as $row)
|
||||
@if(isset($document))
|
||||
<option value="{{ $row->id }}" {{ isset($document->jenis_legalitas_jaminan_id) && $document->jenis_legalitas_jaminan_id == $row->id?'selected' : '' }}>
|
||||
{{ $row->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $row->id }}">{{ $row->name }}</option>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@error('jenis_legalitas_jaminan_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">
|
||||
<label class="form-label max-w-56">
|
||||
Nama Dokumen
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror" type="text " id="name" name="name" value="{{ $document->name ?? '' }}" placeholder="Nama Dokumen">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div id="doctainer" class="grid gap-5">
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Dokumen Jaminan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="file-input @error('dokumen_jaminan') border-danger bg-danger-light @enderror" type="file" name="dokumen_jaminan" value="">
|
||||
@if(isset($document->dokumen_jaminan))
|
||||
<a href="{{ route('debitur.download',$document->id) }}" class="mt-1 badge badge-sm badge-outline">{{ basename($document->dokumen_jaminan) }}
|
||||
<i class="ki-filled ki-cloud-download"></i></a>
|
||||
@endif
|
||||
@error('dokumen_jaminan')
|
||||
<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">
|
||||
Keterangan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea class="textarea @error('keterangan') border-danger bg-danger-light @enderror" rows="3" type="number" name="keterangan"> {{ $document->keterangan ?? '' }}</textarea>
|
||||
@error('keterangan')
|
||||
<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">
|
||||
@ -155,7 +97,8 @@
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@endif
|
||||
; @endforeach
|
||||
;
|
||||
@endforeach
|
||||
</select>
|
||||
@error('province_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@ -253,29 +196,66 @@
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function getLegalitasJaminan() {
|
||||
var legalitasJaminan = document.getElementById('jenis_jaminan_id').value;
|
||||
var url = '/basic-data/jenis-jaminan/legalitas/' + legalitasJaminan;
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
// Process the received data here
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
// Handle the error here
|
||||
});
|
||||
}
|
||||
function getLegalitasJaminan() {
|
||||
var legalitasJaminan = document.getElementById('jenis_jaminan_id').value;
|
||||
var url = '/basic-data/jenis-jaminan/legalitas/' + legalitasJaminan;
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
var doctainer = document.getElementById('doctainer');
|
||||
doctainer.innerHTML = '';
|
||||
data.forEach((item,index) => {
|
||||
doctainer.innerHTML += `
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56 font-bold">
|
||||
${index+1}. ${item.name}
|
||||
</label>
|
||||
<input type="hidden" name="jenis_legalitas_jaminan_id[]" value="${item.id}">
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nama Dokumen
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input " type="text" id="name" name="name[]" value="" placeholder="Nama Dokumen">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Dokumen Jaminan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="file-input" type="file" name="dokumen_jaminan[]" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Keterangan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea class="textarea" rows="3" type="number" name="keterangan[]"></textarea>
|
||||
</div>
|
||||
</div>`;
|
||||
})
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
// Handle the error here
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -19,14 +19,7 @@
|
||||
</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<a class="text-md font-semibold text-gray-900 hover:text-primary-active mb-px" href="/metronic/tailwind/demo1/public-profile/profiles/creator">
|
||||
{{ $document->name }}
|
||||
</a>
|
||||
<span class="text-2sm font-medium text-gray-600">
|
||||
{{ $document->jenisJaminan->name }} | {{ $document->jenisLegalitasJaminan->name }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="menu inline-flex" data-menu="true">
|
||||
<div class="flex flex-nowrap justify-center gap-1.5">
|
||||
|
Loading…
Reference in New Issue
Block a user