perbaikan nomor laporan, dan penambahan button revisi laporan di so

This commit is contained in:
majid
2025-01-09 17:01:35 +07:00
parent 9c5c91ae9c
commit e84bce7034
12 changed files with 290 additions and 134 deletions

View File

@@ -8,6 +8,7 @@ use Modules\Lpj\Models\PenawaranTender;
use Modules\Lpj\Models\Penilaian;
use Modules\Lpj\Models\JenisDokumen;
use Modules\Lpj\Models\TeamsUsers;
use Modules\Lpj\Models\Laporan;
use Modules\Usermanagement\Models\User;
function formatTanggalIndonesia($date, $time = false)
@@ -350,3 +351,11 @@ function checkRegionUserName($userId)
return null;
}
}
function getNomorLaporan($permohonanId, $documentId){
$laporan = Laporan::where([
'permohonan_id' => $permohonanId,
'dokumen_jaminan_id' => $documentId,
])->first();
return $laporan->nomor_laporan ?? null;
}

View File

@@ -75,12 +75,23 @@ class PenilaiController extends Controller
$documentId = $request->query('documentId');
$jaminanId = $request->query('jaminanId');
$inspeksiId = $request->query('inspeksiId');
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
$basicData = $this->surveyorController->getCommonData();
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
$lpj = Penilai::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
$lpj = Penilai::updateOrCreate(
[
'permohonan_id' => $id,
'dokument_id' => $documentId,
'inspeksi_id' => $inspeksiId,
],
[
'type_penilai' => 'standard',
]
);
$forminspeksi = null;
$lpjData = null;
@@ -100,12 +111,24 @@ class PenilaiController extends Controller
$documentId = $request->query('documentId');
$jaminanId = $request->query('jaminanId');
$inspeksiId = $request->query('inspeksiId');
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
$basicData = $this->surveyorController->getCommonData();
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
$lpj = Penilai::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
$lpj = Penilai::updateOrCreate(
[
'permohonan_id' => $id,
'dokument_id' => $documentId,
'inspeksi_id' => $inspeksiId,
],
[
'type_penilai' => 'standard',
]
);
$forminspeksi = null;
$lpjData = null;
@@ -129,6 +152,7 @@ class PenilaiController extends Controller
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
$noLpresume = $this->generateNoLaporan($permohonan, $documentId, 'resume');
Penilai::updateOrCreate(
[
'permohonan_id' => $permohonanId,
@@ -163,6 +187,7 @@ class PenilaiController extends Controller
$data = $this->getDataPermohonanWithPenilaiAndInspeksi($req['permohonanId'], $req['documentId'], $req['jaminanId']);
$permohonan = $data['permohonan'];
$noLpmemo = $this->generateNoLaporan($permohonan, $req['documentId'], 'memo');
$inspeksi = Inspeksi::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
$penilai = Penilai::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
$provinces = Province::all();
@@ -198,7 +223,7 @@ class PenilaiController extends Controller
}
}
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages'));
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages', 'noLpmemo'));
}
@@ -310,6 +335,7 @@ class PenilaiController extends Controller
});
}
$query->whereRaw('LOWER(status) IN (?, ?, ?)', ['assign','done', 'proses-laporan']);
if (!Auth::user()->hasRole('administrator')) {
$query->whereHas('penilaian.userPenilai', function ($q) {
@@ -373,12 +399,17 @@ class PenilaiController extends Controller
{
$permohonanId = $request->query('permohonanId');
$documentId = $request->query('documentId');
$jaminanId = $request->query('jaminanId');
// Fetch the data from the database
$data = Inspeksi::where('permohonan_id', $permohonanId)
->where('dokument_id', $documentId)
->first();
$permohonan = $this->surveyorController->getPermohonanJaminanId(
$permohonanId,
$documentId,
$jaminanId
);
// Check if data exists
if (!$data) {
return response()->json(['message' => 'Data not found'], 404);
@@ -436,7 +467,10 @@ class PenilaiController extends Controller
// Now create the export
// return response()->json([ 'data' => $fotoForm]);
return Excel::download(new KertasKerjaExport($exportData), 'kertas-kerja.xlsx');
// return view('lpj::component.kertas-kerja-tes
// ', compact('permohonan', 'data'));
return Excel::download(new KertasKerjaExport($permohonan, $data), 'kertas-kerja.xlsx');
}
@@ -718,26 +752,18 @@ class PenilaiController extends Controller
$statusLpj = $request->query('statusLpj');
$tipeLaporan = $request->query('type');
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId,
$permohonan = $this->surveyorController->getPermohonanJaminanId(
$permohonanId,
$documentId,
$jaminanId);
$jaminanId
);
$basicData = $this->surveyorController->getCommonData();
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
$lpj = Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
$laporan = Laporan::firstOrCreate(
[
'permohonan_id' => $permohonanId,
'dokumen_jaminan_id' => $documentId,
],
[
'nomor_laporan' => generateLpjUniqueCode(6),
]
);
$nomorLaporan = $laporan->nomor_laporan;
$nomorLaporan = getNomorLaporan($permohonanId, $documentId);
$forminspeksi = null;
$lpjData = null;
$formFoto = null;
@@ -806,8 +832,10 @@ class PenilaiController extends Controller
));
// return $pdf;
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
$pdf->setPaper('A4', 'portrait');
return $pdf->download('Laporan_'. $tipeLaporan . '_' . $permohonan->nomor_registrasi . '_' .$permohonan->debiture->name .'_data.pdf');
return $pdf->download('Laporan_'. $tipeLaporan . '_' .$permohonan->debiture->name . '_' . $cleanNomorLaporan .'_data.pdf');
}
} catch (\Exception $e) {
@@ -887,7 +915,8 @@ class PenilaiController extends Controller
];
}
public function checkPrintOutLaporan(Request $request) {
public function checkPrintOutLaporan(Request $request)
{
$permohonanId = $request->query('permohonanId');
$documentId = $request->query('documentId');
$inspeksiId = $request->query('inspeksiId');
@@ -911,4 +940,42 @@ class PenilaiController extends Controller
}
public function generateNoLaporan($permohonan, $documentId, $type)
{
$typeMapping = ['lpj' => 'LPJ', 'memo' => 'MAK', 'rap' => 'RAP'];
// Cek apakah data sudah ada
$laporan = Laporan::where([
'permohonan_id' => $permohonan->id,
'dokumen_jaminan_id' => $documentId,
])->first();
if ($laporan) {
$nomorArray = explode('/', $laporan->nomor_laporan);
$nomorArray[2] = $typeMapping[$type] ?? 'RSM';
$laporan->update([
'nomor_laporan' => implode('/', $nomorArray)
]);
} else {
$laporan = Laporan::create([
'permohonan_id' => $permohonan->id,
'dokumen_jaminan_id' => $documentId,
'nomor_laporan' => implode('/', [
$permohonan->debiture->branch->code,
generateLpjUniqueCode(3),
$typeMapping[$type] ?? 'RSM',
$permohonan->nomor_registrasi,
onRomawi(date('m')),
substr(date('Y'), -2)
])
]);
}
return $laporan->nomor_laporan;
}
}

