Merge branch 'staging' into feature/senior-officer
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
use Modules\Lpj\Models\PemilikJaminan;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class DebitureController extends Controller
|
||||
{
|
||||
@@ -128,6 +129,10 @@
|
||||
// Retrieve data from the database
|
||||
$query = Debiture::query();
|
||||
|
||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
@@ -167,7 +172,7 @@
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with('branch')->get();
|
||||
$data = $query->with(['branch','permohonan'])->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
@@ -488,7 +488,7 @@
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
|
||||
foreach ($documents as $document) {
|
||||
$jenisJaminan = $document->debiture->permohonan->nomor_registrasi ?? 'Uncategorized';
|
||||
$jenisJaminan = $document->permohonan->nomor_registrasi ?? 'Uncategorized';
|
||||
$folderName = $this->sanitizeFolderName($jenisJaminan);
|
||||
|
||||
foreach ($document->detail as $detail) {
|
||||
|
||||
@@ -280,6 +280,10 @@ class PermohonanController extends Controller
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query()->with('documents')->has('documents', '>', 0)->where('status', '=', 'order');
|
||||
|
||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
'authorized_at.date' => 'Tanggal otorisasi harus berupa tanggal yang valid.',
|
||||
'authorized_by.exists' => 'ID pengguna yang mengotorisasi tidak valid.',
|
||||
'status_bayar.required' => 'Status bayar wajib diisi.',
|
||||
'status_bayar.in' => 'Status bayar harus berupa "sudah_bayar" atau "belum_bayar".',
|
||||
'status_bayar.in' => 'Status bayar harus berupa "sudah_bayar", "belum_bayar" atau "tidak bayar".',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
}
|
||||
|
||||
public function permohonan(){
|
||||
return $this->hasOne(Permohonan::class, 'debiture_id', 'id' );
|
||||
return $this->hasMany(Permohonan::class, 'debiture_id', 'id' );
|
||||
}
|
||||
|
||||
public function laporanAdminKredit(): HasMany
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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('permohonan', function (Blueprint $table) {
|
||||
$table->enum('status_bayar',['sudah_bayar','belum_bayar','tidak_bayar'])->default('sudah_bayar')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$table->enum('status_bayar',['sudah_bayar','belum_bayar'])->default('sudah_bayar')->change();
|
||||
}
|
||||
};
|
||||
@@ -7,22 +7,22 @@
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56 gap-1">
|
||||
Cabang
|
||||
<span class="text-danger">
|
||||
*
|
||||
</span>
|
||||
<span class="text-danger">*</span>
|
||||
</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="branch_id" id="branch_id">
|
||||
<option value="">Pilih Cabang</option>
|
||||
@foreach($branches as $branch)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $branch->id }}" {{ $branch->id == $debitur->branch_id ? 'selected' : '' }}>{{ $branch->name }}</option>
|
||||
@else
|
||||
<option value="{{ $branch->id }}">{{ $branch->name }}</option>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@if(auth()->user()->hasRole('administrator'))
|
||||
<select class="input tomselect w-full @error('branch_id') border-danger bg-danger-light @enderror" name="branch_id" id="branch_id">
|
||||
<option value="">Pilih Cabang</option>
|
||||
@foreach($branches as $branch)
|
||||
<option value="{{ $branch->id }}" {{ (isset($debitur) && $branch->id == $debitur->branch_id) || (old('branch_id') == $branch->id) ? 'selected' : '' }}>
|
||||
{{ $branch->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<input type="hidden" name="branch_id" value="{{ auth()->user()->branch_id }}">
|
||||
<input type="text" class="input w-full" value="{{ auth()->user()->branch->name }}" readonly>
|
||||
@endif
|
||||
@error('branch_id')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('debitur.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('debitur.create') }}"> Tambah Debitur </a>
|
||||
@if(auth()->user()->hasAnyRole(['administrator', 'pemohon-ao']))
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('debitur.create') }}"> Tambah Debitur </a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,6 +92,10 @@
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
const userRoles = @json(auth()->user()->roles->pluck('name'));
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
@@ -118,8 +124,7 @@
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
||||
Swal.fire('Error!', error.responseJSON.message, 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -177,14 +182,36 @@
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
let actionHtml = `<div class="flex flex-nowrap justify-center">`;
|
||||
|
||||
// Fungsi helper untuk memeriksa peran
|
||||
const hasRole = (roles) => roles.some(role => userRoles.includes(role));
|
||||
|
||||
// Fungsi helper untuk memeriksa status permohonan
|
||||
const hasValidStatus = (permohonan) => ['order', 'revisi'].includes(permohonan.status);
|
||||
|
||||
// Periksa apakah permohonan ada dan merupakan array
|
||||
const permohonanArray = Array.isArray(data.permohonan) ? data.permohonan : [];
|
||||
|
||||
// Periksa apakah ada setidaknya satu permohonan dengan status yang valid
|
||||
const hasAnyValidPermohonan = permohonanArray.some(hasValidStatus);
|
||||
|
||||
if (hasRole(['administrator']) && hasAnyValidPermohonan || data.permohonan.length < 1) {
|
||||
actionHtml += `
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="/debitur/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
</a>`;
|
||||
}
|
||||
|
||||
if (hasRole(['administrator', 'pemohon-ao']) && data.permohonan.length < 1) {
|
||||
actionHtml += `
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>`;
|
||||
}
|
||||
|
||||
actionHtml += `</div>`;
|
||||
return actionHtml;
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
</a>`;
|
||||
}
|
||||
|
||||
if(data.status_bayar=="sudah_bayar" && data.nilai_liquidasi >0) {
|
||||
if((data.status_bayar=="sudah_bayar" || data.status_bayar=="tidak_bayar") && data.nilai_liquidasi >0) {
|
||||
if(data.penilai.type_penilai=='resume' && !data.penilai.resume){
|
||||
laporanButton = `
|
||||
<a href="{{ route('penilai.print-out') }}?permohonanId=${data.id}&documentId=${dokumenID}&inspeksiId=${inspeksiId}&jaminanId=${jenisJaminanID}&statusLpj=0&type=${type}" class="btn btn-sm btn-primary">
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
'nilai_plafond_id' => ['label' => 'Nilai Plafond', 'type' => 'select', 'options' => $plafond],
|
||||
'status_bayar' => ['label' => 'Status Bayar', 'type' => 'select', 'options' => [
|
||||
'sudah_bayar' => 'Sudah Bayar',
|
||||
'belum_bayar' => 'Belum Bayar'
|
||||
'belum_bayar' => 'Belum Bayar',
|
||||
'tidak_bayar' => 'Tidak Bayar'
|
||||
]],
|
||||
'nilai_njop' => ['label' => 'Nilai NJOP', 'type' => 'text'],
|
||||
];
|
||||
@@ -130,8 +131,12 @@
|
||||
const nilaiPlafondValue = nilaiPlafondSelect.value;
|
||||
console.log('Tujuan Penilaian:', tujuanPenilaianValue, 'Nilai Plafond:', nilaiPlafondValue);
|
||||
|
||||
if (tujuanPenilaianValue === '2' && (nilaiPlafondValue === '2' || nilaiPlafondValue === '3')) {
|
||||
statusBayarTomSelect.setValue('sudah_bayar');
|
||||
const hideAndSetTidakBayar = (tujuanPenilaianValue === '2' || tujuanPenilaianValue === '4') &&
|
||||
['1', '2', '3'].includes(nilaiPlafondValue);
|
||||
|
||||
|
||||
if (hideAndSetTidakBayar) {
|
||||
statusBayarTomSelect.setValue('tidak_bayar');
|
||||
statusBayarWrapper.style.display = 'none';
|
||||
} else {
|
||||
@if(isset($permohonan))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
|
||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="permohonan-table" data-api-url="{{ route('permohonan.datatables') }}">
|
||||
data-datatable-state-save="false" id="permohonan-table" data-api-url="{{ route('permohonan.datatables') }}">
|
||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Permohonan
|
||||
@@ -22,53 +22,55 @@
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('permohonan.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('permohonan.create') }}"> Tambah Permohonan </a>
|
||||
@if(auth()->user()->hasAnyRole(['administrator', 'pemohon-ao']))
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('permohonan.create') }}"> Tambah Permohonan </a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm"
|
||||
data-datatable-table="true">
|
||||
data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
<span class="sort"> <span class="sort-label"> User Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||
<span class="sort"> <span class="sort-label"> Cabang Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
<span class="sort"> <span class="sort-label"> Tujuan Penilaian </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
||||
</th>
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
||||
<span class="sort"> <span class="sort-label"> Status </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
||||
<span class="sort"> <span class="sort-label"> Keterangan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
@@ -90,6 +92,10 @@
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
const userRoles = @json(auth()->user()->roles->pluck('name'));
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function deleteData(data, noReg, debitur) {
|
||||
Swal.fire({
|
||||
@@ -198,11 +204,11 @@
|
||||
},
|
||||
keterangan: {
|
||||
title: 'Keterangan',
|
||||
render : (item, data) => {
|
||||
render: (item, data) => {
|
||||
|
||||
let keterangan = data.keterangan ?? ""
|
||||
if(data.registrasi_catatan){
|
||||
if(keterangan) keterangan += "\n";
|
||||
if (data.registrasi_catatan) {
|
||||
if (keterangan) keterangan += "\n";
|
||||
keterangan += data.registrasi_catatan;
|
||||
}
|
||||
|
||||
@@ -213,6 +219,7 @@
|
||||
title: 'Actions',
|
||||
render: (item, data) => {
|
||||
let actionHtml = `<div class="flex flex-nowrap justify-end gap-1.5">`;
|
||||
const hasRole = (roles) => roles.some(role => userRoles.includes(role));
|
||||
|
||||
if (data.status === 'proses-survey' || data.status == 'rejected-reschedule') {
|
||||
actionHtml += `
|
||||
@@ -255,18 +262,17 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
`;
|
||||
}
|
||||
|
||||
if (data.status !== 'done' && data.status !== 'batal') {
|
||||
if (data.status !== 'done' && data.status !== 'batal' && hasRole(['administrator', 'pemohon-ao'])) {
|
||||
actionHtml += `
|
||||
<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>
|
||||
</a>`;
|
||||
}
|
||||
if (data.status === 'order') {
|
||||
if (data.status === 'order' && hasRole(['administrator', 'pemohon-ao'])) {
|
||||
actionHtml += `
|
||||
<a onclick="deleteData(${data.id}, '${data.nomor_registrasi}','${data.debiture?.name}')" class="delete btn btn-sm btn-outline btn-danger" title="Batalkan Permohonan">
|
||||
<i class="ki-outline ki-cross-square"></i>
|
||||
</a>`;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +286,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function() {
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
@@ -325,7 +331,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
if ('success' == response.status) {
|
||||
swal.fire('Sukses Menyetujui!', response.message, 'success').then(
|
||||
@@ -337,7 +343,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
}
|
||||
|
||||
},
|
||||
error: function(response, textStatus, errorThrown) {
|
||||
error: function (response, textStatus, errorThrown) {
|
||||
// var errors = response.responseJSON.errors;
|
||||
// console.log(errors);
|
||||
console.log(response);
|
||||
@@ -415,7 +421,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses Reschedule!', response.message,
|
||||
'success').then(() => {
|
||||
@@ -425,7 +431,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
error: function (response) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
@@ -529,17 +535,17 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses Reschedule!', response.message, 'success').then(
|
||||
() => {
|
||||
location.reload();
|
||||
});
|
||||
() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
error: function (response) {
|
||||
const errorMessage = response.responseJSON?.message ||
|
||||
'Terjadi kesalahan saat memproses data.';
|
||||
Swal.fire('Error!', errorMessage, 'error');
|
||||
|
||||
Reference in New Issue
Block a user