Merge remote-tracking branch 'composer/feature/senior-officer' into staging

This commit is contained in:
Daeng Deni Mardaeni
2024-12-27 14:08:12 +07:00
6 changed files with 652 additions and 336 deletions

View File

@@ -7,6 +7,7 @@ use Barryvdh\DomPDF\Facade\Pdf; // https://github.com/barryvdh/laravel-dompdf
use Modules\Lpj\Models\Permohonan;
use Modules\Lpj\Models\Inspeksi;
use Modules\Lpj\Models\Penilai;
use Modules\Lpj\Models\Laporan;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
@@ -17,6 +18,7 @@ use Modules\Location\Models\City;
use Modules\Location\Models\District;
use Modules\Location\Models\Village;
use Illuminate\Support\Facades\Log;
use App\Helpers\Lpj;
class PenilaiController extends Controller
{
@@ -247,7 +249,7 @@ class PenilaiController extends Controller
}
if(!Auth::user()->hasRole('administrator')) {
if (!Auth::user()->hasRole('administrator')) {
$query->whereHas('penilaian.userPenilai', function ($q) {
$q
->where('role', 'penilai')
@@ -597,6 +599,17 @@ class PenilaiController extends Controller
$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;
$forminspeksi = null;
$lpjData = null;
$formFoto = null;
@@ -616,20 +629,20 @@ class PenilaiController extends Controller
$inputAddress = $forminspeksi['asset']['alamat']['sesuai'] ?? $forminspeksi['asset']['alamat']['tidak sesuai'];
$alamat = [
'address' => $inputAddress['address'] ?? null,
'village_code' => $this->getWilayahName($inputAddress['village_code'] ?? null, 'village'),
'district_code' => $this->getWilayahName($inputAddress['district_code'] ?? null, 'district'),
'city_code' => $this->getWilayahName($inputAddress['city_code'] ?? null, 'city'),
'province_code' => $this->getWilayahName($inputAddress['province_code'] ?? null, 'province')
];
$alamat = [
'address' => $inputAddress['address'] ?? null,
'village_code' => $this->getWilayahName($inputAddress['village_code'] ?? null, 'village'),
'district_code' => $this->getWilayahName($inputAddress['district_code'] ?? null, 'district'),
'city_code' => $this->getWilayahName($inputAddress['city_code'] ?? null, 'city'),
'province_code' => $this->getWilayahName($inputAddress['province_code'] ?? null, 'province')
];
$laporan = $lpj->type == 'sederhana' ? true : false;
$viewLaporan = null;
if($laporan){
$viewLaporan = 'penilai.components.print-out-sederhana';
}else{
if ($laporan) {
$viewLaporan = 'penilai.components.print-out-sederhana';
} else {
$viewLaporan = 'penilai.components.print-out-standard';
}
@@ -646,9 +659,10 @@ $alamat = [
'lpj',
'statusLpj',
'alamat',
'dataPembanding'
'dataPembanding',
'nomorLaporan'
));
}else{
} else {
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
'permohonan',
'forminspeksi',
@@ -659,7 +673,8 @@ $alamat = [
'lpj',
'statusLpj',
'alamat',
'dataPembanding'
'dataPembanding',
'nomorLaporan'
));
$pdf->setPaper('A4', 'portrait');
@@ -673,31 +688,32 @@ $alamat = [
}
function getWilayahName($code, $type) {
public function getWilayahName($code, $type)
{
try {
$wilayah = null;
if (!$code) {
return null;
}
switch($type) {
switch ($type) {
case 'province':
$wilayah = Province::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'city':
$wilayah = City::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'district':
$wilayah = District::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'village':
$wilayah = Village::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
default:
return null;
}
@@ -705,6 +721,6 @@ $alamat = [
return null;
}
}
}