View File

@@ -731,8 +731,21 @@ class PenilaianController extends Controller
'error' => $e->getMessage()
], 500);
}
}
public function revisiLaporan($id, Request $request)
{
$permohonan = Permohonan::findOrFail($id);
$permohonan->update([
'status' => 'done',
'keterangan' => $request->message,
'submitted_at' => now()
]);
return response()->json([
'success' => true,
'message' => 'Berhasil Revisi Laporan penilai',
], 200);
}
}

View File

@@ -16,9 +16,6 @@
<span id="saveButtonText">Save</span>
</button>
@if (Auth::user()->hasAnyRole(['senior-officer']))
<a href="_blank" class="btn btn-warning">
Revisi
</a>
<a class="btn btn-primary"
onclick="checkLaporan('{{ $permohonan->id }}', '{{ request('documentId') }}', '{{ request('inspeksiId') }}', {{ request('jaminanId') }}, )">
<i class="ki-filled ki-printer"></i> Print

View File

@@ -38,10 +38,10 @@
<label class="form-label max-w-56">Nomor Memo</label>
<div class="flex flex-wrap items-base line w-full">
<input type="text" name="nomor_memo" class="input w-full" placeholder="Masukkan..."
value="{{ $memo->nomor_memo ?? "" }}">
value="{{ $noLpmemo ?? "" }}" @readonly(true)>
</div>
</div>
{{-- 250109828129/ --}}
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Tanggal</label>
@@ -264,16 +264,13 @@
</div>
</div>
@include('lpj::penilai.components.foto-lampiran')
{{-- @include('lpj::penilai.components.foto-lampiran') --}}
<div class="flex card-footer justify-end gap-5">
<a class="btn btn-success" onclick="saveMemo()">
SAVE
</a>
@if (Auth::user()->hasAnyRole(['senior-officer']))
<a href="_blank" class="btn btn-warning">
Revisi
</a>
<a class="btn btn-primary"
onclick="checkLaporan('{{ $permohonan->id }}', '{{ request('documentId') }}', '{{ request('inspeksiId') }}', {{ request('jaminanId') }}, )">
<i class="ki-filled ki-printer"></i> Print

View File

