Merge branch 'staging' into feature/senior-officer
This commit is contained in:
@@ -326,7 +326,7 @@ class ActivityController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data with necessary relationships
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan','nilaiPlafond'])->get();
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
@@ -444,26 +444,40 @@ class ActivityController extends Controller
|
||||
$jeniAsset = null;
|
||||
$statusPembayaran = trim(strtolower($item->permohonan->status_bayar ?? ''));
|
||||
$tujuanPenilaian = $item->permohonan->tujuanPenilaian->name ?? null;
|
||||
$plafond = $item->permohonan->nilaiPlafond->name ?? null;
|
||||
|
||||
$now = Carbon::now();
|
||||
$type_report = $item->permohonan->penilai->type ?? "";
|
||||
|
||||
// $plafond = $item->permohonan->nilaiPlafond->name ?? null;
|
||||
// $type_report = $item->permohonan->penilai->type_penilai;
|
||||
$hari = $hariPaparan = 0;
|
||||
|
||||
// $hari = 0;
|
||||
// if ($plafond == '< 1M') {
|
||||
// $item->paparan = 'Tidak Ada';
|
||||
// }else if($plafond == '2 M - 5 M'){
|
||||
// $hari = 2;
|
||||
// }else if($plafond == '5 M - 10 M'){
|
||||
// $hari = 3;
|
||||
// }
|
||||
if($type_report == "sederhana"){
|
||||
$hari = 2;
|
||||
$item->paparan = 'Tidak Ada';
|
||||
} else{
|
||||
if ($plafond == '< 2M') {
|
||||
$item->paparan = 'Tidak Ada';
|
||||
$hari = 3;
|
||||
}else if($plafond == '2 M - 5 M'){
|
||||
$hari = 3;
|
||||
$hariPaparan = 2;
|
||||
}else {
|
||||
$hari = 5;
|
||||
$hariPaparan = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tujuanPenilaian == 'RAP') {
|
||||
$hari = 2;
|
||||
$hariPaparan = 2;
|
||||
}
|
||||
|
||||
|
||||
if ($item->permohonan && $item->permohonan->debiture) {
|
||||
$jeniAsset = $item->permohonan->debiture->documents->first() ?? null;
|
||||
}
|
||||
|
||||
$hariTambahan = 0;
|
||||
/*$hariTambahan = 0;
|
||||
|
||||
if ($tujuanPenilaian == 'RAP') {
|
||||
$hariTambahan = 2;
|
||||
@@ -473,33 +487,50 @@ class ActivityController extends Controller
|
||||
} else {
|
||||
$hariTambahan = 2; // H+2 untuk yang belum bayar
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$tanggalMulai = $item->waktu_penilaian;
|
||||
|
||||
if ($tanggalMulai) {
|
||||
if (!$tanggalMulai instanceof Carbon) {
|
||||
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||
}
|
||||
$hariKerjaBerikutnya = hitungHariKerja($tanggalMulai->toDateString(),$tanggalMulai->copy()->addDays(1));
|
||||
$hariKerjaBerikutnya = max($hariKerjaBerikutnya, 1);
|
||||
$tanggalMulai = $tanggalMulai->copy()->addDays($hariKerjaBerikutnya);
|
||||
|
||||
// Konversi string tanggal ke objek Carbon jika belum
|
||||
if (!$tanggalMulai instanceof Carbon) {
|
||||
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||
}
|
||||
|
||||
// Hitung tanggal selesai berdasarkan hari tambahan
|
||||
$tanggalSelesai = $tanggalMulai->copy()->addDays($hariTambahan);
|
||||
$tanggalSelesai = $tanggalMulai->copy()->addDays($hari);
|
||||
$tanggalPaparan = $tanggalMulai->copy()->addDays($hariPaparan);
|
||||
|
||||
// Hitung hari kerja
|
||||
$hariKerja = hitungHariKerja($tanggalMulai->toDateString(), $tanggalSelesai->toDateString());
|
||||
$hariKerja = max($hariKerja, $hari);
|
||||
|
||||
$hariKerjaPaparan = hitungHariKerja($tanggalMulai->toDateString(), $tanggalPaparan->toDateString());
|
||||
$hariKerjaPaparan = max($hariKerjaPaparan, $hariPaparan);
|
||||
|
||||
// Set due date SLA
|
||||
$dueDateSla = $tanggalMulai->copy()->addDays($hariKerja);
|
||||
$dueDateSlaPaparan = $tanggalMulai->copy()->addDays($hariKerjaPaparan);
|
||||
|
||||
// Cek apakah sudah melewati due date
|
||||
if ($now->greaterThan($dueDateSla)) {
|
||||
/*if ($now->greaterThan($dueDateSla)) {
|
||||
$item->due_date_sla = null;
|
||||
} else {
|
||||
$item->due_date_sla = $dueDateSla->toDateString();
|
||||
}
|
||||
}*/
|
||||
|
||||
$item->due_date_sla = $dueDateSla->toDateString();
|
||||
$item->paparan = $dueDateSlaPaparan->toDateString();
|
||||
} else {
|
||||
$item->due_date_sla = null;
|
||||
$item->paparan = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class LaporanController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','jenisFasilitasKredit', 'documents.inspeksi','penilai'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','jenisFasilitasKredit', 'documents.inspeksi','penilai','documents.detail'])->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Barryvdh\DomPDF\Facade\Pdf; // https://github.com/barryvdh/laravel-dompdf
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Inspeksi;
|
||||
use Modules\Lpj\Models\Penilai;
|
||||
@@ -544,7 +545,9 @@ class PenilaiController extends Controller
|
||||
'branch',
|
||||
'tujuanPenilaian',
|
||||
'jenisfasilitasKredit',
|
||||
'penilaian.userPenilai' // Ensure this relation is included
|
||||
'penilaian.userPenilai',
|
||||
'penilai',
|
||||
'nilaiPlafond'
|
||||
])->get();
|
||||
|
||||
// Calculate the page count
|
||||
@@ -754,10 +757,10 @@ class PenilaiController extends Controller
|
||||
|
||||
|
||||
if (!$allComplete) {
|
||||
$message = $rap
|
||||
? 'Harap Mengisi laporan terlebih dahulu'
|
||||
$message = $rap
|
||||
? 'Harap Mengisi laporan terlebih dahulu'
|
||||
: 'Harap Mengisi laporan terlebih dahulu atau kertas kerja';
|
||||
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $message,
|
||||
@@ -799,6 +802,18 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function uploadTempPhoto(Request $request)
|
||||
{
|
||||
if ($request->hasFile('file')) {
|
||||
$file = $request->file('file');
|
||||
$filename = time() . '_' . $file->getClientOriginalName();
|
||||
$path = $file->storeAs('temp_photos', $filename, 'public');
|
||||
return response()->json(['success' => true, 'id' => $path]);
|
||||
}
|
||||
|
||||
return response()->json(['success' => false], 400);
|
||||
}
|
||||
|
||||
public function storeResume(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -917,6 +932,59 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function storeMemoWithPhotos(Request $request)
|
||||
{
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'permohonan_id' => 'required|integer',
|
||||
'document_id' => 'required|integer',
|
||||
'inspeksi_id' => 'required|integer',
|
||||
'memo' => 'required',
|
||||
]);
|
||||
|
||||
$memoData = json_decode($validatedData['memo'], true);
|
||||
|
||||
$memo = Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $validatedData['permohonan_id'],
|
||||
'dokument_id' => $validatedData['document_id'],
|
||||
'inspeksi_id' => $validatedData['inspeksi_id'],
|
||||
],
|
||||
[
|
||||
'memo' => json_encode($memoData),
|
||||
]
|
||||
);
|
||||
|
||||
// Simpan foto-foto
|
||||
if ($request->hasFile('foto_0')) {
|
||||
$photoUrls = [];
|
||||
$index = 0;
|
||||
while ($request->hasFile("foto_$index")) {
|
||||
$file = $request->file("foto_$index");
|
||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||
$filePath = $file->storeAs('public/memo_photos', $fileName);
|
||||
$photoUrls[] = Storage::url($filePath);
|
||||
$index++;
|
||||
}
|
||||
|
||||
// Tambahkan URL foto ke data memo
|
||||
$memoData['foto'] = $photoUrls;
|
||||
$memo->memo = json_encode($memoData);
|
||||
$memo->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Memo dan foto berhasil disimpan',
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function storeLpjSederhanadanStandard(Request $request)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
|
||||
@@ -891,11 +891,13 @@ class PenilaianController extends Controller
|
||||
|
||||
public function revisiLaporan(Request $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::find($id);
|
||||
$userRole = Auth::user()->roles[0]->name;
|
||||
|
||||
$authorization = Authorization::where('permohonan_id', $permohonan->id)
|
||||
->where('jenis', 'paparan')->first();
|
||||
if($request->dataHeader=='Paparan'){
|
||||
$authorization = Authorization::find($id);
|
||||
$permohonan = Permohonan::find($authorization->permohonan_id);
|
||||
} else {
|
||||
$permohonan = Permohonan::find($id);
|
||||
$userRole = Auth::user()->roles[0]->name;
|
||||
}
|
||||
|
||||
if ($permohonan->status === 'proses-paparan') {
|
||||
if ($authorization) {
|
||||
|
||||
@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Models\Penilai;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Regions;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
@@ -167,6 +168,13 @@ class RegistrasiController extends Controller
|
||||
$modal = Permohonan::find($id);
|
||||
|
||||
$modal->update($dataku);
|
||||
|
||||
if($modal && $request->jenis_laporan){
|
||||
Penilai::updateOrCreate(
|
||||
['permohonan_id' => $id],
|
||||
['type' => $request->jenis_laporan]
|
||||
);
|
||||
}
|
||||
//
|
||||
$data['status'] = 'success';
|
||||
$data['message'] ['message_success'] = ['Regitrasi ' . $modal->nomor_registrasi . ' successfully'];
|
||||
|
||||
Reference in New Issue
Block a user