update print out
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
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;
|
||||
@@ -12,7 +13,6 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\KertasKerjaExport;
|
||||
use Modules\Lpj\Http\Controllers\SurveyorController;
|
||||
use Modules\Location\Models\Province;
|
||||
|
||||
class PenilaiController extends Controller
|
||||
{
|
||||
public $user;
|
||||
@@ -195,8 +195,7 @@ class PenilaiController extends Controller
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
$penilai = Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where
|
||||
('dokument_id', $documentId)->first();
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
$formFoto = null;
|
||||
if ($inspeksi) {
|
||||
$formFoto = json_decode($inspeksi->foto_form, true);
|
||||
@@ -299,74 +298,74 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
public function export_kertas_kerja(Request $request)
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
|
||||
// Fetch the data from the database
|
||||
$data = Inspeksi::where('permohonan_id', $permohonanId)
|
||||
->where('dokument_id', $documentId)
|
||||
->first();
|
||||
// Fetch the data from the database
|
||||
$data = Inspeksi::where('permohonan_id', $permohonanId)
|
||||
->where('dokument_id', $documentId)
|
||||
->first();
|
||||
|
||||
// Check if data exists
|
||||
if (!$data) {
|
||||
return response()->json(['message' => 'Data not found'], 404);
|
||||
}
|
||||
// Check if data exists
|
||||
if (!$data) {
|
||||
return response()->json(['message' => 'Data not found'], 404);
|
||||
}
|
||||
|
||||
// Decode the JSON fields
|
||||
$dataForm = json_decode($data->data_form, true);
|
||||
$fotoForm = json_decode($data->foto_form, true);
|
||||
$denahForm = json_decode($data->denah_form, true);
|
||||
$dataPembanding = json_decode($data->data_pembanding, true);
|
||||
// Decode the JSON fields
|
||||
$dataForm = json_decode($data->data_form, true);
|
||||
$fotoForm = json_decode($data->foto_form, true);
|
||||
$denahForm = json_decode($data->denah_form, true);
|
||||
$dataPembanding = json_decode($data->data_pembanding, true);
|
||||
|
||||
// Prepare the data for export
|
||||
$exportData = [
|
||||
'objek' => [
|
||||
'jenis_aset' => $dataForm['asset']['jenis_asset']['sesuai'] ?? '',
|
||||
'luas_tanah' => $dataForm['tanah']['luas_tanah']['tidak sesuai'] ?? '',
|
||||
'harga' => $dataForm['asset']['harga'] ?? '',
|
||||
'tanggal_penawaran' => $dataForm['tanggal_penawaran'] ?? '',
|
||||
'diskon' => $dataForm['diskon'] ?? '',
|
||||
'no_telepon' => $dataForm['no_telepon'] ?? '',
|
||||
'nama_nara_sumber' => $dataForm['nama_nara_sumber'] ?? '',
|
||||
'status_nara_sumber' => $dataForm['status_nara_sumber'] ?? '',
|
||||
'alamat' => $dataForm['alamat'] ?? '',
|
||||
// Add other fields as necessary
|
||||
],
|
||||
'pembanding1' => [],
|
||||
'pembanding2' => [],
|
||||
'pembanding3' => [],
|
||||
'foto_peta' => [
|
||||
'foto_tempat' => $dataForm['foto_tempat'] ?? [],
|
||||
'foto_gistaru' => $dataForm['foto_gistaru'] ?? [],
|
||||
'foto_bhumi' => $dataForm['foto_bhumi'] ?? [],
|
||||
'foto_argis_region' => $dataForm['foto_argis_region'] ?? [],
|
||||
],
|
||||
'foto_objek' => $fotoForm['object_jaminan'] ?? [],
|
||||
'foto_objek1' => [], // Populate with relevant data
|
||||
'foto_objek2' => [], // Populate with relevant data
|
||||
'tanggal_penilaian' => $data->tanggal_penilaian ?? '',
|
||||
'nama_pemilik' => $data->nama_pemilik ?? '',
|
||||
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
||||
];
|
||||
// Prepare the data for export
|
||||
$exportData = [
|
||||
'objek' => [
|
||||
'jenis_aset' => $dataForm['asset']['jenis_asset']['sesuai'] ?? '',
|
||||
'luas_tanah' => $dataForm['tanah']['luas_tanah']['tidak sesuai'] ?? '',
|
||||
'harga' => $dataForm['asset']['harga'] ?? '',
|
||||
'tanggal_penawaran' => $dataForm['tanggal_penawaran'] ?? '',
|
||||
'diskon' => $dataForm['diskon'] ?? '',
|
||||
'no_telepon' => $dataForm['no_telepon'] ?? '',
|
||||
'nama_nara_sumber' => $dataForm['nama_nara_sumber'] ?? '',
|
||||
'status_nara_sumber' => $dataForm['status_nara_sumber'] ?? '',
|
||||
'alamat' => $dataForm['alamat'] ?? '',
|
||||
// Add other fields as necessary
|
||||
],
|
||||
'pembanding1' => [],
|
||||
'pembanding2' => [],
|
||||
'pembanding3' => [],
|
||||
'foto_peta' => [
|
||||
'foto_tempat' => $dataForm['foto_tempat'] ?? [],
|
||||
'foto_gistaru' => $dataForm['foto_gistaru'] ?? [],
|
||||
'foto_bhumi' => $dataForm['foto_bhumi'] ?? [],
|
||||
'foto_argis_region' => $dataForm['foto_argis_region'] ?? [],
|
||||
],
|
||||
'foto_objek' => $fotoForm['object_jaminan'] ?? [],
|
||||
'foto_objek1' => [], // Populate with relevant data
|
||||
'foto_objek2' => [], // Populate with relevant data
|
||||
'tanggal_penilaian' => $data->tanggal_penilaian ?? '',
|
||||
'nama_pemilik' => $data->nama_pemilik ?? '',
|
||||
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
||||
];
|
||||
|
||||
// Extract data pembanding
|
||||
if (isset($dataPembanding['data_pembanding'])) {
|
||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||
if ($index == 0) {
|
||||
$exportData['pembanding1'] = $pembanding;
|
||||
} elseif ($index == 1) {
|
||||
$exportData['pembanding2'] = $pembanding;
|
||||
} elseif ($index == 2) {
|
||||
$exportData['pembanding3'] = $pembanding;
|
||||
// Extract data pembanding
|
||||
if (isset($dataPembanding['data_pembanding'])) {
|
||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||
if ($index == 0) {
|
||||
$exportData['pembanding1'] = $pembanding;
|
||||
} elseif ($index == 1) {
|
||||
$exportData['pembanding2'] = $pembanding;
|
||||
} elseif ($index == 2) {
|
||||
$exportData['pembanding3'] = $pembanding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now create the export
|
||||
// return response()->json([ 'data' => $fotoForm]);
|
||||
return Excel::download(new KertasKerjaExport($exportData), 'kertas-kerja.xlsx');
|
||||
}
|
||||
// Now create the export
|
||||
// return response()->json([ 'data' => $fotoForm]);
|
||||
return Excel::download(new KertasKerjaExport($exportData), 'kertas-kerja.xlsx');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -577,7 +576,48 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function print_out(Request $request)
|
||||
{
|
||||
$documentId = $request->query('documentId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $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();
|
||||
|
||||
$forminspeksi = null;
|
||||
$lpjData = null;
|
||||
$formFoto = null;
|
||||
|
||||
if ($inspeksi) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
|
||||
$formFoto = json_decode($inspeksi->foto_form, true);
|
||||
// $denahForm = json_decode($data->denah_form, true);
|
||||
}
|
||||
|
||||
if ($lpj) {
|
||||
$lpjData = json_decode($lpj->lpj, true);
|
||||
}
|
||||
|
||||
|
||||
$pdf =Pdf::loadView('lpj::penilai.components.print-out', compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
'formFoto',
|
||||
'basicData',
|
||||
'inspeksi',
|
||||
'lpj'
|
||||
));
|
||||
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
return $pdf->download('laporan.pdf');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user