memperbaiki konflik dari branch staging
This commit is contained in:
152
app/Http/Controllers/ActivityController.php
Normal file
152
app/Http/Controllers/ActivityController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
|
||||
class ActivityController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$status_permohonan = StatusPermohonan::all();
|
||||
return view('lpj::activity.index', compact('status_permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$status_permohonan = StatusPermohonan::orderBy('id')->get();
|
||||
|
||||
$permohonan = Permohonan::with(
|
||||
[
|
||||
'user',
|
||||
'debiture.province',
|
||||
'debiture.city',
|
||||
'debiture.district',
|
||||
'debiture.village',
|
||||
'branch',
|
||||
'tujuanPenilaian',
|
||||
'penilaian'
|
||||
],
|
||||
)->findOrFail($id);
|
||||
|
||||
return view('lpj::activity.activitydetail', compact('id', 'status_permohonan', 'permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
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 status filter if provided
|
||||
if ($request->has('status') && !empty($request->get('status'))) {
|
||||
$status = $request->get('status');
|
||||
$query->where('status', '=', $status);
|
||||
}
|
||||
|
||||
// Default sorting if no sort provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
} else {
|
||||
$query->orderBy('nomor_registrasi', 'asc'); // Default order by nomor_registrasi
|
||||
}
|
||||
|
||||
// Get the total count of records before paginating
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1); // Default page is 1
|
||||
$size = (int) $request->get('size', 10); // Default size is 10
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
// Limit results based on pagination
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records (after search & filters applied)
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||
|
||||
// Calculate the total number of pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $request->get('page', 1),
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Download the specified resource from storage.
|
||||
*/
|
||||
public function download($id)
|
||||
{
|
||||
$document = Permohonan::find($id);
|
||||
return response()->download(storage_path('app/public/' . $document->dokumen));
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@
|
||||
|
||||
public function update(DebitureRequest $request, $id)
|
||||
{
|
||||
//print_r($request->all());exit;
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
@@ -174,10 +175,4 @@
|
||||
{
|
||||
return Excel::download(new DebitureExport, 'debitur.xlsx');
|
||||
}
|
||||
|
||||
public function download($id)
|
||||
{
|
||||
$document = DokumenJaminan::find($id);
|
||||
return response()->download(storage_path('app/public/' . $document->dokumen_jaminan));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DetailDokumenJaminan;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
@@ -23,7 +26,7 @@
|
||||
public function index($id)
|
||||
{
|
||||
$debitur = Debiture::find($id);
|
||||
$documents = DokumenJaminan::with('pemilik')->where('debiture_id', $id)->get();
|
||||
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
||||
|
||||
return view(
|
||||
'lpj::debitur.edit',
|
||||
@@ -36,8 +39,10 @@
|
||||
$debitur = Debiture::find($id);
|
||||
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$validate['debiture_id'] = $id;
|
||||
|
||||
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||
@@ -61,22 +66,53 @@
|
||||
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||
}
|
||||
|
||||
if ($request->hasFile('dokumen_jaminan')) {
|
||||
$file = $request->file('dokumen_jaminan');
|
||||
$file_name = $file->getClientOriginalName();
|
||||
$file->storeAs('public/jaminan/' . $debitur->id, $file_name);
|
||||
$validate['dokumen_jaminan'] = 'jaminan/' . $debitur->id . '/' . $file_name;
|
||||
$document = DokumenJaminan::create($validate);
|
||||
|
||||
try {
|
||||
foreach ($request->dokumen_jaminan as $key => $value) {
|
||||
$file_name = $value->getClientOriginalName();
|
||||
|
||||
if ($file_name) {
|
||||
try {
|
||||
$file_name = $value->getClientOriginalName();
|
||||
$value->storeAs(
|
||||
'public/jaminan/' . $debitur->id . '/' . $document->id . '/',
|
||||
$file_name,
|
||||
);
|
||||
|
||||
$detail = [
|
||||
'dokumen_jaminan_id' => $document->id,
|
||||
'jenis_legalitas_jaminan_id' => $request->jenis_legalitas_jaminan_id[$key],
|
||||
'dokumen_jaminan' => 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name,
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
];
|
||||
DetailDokumenJaminan::create($detail);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'error',
|
||||
'Gagal upload file dokumen jaminan ' . $key . ': ' . $e->getMessage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'error',
|
||||
'gg' . $e->getMessage(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
DokumenJaminan::create($validate);
|
||||
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'success',
|
||||
'Dokumen Jaminan berhasil ditambahkan',
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', 'ggl' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,6 +138,7 @@
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$validate['debiture_id'] = $id;
|
||||
|
||||
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||
@@ -124,29 +161,77 @@
|
||||
], $pemilik_jaminan);
|
||||
}
|
||||
|
||||
if ($request->hasFile('dokumen_jaminan')) {
|
||||
$file = $request->file('dokumen_jaminan');
|
||||
$file_name = $file->getClientOriginalName();
|
||||
$file->storeAs('public/jaminan/' . $debitur->id, $file_name);
|
||||
$validate['dokumen_jaminan'] = 'jaminan/' . $debitur->id . '/' . $file_name;
|
||||
}
|
||||
|
||||
$document = DokumenJaminan::find($jaminan);
|
||||
$document->update($validate);
|
||||
|
||||
if ($request->detail_dokumen_jaminan_id) {
|
||||
foreach ($request->detail_dokumen_jaminan_id as $key => $value) {
|
||||
if (isset($request->dokumen_jaminan[$key])) {
|
||||
$file = $request->dokumen_jaminan[$key];
|
||||
if ($file) {
|
||||
$file_name = $file->getClientOriginalName();
|
||||
}
|
||||
|
||||
if (isset($file_name)) {
|
||||
$file->storeAs(
|
||||
'public/jaminan/' . $debitur->id . '/' . $document->id . '/',
|
||||
$file_name,
|
||||
);
|
||||
|
||||
$detail = [
|
||||
'dokumen_jaminan_id' => $document->id,
|
||||
'jenis_legalitas_jaminan_id' => $request->jenis_legalitas_jaminan_id[$key],
|
||||
'dokumen_jaminan' => 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name,
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
];
|
||||
if (isset($request->detail_dokumen_jaminan_id[$key])) {
|
||||
$detailDocument = DetailDokumenJaminan::find(
|
||||
$request->detail_dokumen_jaminan_id[$key],
|
||||
);
|
||||
|
||||
$detailDocument->update($detail);
|
||||
$detailDocument->save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$detail = [
|
||||
'dokumen_jaminan_id' => $document->id,
|
||||
'jenis_legalitas_jaminan_id' => $request->jenis_legalitas_jaminan_id[$key],
|
||||
'name' => $request->name[$key],
|
||||
'keterangan' => $request->keterangan[$key],
|
||||
];
|
||||
|
||||
if (isset($request->detail_dokumen_jaminan_id[$key])) {
|
||||
$detailDocument = DetailDokumenJaminan::find(
|
||||
$request->detail_dokumen_jaminan_id[$key],
|
||||
);
|
||||
$detailDocument->update($detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||
'success',
|
||||
'Dokumen Jaminan berhasil diubah',
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
} catch
|
||||
(Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id, $jaminan)
|
||||
{
|
||||
public
|
||||
function edit(
|
||||
$id,
|
||||
$jaminan,
|
||||
) {
|
||||
$document = DokumenJaminan::find($jaminan);
|
||||
$details = DetailDokumenJaminan::where('dokumen_jaminan_id', $document->id)->get();
|
||||
$debitur = Debiture::find($document->debiture_id);
|
||||
$provinces = Province::all();
|
||||
$cities = City::where('province_code', $document->province_code)->get();
|
||||
@@ -164,6 +249,7 @@
|
||||
'jenisJaminan',
|
||||
'jenisLegalitasJaminan',
|
||||
'document',
|
||||
'details',
|
||||
'cities',
|
||||
'districts',
|
||||
'villages',
|
||||
@@ -172,14 +258,30 @@
|
||||
);
|
||||
}
|
||||
|
||||
public function destroy($id, $jaminan_id)
|
||||
{
|
||||
public
|
||||
function destroy(
|
||||
$id,
|
||||
$jaminan_id,
|
||||
) {
|
||||
try {
|
||||
$jaminan = DokumenJaminan::find($jaminan_id);
|
||||
$details = DetailDokumenJaminan::where('dokumen_jaminan_id',$jaminan->id)->get();
|
||||
foreach ($details as $detail){
|
||||
Storage::delete('public/'. $detail->dokumen_jaminan);
|
||||
$detail->delete();
|
||||
}
|
||||
$jaminan->delete();
|
||||
echo json_encode(['success' => true, 'message' => 'Dokumen Jaminan deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete Dokumen Jaminan']);
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function download(
|
||||
$id,
|
||||
) {
|
||||
$document = DetailDokumenJaminan::find($id);
|
||||
return response()->download(storage_path('app/public/' . $document->dokumen_jaminan));
|
||||
}
|
||||
}
|
||||
|
||||
174
app/Http/Controllers/IjinUsahaController.php
Normal file
174
app/Http/Controllers/IjinUsahaController.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\IjinUsahaExport;
|
||||
use Modules\Lpj\Http\Requests\IjinUsahaRequest;
|
||||
use Modules\Lpj\Models\IjinUsaha;
|
||||
|
||||
class IjinUsahaController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::Ijin_usaha.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::Ijin_usaha.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(IjinUsahaRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
IjinUsaha::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.ijin_usaha.index')
|
||||
->with('success', 'Ijin Usaha created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.ijin_usaha.create')
|
||||
->with('error', 'Failed to create ijin Usaha');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
// return view('lpj::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$ijin_usaha = IjinUsaha::find($id);
|
||||
return view('lpj::Ijin_usaha.create', compact('ijin_usaha'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(IjinUsahaRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$ijin_usaha = IjinUsaha::find($id);
|
||||
$ijin_usaha->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.ijin_usaha.index')
|
||||
->with('success', 'Ijin Usaha updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.ijin_usaha.edit', $id)
|
||||
->with('error', 'Failed to update ijin$ijin_usaha');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$ijin_usaha = IjinUsaha::find($id);
|
||||
$ijin_usaha->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Ijin Usaha deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete Ijin Usaha']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('Ijin_usaha.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = IjinUsaha::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('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', '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 IjinUsahaExport, 'ijin_usaha.xlsx');
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
use Modules\Lpj\Exports\JenisJaminanExport;
|
||||
use Modules\Lpj\Http\Requests\JenisJaminanRequest;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
|
||||
class JenisJaminanController extends Controller
|
||||
{
|
||||
@@ -40,13 +41,15 @@
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::jenis_jaminan.create');
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
return view('lpj::jenis_jaminan.create', compact('jenisLegalitasJaminan'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$jenisJaminan = JenisJaminan::find($id);
|
||||
return view('lpj::jenis_jaminan.create', compact('jenisJaminan'));
|
||||
$jenisJaminan = JenisJaminan::find($id);
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
return view('lpj::jenis_jaminan.create', compact('jenisJaminan', 'jenisLegalitasJaminan'));
|
||||
}
|
||||
|
||||
public function update(JenisJaminanRequest $request, $id)
|
||||
@@ -147,4 +150,13 @@
|
||||
{
|
||||
return Excel::download(new JenisJaminanExport, 'jenis_jaminan.xlsx');
|
||||
}
|
||||
|
||||
public function legalitasJaminan($id)
|
||||
{
|
||||
$jenisJaminan = JenisJaminan::find($id);
|
||||
$legalitasJaminan = $jenisJaminan->jenis_legalitas_jaminan_id;
|
||||
|
||||
$legalitas = JenisLegalitasJaminan::whereIn('code', json_decode($legalitasJaminan, true))->get();
|
||||
echo json_encode($legalitas);
|
||||
}
|
||||
}
|
||||
|
||||
174
app/Http/Controllers/JenisLaporanController.php
Normal file
174
app/Http/Controllers/JenisLaporanController.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\JenisLaporan;
|
||||
use Modules\Lpj\Exports\JenisLaporanExport;
|
||||
use Modules\Lpj\Http\Requests\JenisLaporanRequest;
|
||||
use Throwable;
|
||||
|
||||
class JenisLaporanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::jenis_laporan.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::jenis_laporan.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(JenisLaporanRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
JenisLaporan::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.jenis_laporan.index')
|
||||
->with('success', 'Jenis Laporan created successfully');
|
||||
} catch (Throwable $e) {
|
||||
return redirect()
|
||||
->route('basicdata.jenis_laporan.create')
|
||||
->with('success', 'Failed to create Jenis Laporan: ' . $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
// return view('lpj::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$jenisLaporan = JenisLaporan::find($id);
|
||||
return view('lpj::jenis_laporan.create', compact('jenisLaporan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(JenisLaporanRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
$jenisLaporan = JenisLaporan::find($id);
|
||||
$jenisLaporan->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.jenis_laporan.index')
|
||||
->with('success', 'Jenis Laporan updated successfully');
|
||||
} catch (Throwable $e) {
|
||||
return redirect()
|
||||
->route('basicdata.jenis_laporan.edit', $id)
|
||||
->with('success', 'Failed to update Jenis Laporan: ' . $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$jenisLaporan = JenisLaporan::find($id);
|
||||
$jenisLaporan->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Jenis Laporan deleted successfully']);
|
||||
} catch (Throwable $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis Laporan']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = JenisLaporan::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('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', '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 JenisLaporanExport, 'jenis_laporan.xlsx');
|
||||
}
|
||||
}
|
||||
156
app/Http/Controllers/JenisPenilaianController.php
Normal file
156
app/Http/Controllers/JenisPenilaianController.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Http\Requests\JenisPenilaianRequest;
|
||||
use Modules\Lpj\Exports\JenisPenilaianExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class JenisPenilaianController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::jenis_penilaian.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::jenis_penilaian.form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(JenisPenilaianRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
try {
|
||||
JenisPenilaian::create($validate);
|
||||
return redirect()->route('basicdata.jenis-penilaian.index')->with('success', 'Jenis Penilaian created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('basicdata.jenis-penilaian.create')->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$jenisPenilaian = JenisPenilaian::find($id);
|
||||
return view('lpj::jenis_penilaian.form', compact('jenisPenilaian'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(JenisPenilaianRequest $request, $id)
|
||||
{
|
||||
|
||||
$validated = $request->validated();
|
||||
|
||||
|
||||
if ($validated) {
|
||||
try {
|
||||
$jenisPenilaian = JenisPenilaian::find($id);
|
||||
$jenisPenilaian->update($validated);
|
||||
return redirect()->route('basicdata.jenis-penilaian.index')->with('success', 'Jenis Penilaian updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('basicdata.jenis-penilaian.edit', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$jenisPenilaian = JenisPenilaian::find($id);
|
||||
$jenisPenilaian->delete();
|
||||
echo json_encode(['success' => true, 'message' => 'Jenis Penilaian deleted successfully']);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete Jenis Penilaian']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_penilaian.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
$query = JenisPenilaian::query();
|
||||
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
$pageCount = 1;
|
||||
|
||||
if ($size > 0) {
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$offset = ($page - 1) * $size;
|
||||
$query->skip($offset)->take($size);
|
||||
$filteredRecords = $query->count();
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} else {
|
||||
$filteredRecords = $totalRecords;
|
||||
$data = $query->get();
|
||||
}
|
||||
|
||||
$currentPage = $request->get('page') ?? 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 JenisPenilaianExport(), 'jenis-penilaian.xlsx');
|
||||
}
|
||||
}
|
||||
255
app/Http/Controllers/KJPPController.php
Normal file
255
app/Http/Controllers/KJPPController.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Lpj\Http\Requests\KJPPRequest;
|
||||
|
||||
class KJPPController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::kjpp.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$branch = Branch::all();
|
||||
$ijin_usaha = IjinUsaha::all();
|
||||
$jenis_aset = JenisJaminan::all();
|
||||
$provinces = Province::all();
|
||||
|
||||
// Generate KJPP Number
|
||||
$lastKjpp = KJPP::orderBy('code', 'desc')->first();
|
||||
$nextNumber = $lastKjpp ? intval(substr($lastKjpp->code, 1, 6)) + 1 : 1;
|
||||
$kjppNumber = 'K' . str_pad($nextNumber, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
// Combine KJPP number with branch code
|
||||
$fullKjppNumber = $kjppNumber;
|
||||
|
||||
return view('lpj::kjpp.create', compact('branch', 'ijin_usaha', 'jenis_aset', 'provinces', 'fullKjppNumber'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(KJPPRequest $request)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($validated) {
|
||||
$file = $request->file('attachment');
|
||||
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : 'default.pdf';
|
||||
|
||||
if ($file) {
|
||||
// Simpan file yang diunggah
|
||||
$file->storeAs('public/uploads_pdf', $filename);
|
||||
} else {
|
||||
// Salin file default ke lokasi yang diinginkan
|
||||
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'));
|
||||
|
||||
// Tambahkan nama file ke data yang divalidasi
|
||||
$validated['attachment'] = $filename;
|
||||
|
||||
// Simpan data ke database
|
||||
KJPP::create($validated);
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.kjpp.index')
|
||||
->with('success', 'KJPP created successfully');
|
||||
} else {
|
||||
return redirect()
|
||||
->route('basicdata.kjpp.create')
|
||||
->with('error', 'Validation failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$kjpp = KJPP::find($id);
|
||||
$ijin_usaha = IjinUsaha::where('code', $kjpp->nomor_ijin_usaha)->get();
|
||||
$ijin_usahas = IjinUsaha::all();
|
||||
$jenis_jaminan = JenisJaminan::all();
|
||||
$branches = Branch::where('name', $kjpp->jenis_kantor)->get();
|
||||
$provinces = Province::where('code', $kjpp->province_code)->get();
|
||||
$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', 'branches', 'kjpp', 'provinces', 'cities', 'districts', 'villages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$kjpp = KJPP::find($id);
|
||||
$branch = Branch::all();
|
||||
$ijin_usaha = IjinUsaha::all();
|
||||
$jenis_aset = JenisJaminan::all();
|
||||
$provinces = Province::all();
|
||||
$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();
|
||||
|
||||
return view('lpj::kjpp.create', compact('kjpp', 'branch', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(KJPPRequest $request, $id)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($validated) {
|
||||
$file = $request->file('attachment');
|
||||
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : null;
|
||||
|
||||
if ($file !== null) {
|
||||
// Jika ada file dari database maka hapus file yang lama ke file yang baru
|
||||
$kjpp = KJPP::find($id);
|
||||
// Jika filenya ada default.pdf jangan dihapus
|
||||
if ($kjpp->attachment !== 'default.pdf') {
|
||||
Storage::delete('public/uploads_pdf/' . $kjpp->attachment);
|
||||
}
|
||||
// Simpan file yang diunggah
|
||||
$file->storeAs('public/uploads_pdf', $filename);
|
||||
$validated['attachment'] = $filename;
|
||||
} else {
|
||||
// Jika tidak ada file yang diunggah, gunakan file yang sudah ada atau file default
|
||||
$kjpp = KJPP::find($id);
|
||||
$validated['attachment'] = $kjpp->attachment ?? 'default.pdf';
|
||||
}
|
||||
|
||||
// Perbarui data di database
|
||||
KJPP::where('id', $id)->update($validated);
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.kjpp.index')
|
||||
->with('success', 'KJPP updated successfully');
|
||||
} else {
|
||||
return redirect()
|
||||
->route('basicdata.kjpp.edit', $id)
|
||||
->with('error', 'Validation failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$kjpp = KJPP::find($id);
|
||||
|
||||
// Jangan hapus file default.pdf
|
||||
if ($kjpp->attachment && $kjpp->attachment !== 'default.pdf') {
|
||||
Storage::delete('public/uploads_pdf/' . $kjpp->attachment);
|
||||
}
|
||||
|
||||
// Hapus data dari database
|
||||
$kjpp->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'KJPP deleted successfully']);
|
||||
} catch (Throwable $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete branch: ' . $e]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('kjpp.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = KJPP::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('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
$q->orWhere('jenis_kantor', '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 KJPPExport, 'kjpp.xlsx');
|
||||
}
|
||||
}
|
||||
225
app/Http/Controllers/PenilaianController.php
Normal file
225
app/Http/Controllers/PenilaianController.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Http\Requests\PenilaianRequest;
|
||||
use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Models\Teams;
|
||||
use Modules\Lpj\Models\TeamsUsers;
|
||||
use Modules\Usermanagement\Models\User;
|
||||
|
||||
class PenilaianController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$status_permohonan = StatusPermohonan::all();
|
||||
|
||||
return view('lpj::penilaian.index', compact('status_permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(PenilaianRequest $request)
|
||||
{
|
||||
//print_r($request->all());exit;
|
||||
$validatedData = $request->validated();
|
||||
if ($validatedData) {
|
||||
try {
|
||||
$penilaian = Penilaian::create($validatedData);
|
||||
|
||||
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi);
|
||||
$permohonan->update([
|
||||
'status' => 'assign',
|
||||
]);
|
||||
|
||||
return redirect()->route('penilaian.index')->with('success', 'Penilaian berhasil disimpan');
|
||||
} catch (Exception $e) {
|
||||
|
||||
return redirect()->route('penilaian.index')->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create($id)
|
||||
{
|
||||
return view('lpj::penilaian.form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(PenilaianRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
$penilaian = Penilaian::where('nomor_registrasi', $request->nomor_registrasi)->firstOrFail();
|
||||
$penilaian->update($validate);
|
||||
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi);
|
||||
$permohonan->update([
|
||||
'status' => 'assign',
|
||||
]);
|
||||
|
||||
return redirect()->route('penilaian.index', $id)->with('success', 'Penilaian berhasil diubah');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('penilaian.index', $id)->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function assignment($id)
|
||||
{
|
||||
$permohonan = Permohonan::with(
|
||||
[
|
||||
'user',
|
||||
'debiture.province',
|
||||
'debiture.city',
|
||||
'debiture.district',
|
||||
'debiture.village',
|
||||
'branch',
|
||||
'tujuanPenilaian',
|
||||
],
|
||||
)->findOrFail($id);
|
||||
|
||||
$jenisPenilaian = JenisPenilaian::all();
|
||||
$teamPenilai = Teams::with(['regions', 'teamsUsers'])->get();
|
||||
|
||||
$penilaian = Penilaian::where('nomor_registrasi', $permohonan->nomor_registrasi)->first();
|
||||
|
||||
return view('lpj::penilaian.form', compact('permohonan', 'teamPenilai', 'jenisPenilaian', 'penilaian'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
|
||||
public function revisi(PenilaianRequest $request, $nomor_registrasi)
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
if ($validatedData) {
|
||||
|
||||
try {
|
||||
|
||||
if (isset($validatedData['dokumen']) && $request->hasFile('dokumen')) {
|
||||
$file_name = $validatedData['dokumen']->getClientOriginalName();
|
||||
$validatedData['dokumen']->storeAs('public/dokumen_revisi', $file_name);
|
||||
}
|
||||
|
||||
$dataToUpdate = [
|
||||
'keterangan' => $validatedData['keterangan'],
|
||||
'dokumen' => 'dokumen_revisi/' . $file_name,
|
||||
'status' => 'revisi',
|
||||
];
|
||||
|
||||
// dump($dataToUpdate);
|
||||
|
||||
$permohonan = Permohonan::where('nomor_registrasi', $nomor_registrasi)->first();
|
||||
|
||||
$permohonan->update($dataToUpdate);
|
||||
return redirect()->route('penilaian.index')->with('success', 'Penilaian berhasil direvisi');
|
||||
} catch (Exception $e) {
|
||||
dump($e->getMessage());
|
||||
// return redirect()->route('penilaian.index')->with('error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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) = ?', ['register']);
|
||||
|
||||
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'])->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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUserTeams($id)
|
||||
{
|
||||
$teamsUser = TeamsUsers::where('teams_id', $id)->get();
|
||||
$userIds = $teamsUser->pluck('user_id');
|
||||
$users = User::whereIn('id', $userIds)
|
||||
->with('roles')
|
||||
->get();
|
||||
|
||||
|
||||
if ($users->isNotEmpty()) {
|
||||
return response()->json($users, 200);
|
||||
}
|
||||
|
||||
return response()->json([], 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,11 +6,19 @@
|
||||
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\PermohonanExport;
|
||||
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||
use Modules\Lpj\Models\NilaiPlafond;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Models\TujuanPenilaian;
|
||||
|
||||
class PermohonanController extends Controller
|
||||
@@ -26,7 +34,6 @@
|
||||
{
|
||||
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
@@ -37,7 +44,7 @@
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.create')
|
||||
->with('error', 'Failed to create permohonan'. $e->getMessage());
|
||||
->with('error', 'Failed to create permohonan' . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
return redirect()
|
||||
@@ -49,49 +56,56 @@
|
||||
|
||||
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.create');
|
||||
}
|
||||
|
||||
return view('lpj::permohonan.form', compact('branches', 'debitures', 'tujuanPenilaian','status'));
|
||||
public function createPermohonan($debitur)
|
||||
{
|
||||
$branches = Branch::all();
|
||||
$debitur = Debiture::find($debitur);
|
||||
$tujuanPenilaian = TujuanPenilaian::all();
|
||||
$status = StatusPermohonan::all();
|
||||
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||
$plafond = NilaiPlafond::all();
|
||||
|
||||
return view(
|
||||
'lpj::permohonan.form',
|
||||
compact('branches', 'debitur', 'tujuanPenilaian', 'status', 'fasilitasKredit', 'plafond'),
|
||||
);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$permohonan = Permohonan::find($id);
|
||||
$branches = Branch::all();
|
||||
$debitures = Debiture::all();
|
||||
$debitur = Debiture::find($permohonan->debiture_id);
|
||||
$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',
|
||||
];
|
||||
$status = StatusPermohonan::all();
|
||||
$provinces = Province::all();
|
||||
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
||||
|
||||
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||
$plafond = NilaiPlafond::all();
|
||||
|
||||
return view(
|
||||
'lpj::permohonan.form',
|
||||
compact('permohonan', 'branches', 'debitures', 'tujuanPenilaian','status'),
|
||||
compact(
|
||||
'permohonan',
|
||||
'branches',
|
||||
'debitur',
|
||||
'tujuanPenilaian',
|
||||
'status',
|
||||
'provinces',
|
||||
'cities',
|
||||
'districts',
|
||||
'villages',
|
||||
'documents',
|
||||
'fasilitasKredit',
|
||||
'plafond',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -198,4 +212,96 @@
|
||||
{
|
||||
return Excel::download(new PermohonanExport, 'permohonan.xlsx');
|
||||
}
|
||||
|
||||
public function authorization()
|
||||
{
|
||||
return view('lpj::permohonan.authorization.index');
|
||||
}
|
||||
|
||||
public function dataForAuthorization(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'])->where('status', '=', 'order')->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 showAuthorization($id)
|
||||
{
|
||||
$permohonan = Permohonan::find($id);
|
||||
return view('lpj::permohonan.authorization.show', compact('permohonan'));
|
||||
}
|
||||
|
||||
public function updateAuthorization(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$permohonan = Permohonan::find($id);
|
||||
$permohonan->status = $request->status;
|
||||
$permohonan->keterangan = $request->keterangan;
|
||||
$permohonan->save();
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('authorization.show', $id)->with('error', 'Failed to update permohonan');
|
||||
}
|
||||
|
||||
return redirect()->route('authorization.index')->with('success', 'Permohonan updated successfully');
|
||||
}
|
||||
}
|
||||
|
||||
164
app/Http/Controllers/RegionController.php
Normal file
164
app/Http/Controllers/RegionController.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?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\Regions;
|
||||
use Modules\Lpj\Http\Requests\RegionRequest;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\RegionExport;
|
||||
|
||||
|
||||
class RegionController extends Controller
|
||||
{
|
||||
public $user;
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::region.index');
|
||||
}
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::region.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(RegionRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
Regions::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.region.index')
|
||||
->with('success', 'region created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.region.create')
|
||||
->with('error', 'Failed to create region');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$region = Regions::find($id);
|
||||
return view('lpj::region.create', compact('region'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(RegionRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$region = Regions::find($id);
|
||||
$region->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.region.index')
|
||||
->with('success', 'Region updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.region.edit', $id)
|
||||
->with('error', 'Failed to update region');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$region = Regions::find($id);
|
||||
$region->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Region deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete region']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
|
||||
|
||||
if (is_null($this->user) || !$this->user->can('region.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
$query = Regions::query();
|
||||
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
if($request->has('sortOrder') && !empty($request->get('sortOrder'))){
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
// dump($data);
|
||||
|
||||
// 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 RegionExport, 'region.xlsx');
|
||||
}
|
||||
}
|
||||
260
app/Http/Controllers/TeamsController.php
Normal file
260
app/Http/Controllers/TeamsController.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?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\Regions;
|
||||
use Modules\Usermanagement\Models\User;
|
||||
use Modules\Lpj\Models\Teams;
|
||||
use Modules\Lpj\Models\TeamsUsers;
|
||||
use Modules\Lpj\Http\Requests\TeamsRequest;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Lpj\Exports\TeamPenilaianExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class TeamsController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::teams.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
|
||||
// cek region apakah sudah ada di tabel teams
|
||||
$regionTeam = Teams::pluck('regions_id')->toArray();
|
||||
$region = Regions::whereNotIn('id', $regionTeam)->get();
|
||||
|
||||
// cek user apakah sudah ada di tabel teams_users
|
||||
$userTeam = TeamsUsers::pluck('user_id')->toArray();
|
||||
$user = User::whereNotIn('id', $userTeam)
|
||||
->with('roles')
|
||||
->get();
|
||||
|
||||
return view('lpj::teams.form', compact('region', 'user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(TeamsRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$teams = Teams::create($validate);
|
||||
|
||||
$users = $request->input('user', []);
|
||||
|
||||
// loop untuk insert data users ke tabel teams_users
|
||||
foreach ($users as $user) {
|
||||
TeamsUsers::create([
|
||||
'teams_id' => $teams->id,
|
||||
'user_id' => $user
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.teams.index')
|
||||
->with('success', 'Data saved successfully. ');
|
||||
} catch (Exception $e) {
|
||||
|
||||
DB::rollBack();
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.teams.create')
|
||||
->with('error', 'Failed to save data. ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('lpj::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$teams = Teams::find($id);
|
||||
|
||||
|
||||
$region = Regions::all();
|
||||
$usedUsers = TeamsUsers::where('teams_id', '!=', $id)->pluck('user_id')->toArray();
|
||||
$user = User::whereNotIn('id', $usedUsers)
|
||||
->with('roles')
|
||||
->get();
|
||||
// Ambil user yang sudah ada di tim ini
|
||||
$selectedUsers = $teams->teamsUsers->pluck('user_id')->toArray();
|
||||
|
||||
return view('lpj::teams.form', compact('teams', 'region', 'user', 'selectedUsers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(TeamsRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$teams = Teams::findOrFail($id);
|
||||
|
||||
// Update data tim
|
||||
$teams->update($validate);
|
||||
$userIds = $request->input('user', []);
|
||||
|
||||
$teams->teamsUsers()->delete();
|
||||
|
||||
|
||||
foreach ($userIds as $userId) {
|
||||
TeamsUsers::create([
|
||||
'teams_id' => $teams->id,
|
||||
'user_id' => $userId
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.teams.index')
|
||||
->with('success', 'Data updated successfully. ');
|
||||
} catch (Exception $e) {
|
||||
|
||||
DB::rollBack();
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.teams.create')
|
||||
->with('error', 'Failed to update data. ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
|
||||
$teams = Teams::findOrFail($id);
|
||||
$teams->teamsUsers()->delete();
|
||||
|
||||
// Hapus tim
|
||||
$teams->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Team has been deleted successfully']);
|
||||
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete Team']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('teams.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Inisialisasi query
|
||||
$query = Teams::select('teams.id as id', 'teams.name as team_name', 'regions.name as region_name')
|
||||
->join('regions', 'teams.regions_id', '=', 'regions.id')
|
||||
->leftJoin('teams_users', 'teams.id', '=', 'teams_users.teams_id')
|
||||
->leftJoin('users', 'teams_users.user_id', '=', 'users.id')
|
||||
->addSelect('users.id as user_id', 'users.name as user_name');
|
||||
|
||||
// Filter pencarian
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('teams.name', 'LIKE', "%$search%")
|
||||
->orWhere('regions.name', 'LIKE', "%$search%")
|
||||
->orWhere('users.name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Sorting
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Hitung total records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
$size = $request->get('size', 10);
|
||||
$page = $request->get('page', 1);
|
||||
$offset = ($page - 1) * $size;
|
||||
|
||||
// Ambil data dengan pagination
|
||||
$data = $query->skip($offset)->take($size)->get();
|
||||
$filteredRecords = $data->count();
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Ambil ID pengguna dari hasil query
|
||||
$userIds = $data->pluck('user_id')->unique();
|
||||
|
||||
// Ambil data pengguna dengan peran mereka
|
||||
$users = User::whereIn('id', $userIds)
|
||||
->with('roles')
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
||||
// Format data
|
||||
$formattedData = $data->groupBy('id')->map(function ($group) use ($users) {
|
||||
$team = $group->first();
|
||||
$team->user_team = $group->map(function ($item) use ($users) {
|
||||
$user = $users->get($item->user_id);
|
||||
return [
|
||||
'nama' => $item->user_name,
|
||||
'roles' => $user ? $user->roles->pluck('name')->toArray() : [],
|
||||
];
|
||||
})->toArray();
|
||||
return $team;
|
||||
})->values();
|
||||
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $page,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $formattedData
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function export()
|
||||
{
|
||||
return Excel::download(new TeamPenilaianExport(), 'team-penilai.xlsx');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
179
app/Http/Controllers/TenderController.php
Normal file
179
app/Http/Controllers/TenderController.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Lpj\Models\Penawaran;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
use Modules\Lpj\Exports\PenawaranTenderExport;
|
||||
use Modules\Lpj\Http\Requests\TenderPenawaranRequest;
|
||||
use Modules\Lpj\Models\JenisLaporan;
|
||||
use Modules\Lpj\Models\KJPP;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Models\TujuanPenilaianKJPP;
|
||||
|
||||
class TenderController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function penawaran_index()
|
||||
{
|
||||
return view('lpj::penawaran/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function penawaran_create($id)
|
||||
{
|
||||
$status = StatusPermohonan::all();
|
||||
$tujuan_penilaian_kjpp = TujuanPenilaianKJPP::all();
|
||||
$jenis_laporan = JenisLaporan::all();
|
||||
$kjpp = KJPP::all();
|
||||
$permohonan = Permohonan::find($id);
|
||||
$permohonanId = $permohonan->id;
|
||||
$permohonanNomorRegistrasi = $permohonan->nomor_registrasi;
|
||||
|
||||
return view('lpj::penawaran/create', compact('status', 'tujuan_penilaian_kjpp', 'jenis_laporan', 'kjpp', 'permohonanId', 'permohonanNomorRegistrasi'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function penawaran_store(TenderPenawaranRequest $request, $id)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($validated) {
|
||||
$validated['nomor_registrasi'] = $request->nomor_registrasi;
|
||||
|
||||
$validated['nama_kjpp_sebelumnya'] = json_encode($request->input('nama_kjpp_sebelumnya'));
|
||||
|
||||
PenawaranTender::create($validated);
|
||||
|
||||
return redirect()
|
||||
->route('tender.penawaran.index')
|
||||
->with('success', 'Data Penawaran created successfully');
|
||||
} else {
|
||||
return redirect()
|
||||
->route('tender.penawaran.createPenawaran', $id)
|
||||
->with('error', 'Validation failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function penawaran_show($id)
|
||||
{
|
||||
return view('lpj::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function datatablesPenawaran(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('penawaran.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = PenawaranTender::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('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('nama_kjpp_sebelumnya', 'LIKE', "%$search%");
|
||||
$q->orWhere('tanggal_penilaian_sebelumnya', '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 exportPenawaran()
|
||||
{
|
||||
return Excel::download(new PenawaranTenderExport, 'kjpp.xlsx');
|
||||
}
|
||||
|
||||
public function proses_penawaran_index()
|
||||
{
|
||||
return view('lpj::proses_penawaran/index');
|
||||
}
|
||||
|
||||
public function penawaran_ulang_index()
|
||||
{
|
||||
return view('lpj::penawaran_ulang/index');
|
||||
}
|
||||
}
|
||||
174
app/Http/Controllers/TujuanPenilaianKJPPController.php
Normal file
174
app/Http/Controllers/TujuanPenilaianKJPPController.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Throwable;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\TujuanPenilaianKJPP;
|
||||
use Modules\Lpj\Exports\TujuanPenilaianKJPPExport;
|
||||
use Modules\Lpj\Http\Requests\JenisPenilaianKJPPRequest;
|
||||
|
||||
class TujuanPenilaianKJPPController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::tujuan_penilaian_kjpp.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::tujuan_penilaian_kjpp.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(JenisPenilaianKJPPRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
TujuanPenilaianKJPP::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.tujuan_penilaian_kjpp.index')
|
||||
->with('success', 'Tujuan Penilaian KJPP created successfully');
|
||||
} catch (Throwable $e) {
|
||||
return redirect()
|
||||
->route('basicdata.tujuan_penilaian_kjpp.create')
|
||||
->with('success', 'Failed to create Tujuan Penilaian KJPP: ' . $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('lpj::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||
return view('lpj::tujuan_penilaian_kjpp.create', compact('tujuanPenilaianKJPP'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(JenisPenilaianKJPPRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||
$tujuanPenilaianKJPP->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.tujuan_penilaian_kjpp.index')
|
||||
->with('success', 'Tujuan Penilaian KJPP updated successfully');
|
||||
} catch (Throwable $e) {
|
||||
return redirect()
|
||||
->route('basicdata.tujuan_penilaian_kjpp.edit', $id)
|
||||
->with('success', 'Failed to update Tujuan Penilaian KJPP: ' . $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||
$tujuanPenilaianKJPP->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Tujuan Penilaian deleted successfully']);
|
||||
} catch (Throwable $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete deleted']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = TujuanPenilaianKJPP::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('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', '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 TujuanPenilaianKJPPExport, 'jenis_laporan.xlsx');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user