Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender
This commit is contained in:
@@ -383,7 +383,8 @@
|
||||
public function bulkDownload()
|
||||
{
|
||||
$dokumenIds = request()->get('jaminan'); // Expecting an array of dokumen_jaminan_id
|
||||
$documents = DetailDokumenJaminan::where('dokumen_jaminan_id', $dokumenIds)->get();
|
||||
$documents = DokumenJaminan::where('id', $dokumenIds)->with(['jenisJaminan', 'detail','debiture'])->get();
|
||||
|
||||
if ($documents->isEmpty()) {
|
||||
return redirect()->back()->with('error', 'No documents found for the provided IDs.');
|
||||
}
|
||||
@@ -394,18 +395,24 @@
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
|
||||
foreach ($documents as $document) {
|
||||
if($document->dokumen_jaminan) {
|
||||
$files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode(
|
||||
$document->dokumen_jaminan,
|
||||
) : [$document->dokumen_jaminan];
|
||||
$jenisJaminan = $document->debiture->permohonan->nomor_registrasi ?? 'Uncategorized';
|
||||
$folderName = $this->sanitizeFolderName($jenisJaminan);
|
||||
|
||||
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 ($document->detail as $detail) {
|
||||
if($detail->dokumen_jaminan) {
|
||||
$folderJaminanName = $this->sanitizeFolderName($detail->jenisLegalitasJaminan->name?? 'Uncategorized');
|
||||
$files = is_array(json_decode($detail->dokumen_jaminan))
|
||||
? json_decode($detail->dokumen_jaminan)
|
||||
: [$detail->dokumen_jaminan];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filePath = storage_path('app/public/' . $file);
|
||||
if (file_exists($filePath)) {
|
||||
$zip->addFile($filePath, $folderName . '/' .$folderJaminanName.'/'.basename($filePath));
|
||||
} else {
|
||||
// Log or display an error message for missing files
|
||||
\Log::warning('File not found: ' . $filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +430,13 @@
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Disposition' => 'attachment; filename="' . $zipFileName . '"',
|
||||
'Content-Length' => filesize($zipFilePath),
|
||||
])->deleteFileAfterSend(false);
|
||||
])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
private function sanitizeFolderName($name)
|
||||
{
|
||||
// Remove any characters that are not allowed in folder names
|
||||
return preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -225,6 +225,10 @@
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
$size = $request->get('size', 10);
|
||||
if ($size == 0) {
|
||||
$size = 10;
|
||||
}
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
@@ -239,13 +243,13 @@
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian','penilaian'])->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
$currentPage = max(1, $request->get('page', 1));
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
|
||||
@@ -4,28 +4,14 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
// use Modules\Location\Models\City;
|
||||
// use Modules\Location\Models\District;
|
||||
// use Modules\Location\Models\Province;
|
||||
// use Modules\Location\Models\Village;
|
||||
// use Modules\Lpj\Exports\DebitureExport;
|
||||
// use Modules\Lpj\Http\Requests\DebitureRequest;
|
||||
// use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||
// use Modules\Lpj\Models\Branch;
|
||||
// use Modules\Lpj\Models\Debiture;
|
||||
// use Modules\Lpj\Models\DokumenJaminan;
|
||||
// use Modules\Lpj\Models\JenisJaminan;
|
||||
// use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
// use Modules\Lpj\Models\PemilikJaminan;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Models\Regions;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Regions;
|
||||
|
||||
class RegistrasiController extends Controller
|
||||
{
|
||||
@@ -43,7 +29,7 @@
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query()->where('status','=','preregister');
|
||||
$query = Permohonan::query()->where('status', '=', 'preregister');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
@@ -101,143 +87,132 @@
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::registrasi.edit', compact('id'));
|
||||
}
|
||||
|
||||
public function setData(Request $request): JsonResponse
|
||||
{
|
||||
$data = array();
|
||||
$datas = array();
|
||||
public function setData(Request $request)
|
||||
: JsonResponse {
|
||||
$data = [];
|
||||
$datas = [];
|
||||
|
||||
if (request()->ajax()) {
|
||||
$id = $request->id;
|
||||
$id = $request->id;
|
||||
$datas = Permohonan::find($id);
|
||||
|
||||
|
||||
if ($datas) {
|
||||
$jenisPenilaians=null;
|
||||
$regions=null;
|
||||
$regions=Regions::pluck('name', 'id');
|
||||
$jenisPenilaians=JenisPenilaian::pluck('name', 'id');
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['regions'] = $regions;
|
||||
$data['jenisPenilaians'] = $jenisPenilaians;
|
||||
$data['datas'] = $datas;
|
||||
$data['message'] ['message_success'] = array("data successfully found");
|
||||
$jenisPenilaians = null;
|
||||
$regions = null;
|
||||
$regions = Regions::pluck('name', 'id');
|
||||
$jenisPenilaians = JenisPenilaian::pluck('name', 'id');
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['regions'] = $regions;
|
||||
$data['jenisPenilaians'] = $jenisPenilaians;
|
||||
$data['datas'] = $datas;
|
||||
$data['message'] ['message_success'] = ["data successfully found"];
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['datas'] = null;
|
||||
$data['message'] ['message_data'] = array("data not found");
|
||||
$data['status'] = 'error';
|
||||
$data['datas'] = null;
|
||||
$data['message'] ['message_data'] = ["data not found"];
|
||||
}
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_ajax'] = array("no ajax request");
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_ajax'] = ["no ajax request"];
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id): JsonResponse
|
||||
{
|
||||
public function update(Request $request, $id)
|
||||
: JsonResponse {
|
||||
// init
|
||||
$data = array();
|
||||
$dataku = array();
|
||||
$data = [];
|
||||
$dataku = [];
|
||||
$tindakan = null;
|
||||
if (request()->ajax()) {
|
||||
$validator = RegistrasiController::rulesEditnya($request, $id);
|
||||
|
||||
|
||||
if ($validator['fails']) {
|
||||
$data['message'] = $validator['errors'];
|
||||
$data['status'] = 'error';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['status'] = 'error';
|
||||
} else {
|
||||
try {
|
||||
$tindakan = $request->tindakan;
|
||||
$dataku = [
|
||||
'registrasi_by' => Auth::id(),
|
||||
'registrasi_at' => now(),
|
||||
];
|
||||
|
||||
$tindakan=$request->tindakan;
|
||||
$dataku = ['registrasi_by' => Auth::id(),
|
||||
'registrasi_at' => now()
|
||||
];
|
||||
|
||||
if($tindakan==0)
|
||||
{
|
||||
$dataku['jenis_penilaian_id'] =$request->jenis_penilaian;
|
||||
$dataku['region_id'] =$request->region;
|
||||
$dataku['status'] = 'registered';
|
||||
if($request->catatan2)
|
||||
$dataku['registrasi_catatan'] =$request->catatan2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dataku['registrasi_catatan'] =$request->catatan;
|
||||
$dataku['status'] = 'revisi';
|
||||
if ($tindakan == 0) {
|
||||
$dataku['jenis_penilaian_id'] = $request->jenis_penilaian;
|
||||
$dataku['region_id'] = $request->region;
|
||||
$dataku['status'] = 'registered';
|
||||
if ($request->catatan2) {
|
||||
$dataku['registrasi_catatan'] = $request->catatan2;
|
||||
}
|
||||
} else {
|
||||
$dataku['registrasi_catatan'] = $request->catatan;
|
||||
$dataku['status'] = 'revisi';
|
||||
}
|
||||
|
||||
$data['dataku'] =$dataku;
|
||||
|
||||
$data['dataku'] = $dataku;
|
||||
|
||||
$modal = Permohonan::find($id);
|
||||
|
||||
|
||||
$modal->update($dataku);
|
||||
//
|
||||
$data['status'] = 'success';
|
||||
$data['message'] ['message_success'] = array('Regitrasi '.$modal->nomor_registrasi.' successfully');
|
||||
//
|
||||
$data['status'] = 'success';
|
||||
$data['message'] ['message_success'] = ['Regitrasi ' . $modal->nomor_registrasi . ' successfully'];
|
||||
} catch (Exception $e) {
|
||||
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_try_catch'] = array('Regitrasi updated failed.');
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_try_catch'] = ['Regitrasi updated failed.'];
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_ajax'] = array("no ajax request");
|
||||
$data['status'] = 'error';
|
||||
$data['message'] ['message_ajax'] = ["no ajax request"];
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
|
||||
}
|
||||
|
||||
public function rulesEditnya($request, $id)
|
||||
{
|
||||
$tindakan=null;
|
||||
$jenis_penilaian=null;
|
||||
$validate_catatan='';
|
||||
$tindakan=$request->tindakan;
|
||||
$jenis_penilaian=$request->jenis_penilaian;
|
||||
|
||||
$tindakan = null;
|
||||
$jenis_penilaian = null;
|
||||
$validate_catatan = '';
|
||||
$tindakan = $request->tindakan;
|
||||
$jenis_penilaian = $request->jenis_penilaian;
|
||||
|
||||
$validateIt = [
|
||||
// 'name' diambil dari definisi parameter yang di kirim pada POST Data
|
||||
'tindakan' => 'required',
|
||||
];
|
||||
|
||||
$messageIt = [
|
||||
'tindakan.required' => 'Silahkan pilih Tindakan'
|
||||
'tindakan.required' => 'Silahkan pilih Tindakan',
|
||||
];
|
||||
|
||||
if($tindakan==0)
|
||||
{
|
||||
$validateIt['jenis_penilaian'] = ['required'];
|
||||
$messageIt ['jenis_penilaian.required']= 'Silahkan pilih Jenis Penilaian';
|
||||
if ($tindakan == 0) {
|
||||
$validateIt['jenis_penilaian'] = ['required'];
|
||||
$messageIt ['jenis_penilaian.required'] = 'Silahkan pilih Jenis Penilaian';
|
||||
|
||||
// INTERNAL
|
||||
if(1==$jenis_penilaian)
|
||||
{
|
||||
$validateIt['region'] = ['required'];
|
||||
$messageIt ['region.required']= 'Silahkan pilih Region';
|
||||
// INTERNAL
|
||||
if (1 == $jenis_penilaian) {
|
||||
$validateIt['region'] = ['required'];
|
||||
$messageIt ['region.required'] = 'Silahkan pilih Region';
|
||||
}
|
||||
}
|
||||
elseif($tindakan==1)
|
||||
{
|
||||
$validateIt['catatan'] = ['required'];
|
||||
$messageIt ['catatan.required']= 'Silahkan isi Catatan';
|
||||
} elseif ($tindakan == 1) {
|
||||
$validateIt['catatan'] = ['required'];
|
||||
$messageIt ['catatan.required'] = 'Silahkan isi Catatan';
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), $validateIt, $messageIt);
|
||||
|
||||
$data['fails'] = $validator->fails();
|
||||
$data['fails'] = $validator->fails();
|
||||
$data['errors'] = $validator->errors();
|
||||
|
||||
return $data;
|
||||
@@ -245,8 +220,8 @@
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$permohonan = Permohonan::find($id);
|
||||
return view('lpj::registrasi.show', compact('id','permohonan'));
|
||||
$permohonan = Permohonan::find($id);
|
||||
return view('lpj::registrasi.show', compact('id', 'permohonan'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,75 +19,50 @@ class FormSurveyorRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$commonRules = $this->getBangunanRules();
|
||||
|
||||
$actionSpecificRules = $this->getActionSpecificRules();
|
||||
|
||||
return array_merge($commonRules, $actionSpecificRules);
|
||||
return $actionSpecificRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get common rules that apply to all actions.
|
||||
*/
|
||||
private function getCommonRules(): array
|
||||
{
|
||||
return [
|
||||
'fakta_positif' => 'nullable|array',
|
||||
'fakta_negatif' => 'nullable|array',
|
||||
'rute_menuju' => 'nullable',
|
||||
'batas_batas' => 'nullable|array',
|
||||
'kondisi_linkungan' => 'nullable|array',
|
||||
'kondisi_lain_bangunan' => 'nullable|array',
|
||||
'informasi_dokument' => 'nullable',
|
||||
'peruntukan' => 'nullable',
|
||||
'kdb' => 'nullable',
|
||||
'kdh' => 'nullable',
|
||||
'gsb' => 'nullable',
|
||||
'max_lantai' => 'nullable',
|
||||
'klb' => 'nullable',
|
||||
'gss' => 'nullable',
|
||||
'pelebaran_jalan' => 'nullable',
|
||||
'nama_petugas' => 'nullable',
|
||||
'lat' => 'nullable|numeric',
|
||||
'lng' => 'nullable|numeric',
|
||||
'foto_gistaru' => 'nullable',
|
||||
'foto_bhumi' => 'nullable',
|
||||
'foto_argis_region' => 'nullable',
|
||||
'foto_tempat' => 'nullable',
|
||||
'keterangan' => 'nullable',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rules specific to the action.
|
||||
*/
|
||||
private function getActionSpecificRules(): array
|
||||
{
|
||||
$action = $this->input('action');
|
||||
$pisah = explode(',', $action);
|
||||
|
||||
switch ($action) {
|
||||
case 'tanah':
|
||||
return $this->getTanahRules();
|
||||
case 'unit':
|
||||
return $this->getUnitRules();
|
||||
case 'kapal':
|
||||
return $this->getUnitRules();
|
||||
case 'kendaraan':
|
||||
return $this->getUnitRules();
|
||||
case 'mesin':
|
||||
return $this->getUnitRules();
|
||||
case 'bangunan':
|
||||
return $this->getTanahBangunanRules();
|
||||
case 'tanah_bangunan':
|
||||
return array_merge($this->getAssetDescriptionRules(),$this->getTanahRules(), $this->getBangunanRules(), $this->getLinkunganRules(), $this->getCommonRules());
|
||||
$allRules = [
|
||||
'tanah' => $this->getTanahRules(),
|
||||
'bangunan' => $this->getBangunanRules(),
|
||||
'kapal' => $this->getKapalRules(),
|
||||
'kendaraan' => $this->getKendaraanRules(),
|
||||
'mesin' => $this->getMesinRules(),
|
||||
'pesawat' => $this->getLinkunganRules(),
|
||||
'alat-berat' => $this->getLinkunganRules(),
|
||||
'apartemen-kantor' => $this->getUnitRules(),
|
||||
'lingkungan' => $this->getLinkunganRules(),
|
||||
'fakta' => $this->getCommonRules(),
|
||||
];
|
||||
|
||||
case 'alat-berat':
|
||||
return $this->getUnitRules();
|
||||
default:
|
||||
return [];
|
||||
$rules = [];
|
||||
$hasAssetDescriptionRules = false;
|
||||
|
||||
foreach ($pisah as $act) {
|
||||
if (isset($allRules[$act])) {
|
||||
$rules = array_merge($rules, $allRules[$act]);
|
||||
if ($act == 'tanah' || $act == 'bangunan') {
|
||||
$hasAssetDescriptionRules = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasAssetDescriptionRules) {
|
||||
$rules = array_merge($rules, $this->getAssetDescriptionRules());
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
/**
|
||||
* Get rules specific to tanah action.
|
||||
*/
|
||||
@@ -133,9 +108,9 @@ class FormSurveyorRequest extends FormRequest
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rules specific to unit action.
|
||||
*/
|
||||
/**
|
||||
* Get rules specific to unit action.
|
||||
*/
|
||||
private function getUnitRules(): array
|
||||
{
|
||||
return [
|
||||
@@ -164,7 +139,7 @@ class FormSurveyorRequest extends FormRequest
|
||||
'jarak_cbd_point' => 'nullable',
|
||||
'nama_cbd_point' => 'nullable',
|
||||
'lebar_perkerasan_jalan' => 'nullable',
|
||||
'perkerasan_jalan' => 'nullable',
|
||||
'perkerasan_jalan.*' => 'nullable',
|
||||
'lalu_lintas' => 'nullable',
|
||||
'gol_mas_sekitar' => 'nullable',
|
||||
'tingkat_keramaian' => 'nullable',
|
||||
@@ -223,24 +198,57 @@ class FormSurveyorRequest extends FormRequest
|
||||
|
||||
|
||||
private function getAssetDescriptionRules(): array
|
||||
{
|
||||
return [
|
||||
'permohonan_id' => 'required',
|
||||
'type' => 'required',
|
||||
'debitur_perwakilan' => 'required|array',
|
||||
'jenis_asset' => 'required',
|
||||
'jenis_asset_tidak_sesuai' => 'nullable',
|
||||
'alamat_sesuai' => 'required',
|
||||
'alamat_tidak_sesuai' => 'nullable',
|
||||
'nama_jalan' => 'nullable',
|
||||
'desa_kelurahan' => 'nullable',
|
||||
'kecamatan' => 'nullable',
|
||||
'kota_kabupaten' => 'nullable',
|
||||
'provinsi' => 'nullable',
|
||||
'kordinat_lng' => 'nullable',
|
||||
'kordinat_lat' => 'nullable',
|
||||
];
|
||||
}
|
||||
{
|
||||
return [
|
||||
'permohonan_id' => 'required',
|
||||
'type' => 'required',
|
||||
'debitur_perwakilan' => 'required|array',
|
||||
'jenis_asset' => 'required',
|
||||
'jenis_asset_tidak_sesuai' => 'nullable',
|
||||
'alamat_sesuai' => 'required',
|
||||
'alamat_tidak_sesuai' => 'nullable',
|
||||
'nama_jalan' => 'nullable',
|
||||
'desa_kelurahan' => 'nullable',
|
||||
'kecamatan' => 'nullable',
|
||||
'kota_kabupaten' => 'nullable',
|
||||
'provinsi' => 'nullable',
|
||||
'kordinat_lng' => 'nullable',
|
||||
'kordinat_lat' => 'nullable',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get common rules that apply to all actions.
|
||||
*/
|
||||
private function getCommonRules(): array
|
||||
{
|
||||
return [
|
||||
'fakta_positif' => 'nullable|array',
|
||||
'fakta_negatif' => 'nullable|array',
|
||||
'rute_menuju' => 'nullable',
|
||||
'batas_batas' => 'nullable|array',
|
||||
'kondisi_lingkungan' => 'nullable|array',
|
||||
'kondisi_lain_bangunan' => 'nullable|array',
|
||||
'informasi_dokument' => 'nullable',
|
||||
'peruntukan' => 'nullable',
|
||||
'kdb' => 'nullable',
|
||||
'kdh' => 'nullable',
|
||||
'gsb' => 'nullable',
|
||||
'max_lantai' => 'nullable',
|
||||
'klb' => 'nullable',
|
||||
'gss' => 'nullable',
|
||||
'pelebaran_jalan' => 'nullable',
|
||||
'nama_petugas' => 'nullable',
|
||||
'lat' => 'nullable|numeric',
|
||||
'lng' => 'nullable|numeric',
|
||||
'foto_gistaru' => 'nullable',
|
||||
'foto_bhumi' => 'nullable',
|
||||
'foto_argis_region' => 'nullable',
|
||||
'foto_tempat' => 'nullable',
|
||||
'keterangan' => 'nullable',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
'name' => 'required|max:255',
|
||||
'slug' => 'required|max:255',
|
||||
'jenis_legalitas_jaminan_id' => 'nullable',
|
||||
'form_kategori.*' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user