menambahkan Feature Pembayaran di Admin LPJ
This commit is contained in:
150
app/Http/Controllers/PembayaranController.php
Normal file
150
app/Http/Controllers/PembayaranController.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
// use Modules\Lpj\Models\JenisPenilaian;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
// use Modules\Lpj\Models\Regions;
|
||||
|
||||
class PembayaranController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::pembayaran.index');
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Tentukan status berdasarkan otorisator
|
||||
$status = match ($otorisator) {
|
||||
'Pelaporan' => 'proses-laporan',
|
||||
'Pembayaran' => 'proses',
|
||||
'Pembatalan' => 'batal',
|
||||
'SLA' => 'freeze',
|
||||
default => '',
|
||||
};
|
||||
*/
|
||||
|
||||
$query = Permohonan::query()->whereIn('status_bayar', ['sudah_bayar']);
|
||||
/*
|
||||
// Pencarian berdasarkan parameter search
|
||||
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 . '%');
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
// Filter berdasarkan region user yang login
|
||||
// $query->whereHas('region.teams.teamsUsers', function ($q) {
|
||||
// $q->where('user_id', Auth::id());
|
||||
// });
|
||||
|
||||
|
||||
// Sorting berdasarkan sortField dan sortOrder
|
||||
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 (default page size 10)
|
||||
$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);
|
||||
}
|
||||
|
||||
// Filtered records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Ambil data dengan relasi
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'region.teams.teamsUsers'])->get();
|
||||
|
||||
|
||||
// Hitung jumlah halaman
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Ambil current page
|
||||
$currentPage = max(1, $request->get('page', 1));
|
||||
|
||||
// Return JSON response
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
: JsonResponse {
|
||||
// init
|
||||
$data = [];
|
||||
$dataku = [];
|
||||
$tindakan = null;
|
||||
if (request()->ajax()) {
|
||||
|
||||
try {
|
||||
|
||||
$dataku = [
|
||||
'approve_bayar_by' => Auth::id(),
|
||||
'approve_bayar_at' => now(),
|
||||
];
|
||||
|
||||
if ($request->keterangan) {
|
||||
$dataku['approve_keterangan_bayar'] = $request->keterangan;
|
||||
}
|
||||
|
||||
$data['dataku'] = $dataku;
|
||||
|
||||
$modal = Permohonan::find($id);
|
||||
$modal->update($dataku);
|
||||
//
|
||||
$data['status'] = 'success';
|
||||
$data['message'] = ['Otorisasi' . $modal->nomor_registrasi . 'berhasil di lakukan'];
|
||||
} catch (Exception $e) {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = ['Otorisasi gagal di lakukan.'];
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,11 @@
|
||||
'registrasi_at',
|
||||
'jenis_penilaian_id',
|
||||
'region_id',
|
||||
'sla'
|
||||
'sla',
|
||||
// andy add
|
||||
'approve_keterangan_bayar',
|
||||
'approve_bayar_by',
|
||||
'approve_bayar_at',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
|
||||
@@ -26,7 +26,11 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('permohonan', function (Blueprint $table) {
|
||||
|
||||
$table->dropColumn('registrasi_catatan');
|
||||
$table->dropColumn('registrasi_by');
|
||||
$table->dropColumn('registrasi_at');
|
||||
$table->dropColumn('jenis_penilaian_id');
|
||||
$table->dropColumn('region_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('permohonan', function (Blueprint $table) {
|
||||
$table->text('approve_keterangan_bayar')->nullable()->after('status_bayar')->comment('kebutuhan untuk feature Pembayaran di adminl lpj');
|
||||
$table->unsignedBigInteger('approve_bayar_by')->nullable()->after('approve_keterangan_bayar')->comment('kebutuhan untuk feature Pembayaran di adminl lpj');
|
||||
$table->timestamp('approve_bayar_at')->nullable()->after('approve_bayar_by')->comment('kebutuhan untuk feature Pembayaran di adminl lpj');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('permohonan', function (Blueprint $table) {
|
||||
$table->dropColumn('approve_keterangan_bayar');
|
||||
$table->dropColumn('approve_bayar_by');
|
||||
$table->dropColumn('approve_bayar_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
12
module.json
12
module.json
@@ -151,6 +151,18 @@
|
||||
"admin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Pembayaran",
|
||||
"path": "pembayaran",
|
||||
"icon": "ki-filled ki-file-added text-lg text-success",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"admin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Data Debitur",
|
||||
"path": "debitur",
|
||||
|
||||
265
resources/views/pembayaran/index.blade.php
Normal file
265
resources/views/pembayaran/index.blade.php
Normal file
@@ -0,0 +1,265 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('pembayaran') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false"
|
||||
id="pembayaran-table" data-api-url="{{ route('pembayaran.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Pembayaran
|
||||
</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 Pembayaran" 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>
|
||||
</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-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
<span class="sort"> <span class="sort-label"> User Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||
<span class="sort"> <span class="sort-label"> Cabang Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
<span class="sort"> <span class="sort-label"> Tujuan Penilaian </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="approve_bayar_by">
|
||||
<span class="sort"> <span class="sort-label"> Status Approve </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="tujuan_penilaian_id">
|
||||
<span class="sort"> <span class="sort-label"> Status Bayar </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 type="text/javascript">
|
||||
function pembayaranOtorisator(id)
|
||||
{
|
||||
// alert('hai id = ' + id);
|
||||
Swal.fire({
|
||||
title: 'Apakah Anda yakin?',
|
||||
text: `Untuk melakukan approve Pembayaran!`,
|
||||
icon: 'warning',
|
||||
input: 'textarea', // Menambahkan input textarea
|
||||
inputLabel: 'Keterangan',
|
||||
inputPlaceholder: 'Masukkan keterangan...',
|
||||
inputAttributes: {
|
||||
'aria-label': 'Masukkan keterangan'
|
||||
},
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, Lanjutkan!',
|
||||
cancelButtonText: 'Lain kali',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
let useURL= "{{ URL::to('pembayaran') }}"+"/"+id;
|
||||
const keterangan = result.value || ''; // Ambil pesan dari textarea
|
||||
|
||||
var input_data = new Object();
|
||||
input_data._method= 'PUT';
|
||||
input_data.id= id;
|
||||
input_data.keterangan = keterangan;
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
type: 'PUT',
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
success: (response) => {
|
||||
if('success' == response.status)
|
||||
{
|
||||
Swal.fire('Berhasil!', response.message, 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
else if('error' == response.status)
|
||||
{
|
||||
Swal.fire('Error!', response.message, 'error').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
console.log(response);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan otorisator.',
|
||||
'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#pembayaran-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',
|
||||
},
|
||||
tanggal_permohonan: {
|
||||
title: 'Tanggal Permohonan'
|
||||
},
|
||||
user_id: {
|
||||
title: 'User Pemohon',
|
||||
render: (item, data) => {
|
||||
return `${data.user.name}`;
|
||||
},
|
||||
},
|
||||
branch_id: {
|
||||
title: 'Cabang Pemohon',
|
||||
render: (item, data) => {
|
||||
return `${data.branch.name}`;
|
||||
},
|
||||
},
|
||||
debitur_id: {
|
||||
title: 'Debitur',
|
||||
render: (item, data) => {
|
||||
return `${data.debiture.name}`;
|
||||
},
|
||||
},
|
||||
tujuan_penilaian_id: {
|
||||
title: 'Tujuan Penilaian',
|
||||
render: (item, data) => {
|
||||
return `${data.tujuan_penilaian.name}`;
|
||||
},
|
||||
},
|
||||
approve_bayar_by: {
|
||||
title: 'Status Approve',
|
||||
render: (item, data) => {
|
||||
var status_bayar='';
|
||||
if(data.approve_bayar_by)
|
||||
status_bayar=`<span class="text-md font-bold text-green-600 uppercase">CLEAR</span>`;
|
||||
// return `${data.tujuan_penilaian.name}`;
|
||||
|
||||
return status_bayar;
|
||||
},
|
||||
},
|
||||
status_bayar: {
|
||||
title: 'Status Bayar',
|
||||
render: (item, data) => {
|
||||
const status = data.status_bayar.replace(/_/g,
|
||||
' ');
|
||||
const statusClass = data.status_bayar === 'belum_bayar' ? 'text-red-600' :
|
||||
'text-green-600';
|
||||
return `<span class="text-md font-bold ${statusClass} uppercase">
|
||||
${status}
|
||||
</span>`;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
var iconPembayaranOtorisator ='';
|
||||
if(!data.approve_bayar_by)
|
||||
{
|
||||
iconPembayaranOtorisator = `<a class="btn btn-sm btn-icon btn-clear btn-primary " onclick="pembayaranOtorisator(${data.id})">
|
||||
<i class="ki-filled ki-double-check"></i>
|
||||
</a>`;
|
||||
}
|
||||
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-warning " href="#">
|
||||
<i class="ki-outline ki-eye"></i>
|
||||
</a>`
|
||||
+iconPembayaranOtorisator+`
|
||||
</div>`;
|
||||
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function() {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -103,3 +103,9 @@ Breadcrumbs::for('registrasifinal.edit', function (BreadcrumbTrail $trail) {
|
||||
$trail->push('Tambah Registrasi Final');
|
||||
});
|
||||
// registrasi final
|
||||
|
||||
// pembayaran
|
||||
Breadcrumbs::for('pembayaran', function (BreadcrumbTrail $trail) {
|
||||
$trail->push('Pembayaran', route('pembayaran.index'));
|
||||
});
|
||||
// pembayaran
|
||||
|
||||
@@ -7,6 +7,7 @@ use Modules\Lpj\Http\Controllers\ProsesPenawaranController;
|
||||
use Modules\Lpj\Http\Controllers\RegistrasiFinalController;
|
||||
use Modules\Lpj\Http\Controllers\OtorisasiPenawaranController;
|
||||
use Modules\Lpj\Http\Controllers\ProsesPenawaranUlangController;
|
||||
use Modules\Lpj\Http\Controllers\PembayaranController;
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
||||
@@ -124,4 +125,11 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/registrasifinal/{registrasifinal}/edit', 'edit')->name('registrasifinal.edit');
|
||||
Route::put('/registrasifinal/{registrasifinal}', 'update')->name('registrasifinal.update');
|
||||
});
|
||||
|
||||
Route::controller(PembayaranController::class)->group(function () {
|
||||
Route::get('/pembayaran', 'index')->name('pembayaran.index');
|
||||
Route::get('/pembayaran/datatables', 'dataForDatatables')->name('pembayaran.datatables');
|
||||
|
||||
Route::put('/pembayaran/{pembayaran}', 'update')->name('pembayaran.update');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user