menerapkan feature approve permohonan (blm selesai)
This commit is contained in:
parent
1ee42703ba
commit
7d09e3f77d
200
app/Http/Controllers/AuthorizationController.php
Normal file
200
app/Http/Controllers/AuthorizationController.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?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\BranchExport;
|
||||
use Modules\Lpj\Http\Requests\BranchRequest;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
|
||||
class AuthorizationController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{// dd('hai');
|
||||
// return view('lpj::branch.index');
|
||||
// $permohonan = Permohonan::find(2);
|
||||
// dd($permohonan->get());
|
||||
return view('lpj::authorization.index');
|
||||
}
|
||||
|
||||
public function store(BranchRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
Branch::create($validate);
|
||||
return redirect()
|
||||
->route('basicdata.branch.index')
|
||||
->with('success', 'Branch created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.branch.create')
|
||||
->with('error', 'Failed to create branch');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::branch.create');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$branch = Branch::find($id);
|
||||
return view('lpj::branch.create', compact('branch'));
|
||||
}
|
||||
|
||||
public function update(BranchRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$branch = Branch::find($id);
|
||||
$branch->update($validate);
|
||||
return redirect()
|
||||
->route('basicdata.branch.index')
|
||||
->with('success', 'Branch updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.branch.edit', $id)
|
||||
->with('error', 'Failed to update branch');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$branch = Branch::find($id);
|
||||
$branch->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Branch deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete branch']);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
// if (is_null($this->user) || !$this->user->can('branch.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
// }
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
// 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();
|
||||
$data = $query->select('permohonan.id', 'permohonan.nomor_registrasi'
|
||||
, 'branches.name AS branche_name'
|
||||
, 'debitures.name AS debiture_name'
|
||||
// , 'tujuan_penilaian.name AS debiture_name'
|
||||
, DB::raw("CONCAT(tujuan_penilaian.code,' - ', tujuan_penilaian.name) AS nama_tujuan_penilaian")
|
||||
, 'users.name AS account_officer')
|
||||
->leftJoin('branches', 'branches.id', '=', 'permohonan.branch_id')
|
||||
->leftJoin('debitures', 'debitures.id', '=', 'permohonan.debiture_id')
|
||||
->leftJoin('tujuan_penilaian', 'tujuan_penilaian.id', '=', 'permohonan.tujuan_penilaian_id')
|
||||
->leftJoin('users', 'users.id', '=', 'permohonan.user_id')
|
||||
->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,
|
||||
]);
|
||||
/*
|
||||
// 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 BranchExport, 'branch.xlsx');
|
||||
}
|
||||
}
|
23
app/Models/PermohonanJaminan.php
Normal file
23
app/Models/PermohonanJaminan.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\PermohonanJaminanFactory;
|
||||
|
||||
class PermohonanJaminan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'dokumen_jaminan';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
// protected $fillable = [];
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function newFactory(): PermohonanJaminanFactory
|
||||
{
|
||||
//return PermohonanJaminanFactory::new();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('permohonan_jaminan', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Permohonan::class)->constrained('permohonan');
|
||||
$table->foreignIdFor(DokumenJaminan::class)->contrained('dokumen_jaminan');
|
||||
$table->boolean('status')->default(true)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('permohonan_jaminan');
|
||||
}
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('jenis_jaminan', function (Blueprint $table) {
|
||||
$table->text('jenis_legalitas_jaminan_id')->nullable()->after('id')->comment('fk dari table jenis_legalitas_jaminan');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('jenis_jaminan', function (Blueprint $table) {
|
||||
$table->dropColumn('jenis_legalitas_jaminan_id');
|
||||
});
|
||||
}
|
||||
};
|
@ -46,7 +46,7 @@
|
||||
},
|
||||
{
|
||||
"title": "Authorization",
|
||||
"path": "",
|
||||
"path": "authorization",
|
||||
"icon": "ki-filled ki-some-files text-lg",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
|
138
resources/views/authorization/index.blade.php
Normal file
138
resources/views/authorization/index.blade.php
Normal file
@ -0,0 +1,138 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('authorization') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="authorization-table" data-api-url="{{ route('authorization.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Authorization
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<div class="flex">
|
||||
<label class="input input-sm"> <i class="ki-filled ki-magnifier"> </i>
|
||||
<input placeholder="Search Authorization" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="#"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="#"> Tambah Authorization </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="nomor_registrasi">
|
||||
<span class="sort"> <span class="sort-label"> Nomor Permohonan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="branche_name">
|
||||
<span class="sort"> <span class="sort-label"> Cabang </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="debiture_name">
|
||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="nama_tujuan_penilaian">
|
||||
<span class="sort"> <span class="sort-label"> Tujuan Penilain </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="account_officer">
|
||||
<span class="sort"> <span class="sort-label"> Account Officer </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
||||
<div class="flex items-center gap-2">
|
||||
Show
|
||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<span data-datatable-info="true"> </span>
|
||||
<div class="pagination" data-datatable-pagination="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#authorization-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
columns: {
|
||||
select: {
|
||||
render: (item, data, context) => {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.className = 'checkbox checkbox-sm';
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.value = data.id.toString();
|
||||
checkbox.setAttribute('data-datatable-row-check', 'true');
|
||||
return checkbox.outerHTML.trim();
|
||||
},
|
||||
},
|
||||
nomor_registrasi: {
|
||||
title: 'Nomor Registrasi',
|
||||
},
|
||||
branche_name: {
|
||||
title: 'Cabang',
|
||||
},
|
||||
debiture_name: {
|
||||
title: 'Debitur',
|
||||
},
|
||||
nama_tujuan_penilaian: {
|
||||
title: 'Tujuan Penilain',
|
||||
},
|
||||
account_officer: {
|
||||
title: 'Account Officer',
|
||||
},
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="/debitur/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
dataTable.showSpinner();
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -232,4 +232,10 @@
|
||||
$trail->parent('debitur.pemilik.index');
|
||||
$trail->push('Edit Data Pemilik Jaminan Debitur');
|
||||
});
|
||||
|
||||
// andy add
|
||||
Breadcrumbs::for('authorization', function (BreadcrumbTrail $trail) {
|
||||
$trail->push('Authorization', route('authorization.index'));
|
||||
});
|
||||
// andy add
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
use Modules\Lpj\Http\Controllers\NilaiPlafondController;
|
||||
use Modules\Lpj\Http\Controllers\PemilikJaminanController;
|
||||
use Modules\Lpj\Http\Controllers\TujuanPenilaianController;
|
||||
use Modules\Lpj\Http\Controllers\AuthorizationController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -177,4 +178,14 @@
|
||||
});
|
||||
|
||||
Route::resource('debitur', DebitureController::class);
|
||||
|
||||
// andy
|
||||
Route::name('authorization.')->prefix('authorization')->group(function () {
|
||||
Route::get('/', [AuthorizationController::class, 'index'])->name('index');
|
||||
Route::get('datatables', [AuthorizationController::class, 'dataForDatatables'])
|
||||
->name('datatables');
|
||||
});
|
||||
|
||||
// Route::resource('authorization', AuthorizationController::class);
|
||||
// andy
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user