Merge branch 'master' of https://git.putrakuningan.com/daengdeni/lpj into andydev
This commit is contained in:
@@ -54,10 +54,11 @@
|
||||
'address' => $debitur->address,
|
||||
];
|
||||
|
||||
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||
'debiture_id' => $id,
|
||||
'name' => $debitur->name,
|
||||
], $pemilik_jaminan);
|
||||
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||
}
|
||||
|
||||
if ($request->hasFile('dokumen_jaminan')) {
|
||||
@@ -67,14 +68,15 @@
|
||||
$validate['dokumen_jaminan'] = 'jaminan/' . $debitur->id . '/' . $file_name;
|
||||
}
|
||||
|
||||
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||
|
||||
DokumenJaminan::create($validate);
|
||||
|
||||
|
||||
return redirect()->route('debitur.jaminan.index', $id);
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'success',
|
||||
'Dokumen Jaminan berhasil ditambahkan',
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
exit;
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,10 +87,11 @@
|
||||
$provinces = Province::all();
|
||||
$jenisJaminan = JenisJaminan::all();
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
$pemilikJaminan = PemilikJaminan::where('debiture_id', $id)->get();
|
||||
|
||||
return view(
|
||||
'lpj::debitur.jaminan',
|
||||
compact('debitur', 'provinces', 'jenisJaminan', 'jenisLegalitasJaminan'),
|
||||
compact('debitur', 'provinces', 'jenisJaminan', 'jenisLegalitasJaminan', 'pemilikJaminan'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,11 +134,12 @@
|
||||
$document = DokumenJaminan::find($jaminan);
|
||||
$document->update($validate);
|
||||
|
||||
|
||||
return redirect()->route('debitur.jaminan.index', $id);
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'success',
|
||||
'Dokumen Jaminan berhasil diubah',
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
exit;
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,7 +154,7 @@
|
||||
$villages = Village::where('district_code', $document->district_code)->get();
|
||||
$jenisJaminan = JenisJaminan::all();
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
$pemilikJaminan = PemilikJaminan::all();
|
||||
$pemilikJaminan = PemilikJaminan::where('debiture_id', $document->debiture_id)->get();
|
||||
|
||||
return view(
|
||||
'lpj::debitur.jaminan',
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
try {
|
||||
PemilikJaminan::create($validate);
|
||||
|
||||
return redirect()->route('debitur.pemilik.index', $id);
|
||||
if($request->get('from') == 'create-document'){
|
||||
return redirect()->route('debitur.document.create', $id)->with('success', 'Pemilik Jaminan berhasil ditambahkan');
|
||||
}
|
||||
return redirect()->route('debitur.pemilik.index', $id)->with('success', 'Pemilik Jaminan berhasil ditambahkan');
|
||||
} catch (Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
exit;
|
||||
return redirect()->route('debitur.pemilik.index', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,10 +68,13 @@
|
||||
$pemilik = PemilikJaminan::find($pemilik);
|
||||
$pemilik->update($validate);
|
||||
|
||||
return redirect()->route('debitur.pemilik.index', $id);
|
||||
if($request->get('from') == 'update-document'){
|
||||
return redirect()->route('debitur.document.edit', [$id, $request->document])->with('success', 'Pemilik Jaminan berhasil diubah');
|
||||
}
|
||||
|
||||
return redirect()->route('debitur.pemilik.index', $id)->with('success', 'Pemilik Jaminan berhasil diubah');
|
||||
} catch (Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
exit;
|
||||
return redirect()->route('debitur.pemilik.index', $id)->with('error',$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
201
app/Http/Controllers/PermohonanController.php
Normal file
201
app/Http/Controllers/PermohonanController.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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\PermohonanExport;
|
||||
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\TujuanPenilaian;
|
||||
|
||||
class PermohonanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::permohonan.index');
|
||||
}
|
||||
|
||||
public function store(PermohonanRequest $request)
|
||||
{
|
||||
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
Permohonan::create($validate);
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('success', 'Permohonan created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.create')
|
||||
->with('error', 'Failed to create permohonan'. $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
return redirect()
|
||||
->route('permohonan.create')
|
||||
->with('success', 'error naon iye')
|
||||
->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$branches = Branch::all();
|
||||
$debitures = Debiture::all();
|
||||
$tujuanPenilaian = TujuanPenilaian::all();
|
||||
$status = [
|
||||
'order' => 'Order',
|
||||
'revisi' => 'Revisi',
|
||||
'register' => 'Register',
|
||||
'assign' => 'Assign',
|
||||
'survey' => 'Survey',
|
||||
'finalisasi' => 'Proses Laporan',
|
||||
'approved' => 'Diterima',
|
||||
'rejected' => 'Ditolak',
|
||||
'cancel' => 'Dibatalkan',
|
||||
'finished' => 'Selesai',
|
||||
'not_started' => 'Belum dimulai',
|
||||
];
|
||||
|
||||
return view('lpj::permohonan.form', compact('branches', 'debitures', 'tujuanPenilaian','status'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$permohonan = Permohonan::find($id);
|
||||
$branches = Branch::all();
|
||||
$debitures = Debiture::all();
|
||||
$tujuanPenilaian = TujuanPenilaian::all();
|
||||
$status = [
|
||||
'order' => 'Order',
|
||||
'revisi' => 'Revisi',
|
||||
'register' => 'Register',
|
||||
'assign' => 'Assign',
|
||||
'survey' => 'Survey',
|
||||
'finalisasi' => 'Proses Laporan',
|
||||
'approved' => 'Diterima',
|
||||
'rejected' => 'Ditolak',
|
||||
'cancel' => 'Dibatalkan',
|
||||
'finished' => 'Selesai',
|
||||
'not_started' => 'Belum dimulai',
|
||||
];
|
||||
|
||||
return view(
|
||||
'lpj::permohonan.form',
|
||||
compact('permohonan', 'branches', 'debitures', 'tujuanPenilaian','status'),
|
||||
);
|
||||
}
|
||||
|
||||
public function update(PermohonanRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$permohonan = Permohonan::find($id);
|
||||
$permohonan->update($validate);
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('success', 'Permohonan updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.edit', $id)
|
||||
->with('error', 'Failed to update permohonan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$permohonan = Permohonan::find($id);
|
||||
$permohonan->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Permohonan deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete permohonan']);
|
||||
}
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::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('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 . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// 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->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->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 PermohonanExport, 'permohonan.xlsx');
|
||||
}
|
||||
}
|
||||
150
app/Http/Controllers/StatusPermohonanController.php
Normal file
150
app/Http/Controllers/StatusPermohonanController.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?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\StatusPermohonanExport;
|
||||
use Modules\Lpj\Http\Requests\StatusPermohonanRequest;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
|
||||
class StatusPermohonanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::status_permohonan.index');
|
||||
}
|
||||
|
||||
public function store(StatusPermohonanRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
StatusPermohonan::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.status-permohonan.index')
|
||||
->with('success', 'Status Permohonan created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.status-permohonan.create')
|
||||
->with('error', 'Failed to create status permohonan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::status_permohonan.form');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$statusPermohonan = StatusPermohonan::find($id);
|
||||
return view('lpj::status_permohonan.form', compact('statusPermohonan'));
|
||||
}
|
||||
|
||||
public function update(StatusPermohonanRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$statusPermohonan = StatusPermohonan::find($id);
|
||||
$statusPermohonan->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.status-permohonan.index')
|
||||
->with('success', 'Status Permohonan updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.status-permohonan.edit', $id)
|
||||
->with('error', 'Failed to update status permohonan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$statusPermohonan = StatusPermohonan::find($id);
|
||||
$statusPermohonan->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Status Permohonan deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete status permohonan']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('status_permohonan.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = StatusPermohonan::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('description', '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 StatusPermohonanExport, 'status_permohonan.xlsx');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user