Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into andydev
This commit is contained in:
@@ -79,6 +79,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]) : ''
|
||||
];
|
||||
|
||||
$dokumenJaminan = [];
|
||||
@@ -234,6 +235,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]) : ''
|
||||
];
|
||||
|
||||
$dokumenJaminan = [];
|
||||
@@ -392,17 +394,19 @@
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
|
||||
foreach ($documents as $document) {
|
||||
$files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode(
|
||||
$document->dokumen_jaminan,
|
||||
) : [$document->dokumen_jaminan];
|
||||
if($document->dokumen_jaminan) {
|
||||
$files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode(
|
||||
$document->dokumen_jaminan,
|
||||
) : [$document->dokumen_jaminan];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filePath = storage_path('app/public/' . $file);
|
||||
if (file_exists($filePath)) {
|
||||
$zip->addFile($filePath, basename($filePath));
|
||||
} else {
|
||||
// Log or display an error message for missing files
|
||||
return redirect()->back()->with('error', 'File not found: ' . $filePath);
|
||||
foreach ($files as $file) {
|
||||
$filePath = storage_path('app/public/' . $file);
|
||||
if (file_exists($filePath)) {
|
||||
$zip->addFile($filePath, basename($filePath));
|
||||
} else {
|
||||
// Log or display an error message for missing files
|
||||
return redirect()->back()->with('error', 'File not found: ' . $filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,6 +472,9 @@
|
||||
'dokumen_jaminan' => json_decode(
|
||||
$detail->dokumen_jaminan,
|
||||
) ?? $detail->dokumen_jaminan,
|
||||
'dokumen_nomor' => json_decode(
|
||||
$detail->dokumen_nomor,
|
||||
) ?? $detail->dokumen_nomor,
|
||||
'custom_field' => $detail->jenisLegalitasJaminan->custom_field,
|
||||
'custom_field_type' => $detail->jenisLegalitasJaminan->custom_field_type,
|
||||
'details' => $detail->details,
|
||||
@@ -486,6 +493,7 @@
|
||||
'jenis_legalitas_jaminan_id' => $legalitas->id,
|
||||
'name' => $legalitas->name,
|
||||
'dokumen_jaminan' => null,
|
||||
'dokumen_nomor' => null,
|
||||
'custom_field' => $legalitas->custom_field,
|
||||
'custom_field_type' => $legalitas->custom_field_type,
|
||||
'details' => null,
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace Modules\Lpj\Http\Controllers;
|
||||
use Throwable;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\KJPP;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Lpj\Models\IjinUsaha;
|
||||
use Modules\Lpj\Exports\KJPPExport;
|
||||
@@ -58,6 +56,79 @@ class KJPPController extends Controller
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($validated) {
|
||||
$detailEmailKantor = [];
|
||||
$detailNamaPicReviewer = [];
|
||||
$detailNomorHpPicReviewer = [];
|
||||
$detailNamaPicAdmin = [];
|
||||
$detailNomorHpPicAdmin = [];
|
||||
$detailNamaPicMarketing = [];
|
||||
$detailNomorHpPicMarketing = [];
|
||||
|
||||
$emailKantor = $request->input('detail_email_kantor.email_kantor', []);
|
||||
$namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []);
|
||||
$nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []);
|
||||
$namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []);
|
||||
$nomorHpPicAdmin = $request->input('detail_nomor_hp_pic_admin.nomor_hp_pic_admin', []);
|
||||
$namaPicMarketing = $request->input('detail_nama_pic_marketing.nama_pic_marketing', []);
|
||||
$nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []);
|
||||
|
||||
foreach ($emailKantor as $value) {
|
||||
$detailEmailKantor[] = [
|
||||
'email_kantor' => $value
|
||||
];
|
||||
}
|
||||
// Encode to JSON and store
|
||||
$detailEmailKantorJson = json_encode($detailEmailKantor);
|
||||
|
||||
// Process detail_nama_pic_reviewer
|
||||
foreach ($namaPicReviewer as $value) {
|
||||
$detailNamaPicReviewer[] = [
|
||||
'nama_pic_reviewer' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer);
|
||||
|
||||
// Process detail_nomor_hp_pic_reviewer
|
||||
foreach ($nomorHpPicReviewer as $value) {
|
||||
$detailNomorHpPicReviewer[] = [
|
||||
'nomor_hp_pic_reviewer' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer);
|
||||
|
||||
// Process detail_nama_pic_admin
|
||||
foreach ($namaPicAdmin as $value) {
|
||||
$detailNamaPicAdmin[] = [
|
||||
'nama_pic_admin' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicAdminJson = json_encode($detailNamaPicAdmin);
|
||||
|
||||
// Process detail_nomor_hp_pic_admin
|
||||
foreach ($nomorHpPicAdmin as $value) {
|
||||
$detailNomorHpPicAdmin[] = [
|
||||
'nomor_hp_pic_admin' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin);
|
||||
|
||||
// Process detail_nama_pic_marketing
|
||||
foreach ($namaPicMarketing as $value) {
|
||||
$detailNamaPicMarketing[] = [
|
||||
'nama_pic_marketing' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing);
|
||||
|
||||
// Process detail_nomor_hp_pic_marketing
|
||||
foreach ($nomorHpPicMarketing as $value) {
|
||||
$detailNomorHpPicMarketing[] = [
|
||||
'nomor_hp_pic_marketing' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing);
|
||||
|
||||
|
||||
$file = $request->file('attachment');
|
||||
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : 'default.pdf';
|
||||
|
||||
@@ -69,12 +140,20 @@ class KJPPController extends Controller
|
||||
Storage::copy('public/test/default.pdf', 'public/uploads_pdf/' . $filename);
|
||||
}
|
||||
|
||||
$validated['ijin_usaha_id'] = json_encode($request->input('ijin_usaha_id'));
|
||||
$validated['jenis_aset_id'] = json_encode($request->input('jenis_aset_id'));
|
||||
|
||||
$validated['detail_email_kantor'] = $detailEmailKantorJson;
|
||||
$validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson;
|
||||
$validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson;
|
||||
$validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson;
|
||||
$validated['detail_nomor_hp_pic_admin'] = $detailNomorHpPicAdminJson;
|
||||
$validated['detail_nama_pic_marketing'] = $detailNamaPicMarketingJson;
|
||||
$validated['detail_nomor_hp_pic_marketing'] = $detailNomorHpPicMarketingJson;
|
||||
$validated['ijin_usaha_id'] = json_encode($validated['ijin_usaha_id']);
|
||||
$validated['jenis_aset_id'] = json_encode($validated['jenis_aset_id']);
|
||||
// Tambahkan nama file ke data yang divalidasi
|
||||
$validated['attachment'] = $filename;
|
||||
|
||||
// dd($validated);
|
||||
|
||||
// Simpan data ke database
|
||||
KJPP::create($validated);
|
||||
|
||||
@@ -101,8 +180,36 @@ class KJPPController extends Controller
|
||||
$cities = City::where('code', $kjpp->city_code)->get();
|
||||
$districts = District::where('code', $kjpp->district_code)->get();
|
||||
$villages = Village::where('code', $kjpp->village_code)->get();
|
||||
// dd($branches);
|
||||
return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages'));
|
||||
$detailEmailKantor = json_decode($kjpp->detail_email_kantor);
|
||||
$detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer);
|
||||
$detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer);
|
||||
$detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin);
|
||||
$detailNomorHpPicAdmin = json_decode($kjpp->detail_nomor_hp_pic_admin);
|
||||
$detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing);
|
||||
$detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing);
|
||||
|
||||
$detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_reviewer' => $nama->nama_pic_reviewer,
|
||||
'nomor_hp_pic_reviewer' => $nomor->nomor_hp_pic_reviewer
|
||||
];
|
||||
}, $detailNamaPicReviewer, $detailNomorHpPicReviewer));
|
||||
|
||||
$detailJoinPicAdmin = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_admin' => $nama->nama_pic_admin,
|
||||
'nomor_hp_pic_admin' => $nomor->nomor_hp_pic_admin
|
||||
];
|
||||
}, $detailNamaPicAdmin, $detailNomorHpPicAdmin));
|
||||
|
||||
$detailJoinPicMarketing = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_marketing' => $nama->nama_pic_marketing,
|
||||
'nomor_hp_pic_marketing' => $nomor->nomor_hp_pic_marketing
|
||||
];
|
||||
}, $detailNamaPicMarketing, $detailNomorHpPicMarketing));
|
||||
|
||||
return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages', 'detailEmailKantor', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +224,36 @@ class KJPPController extends Controller
|
||||
$cities = City::where('province_code', $kjpp->province_code)->get();
|
||||
$districts = District::where('city_code', $kjpp->city_code)->get();
|
||||
$villages = Village::where('district_code', $kjpp->district_code)->get();
|
||||
$detailEmailKantor = json_decode($kjpp->detail_email_kantor);
|
||||
$detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer);
|
||||
$detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer);
|
||||
$detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin);
|
||||
$detailNomorHpPicAdmin = json_decode($kjpp->detail_nomor_hp_pic_admin);
|
||||
$detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing);
|
||||
$detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing);
|
||||
|
||||
return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages'));
|
||||
$detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_reviewer' => $nama->nama_pic_reviewer,
|
||||
'nomor_hp_pic_reviewer' => $nomor->nomor_hp_pic_reviewer
|
||||
];
|
||||
}, $detailNamaPicReviewer, $detailNomorHpPicReviewer));
|
||||
|
||||
$detailJoinPicAdmin = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_admin' => $nama->nama_pic_admin,
|
||||
'nomor_hp_pic_admin' => $nomor->nomor_hp_pic_admin
|
||||
];
|
||||
}, $detailNamaPicAdmin, $detailNomorHpPicAdmin));
|
||||
|
||||
$detailJoinPicMarketing = json_encode(array_map(function ($nama, $nomor) {
|
||||
return [
|
||||
'nama_pic_marketing' => $nama->nama_pic_marketing,
|
||||
'nomor_hp_pic_marketing' => $nomor->nomor_hp_pic_marketing
|
||||
];
|
||||
}, $detailNamaPicMarketing, $detailNomorHpPicMarketing));
|
||||
|
||||
return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailEmailKantor'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +263,82 @@ class KJPPController extends Controller
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
// dd($validated);
|
||||
|
||||
if ($validated) {
|
||||
$detailEmailKantor = [];
|
||||
$detailNamaPicReviewer = [];
|
||||
$detailNomorHpPicReviewer = [];
|
||||
$detailNamaPicAdmin = [];
|
||||
$detailNomorHpPicAdmin = [];
|
||||
$detailNamaPicMarketing = [];
|
||||
$detailNomorHpPicMarketing = [];
|
||||
|
||||
$emailKantor = $request->input('detail_email_kantor.email_kantor', []);
|
||||
$namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []);
|
||||
$nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []);
|
||||
$namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []);
|
||||
$nomorHpPicAdmin = $request->input('detail_nomor_hp_pic_admin.nomor_hp_pic_admin', []);
|
||||
$namaPicMarketing = $request->input('detail_nama_pic_marketing.nama_pic_marketing', []);
|
||||
$nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []);
|
||||
|
||||
foreach ($emailKantor as $value) {
|
||||
$detailEmailKantor[] = [
|
||||
'email_kantor' => $value
|
||||
];
|
||||
}
|
||||
// Encode to JSON and store
|
||||
$detailEmailKantorJson = json_encode($detailEmailKantor);
|
||||
|
||||
// Process detail_nama_pic_reviewer
|
||||
foreach ($namaPicReviewer as $value) {
|
||||
$detailNamaPicReviewer[] = [
|
||||
'nama_pic_reviewer' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer);
|
||||
|
||||
// Process detail_nomor_hp_pic_reviewer
|
||||
foreach ($nomorHpPicReviewer as $value) {
|
||||
$detailNomorHpPicReviewer[] = [
|
||||
'nomor_hp_pic_reviewer' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer);
|
||||
|
||||
// Process detail_nama_pic_admin
|
||||
foreach ($namaPicAdmin as $value) {
|
||||
$detailNamaPicAdmin[] = [
|
||||
'nama_pic_admin' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicAdminJson = json_encode($detailNamaPicAdmin);
|
||||
|
||||
// Process detail_nomor_hp_pic_admin
|
||||
foreach ($nomorHpPicAdmin as $value) {
|
||||
$detailNomorHpPicAdmin[] = [
|
||||
'nomor_hp_pic_admin' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin);
|
||||
|
||||
// Process detail_nama_pic_marketing
|
||||
foreach ($namaPicMarketing as $value) {
|
||||
$detailNamaPicMarketing[] = [
|
||||
'nama_pic_marketing' => $value
|
||||
];
|
||||
}
|
||||
$detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing);
|
||||
|
||||
// Process detail_nomor_hp_pic_marketing
|
||||
foreach ($nomorHpPicMarketing as $value) {
|
||||
$detailNomorHpPicMarketing[] = [
|
||||
'nomor_hp_pic_marketing' => $value
|
||||
];
|
||||
}
|
||||
$detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing);
|
||||
|
||||
|
||||
$file = $request->file('attachment');
|
||||
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : null;
|
||||
|
||||
@@ -148,6 +358,16 @@ class KJPPController extends Controller
|
||||
$validated['attachment'] = $kjpp->attachment ?? 'default.pdf';
|
||||
}
|
||||
|
||||
$validated['detail_email_kantor'] = $detailEmailKantorJson;
|
||||
$validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson;
|
||||
$validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson;
|
||||
$validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson;
|
||||
$validated['detail_nomor_hp_pic_admin'] = $detailNomorHpPicAdminJson;
|
||||
$validated['detail_nama_pic_marketing'] = $detailNamaPicMarketingJson;
|
||||
$validated['detail_nomor_hp_pic_marketing'] = $detailNomorHpPicMarketingJson;
|
||||
$validated['ijin_usaha_id'] = json_encode($validated['ijin_usaha_id']);
|
||||
$validated['jenis_aset_id'] = json_encode($validated['jenis_aset_id']);
|
||||
|
||||
// Perbarui data di database
|
||||
KJPP::where('id', $id)->update($validated);
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ class PenilaianController extends Controller
|
||||
});
|
||||
})->unique('id');
|
||||
|
||||
$existingTeamIds = $teamPenilai->pluck('id')->toArray();
|
||||
$existingTeamIds = $userTeam->pluck('id')->toArray();
|
||||
|
||||
$updateTeamPenilai = Teams::with(['regions', 'teamsUsers', 'teamsUsers.user'])
|
||||
->whereNotIn('id', $existingTeamIds)
|
||||
@@ -232,23 +232,14 @@ class PenilaianController extends Controller
|
||||
foreach ($userTeam as $item) {
|
||||
$regionName = $item->regions;
|
||||
}
|
||||
// $regionName = $userTeam->first()?->regions->name;
|
||||
|
||||
|
||||
|
||||
$penilaian = Penilaian::where('nomor_registrasi', $permohonan->nomor_registrasi)->first();
|
||||
|
||||
|
||||
$penilaianTeam = collect();
|
||||
if ($penilaian && $penilaian->id) {
|
||||
$penilaianTeam = PenilaianTeam::where('penilaian_id', $penilaian->id)->get();
|
||||
}
|
||||
|
||||
// return response()->json([
|
||||
// 'penilaianTeam' => $penilaianTeam
|
||||
// ]);
|
||||
|
||||
|
||||
return view('lpj::penilaian.form', compact('permohonan', 'teamPenilai', 'jenisPenilaian', 'penilaian', 'regionName', 'updateTeamPenilai', 'penilaianTeam'));
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,17 @@
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Models\TujuanPenilaian;
|
||||
use Modules\Lpj\Services\PermohonanHistoryService;
|
||||
|
||||
class PermohonanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
protected $historyService;
|
||||
|
||||
public function __construct(PermohonanHistoryService $historyService)
|
||||
{
|
||||
$this->historyService = $historyService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
@@ -36,8 +43,30 @@
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Process file upload
|
||||
$filePath = null;
|
||||
if ($request->hasFile('attachment')) {
|
||||
$file = $request->file('attachment');
|
||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||
$filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
|
||||
}
|
||||
|
||||
// Get keterangan if provided
|
||||
$keterangan = $request->input('keterangan') ?? null;
|
||||
|
||||
|
||||
// Save to database
|
||||
Permohonan::create($validate);
|
||||
$permohonan = Permohonan::create($validate);
|
||||
|
||||
// Create history
|
||||
$this->historyService->createHistory(
|
||||
$permohonan,
|
||||
$validate['status'],
|
||||
$keterangan,
|
||||
[], // beforeRequest is empty for new permohonan
|
||||
$permohonan->toArray(),
|
||||
$filePath
|
||||
);
|
||||
return redirect()
|
||||
->route('permohonan.index')->with('success', 'Permohonan created successfully');
|
||||
} catch (Exception $e) {
|
||||
@@ -107,16 +136,41 @@
|
||||
|
||||
public function update(PermohonanRequest $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
$beforeRequest = $permohonan->toArray();
|
||||
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$permohonan = Permohonan::find($id);
|
||||
|
||||
if ($permohonan->status == 'revisi') {
|
||||
$validate['status'] = 'order';
|
||||
}
|
||||
|
||||
$permohonan->update($validate);
|
||||
|
||||
$afterRequest = $permohonan->fresh()->toArray();
|
||||
// Process file upload
|
||||
$file = null;
|
||||
if ($request->hasFile('attachment')) {
|
||||
$file = $request->file('attachment');
|
||||
}
|
||||
|
||||
// Get keterangan if provided
|
||||
$keterangan = $request->input('keterangan') ?? null;
|
||||
|
||||
$status =$validate['status'] ?? $permohonan->status;
|
||||
|
||||
$this->historyService->createHistory(
|
||||
$permohonan,
|
||||
$status,
|
||||
$keterangan,
|
||||
$beforeRequest,
|
||||
$afterRequest,
|
||||
$file
|
||||
);
|
||||
|
||||
return redirect()
|
||||
->route('permohonan.index')->with('success', 'Permohonan updated successfully');
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -145,7 +145,6 @@
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
// $id => penawaran.id
|
||||
return view('lpj::registrasifinal.edit', compact('id'));
|
||||
}
|
||||
|
||||
@@ -173,7 +172,7 @@
|
||||
if ($datas->dokumen) {
|
||||
$pdfSPK_path = Storage::url($datas->dokumen);
|
||||
$datas->dokumen = $pdfSPK_path;
|
||||
}
|
||||
}
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['regions'] = $regions;
|
||||
|
||||
@@ -152,13 +152,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
'kjpp.address as kjpp_address',
|
||||
'jenis_laporan.name as jenis_laporan_name'
|
||||
)->first();
|
||||
// date_range
|
||||
if($penawaran->start_date && $penawaran->end_date)
|
||||
{
|
||||
$penawaran->date_range = Carbon::parse($penawaran->start_date)->format('d M Y').' - '.Carbon::parse($penawaran->end_date)->format('d M Y');
|
||||
|
||||
}
|
||||
|
||||
|
||||
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)
|
||||
->leftJoin('dokumen_jaminan', 'dokumen_jaminan.permohonan_id','=','permohonan.id')
|
||||
->leftJoin('jenis_jaminan', 'jenis_jaminan.id','=','dokumen_jaminan.jenis_jaminan_id')
|
||||
@@ -187,13 +181,6 @@ use Illuminate\Support\Facades\Auth;
|
||||
'kjpp.address as kjpp_address',
|
||||
'jenis_laporan.name as jenis_laporan_name'
|
||||
)->first();
|
||||
|
||||
// date_range
|
||||
if($penawaran->start_date && $penawaran->end_date)
|
||||
{
|
||||
$penawaran->date_range = Carbon::parse($penawaran->start_date)->format('d M Y').' - '.Carbon::parse($penawaran->end_date)->format('d M Y');
|
||||
|
||||
}
|
||||
|
||||
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)
|
||||
->leftJoin('dokumen_jaminan', 'dokumen_jaminan.permohonan_id','=','permohonan.id')
|
||||
@@ -254,4 +241,9 @@ use Illuminate\Support\Facades\Auth;
|
||||
return view('lpj::spk.dokumennya', compact('data', 'penawaran'));
|
||||
}
|
||||
|
||||
public function download($id) {
|
||||
$document = Permohonan::find($id);
|
||||
|
||||
return response()->download(storage_path('app/public/' .$document->dokumen));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use Modules\Lpj\Models\SpekKategoritBangunan;
|
||||
use Modules\Lpj\Models\SaranaPelengkap;
|
||||
use Modules\Lpj\Models\ArahMataAngin;
|
||||
use Modules\Lpj\Models\Analisa;
|
||||
use Modules\Lpj\Models\PerkerasanJalan;
|
||||
use Modules\Lpj\Models\AnalisaFakta;
|
||||
use Modules\Lpj\Models\AnalisaLingkungan;
|
||||
use Modules\Lpj\Models\AnalisaTanahBagunan;
|
||||
@@ -591,6 +592,7 @@ class SurveyorController extends Controller
|
||||
$golMasySekitar = GolonganMasySekitar::all();
|
||||
$tingkatKeramaian = TingkatKeramaian::all();
|
||||
$laluLintasLokasi = LaluLintasLokasi::all();
|
||||
$perkerasanJalan = PerkerasanJalan::all();
|
||||
|
||||
|
||||
$analisa = Analisa::with('analisaTanahBangunan', 'analisaLingkungan', 'analisaFakta', 'jenisJaminan')
|
||||
@@ -598,6 +600,7 @@ class SurveyorController extends Controller
|
||||
->where('jenis_jaminan_id', $jaminanId)
|
||||
->first();
|
||||
|
||||
// return response()->json($permohonan);
|
||||
|
||||
|
||||
return view('lpj::surveyor.components.inspeksi', compact(
|
||||
@@ -622,7 +625,8 @@ class SurveyorController extends Controller
|
||||
'viewUnit',
|
||||
'golMasySekitar',
|
||||
'tingkatKeramaian',
|
||||
'laluLintasLokasi'
|
||||
'laluLintasLokasi',
|
||||
'perkerasanJalan'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -714,27 +718,27 @@ class SurveyorController extends Controller
|
||||
try {
|
||||
$type = $request->route('type');
|
||||
|
||||
$modelClass = $this->getModelClass($type);
|
||||
$modelClass = $this->getModelClass($type);
|
||||
|
||||
if (!$modelClass) {
|
||||
return redirect()
|
||||
->route('basicdata.'. $type .'.index')
|
||||
->with('error', 'Invalid type specified.');
|
||||
}
|
||||
|
||||
if ($type == 'spek-bangunan') {
|
||||
$validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$data = array_merge($validate, ['status' => true]);
|
||||
$modelClass::create($data);
|
||||
|
||||
if (!$modelClass) {
|
||||
return redirect()
|
||||
->route('basicdata.'. $type .'.index')
|
||||
->with('error', 'Invalid type specified.');
|
||||
}
|
||||
->route('basicdata.' . $type .'.index')
|
||||
->with('success', 'created successfully');
|
||||
|
||||
if ($type == 'spek-bangunan') {
|
||||
$validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$data = array_merge($validate, ['status' => true]);
|
||||
$modelClass::create($data);
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.' . $type .'.index')
|
||||
->with('success', 'created successfully');
|
||||
|
||||
} catch (Exeception $e) {
|
||||
|
||||
return response()->json(array('error' => $e->getMessage()), 400);
|
||||
@@ -842,6 +846,7 @@ class SurveyorController extends Controller
|
||||
'Golongan Masyarakat Sekitar' => GolonganMasySekitar::class,
|
||||
'Lantai Unit' => Lantai::class,
|
||||
'View Unit' => ViewUnit::class,
|
||||
'Perkerasan jalan' => PerkerasanJalan::class
|
||||
];
|
||||
|
||||
|
||||
@@ -961,7 +966,8 @@ class SurveyorController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function validateSubmit(){
|
||||
public function validateSubmit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1039,6 +1045,7 @@ class SurveyorController extends Controller
|
||||
'spek-bangunan' => ['Spek Bangunan', 'spek-bangunan'],
|
||||
'lantai-unit' => ['Lantai Unit', 'lantai-unit'],
|
||||
'view-unit' => ['View Unit', 'view-unit'],
|
||||
'perkerasan-jalan' => ['Perkerasan jalan', 'perkerasan-jalan']
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use daengdeni\LaravelIdGenerator\IdGenerator;
|
||||
|
||||
class KJPPRequest extends FormRequest
|
||||
{
|
||||
@@ -17,21 +16,28 @@ class KJPPRequest extends FormRequest
|
||||
'jenis_kantor' => 'required',
|
||||
'nomor_ijin_usaha' => 'required',
|
||||
'province_code' => 'required',
|
||||
'city_code' => 'required',
|
||||
'district_code' => 'required',
|
||||
'village_code' => 'required',
|
||||
'city_code' => 'nullable',
|
||||
'district_code' => 'nullable',
|
||||
'village_code' => 'nullable',
|
||||
'address' => 'required',
|
||||
'postal_code' => 'required|numeric',
|
||||
'nomor_telepon_kantor' => 'required|numeric|digits_between:8,15',
|
||||
'postal_code' => 'nullable|numeric',
|
||||
'nomor_telepon_kantor' => 'nullable|numeric|digits_between:8,15',
|
||||
'email_kantor' => 'required|email',
|
||||
'detail_email_kantor' => 'nullable',
|
||||
'nama_pimpinan' => 'required|string|not_regex:/^\d+$/|max:255',
|
||||
'nomor_hp_pimpinan' => 'required|numeric|digits_between:10,15',
|
||||
'nama_pic_reviewer' => 'required|string|not_regex:/^\d+$/|max:255',
|
||||
'nomor_hp_pic_reviewer' => 'required|numeric|digits_between:10,15',
|
||||
'nama_pic_admin' => 'required|string|not_regex:/^\d+$/|max:255',
|
||||
'nomor_hp_pic_admin' => 'required|numeric|digits_between:10,15',
|
||||
'nama_pic_marketing' => 'required|string|not_regex:/^\d+$/|max:255',
|
||||
'nomor_hp_pic_marketing' => 'required|numeric|digits_between:10,15',
|
||||
'nama_pic_reviewer' => 'nullable|string|not_regex:/^\d+$/|max:255',
|
||||
'detail_nama_pic_reviewer' => 'nullable',
|
||||
'nomor_hp_pic_reviewer' => 'nullable|numeric|digits_between:10,15',
|
||||
'detail_nomor_hp_pic_reviewer' => 'nullable',
|
||||
'nama_pic_admin' => 'nullable|string|not_regex:/^\d+$/|max:255',
|
||||
'detail_nama_pic_admin' => 'nullable',
|
||||
'nomor_hp_pic_admin' => 'nullable|numeric|digits_between:10,15',
|
||||
'detail_nomor_hp_pic_admin' => 'nullable',
|
||||
'nama_pic_marketing' => 'nullable|string|not_regex:/^\d+$/|max:255',
|
||||
'detail_nama_pic_marketing' => 'nullable',
|
||||
'nomor_hp_pic_marketing' => 'nullable|numeric|digits_between:10,15',
|
||||
'detail_nomor_hp_pic_marketing' => 'nullable',
|
||||
'ijin_usaha_id' => 'required|array',
|
||||
'ijin_usaha_id.*' => 'exists:ijin_usaha,code',
|
||||
'jenis_aset_id' => 'required|array',
|
||||
@@ -69,13 +75,8 @@ class KJPPRequest extends FormRequest
|
||||
'nomor_ijin_usaha.required' => 'Nomor Ijin Usaha Wajib diisi!',
|
||||
'nomor_ijin_usaha.max' => 'Nomor Ijin Usaha maksimal 255 huruf!',
|
||||
'province_code.required' => 'Provinsi Wajib diisi!',
|
||||
'city_code.required' => 'Kota / Kabupaten Wajib diisi!',
|
||||
'district_code.required' => 'Kecamatan Wajib diisi!',
|
||||
'village_code.required' => 'Kelurahan Wajib diisi!',
|
||||
'postal_code.required' => 'Kode Pos Wajib diisi!',
|
||||
'postal_code.numeric' => 'Kode Pos harus berupa angka!',
|
||||
'address.required' => 'Alamat Kantor Wajib diisi!',
|
||||
'nomor_telepon_kantor.required' => 'Nomor Telepon Kantor Wajib diisi!',
|
||||
'nomor_telepon_kantor.numeric' => 'Nomor Telepon Kantor harus berupa angka!',
|
||||
'nomor_telepon_kantor.digits_between' => 'Nomor Telepon Kantor minimum 8 digit dan maksimum 15 digit!',
|
||||
'email_kantor.required' => 'Email Kantor Wajib diisi!',
|
||||
@@ -85,25 +86,17 @@ class KJPPRequest extends FormRequest
|
||||
'nomor_hp_pimpinan.required' => 'Nomor HP Pimpinan Wajib diisi!',
|
||||
'nomor_hp_pimpinan.numeric' => 'Nomor HP Pimpinan harus berupa angka!',
|
||||
'nomor_hp_pimpinan.digits_between' => 'Nomor HP Pimpinan minimum 10 digit dan maksimum 15 digit!',
|
||||
'nama_pic_reviewer.required' => 'Nama PIC Reviewer Wajib diisi!',
|
||||
'nama_pic_reviewer.not_regex' => 'Nama PIC Reviewer harus berupa huruf!',
|
||||
'nomor_hp_pic_reviewer.required' => 'Nomor HP PIC Reviewer Wajib diisi!',
|
||||
'nomor_hp_pic_reviewer.numeric' => 'Nomor HP PIC Reviewer harus berupa angka!',
|
||||
'nomor_hp_pic_reviewer.digits_between' => 'Nomor HP PIC Reviewer minimum 10 digit dan maksimum 15 digit!',
|
||||
'nama_pic_admin.required' => 'Nama PIC Admin Wajib diisi!',
|
||||
'nama_pic_admin.not_regex' => 'Nama PIC Admin harus berupa huruf!',
|
||||
'nomor_hp_pic_admin.required' => 'Nomor HP PIC Admin Wajib diisi!',
|
||||
'nomor_hp_pic_admin.numeric' => 'Nomor HP PIC Admin harus berupa angka!',
|
||||
'nomor_hp_pic_admin.digits_between' => 'Nomor HP PIC Admin minimum 10 digit dan maksimum 15 digit!',
|
||||
'nama_pic_marketing.required' => 'Nama PIC Marketing Wajib diisi!',
|
||||
'nama_pic_marketing.not_regex' => 'Nama PIC Marketing harus berupa huruf!',
|
||||
'nomor_hp_pic_marketing.required' => 'Nomor HP PIC Marketing Wajib diisi!',
|
||||
'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!',
|
||||
'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!',
|
||||
'ijin_usaha_id.required' => 'Ijin Usaha Wajib diisi!',
|
||||
'ijin_usaha_id.min' => 'Ijin Usaha Wajib diisi minimal satu atau lebih!',
|
||||
'jenis_aset_id.required' => 'Jenis Aset Wajib diisi!',
|
||||
'jenis_aset_id.min' => 'Jenis Aset Wajib diisi minimal satu atau lebih!',
|
||||
'attachment.mimes' => 'Attachment harus berformat pdf!',
|
||||
'attachment.max' => 'Attachment berukuran maksimum 1 MB!',
|
||||
];
|
||||
|
||||
@@ -18,29 +18,5 @@ class KJPP extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'jenis_kantor',
|
||||
'nomor_ijin_usaha',
|
||||
'province_code',
|
||||
'city_code',
|
||||
'district_code',
|
||||
'village_code',
|
||||
'address',
|
||||
'postal_code',
|
||||
'nomor_telepon_kantor',
|
||||
'email_kantor',
|
||||
'nama_pimpinan',
|
||||
'nomor_hp_pimpinan',
|
||||
'nama_pic_reviewer',
|
||||
'nomor_hp_pic_reviewer',
|
||||
'nama_pic_admin',
|
||||
'nomor_hp_pic_admin',
|
||||
'nama_pic_marketing',
|
||||
'nomor_hp_pic_marketing',
|
||||
'ijin_usaha_id',
|
||||
'jenis_aset_id',
|
||||
'attachment'
|
||||
];
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class PerkerasanJalan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'perkerasan_jalan';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
|
||||
31
app/Models/PermohonanHistory.php
Normal file
31
app/Models/PermohonanHistory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\PermohonanHistoryFactory;
|
||||
|
||||
class PermohonanHistory extends Base
|
||||
{
|
||||
protected $fillable = [
|
||||
'permohonan_id',
|
||||
'status',
|
||||
'keterangan',
|
||||
'before_request',
|
||||
'after_request',
|
||||
'file_path',
|
||||
'user_id'
|
||||
];
|
||||
|
||||
|
||||
public function permohonan()
|
||||
{
|
||||
return $this->belongsTo(Permohonan::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
43
app/Services/PermohonanHistoryService.php
Normal file
43
app/Services/PermohonanHistoryService.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\PermohonanHistory;
|
||||
|
||||
class PermohonanHistoryService
|
||||
{
|
||||
public function createHistory(Permohonan $permohonan, string $status, ?string $keterangan, array $beforeRequest, array $afterRequest, ?string $file = null)
|
||||
{
|
||||
|
||||
$filePath = null;
|
||||
if ($file) {
|
||||
$filePath = $file->store('permohonan_history_files', 'public');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$history = PermohonanHistory::create([
|
||||
'permohonan_id' => $permohonan->id,
|
||||
'status' => $status,
|
||||
'keterangan' => $keterangan,
|
||||
'before_request' => json_encode($beforeRequest),
|
||||
'after_request' => json_encode($afterRequest),
|
||||
'file_path' => $filePath,
|
||||
'user_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Log the error
|
||||
\Log::error('Error creating PermohonanHistory: ' . $e->getMessage());
|
||||
|
||||
// You might want to delete the uploaded file if the database operation fails
|
||||
if ($filePath) {
|
||||
\Storage::disk('public')->delete($filePath);
|
||||
}
|
||||
|
||||
// Rethrow the exception or handle it as per your application's error handling policy
|
||||
throw new \Exception('Failed to create PermohonanHistory: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user