@@ -140,7 +140,7 @@
<tr>
<td style="width: 20%; padding: 2px;">No</td>
<td style="width: 1%; padding: 2px;">:</td>
<td style="width: 79%; padding: 2px;">{{ $memo['nomor_memo'] ?? '' }}</td>
<td style="width: 79%; padding: 2px;">{{ $nomorLaporan ?? '-' }}</td>
</tr>
<tr>
<td style="width: 20%; padding: 2px;">Tanggal</td>
@@ -322,6 +322,33 @@
<td style="height: 50px"></td>
<td style="height: 50px"></td>
</tr>
@php
$senior_officer = null;
if ($permohonan->debiture && $permohonan->debiture->documents) {
foreach ($permohonan->debiture->documents as $dokumen) {
$penilai = $permohonan->penilaian->userPenilai->where('role', 'penilai')->first();
$teams = $permohonan->region->teams;
if ($teams) {
foreach ($teams as $team) {
$team_users = $team->teamsUsers;
// print_r($team_users);
if ($team_users) {
foreach ($team_users as $team_user) {
$user = $team_user->user;
if ($user && $user->hasRole('senior-officer')) {
$senior_officer = $user;
break 3;
}
}
}
}
}
}
}
use Modules\Usermanagement\Models\User;
@endphp
<tr>
<td>{{ $penilai->userPenilaiTeam->name ?? '' }}</br>
Appraisal
@@ -332,7 +359,7 @@
<td> {{ $senior_officer->name ?? '' }}</br>
EO Appraisal
</td>
<td> {{ $senior_officer->name ?? '' }}</br>
<td> {{ User::role('DD Appraisal')->first()->name ?? '' }}</br>
Deputy Director
</td>
</tr>
@@ -360,7 +387,6 @@
<script>
const data = @json($memo);
console.log(data);
</script>
</body>

View File

@@ -260,7 +260,7 @@
<h4 style="text-align: center; text-transform: uppercase; font-size: 14px;">LAPORAN PENILAIAN ATAS
{{ $data }}</h4>
<p style="text-align: center; font-size:12px;">NO:
{{ $permohonan->debiture->branch->code ?? '' }}/{{ $nomorLaporan }}/LPJ/{{ $permohonan->nomor_registrasi }}/{{ onRomawi(date('m')) }}/{{ date('Y') }}
{{ $nomorLaporan }}
</p>
</div>

View File

@@ -24,9 +24,6 @@
</div>
</button>
@if (Auth::user()->hasAnyRole(['senior-officer']))
<a href="_blank" class="btn btn-warning">
Revisi
</a>
<a class="btn btn-primary"
onclick="checkLaporan('{{ $permohonan->id }}', '{{ request('documentId') }}', '{{ request('inspeksiId') }}', {{ request('jaminanId') }}, )">
<i class="ki-filled ki-printer"></i> Print

View File

@@ -338,9 +338,6 @@
<div class="flex card-footer justify-end gap-5">
<button type="button" class="btn btn-success" onclick="saveResume()">Save</button>
@if (Auth::user()->hasAnyRole(['senior-officer']))
<a href="_blank" class="btn btn-warning">
Revisi
</a>
<a class="btn btn-primary"
onclick="checkLaporan('{{ $permohonan->id }}', '{{ request('documentId') }}', '{{ request('inspeksiId') }}', {{ request('jaminanId') }}, )">
<i class="ki-filled ki-printer"></i> Print

View File

@@ -184,6 +184,7 @@
</label>
<div class="flex flex-wrap items-baseline w-full">
<p class="flex w-full text-gray-600 font-medium text-sm">
{{ getNomorLaporan($permohonan->id, $dokumen->id) ?? '-' }}
</p>
</div>
</div>

View File

@@ -132,6 +132,9 @@
<i class="ki-filled ki-double-check"></i>
Otorisator {{ $header ?? '' }}
</button>
<button class="btn btn-warning" onclick="revisiLaporan({{ $permohonan->id }})">
<i class="ki-filled ki-arrow-circle-right"></i> Revisi
</button>
@endif
@if(Auth::user()->hasAnyRole(['administrator','EO Appraisal']) && $permohonan->approval_so && $permohonan->approval_eo==null)
@@ -200,5 +203,53 @@
}
});
}
function revisiLaporan(dataId) {
const dataHeader = @json($header);
Swal.fire({
title: 'Apakah Anda yakin?',
text: `Untuk melakukan Revisi ${dataHeader}!`,
icon: 'warning',
input: 'textarea',
inputLabel: 'Keterangan',
inputPlaceholder: 'Masukkan keterangan...',
inputAttributes: {
'aria-label': 'Masukkan keterangan'
},
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Lanjutkan!',
cancelButtonText: 'Batal',
}).then((result) => {
if (result.isConfirmed) {
const userMessage = result.value || '';
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
});
$.ajax({
url: `/otorisator/revisi/${dataId}/`,
type: 'POST',
data: {
message: userMessage
},
success: (response) => {
Swal.fire('Berhasil!', 'Data berhasil Revisi Laporan', 'success').then(() => {
window.location.href = '{{route('otorisator.pelaporan.index')}}';
});
console.log(response);
},
error: (error) => {
console.error('Error:', error);
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan Revisi.',
'error');
}
});
}
});
}
</script>
@endpush

View File

@@ -514,6 +514,7 @@ Route::middleware(['auth'])->group(function () {
);
Route::post('otorisator/{id}/{context}', [PenilaianController::class, 'otorisatorUpdate'])->name('otorisator.update');
Route::post('revisi/{id}', [PenilaianController::class, 'revisiLaporan'])->name('otorisator.revisi');
Route::get('pembatalan', [PenilaianController::class, 'otorisator'])->name('pembatalan.index')->defaults(
'type',