Merge remote-tracking branch 'origin/feature/senior-officer' into surveyor
This commit is contained in:
@@ -244,6 +244,15 @@ class ActivityController extends Controller
|
||||
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
$userRole = $user->roles->pluck('name')->first();
|
||||
$regionId = null;
|
||||
|
||||
// If user is senior-officer, get their regionId
|
||||
if ($userRole === 'senior-officer') {
|
||||
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||
$regionId = $userTeam?->team->regions_id;
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
|
||||
@@ -289,22 +298,39 @@ class ActivityController extends Controller
|
||||
// Get filtered count
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data
|
||||
|
||||
$data = null;
|
||||
$userRole = $user->roles[0]->name ?? null;
|
||||
|
||||
if (in_array($userRole, ['surveyor', 'surveyor-penilai'])) {
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian'])
|
||||
->whereHas('penilaian.userPenilai', function ($q) use ($user) {
|
||||
$q->where('user_id', $user->id);
|
||||
})
|
||||
->get();
|
||||
} else {
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])
|
||||
->get();
|
||||
// Filter by region if user is senior-officer
|
||||
if ($regionId) {
|
||||
$query->whereHas('region', function ($q) use ($regionId) {
|
||||
$q->where('region_id', $regionId);
|
||||
});
|
||||
}
|
||||
|
||||
// Filter for specific roles
|
||||
if (in_array($userRole, ['surveyor', 'surveyor-penilai'])) {
|
||||
$query->whereHas('penilaian.userPenilai', function ($q) use ($user) {
|
||||
$q->where('user_id', $user->id);
|
||||
});
|
||||
}
|
||||
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data with necessary relationships
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan'])->get();
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
153
app/Http/Controllers/CustomFieldController.php
Normal file
153
app/Http/Controllers/CustomFieldController.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\CustomFieldExport;
|
||||
use Modules\Lpj\Http\Requests\CustomFieldRequest;
|
||||
use Modules\Lpj\Models\CustomField;
|
||||
|
||||
class CustomFieldController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::custom_fields.index');
|
||||
}
|
||||
|
||||
public function store(CustomFieldRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
CustomField::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.custom-field.index')
|
||||
->with('success', 'Custom Field created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.custom-field.create')
|
||||
->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$urutan_prioritas = CustomField::max('urutan_prioritas')+1;
|
||||
return view('lpj::custom_fields.create', compact('urutan_prioritas'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$customField = CustomField::find($id);
|
||||
$urutan_prioritas = $customField->urutan_prioritas ?? CustomField::max('urutan_prioritas')+1;
|
||||
return view('lpj::custom_fields.create', compact('customField', 'urutan_prioritas' ));
|
||||
}
|
||||
|
||||
public function update(CustomFieldRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$customField = CustomField::find($id);
|
||||
$customField->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.custom-field.index')
|
||||
->with('success', 'Custom Field updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.custom-field.edit', $id)
|
||||
->with('error', 'Failed to update custom field');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$customField = CustomField::find($id);
|
||||
$customField->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Custom Field deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete custom field']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('custom_fields.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view custom fields.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = CustomField::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('name', 'LIKE', "%$search%");
|
||||
$q->orWhere('label', 'LIKE', "%$search%");
|
||||
$q->orWhere('type', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
return Excel::download(new CustomFieldExport, 'custom_fields.xlsx');
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||
use Modules\Lpj\Models\CustomField;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DetailDokumenJaminan;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
@@ -88,7 +89,7 @@
|
||||
'jenis_legalitas_jaminan_id' => $value,
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
'details' => isset($request->custom_field[$key]) ? json_encode($request->custom_field[$key]) : ''
|
||||
'details' => isset($request->custom_field[$value]) ? json_encode($request->custom_field[$value]) : ''
|
||||
];
|
||||
|
||||
$dokumenJaminan = [];
|
||||
@@ -247,7 +248,7 @@
|
||||
'jenis_legalitas_jaminan_id' => $value,
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
'details' => isset($request->custom_field[$key]) ? json_encode($request->custom_field[$key]) : ''
|
||||
'details' => isset($request->custom_field[$value]) ? json_encode($request->custom_field[$value]) : ''
|
||||
];
|
||||
|
||||
$dokumenJaminan = [];
|
||||
@@ -496,6 +497,12 @@
|
||||
foreach ($document->detail as $detail) {
|
||||
// Only include existing legalitas if its id is in the new set
|
||||
if (in_array($detail->jenis_legalitas_jaminan_id, $newLegalitasIds)) {
|
||||
$customFields = [];
|
||||
if($detail->jenisLegalitasJaminan->custom_fields) {
|
||||
$customFields = CustomField::whereIn('id', $detail->jenisLegalitasJaminan->custom_fields)
|
||||
->get();
|
||||
}
|
||||
|
||||
$existingLegalitas[] = [
|
||||
'id' => $detail->id,
|
||||
'jenis_legalitas_jaminan_id' => $detail->jenis_legalitas_jaminan_id,
|
||||
@@ -507,6 +514,7 @@
|
||||
$detail->dokumen_nomor,
|
||||
) ?? $detail->dokumen_nomor,
|
||||
'custom_field' => $detail->jenisLegalitasJaminan->custom_field,
|
||||
'custom_fields' => $customFields,
|
||||
'custom_field_type' => $detail->jenisLegalitasJaminan->custom_field_type,
|
||||
'details' => $detail->details,
|
||||
'keterangan' => $detail->keterangan,
|
||||
@@ -519,6 +527,11 @@
|
||||
|
||||
foreach ($newLegalitasJaminan as $legalitas) {
|
||||
if (!Collection::make($existingLegalitas)->contains('jenis_legalitas_jaminan_id', $legalitas->id)) {
|
||||
$customFields = [];
|
||||
if($legalitas->custom_fields) {
|
||||
$customFields = CustomField::whereIn('id', $legalitas->custom_fields)->get();
|
||||
}
|
||||
|
||||
$newLegalitas[] = [
|
||||
'id' => null,
|
||||
'jenis_legalitas_jaminan_id' => $legalitas->id,
|
||||
@@ -527,6 +540,7 @@
|
||||
'dokumen_nomor' => null,
|
||||
'custom_field' => $legalitas->custom_field,
|
||||
'custom_field_type' => $legalitas->custom_field_type,
|
||||
'custom_fields' => $customFields,
|
||||
'details' => null,
|
||||
'keterangan' => null,
|
||||
'is_existing' => false,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\JenisLegalitasJaminanExport;
|
||||
use Modules\Lpj\Http\Requests\JenisLegalitasJaminanRequest;
|
||||
use Modules\Lpj\Models\CustomField;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
|
||||
class JenisLegalitasJaminanController extends Controller
|
||||
@@ -40,13 +41,15 @@
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::jenis_legalitas_jaminan.create');
|
||||
$customFields = CustomField::orderBy('urutan_prioritas', 'asc')->get();
|
||||
return view('lpj::jenis_legalitas_jaminan.create',compact('customFields'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::find($id);
|
||||
return view('lpj::jenis_legalitas_jaminan.create', compact('jenisLegalitasJaminan'));
|
||||
$customFields = CustomField::orderBy('urutan_prioritas', 'asc')->get();
|
||||
return view('lpj::jenis_legalitas_jaminan.create', compact('jenisLegalitasJaminan', 'customFields'));
|
||||
}
|
||||
|
||||
public function update(JenisLegalitasJaminanRequest $request, $id)
|
||||
|
||||
@@ -226,7 +226,7 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages', 'noLpmemo'));
|
||||
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages', 'nomorLaporan'));
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ class PenilaiController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$permohonan = Permohonan::with('debiture')->find($id);
|
||||
return view('lpj::penilai.edit',compact('permohonan'));
|
||||
return view('lpj::penilai.edit', compact('permohonan'));
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ class PenilaiController extends Controller
|
||||
]
|
||||
);
|
||||
|
||||
if($request->hasFile('file_paparan')) {
|
||||
if ($request->hasFile('file_paparan')) {
|
||||
$file = $request->file('file_paparan');
|
||||
$path = $file->store('public/file_paparan');
|
||||
|
||||
@@ -282,10 +282,10 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('penilai.show',['id'=>$id])->with('success', 'diperbarui ke status paparan dan dikirim ke So untuk proses lebih lanjut.');
|
||||
->route('penilai.show', ['id' => $id])->with('success', 'diperbarui ke status paparan dan dikirim ke So untuk proses lebih lanjut.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->route('penilai.show',['id'=>$id])->with('error', 'Terjadi kesalahan saat memproses permohonan.');
|
||||
return redirect()->route('penilai.show', ['id' => $id])->with('error', 'Terjadi kesalahan saat memproses permohonan.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,12 +379,92 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('lpj::penilai.components.rap-penilai', compact('permohonan', 'rap', 'provinces', 'cities',
|
||||
return view('lpj::penilai.components.rap-penilai', compact(
|
||||
'permohonan',
|
||||
'rap',
|
||||
'provinces',
|
||||
'cities',
|
||||
'districts',
|
||||
'villages','forminspeksi', 'noLpRAP', 'basicData','cekAlamat'));
|
||||
'villages',
|
||||
'forminspeksi',
|
||||
'nomorLaporan',
|
||||
'basicData',
|
||||
'cekAlamat'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function call_report(Request $request)
|
||||
{
|
||||
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$provinces = Province::all();
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
// $nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'rap');
|
||||
// $basicData = $this->surveyorController->getCommonData();
|
||||
// $inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
// Penilai::updateOrCreate(
|
||||
// [
|
||||
// 'permohonan_id' => $permohonanId,
|
||||
// 'dokument_id' => $documentId,
|
||||
// 'inspeksi_id' => $inspeksiId,
|
||||
// ],
|
||||
// [
|
||||
// 'type_penilai' => 'call-report',
|
||||
// ]
|
||||
// );
|
||||
|
||||
// $resume = Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
|
||||
// $lpjData = null;
|
||||
// $rap = null;
|
||||
// $forminspeksi = null;
|
||||
// if ($resume) {
|
||||
// $forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
// $rap = json_decode($resume->rap, true);
|
||||
// }
|
||||
// Default: gunakan data dari debitur
|
||||
// $debitur = Debiture::find($permohonan->debiture_id);
|
||||
|
||||
// $provinceCode = $debitur->province_code;
|
||||
// $cityCode = $debitur->city_code;
|
||||
// $districtCode = $debitur->district_code;
|
||||
|
||||
// $cekAlamat = $forminspeksi['asset']['alamat']['tidak sesuai'] ?? null;
|
||||
|
||||
// if ($cekAlamat) {
|
||||
// $provinceCode = $cekAlamat['province_code'] ?? $provinceCode;
|
||||
// $cityCode = $cekAlamat['city_code'] ?? $cityCode;
|
||||
// $districtCode = $cekAlamat['district_code'] ?? $districtCode;
|
||||
// }
|
||||
|
||||
// $cities = City::where('province_code', $provinceCode)->get();
|
||||
// $districts = District::where('city_code', $cityCode)->get();
|
||||
// $villages = Village::where('district_code', $districtCode)->get();
|
||||
|
||||
// if ($forminspeksi) {
|
||||
// if (isset($forminspeksi['alamat']['sesuai']['province_code'])) {
|
||||
// $cities = City::where('province_code', $forminspeksi['alamat']['sesuai']['province_code'])->get();
|
||||
// }
|
||||
|
||||
// if (isset($forminspeksi['alamat']['sesuai']['city_code'])) {
|
||||
// $districts = District::where('city_code', $forminspeksi['alamat']['sesuai']['city_code'])->get();
|
||||
// }
|
||||
|
||||
// if (isset($forminspeksi['alamat']['sesuai']['district_code'])) {
|
||||
// $villages = Village::where('district_code', $forminspeksi['alamat']['sesuai']['district_code'])->get();
|
||||
// }
|
||||
// }
|
||||
|
||||
// return view('lpj::penilai.components.call-report', compact('permohonan', 'rap', 'provinces', 'cities',
|
||||
// 'districts',
|
||||
// 'villages','forminspeksi', 'noLpRAP', 'basicData','cekAlamat'));
|
||||
return view('lpj::penilai.components.call-report', compact('permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
@@ -981,8 +1061,12 @@ class PenilaiController extends Controller
|
||||
'rap'
|
||||
));
|
||||
// return $pdf;
|
||||
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
return $pdf->stream();
|
||||
return response($pdf->output(), 200)
|
||||
->header('Content-Type', 'application/pdf')
|
||||
->header('Content-Disposition', 'inline; filename="Laporan_' . $tipeLaporan . '_' .$permohonan->debiture->name . '_' . $cleanNomorLaporan .'.pdf"');
|
||||
// return $pdf->stream();
|
||||
} else {
|
||||
// $pdf = view('lpj::' . $viewLaporan, compact(
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
@@ -1022,7 +1106,8 @@ class PenilaiController extends Controller
|
||||
'standard' => 'penilai.components.print-out-standard',
|
||||
'resume' => 'penilai.components.print-resume',
|
||||
'memo' => 'penilai.components.print-memo',
|
||||
'rap' => 'penilai.components.print-out-rap'
|
||||
'rap' => 'penilai.components.print-out-rap',
|
||||
'call-report' => 'penilai.components.print-out-call-report'
|
||||
];
|
||||
return $viewMap[$tipe] ?? 'penilai.components.print-resume';
|
||||
}
|
||||
|
||||
@@ -680,6 +680,7 @@ class PenilaianController extends Controller
|
||||
'penilaian.userPenilai' => function ($q) {
|
||||
$q->where('role', 'penilai')->with(['user', 'team.regions'])->first();
|
||||
},
|
||||
'penilai',
|
||||
'approveSo',
|
||||
'approveEo',
|
||||
'approveDd',
|
||||
@@ -833,7 +834,7 @@ class PenilaianController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function revisiLaporan($id, Request $request)
|
||||
public function revisiLaporan(Request $request,$id)
|
||||
{
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
$permohonan->update([
|
||||
|
||||
@@ -14,6 +14,8 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
@@ -77,16 +79,15 @@ use Modules\Lpj\Models\LaluLintasLokasi;
|
||||
use Modules\Lpj\Models\SpekBagunanAnalisaDetail;
|
||||
use Modules\Lpj\Http\Requests\SurveyorRequest;
|
||||
use Modules\Lpj\Http\Requests\FormSurveyorRequest;
|
||||
use Modules\Lpj\Emails\SendEmail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\Lpj\Emails\SendJadwalKunjunganEmail;
|
||||
|
||||
class SurveyorController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::surveyor.index');
|
||||
@@ -831,8 +832,6 @@ private function isValidFormat($data)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function checkButtonStatus($id)
|
||||
{
|
||||
try {
|
||||
@@ -901,24 +900,24 @@ private function isValidFormat($data)
|
||||
'deskripsi_penilaian' => 'required'
|
||||
]);
|
||||
|
||||
// $user = ['user' => 'rustammajid76@gmail.com'];
|
||||
$penilaian = Penilaian::findOrFail($validate['id']);
|
||||
|
||||
// $emailData = [
|
||||
// 'email' => 'rustammajid76@gmail.com',
|
||||
// 'subject' => 'Test',
|
||||
// 'emailData' => '<h2>Hello, World!</h2><h2>This is the email content. Waktu Penilaian:</h2>'
|
||||
// ];
|
||||
$emailData = [
|
||||
'email' => $penilaian->permohonan->user->email,
|
||||
'subject' => 'Jadwal Kunjungan',
|
||||
'emailData' => $validate,
|
||||
|
||||
// $this->sendMessage($emailData, $user);
|
||||
];
|
||||
|
||||
$id = $request->input('id');
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
Mail::to($emailData['email'])->send(new SendJadwalKunjunganEmail($emailData, $penilaian->permohonan->nomor_resitrasi, $penilaian->permohonan->debiture));
|
||||
|
||||
if ($validate['waktu_penilaian'] <= $penilaian->tanggal_kunjungan) {
|
||||
|
||||
if (Carbon::parse($validate['waktu_penilaian']) <= Carbon::parse($penilaian->tanggal_kunjungan)) {
|
||||
return redirect()
|
||||
->route('surveyor.index')
|
||||
->with('error', 'Waktu penilaian harus lebih besar dari tanggal assign.');
|
||||
}
|
||||
|
||||
$penilaian->update([
|
||||
'waktu_penilaian' => $validate['waktu_penilaian'],
|
||||
'deskripsi_penilaian' => $validate['deskripsi_penilaian'],
|
||||
@@ -1940,7 +1939,7 @@ private function isValidFormat($data)
|
||||
|
||||
private function updateJenisAsset($permohonan, $request)
|
||||
{
|
||||
$jenis_jaminan_id = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
||||
$jenis_jaminan_id = $permohonan->documents->first()->jenis_jaminan_id;
|
||||
DokumenJaminan::where('permohonan_id', $permohonan->id)
|
||||
->where('jenis_jaminan_id', $jenis_jaminan_id)
|
||||
->update([
|
||||
@@ -1950,7 +1949,7 @@ private function isValidFormat($data)
|
||||
|
||||
private function updateDetails($permohonan, $key, $newValue)
|
||||
{
|
||||
$document = $permohonan->debiture->documents->first();
|
||||
$document = $permohonan->documents->first();
|
||||
|
||||
if (!$document) {
|
||||
throw new \Exception("Document not found");
|
||||
@@ -1964,18 +1963,18 @@ private function isValidFormat($data)
|
||||
|
||||
$datas = json_decode($detailsUpdate->details, true) ?? [];
|
||||
|
||||
if (is_numeric($newValue)) {
|
||||
$newValue = [$key => $newValue];
|
||||
if (!is_scalar($newValue)) {
|
||||
throw new \InvalidArgumentException("New value must be a scalar (string/number)");
|
||||
}
|
||||
|
||||
if (!is_array($newValue)) {
|
||||
throw new \InvalidArgumentException("'{$key}' must be an array or valid JSON string");
|
||||
}
|
||||
|
||||
foreach ($newValue as $subKey => $value) {
|
||||
$datas[$subKey] = $value; // Update atau tambahkan key baru
|
||||
// Update nilai berdasarkan kunci
|
||||
if (array_key_exists($key, $datas)) {
|
||||
$datas[$key] = $newValue;
|
||||
} else {
|
||||
throw new \Exception("Key '{$key}' not found in details");
|
||||
}
|
||||
|
||||
// Simpan kembali ke database
|
||||
$detailsUpdate->update([
|
||||
'details' => json_encode($datas),
|
||||
]);
|
||||
@@ -2341,26 +2340,48 @@ private function isValidFormat($data)
|
||||
$data['hub_cadeb_penghuni'] => ($data['hub_cadeb_penghuni'] == 'sesuai') ? $data['hub_cadeb_penghuni_sesuai'] : $data['hub_penghuni_tidak_sesuai']
|
||||
],
|
||||
'pihak_bank' => $data['pihak_bank'] ?? null,
|
||||
'nomor_nib' => $data['nomor_nib'] ?? null,
|
||||
|
||||
'kordinat_lng' => $data['kordinat_lng'] ?? null,
|
||||
'kordinat_lat' => $data['kordinat_lat'] ?? null,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function updateFormData(array &$dataForm, array $data, $inspeksi, string $section, string $key, string $sesuaiKey, string $tidakSesuaiKey): void
|
||||
{
|
||||
if (isset($dataForm[$section][$key])) {
|
||||
$dataForm[$section][$key] = []; // Reset data
|
||||
|
||||
if ($data[$key] == 'sesuai') {
|
||||
$dataForm[$section][$key]['sesuai'] = $data[$sesuaiKey] ?? null;
|
||||
} elseif ($data[$key] == 'tidak sesuai') {
|
||||
$dataForm[$section][$key]['tidak sesuai'] = $data[$tidakSesuaiKey] ?? null;
|
||||
}
|
||||
|
||||
if ($inspeksi) {
|
||||
$inspeksi->data_form = json_encode($dataForm);
|
||||
$inspeksi->save();
|
||||
}
|
||||
} else {
|
||||
$data[$key] = $this->getFieldData($data, $key, true);
|
||||
}
|
||||
}
|
||||
|
||||
private function getTanahData(array $data): array
|
||||
{
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $data['permohonan_id'])->where('dokument_id', $data['dokument_id'])->first();
|
||||
|
||||
// Decode data_form dari inspeksi
|
||||
$dataForm = $inspeksi ? json_decode($inspeksi->data_form, true) : [];
|
||||
$this->updateFormData($dataForm, $data, $inspeksi, 'tanah', 'luas_tanah', 'luas_tanah_sesuai', 'luas_tanah_tidak_sesuai');
|
||||
$this->updateFormData($dataForm, $data, $inspeksi, 'tanah', 'hadap_mata_angin', 'hadap_mata_angin_sesuai', 'hadap_mata_angin_tidak_sesuai');
|
||||
// dd($dataForm);
|
||||
|
||||
return [
|
||||
'tanah' => [
|
||||
'luas_tanah' => $this->getFieldData(
|
||||
$data,
|
||||
'luas_tanah',
|
||||
true
|
||||
),
|
||||
'hadap_mata_angin' => [
|
||||
$data['hadap_mata_angin'] => $data['hadap_mata_angin'] == 'sesuai' ? $data['hadap_mata_angin_sesuai'] : $data['hadap_mata_angin_tidak_sesuai'] ?? null
|
||||
],
|
||||
'luas_tanah' => $dataForm['tanah']['luas_tanah'] ?? $data['luas_tanah'],
|
||||
'hadap_mata_angin' => $dataForm['tanah']['hadap_mata_angin'] ?? $data['hadap_mata_angin'],
|
||||
'bentuk_tanah' => $this->getFieldData(
|
||||
$data,
|
||||
'bentuk_tanah',
|
||||
@@ -2433,14 +2454,16 @@ private function isValidFormat($data)
|
||||
}
|
||||
}
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $data['permohonan_id'])->where('dokument_id', $data['dokument_id'])->first();
|
||||
|
||||
// Decode data_form dari inspeksi
|
||||
$dataForm = $inspeksi ? json_decode($inspeksi->data_form, true) : [];
|
||||
$this->updateFormData($dataForm, $data, $inspeksi, 'bangunan', 'luas_tanah_bagunan', 'luas_tanah_bagunan_sesuai', 'luas_tanah_bagunan_tidak_sesuai');
|
||||
|
||||
|
||||
return [
|
||||
'bangunan' => [
|
||||
'luas_tanah_bagunan' => $this->getFieldData(
|
||||
$data,
|
||||
'luas_tanah_bagunan',
|
||||
true
|
||||
),
|
||||
'luas_tanah_bagunan' => $dataForm['bangunan']['luas_tanah_bagunan'] ?? $data['luas_tanah_bagunan'],
|
||||
'jenis_bangunan' => $data['jenis_bangunan'] ?? null,
|
||||
'kondisi_bangunan' => $data['kondisi_bangunan'] ?? null,
|
||||
'sifat_bangunan' => $data['sifat_bangunan'] ?? null,
|
||||
@@ -3115,6 +3138,7 @@ private function isValidFormat($data)
|
||||
|
||||
private function getUnitData($data, $request): array
|
||||
{
|
||||
|
||||
return [
|
||||
'action' => $data['action'] ?? null,
|
||||
'luas_unit' => $this->getFieldData(
|
||||
@@ -3196,26 +3220,32 @@ private function isValidFormat($data)
|
||||
bool $checkKesesuaian = false,
|
||||
?string $extraField = null
|
||||
): array {
|
||||
$result = [];
|
||||
|
||||
if ($checkKesesuaian) {
|
||||
return [
|
||||
$data[$fieldName] ?? '' => ($data[$fieldName] ?? '') === 'sesuai'
|
||||
? ($data["{$fieldName}_sesuai"] ?? '')
|
||||
: ($data["{$fieldName}_tidak_sesuai"] ?? '')
|
||||
];
|
||||
$isSesuai = ($data[$fieldName] ?? '') === 'sesuai';
|
||||
$fieldKey = $isSesuai ? "{$fieldName}_sesuai" : "{$fieldName}_tidak_sesuai";
|
||||
|
||||
// Hanya simpan key yang dipilih
|
||||
if ($isSesuai) {
|
||||
$result['sesuai'] = $data[$fieldKey] ?? null;
|
||||
} else {
|
||||
$result['tidak sesuai'] = $data[$fieldKey] ?? null;
|
||||
}
|
||||
} else {
|
||||
$result[$fieldName] = $data[$fieldName] ?? null;
|
||||
|
||||
if ($extraField) {
|
||||
$result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
$fieldName => $data[$fieldName] ?? null
|
||||
];
|
||||
|
||||
if ($extraField) {
|
||||
$result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
// Hapus key dengan nilai null untuk memastikan hanya key yang valid yang disimpan
|
||||
return array_filter($result, fn ($value) => $value !== null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function export(string $type)
|
||||
{
|
||||
$modelClass = $this->getModelClass($type);
|
||||
@@ -3256,10 +3286,11 @@ private function isValidFormat($data)
|
||||
->first();
|
||||
|
||||
if (!$inspeksi) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Data inspeksi tidak ditemukan'
|
||||
], 404);
|
||||
$inspeksi = new Inspeksi();
|
||||
$inspeksi->permohonan_id = $request->input('permohonan_id');
|
||||
$inspeksi->dokument_id = $request->input('document_id');
|
||||
$inspeksi->data_form = json_encode([]); // Inisialisasi data_form kosong
|
||||
$inspeksi->save();
|
||||
}
|
||||
|
||||
// Decode data form yang ada
|
||||
@@ -3416,36 +3447,43 @@ private function isValidFormat($data)
|
||||
|
||||
public function print_out_inspeksi($permohonan_id, $dokument_id, $jenis_jaminan_id)
|
||||
{
|
||||
$permohonan = $this->getPermohonanJaminanId(
|
||||
$permohonan_id,
|
||||
$dokument_id,
|
||||
$jenis_jaminan_id
|
||||
);
|
||||
// Ambil data permohonan dan data umum
|
||||
$permohonan = $this->getPermohonanJaminanId($permohonan_id, $dokument_id, $jenis_jaminan_id);
|
||||
$basicData = $this->getCommonData();
|
||||
|
||||
// Ambil data inspeksi
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonan_id)
|
||||
->where('dokument_id', $dokument_id)
|
||||
->first();
|
||||
|
||||
$forminspeksi = null;
|
||||
|
||||
if ($inspeksi) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
if (!$inspeksi) {
|
||||
// Redirect jika inspeksi tidak ditemukan
|
||||
return redirect()->back()->with('error', 'Data inspeksi tidak ditemukan.');
|
||||
}
|
||||
|
||||
// Cek jika forminspeksi kosong
|
||||
// Decode data form inspeksi
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
|
||||
if (!$forminspeksi) {
|
||||
// Redirect kembali dengan pesan error
|
||||
return redirect()->back()->with('error', 'Silahkan isi terlebih dahulu form inspeksi');
|
||||
// Redirect jika data form inspeksi kosong
|
||||
return redirect()->back()->with('error', 'Silahkan isi terlebih dahulu form inspeksi.');
|
||||
}
|
||||
|
||||
// Pilih template PDF berdasarkan nama inspeksi
|
||||
$templateView = strtolower($inspeksi->name) === 'rap'
|
||||
? 'lpj::surveyor.components.print-out.main'
|
||||
: 'lpj::surveyor.components.print-out.main';
|
||||
|
||||
$pdf = PDF::loadView('lpj::surveyor.components.print-out.main', compact(
|
||||
'permohonan',
|
||||
'basicData',
|
||||
'forminspeksi',
|
||||
));
|
||||
// Generate PDF
|
||||
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi'));
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
return $pdf->download('Laporan_data.pdf');
|
||||
|
||||
// Tentukan nama file PDF
|
||||
$namaDebiture = $permohonan->debiture->name . '-' . $permohonan->nomor_registrasi;
|
||||
$fileName = 'inspeksi-' . $namaDebiture . '-data.pdf';
|
||||
|
||||
return $pdf->download($fileName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -293,12 +293,12 @@ class TenderController extends Controller
|
||||
}
|
||||
|
||||
// Kalau tidak ada dokumen jaminan maka di arahkan ke halaman dokumen jaminan
|
||||
if ($permohonan->debiture->documents->isEmpty()) {
|
||||
if ($permohonan->documents->isEmpty()) {
|
||||
return redirect()->route('debitur.jaminan.create', ['id' => $permohonan->debiture->id])
|
||||
->with('error', 'Anda Belum Membuat Dokumen Jaminan. Silahkan isi terlebih dahulu!');
|
||||
}
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -338,12 +338,12 @@ class TenderController extends Controller
|
||||
}
|
||||
|
||||
// Kalau tidak ada dokumen jaminan maka di arahkan ke halaman dokumen jaminan
|
||||
if ($permohonan->debiture->documents->isEmpty()) {
|
||||
if ($permohonan->documents->isEmpty()) {
|
||||
return redirect()->route('debitur.jaminan.create', ['id' => $permohonan->debiture->id])
|
||||
->with('error', 'Anda Belum Membuat Dokumen Jaminan. Silahkan isi terlebih dahulu!');
|
||||
}
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -535,7 +535,7 @@ class TenderController extends Controller
|
||||
return redirect()->route('otorisasitender.penawaran.index')->with('error', 'Penawaran dengan nomor registrasi ini sudah masuk Otorisasi Tender tidak bisa masuk penawaran lagi!');
|
||||
}
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -563,7 +563,7 @@ class TenderController extends Controller
|
||||
return redirect()->route('otorisasitender.penawaran.index')->with('error', 'Penawaran dengan nomor registrasi ini sudah masuk Otorisasi Tender tidak bisa masuk penawaran lagi!');
|
||||
}
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -602,7 +602,7 @@ class TenderController extends Controller
|
||||
return redirect()->route('otorisasitender.penawaran.index')->with('error', 'Penawaran dengan nomor registrasi ini sudah masuk Otorisasi Tender tidak bisa masuk penawaran lagi!');
|
||||
}
|
||||
|
||||
if ($permohonan->debiture->documents->isEmpty()) {
|
||||
if ($permohonan->documents->isEmpty()) {
|
||||
return redirect()->route('debitur.jaminan.create', ['id' => $permohonan->debiture->id])
|
||||
->with('error', 'Anda Belum Membuat Dokumen Jaminan. Silahkan isi terlebih dahulu!');
|
||||
}
|
||||
@@ -679,11 +679,18 @@ class TenderController extends Controller
|
||||
return redirect()->route('otorisasitender.penawaran.index')->with('error', 'Penawaran dengan nomor registrasi ini sudah masuk Otorisasi Tender tidak bisa masuk penawaran lagi!');
|
||||
}
|
||||
|
||||
if ($permohonan->debiture->documents->isEmpty()) {
|
||||
if ($permohonan->documents->isEmpty()) {
|
||||
return redirect()->route('debitur.jaminan.create', ['id' => $permohonan->debiture->id])
|
||||
->with('error', 'Anda Belum Membuat Dokumen Jaminan. Silahkan isi terlebih dahulu!');
|
||||
}
|
||||
|
||||
$detail_penawaran = PenawaranDetailTender::where('penawaran_id', '=', $penawaran->id)->get();
|
||||
|
||||
|
||||
foreach ($detail_penawaran as $detail) {
|
||||
$this->kirimEmailKJPP($noreg,$detail->kjpp_rekanan_id);
|
||||
}
|
||||
|
||||
$detail_penawaran = PenawaranDetailTender::where('penawaran_id', '=', $penawaran->id)
|
||||
->where('status', '=', 1)
|
||||
->pluck('kjpp_rekanan_id')
|
||||
@@ -713,7 +720,7 @@ class TenderController extends Controller
|
||||
];
|
||||
});
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -724,6 +731,7 @@ class TenderController extends Controller
|
||||
$districts = District::where('code', $district_permohonan)->get();
|
||||
$cities = City::where('code', $city_permohonan)->get();
|
||||
$provinces = Province::where('code', $province_permohonan)->get();
|
||||
$user = auth::user();
|
||||
|
||||
$subject = 'Send Penawaran Email';
|
||||
|
||||
@@ -734,7 +742,8 @@ class TenderController extends Controller
|
||||
'villages' => $villages,
|
||||
'districts' => $districts,
|
||||
'cities' => $cities,
|
||||
'provinces' => $provinces
|
||||
'provinces' => $provinces,
|
||||
'user' => $user,
|
||||
])->render();
|
||||
|
||||
// Dispatch job untuk mengirim email
|
||||
@@ -745,7 +754,8 @@ class TenderController extends Controller
|
||||
$villages,
|
||||
$districts,
|
||||
$cities,
|
||||
$provinces
|
||||
$provinces,
|
||||
$user
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -877,7 +887,7 @@ class TenderController extends Controller
|
||||
return redirect()->route('otorisasitender.penawaran.index')->with('error', 'Penawaran dengan nomor registrasi ini sudah masuk Otorisasi Tender tidak bisa masuk penawaran lagi!');
|
||||
}
|
||||
|
||||
if ($permohonan->debiture->documents->isEmpty()) {
|
||||
if ($permohonan->documents->isEmpty()) {
|
||||
return redirect()->route('debitur.jaminan.create', ['id' => $permohonan->debiture->id])
|
||||
->with('error', 'Anda Belum Membuat Dokumen Jaminan. Silahkan isi terlebih dahulu!');
|
||||
}
|
||||
@@ -907,7 +917,7 @@ class TenderController extends Controller
|
||||
|
||||
$dp1 = PenawaranDetailTender::with('kjpp')->where('kjpp_rekanan_id', '=', $id)->first();
|
||||
|
||||
foreach ($permohonan->debiture->documents as $document) {
|
||||
foreach ($permohonan->documents as $document) {
|
||||
$village_permohonan = $document->village_code;
|
||||
$district_permohonan = $document->district_code;
|
||||
$city_permohonan = $document->city_code;
|
||||
@@ -918,6 +928,7 @@ class TenderController extends Controller
|
||||
$districts = District::where('code', $district_permohonan)->get();
|
||||
$cities = City::where('code', $city_permohonan)->get();
|
||||
$provinces = Province::where('code', $province_permohonan)->get();
|
||||
$user = auth()->user();
|
||||
|
||||
$subject = 'Send Penawaran K J P P Email';
|
||||
|
||||
@@ -929,7 +940,8 @@ class TenderController extends Controller
|
||||
'villages' => $villages,
|
||||
'districts' => $districts,
|
||||
'cities' => $cities,
|
||||
'provinces' => $provinces
|
||||
'provinces' => $provinces,
|
||||
'user' => $user,
|
||||
])->render();
|
||||
|
||||
SendPenawaranKJPPTenderJob::dispatch(
|
||||
@@ -940,7 +952,8 @@ class TenderController extends Controller
|
||||
$villages,
|
||||
$districts,
|
||||
$cities,
|
||||
$provinces
|
||||
$provinces,
|
||||
$user
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user