291 lines
8.0 KiB
PHP
291 lines
8.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\Lpj\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Modules\Lpj\Models\Permohonan;
|
|
use Modules\Lpj\Models\Branch;
|
|
use Modules\Lpj\Models\Surveyor;
|
|
use Modules\Lpj\Models\BentukTanah;
|
|
use Modules\Lpj\Models\KonturTanah;
|
|
use Modules\Location\Models\Province;
|
|
use Modules\Lpj\Models\PosisiKavling;
|
|
use Modules\Lpj\Models\KondisiFisikTanah;
|
|
use Modules\Lpj\Models\KetinggianTanah;
|
|
use Modules\Lpj\Models\SifatBangunan;
|
|
use Modules\Lpj\Models\JenisBangunan;
|
|
use Modules\Lpj\Models\KondisiBangunan;
|
|
use Modules\Lpj\Models\SpekBangunan;
|
|
use Modules\Lpj\Models\SpekKategoritBangunan;
|
|
use Modules\Lpj\Models\SaranaPelengkap;
|
|
use Modules\Lpj\Models\ArahMataAngin;
|
|
|
|
|
|
class SurveyorController extends Controller
|
|
{
|
|
public $user;
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('lpj::surveyor.index');
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('lpj::create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
$permohonan = Permohonan::with(
|
|
[
|
|
'user',
|
|
'debiture.province',
|
|
'debiture.city',
|
|
'debiture.district',
|
|
'debiture.village',
|
|
'branch',
|
|
'tujuanPenilaian',
|
|
'penilaian',
|
|
'documents',
|
|
],
|
|
)->findOrFail($id);
|
|
|
|
$surveyor = $id;
|
|
$branches = Branch::all();
|
|
$provinces = Province::all();
|
|
$bentukTanah = BentukTanah::all();
|
|
$konturTanah = KonturTanah::all();
|
|
$posisiKavling = PosisiKavling::all();
|
|
$ketinggianTanah = KetinggianTanah::all();
|
|
$kondisiFisikTanah = KondisiFisikTanah::all();
|
|
$jenisBangunan = JenisBangunan::all();
|
|
$kondisiBangunan = KondisiBangunan::all();
|
|
$sifatBangunan = SifatBangunan::all();
|
|
$spekKategoriBagunan = SpekKategoritBangunan::all();
|
|
$spekBangunan = SpekBangunan::all();
|
|
$saranaPelengkap = SaranaPelengkap::all();
|
|
$arahMataAngin = ArahMataAngin::all();
|
|
|
|
|
|
return view('lpj::surveyor.detail', compact(
|
|
'permohonan',
|
|
'surveyor',
|
|
'branches',
|
|
'provinces',
|
|
'bentukTanah',
|
|
'konturTanah',
|
|
'posisiKavling',
|
|
'kondisiFisikTanah',
|
|
'ketinggianTanah',
|
|
'kondisiBangunan',
|
|
'jenisBangunan',
|
|
'sifatBangunan',
|
|
'spekKategoriBagunan',
|
|
'spekBangunan',
|
|
'saranaPelengkap',
|
|
'arahMataAngin',
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
return view('lpj::edit');
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
//
|
|
}
|
|
|
|
public function dataForDatatables(Request $request)
|
|
{
|
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
|
}
|
|
|
|
$query = Permohonan::query();
|
|
|
|
if ($request->has('search') && !empty($request->get('search'))) {
|
|
$search = $request->get('search');
|
|
$query->where(function ($q) use ($search) {
|
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
|
});
|
|
}
|
|
|
|
$query->whereRaw('LOWER(status) = ?', ['assign']);
|
|
|
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
|
$order = $request->get('sortOrder');
|
|
$column = $request->get('sortField');
|
|
$query->orderBy($column, $order);
|
|
}
|
|
|
|
$totalRecords = $query->count();
|
|
|
|
$size = $request->get('size', 10);
|
|
if ($size == 0) {
|
|
$size = 10;
|
|
}
|
|
|
|
if ($request->has('page') && $request->has('size')) {
|
|
$page = $request->get('page', 1);
|
|
$offset = ($page - 1) * $size;
|
|
|
|
$query->skip($offset)->take($size);
|
|
}
|
|
|
|
$filteredRecords = $query->count();
|
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'jenisFasilitasKredit'])->get();
|
|
|
|
$pageCount = ceil($totalRecords / $size);
|
|
|
|
$currentPage = max(1, $request->get('page', 1));
|
|
return response()->json([
|
|
'draw' => $request->get('draw'),
|
|
'recordsTotal' => $totalRecords,
|
|
'recordsFiltered' => $filteredRecords,
|
|
'pageCount' => $pageCount,
|
|
'page' => $currentPage,
|
|
'totalCount' => $totalRecords,
|
|
'data' => $data,
|
|
]);
|
|
}
|
|
/**
|
|
* Form inspeksi.
|
|
*/
|
|
|
|
public function formInspeksi($id)
|
|
{
|
|
$permohonan = Permohonan::with(
|
|
[
|
|
'user',
|
|
'debiture.province',
|
|
'debiture.city',
|
|
'debiture.district',
|
|
'debiture.village',
|
|
'branch',
|
|
'tujuanPenilaian',
|
|
'penilaian'
|
|
],
|
|
)->findOrFail($id);
|
|
$branches = Branch::all();
|
|
$provinces = Province::all();
|
|
|
|
return view('lpj::surveyor.detail', compact('permohonan', 'branches', 'provinces'));
|
|
}
|
|
|
|
/**
|
|
* Denah.
|
|
*/
|
|
|
|
public function denah($id)
|
|
{
|
|
$permohonan = Permohonan::with(
|
|
[
|
|
'user',
|
|
'debiture.province',
|
|
'debiture.city',
|
|
'debiture.district',
|
|
'debiture.village',
|
|
'branch',
|
|
'tujuanPenilaian',
|
|
'penilaian'
|
|
],
|
|
)->findOrFail($id);
|
|
$surveyor = $id;
|
|
$branches = Branch::all();
|
|
$provinces = Province::all();
|
|
|
|
return view('lpj::surveyor.detail', compact('permohonan', 'surveyor', 'branches', 'provinces'));
|
|
}
|
|
|
|
/**
|
|
* Foto.
|
|
*/
|
|
|
|
public function foto($id)
|
|
{
|
|
$permohonan = Permohonan::with(
|
|
[
|
|
'user',
|
|
'debiture.province',
|
|
'debiture.city',
|
|
'debiture.district',
|
|
'debiture.village',
|
|
'branch',
|
|
'tujuanPenilaian',
|
|
'penilaian'
|
|
],
|
|
)->findOrFail($id);
|
|
$surveyor = $id;
|
|
$branches = Branch::all();
|
|
$provinces = Province::all();
|
|
|
|
return view('lpj::surveyor.detail', compact('permohonan', 'surveyor', 'branches', 'provinces'));
|
|
}
|
|
|
|
/**
|
|
* Data pembanding.
|
|
*/
|
|
|
|
public function dataPembanding($id)
|
|
{
|
|
$permohonan = Permohonan::with(
|
|
[
|
|
'user',
|
|
'debiture.province',
|
|
'debiture.city',
|
|
'debiture.district',
|
|
'debiture.village',
|
|
'branch',
|
|
'tujuanPenilaian',
|
|
'penilaian'
|
|
],
|
|
)->findOrFail($id);
|
|
$surveyor = $id;
|
|
$branches = Branch::all();
|
|
$provinces = Province::all();
|
|
|
|
return view('lpj::surveyor.detail', compact('permohonan', 'surveyor', 'branches', 'provinces'));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|