feat(pembayaran): implementasi pembayaran kurang & lebih bayar dengan role management

- Tambah method kurang() & lebih() di PembayaranController untuk halaman khusus
- Implementasi dataForDatatablesKurang() & dataForDatatablesLebih() untuk listing data
- Optimasi query dengan filter status + mapping nominal ke format rupiah
- Cleanup code: hapus import & komentar tidak dipakai, rapikan indentasi
- Update module.json: ubah akses menu pembayaran ke "pemohon-ao", tambahkan role "admin" untuk menu NOC
- Tambah route pembayaran/datatables-kurang & pembayaran/datatables-lebih di routes/registrasi.php
- Filtering & sorting data konsisten dengan pagination DataTables
- Format tampilan data finansial distandarisasi (rupiah 2 desimal)
This commit is contained in:
Daeng Deni Mardaeni
2025-09-12 10:17:42 +07:00
parent 2433aacfbc
commit 8a5bf21982
5 changed files with 675 additions and 50 deletions

View File

@@ -9,16 +9,9 @@ use Illuminate\Http\JsonResponse;
use Modules\Lpj\Models\Permohonan;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Lpj\Models\PenawaranTender;
use Illuminate\Support\Facades\Validator;
use Modules\Lpj\Models\PersetujuanPenawaran;
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
// use Modules\Lpj\Models\JenisPenilaian;
// use Modules\Lpj\Models\Regions;
class PembayaranController extends Controller
{
public $user;
@@ -28,6 +21,14 @@ class PembayaranController extends Controller
return view('lpj::pembayaran.index');
}
public function kurang(){
return view('lpj::pembayaran.kurang');
}
public function lebih(){
return view('lpj::pembayaran.lebih');
}
public function approval()
{
return view('lpj::pembayaran.approval');
@@ -36,13 +37,13 @@ class PembayaranController extends Controller
public function dataApprovalForDatatables(Request $request)
{
if (is_null($this->user) || !$this->user->can('noc.view')) {
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
}
// Retrieve data from the database
// Retrieve data from the database
$query = PersetujuanPenawaran::query();
// Apply search filter if provided
// Apply search filter if provided
if ($request->has('search') && !empty($request->get('search'))) {
$search = $request->get('search');
$query->where(function ($q) use ($search) {
@@ -50,29 +51,29 @@ class PembayaranController extends Controller
});
}
// Apply sorting if provided
// 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
// Get the total count of records
$totalRecords = $query->count();
// Apply pagination if provided
// 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
$offset = ($page - 1) * $size; // Calculate the offset
$query->skip($offset)->take($size);
}
// Get the filtered count of records
// Get the filtered count of records
$filteredRecords = $query->count();
// Get the data for the current page
// Get the data for the current page
$data = $query
->with(
[
@@ -90,13 +91,13 @@ class PembayaranController extends Controller
)->get();
// Calculate the page count
// Calculate the page count
$pageCount = ceil($totalRecords / $request->get('size'));
// Calculate the current page number
// Calculate the current page number
$currentPage = $request->get('page', 1);
// Return the response data as a JSON object
// Return the response data as a JSON object
return response()->json([
'draw' => $request->get('draw'),
'recordsTotal' => $totalRecords,
@@ -123,19 +124,19 @@ class PembayaranController extends Controller
$validated['status'] = '0';
$persetujuanPenawaran = PersetujuanPenawaran::where('permohonan_id', $validated['permohonan_id'] ?? null)->first();
$permohonan = Permohonan::find(request()->get('permohonan_id'));
$permohonan = Permohonan::find(request()->get('permohonan_id'));
if ($persetujuanPenawaran) {
// if (isset($validated['penawaran_id'])) {
// if (isset($validated['penawaran_id'])) {
// $persetujuanPenawaran = PersetujuanPenawaran::create(
// ['penawaran_id' => $validated['penawaran_id']],
// $validated,
// );
// $persetujuanPenawaran = PersetujuanPenawaran::create(
// ['penawaran_id' => $validated['penawaran_id']],
// $validated,
// );
$persetujuanPenawaran->fill($validated);
if ($request->hasFile('bukti_bayar')) {
$folderPath = 'persetujuan_penawaran/' . $validated['penawaran_id'];
$folderPath = 'persetujuan_penawaran/' . $validated['penawaran_id'];
$persetujuanPenawaran->bukti_bayar = $request->file('bukti_bayar')->store($folderPath, 'public');
}
@@ -143,7 +144,7 @@ class PembayaranController extends Controller
$permohonan->approve_bayar_by = null;
$permohonan->approve_bayar_at = null;
$permohonan->status = 'done';
$permohonan->status = 'done';
$permohonan->save();
} else {
$persetujuanPenawaran = PersetujuanPenawaran::create(
@@ -154,7 +155,7 @@ class PembayaranController extends Controller
$noc = Noc::where('nomor_tiket',$validated['nomor_tiket'])->first();
if($noc){
$noc->persetujuan_penawaran_id = $persetujuanPenawaran->id;
$noc->permohonan_id = $validated['permohonan_id'];
$noc->permohonan_id = $validated['permohonan_id'];
$noc->save();
}
}
@@ -167,20 +168,20 @@ class PembayaranController extends Controller
$persetujuanPenawaran->save();
}
// Update the status of the related permohonan to 'spk'
// Update the status of the related permohonan to 'spk'
if ($permohonan) {
$permohonan->status_bayar = request()->get('status_bayar');
$permohonan->save();
// andy add, update status penawaran.status='spk'
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
// andy add, update status penawaran.status='spk'
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
'status' => 'noc',
'updated_by' => Auth::id(),
'updated_at' => now(),
]);
// andy add, update status penawaran.status='spk'
// andy add, update status penawaran.status='spk'
}
@@ -190,7 +191,7 @@ class PembayaranController extends Controller
public function update(Request $request, $id): JsonResponse
{
// init
// init
$data = [];
$output = [];
$tindakan = null;
@@ -206,22 +207,22 @@ class PembayaranController extends Controller
}
$output['data'] = $data;
// Update the status of the related permohonan to 'spk'
// Update the status of the related permohonan to 'spk'
$permohonan = Permohonan::find($id);
if ($permohonan) {
if ($request->type === 'revisi') {
$data['status'] = 'revisi-pembayaran';
$data['status'] = 'revisi-pembayaran';
$data['status_bayar'] = 'belum_bayar';
} else {
$data['status_bayar'] = 'sudah_bayar';
$data['status'] = 'proses-laporan';
$data['status'] = 'proses-laporan';
}
if ($permohonan->jenis_penilaian_id == 2) {
$data['status_bayar'] = 'sudah_bayar';
$data['status'] = 'spk';
$data['status'] = 'spk';
}
if ($permohonan->jenis_penilaian_id == 1) {
@@ -261,7 +262,7 @@ class PembayaranController extends Controller
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.');
// abort(403, 'Sorry! You are not allowed to view users.');
}
$query = Permohonan::query()->where(function ($query) {
@@ -277,7 +278,7 @@ class PembayaranController extends Controller
});
// Pencarian berdasarkan parameter search
// Pencarian berdasarkan parameter search
if ($request->has('search') && !empty($request->get('search'))) {
$search = $request->get('search');
$query->where(function ($q) use ($search) {
@@ -291,17 +292,17 @@ class PembayaranController extends Controller
});
}
// Sorting berdasarkan sortField dan sortOrder
// 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
// Hitung total records
$totalRecords = $query->count();
// Pagination (default page size 10)
// Pagination (default page size 10)
$size = $request->get('size', 10);
if ($size == 0) {
$size = 10;
@@ -314,20 +315,156 @@ class PembayaranController extends Controller
$query->skip($offset)->take($size);
}
// Filtered records
// Filtered records
$filteredRecords = $query->count();
// Ambil data dengan relasi
// Ambil data dengan relasi
$data = $query->with(['user', 'debiture', 'branch', 'jenisPenilaian'])->get();
// Hitung jumlah halaman
// Hitung jumlah halaman
$pageCount = ceil($totalRecords / $size);
// Ambil current page
// Ambil current page
$currentPage = max(1, $request->get('page', 1));
// Return JSON response
// Return JSON response
return response()->json([
'draw' => $request->get('draw'),
'recordsTotal' => $totalRecords,
'recordsFiltered' => $filteredRecords,
'pageCount' => $pageCount,
'page' => $currentPage,
'totalCount' => $totalRecords,
'data' => $data,
]);
}
public function dataForDatatablesKurang(Request $request)
{
if (is_null($this->user) || !$this->user->can('debitur.view')) {
// abort(403, 'Sorry! You are not allowed to view users.');
}
$query = Noc::query()->where(function ($query) {
$query->where(['status_kurang_bayar' => '1']);
});
// 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->get();
$data = $data->map(function ($item) {
return [
'id' => $item->id,
'permohonan' => $item->permohonan,
'pemohon' => $item->permohonan->user,
'branch' => $item->permohonan->branch,
'debiture' => $item->permohonan->debiture,
'nominal_kurang_bayar' => formatRupiah($item->nominal_kurang_bayar,2)
];
});
// 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 dataForDatatablesLebih(Request $request)
{
if (is_null($this->user) || !$this->user->can('debitur.view')) {
// abort(403, 'Sorry! You are not allowed to view users.');
}
$query = Noc::query()->where(function ($query) {
$query->where(['status_lebih_bayar' => '1']);
});
// 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->get();
$data = $data->map(function ($item) {
return [
'id' => $item->id,
'permohonan' => $item->permohonan,
'pemohon' => $item->permohonan->user,
'branch' => $item->permohonan->branch,
'debiture' => $item->permohonan->debiture,
'nominal_lebih_bayar' => formatRupiah($item->nominal_lebih_bayar,2)
];
});
// 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,

View File

@@ -398,7 +398,7 @@
"permission": "",
"roles": [
"administrator",
"admin"
"pemohon-ao"
]
},
{
@@ -409,7 +409,7 @@
"permission": "",
"roles": [
"administrator",
"admin"
"pemohon-ao"
]
},
{
@@ -420,7 +420,7 @@
"permission": "",
"roles": [
"administrator",
"admin"
"pemohon-ao"
]
}
]
@@ -459,6 +459,7 @@
"permission": "",
"roles": [
"administrator",
"admin",
"noc"
]
},
@@ -471,6 +472,7 @@
"permission": "",
"roles": [
"administrator",
"admin",
"noc"
]
}

View File

@@ -0,0 +1,242 @@
@extends('layouts.main')
@section('breadcrumbs')
{{ Breadcrumbs::render('pembayaran') }}
@endsection
@section('content')
<div class="grid">
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10"
data-datatable-state-save="false" id="pembayaran-table" data-api-url="{{ route('pembayaran.kurang.datatables') }}">
<div class="flex-wrap py-5 card-header bg-agi-50">
<h3 class="card-title">
Daftar Pembayaran Kurang Bayar
</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 Kurang Bayar" 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 text-sm font-medium text-gray-700 align-middle table-auto table-border"
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="nomor_tiket">
<span class="sort"> <span class="sort-label"> Nomor Tiket </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] text-center" data-datatable-column="status_bayar">
<span class="sort"> <span class="sort-label"> Status Bayar </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[150px] text-center" data-datatable-column="nominal_kurang_bayar">
<span class="sort"> <span class="sort-label"> Nominal </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="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
<div class="flex gap-2 items-center">
Show
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
page
</div>
<div class="flex gap-4 items-center">
<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',
render: (item, data) => {
return `${data.permohonan?.nomor_registrasi}`;
},
},
nomor_tiket: {
title: 'Nomor Tiket',
},
tanggal_permohonan: {
title: 'Tanggal Permohonan',
render: (item, data) => {
return `${data.permohonan?.tanggal_permohonan}`;
},
},
user_id: {
title: 'User Pemohon',
render: (item, data) => {
return `${data.pemohon?.name}`;
},
},
branch_id: {
title: 'Cabang Pemohon',
render: (item, data) => {
if (data.branch) {
return `${data.branch.code} - ${data.branch.name}`;
}
return '-';
},
},
debitur_id: {
title: 'Debitur',
render: (item, data) => {
return `${data.debiture?.name}`;
},
},
status_bayar: {
title: 'Status Bayar',
render: (item, data) => {
return `<span class="font-bold text-red-600 uppercase text-md">
Kurang Bayar
</span>`;
},
},
nominal_kurang_bayar: {
title: 'Kurang Bayar'
},
actions: {
title: 'Status',
render: (item, data) => {
return `<div class="flex gap-2 justify-center">
<a class="btn btn-icon btn-clear btn-warning" href="pembayaran/${data.id}/edit" title="Lakukan Pembayaran">
<i class="ki-outline ki-credit-cart"></i>
</a>
</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

View File

@@ -0,0 +1,242 @@
@extends('layouts.main')
@section('breadcrumbs')
{{ Breadcrumbs::render('pembayaran') }}
@endsection
@section('content')
<div class="grid">
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10"
data-datatable-state-save="false" id="pembayaran-table" data-api-url="{{ route('pembayaran.lebih.datatables') }}">
<div class="flex-wrap py-5 card-header bg-agi-50">
<h3 class="card-title">
Daftar Pembayaran Lebih Bayar
</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 Lebih Bayar" 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 text-sm font-medium text-gray-700 align-middle table-auto table-border"
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="nomor_tiket">
<span class="sort"> <span class="sort-label"> Nomor Tiket </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] text-center" data-datatable-column="status_bayar">
<span class="sort"> <span class="sort-label"> Status Bayar </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[150px] text-center" data-datatable-column="nominal_lebih_bayar">
<span class="sort"> <span class="sort-label"> Nominal </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="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
<div class="flex gap-2 items-center">
Show
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
page
</div>
<div class="flex gap-4 items-center">
<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',
render: (item, data) => {
return `${data.permohonan?.nomor_registrasi}`;
},
},
nomor_tiket: {
title: 'Nomor Tiket',
},
tanggal_permohonan: {
title: 'Tanggal Permohonan',
render: (item, data) => {
return `${data.permohonan?.tanggal_permohonan}`;
},
},
user_id: {
title: 'User Pemohon',
render: (item, data) => {
return `${data.pemohon?.name}`;
},
},
branch_id: {
title: 'Cabang Pemohon',
render: (item, data) => {
if (data.branch) {
return `${data.branch.code} - ${data.branch.name}`;
}
return '-';
},
},
debitur_id: {
title: 'Debitur',
render: (item, data) => {
return `${data.debiture?.name}`;
},
},
status_bayar: {
title: 'Status Bayar',
render: (item, data) => {
return `<span class="font-bold text-green-600 uppercase text-md">
Lebih Bayar
</span>`;
},
},
nominal_lebih_bayar: {
title: 'Lebih Bayar'
},
actions: {
title: 'Status',
render: (item, data) => {
return `<div class="flex gap-2 justify-center">
<a class="btn btn-icon btn-clear btn-warning" href="pembayaran/${data.id}/edit" title="Lakukan Pembayaran">
<i class="ki-outline ki-credit-cart"></i>
</a>
</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

View File

@@ -136,6 +136,8 @@ Route::middleware(['auth'])->group(function () {
Route::get('/pembayaran/{pembayaran}/edit', 'edit')->name('pembayaran.edit');
Route::post('pembayaran','store')->name('pembayaran.store');
Route::get('/pembayaran/datatables', 'dataForDatatables')->name('pembayaran.datatables');
Route::get('/pembayaran/datatables-kurang','dataForDatatablesKurang')->name('pembayaran.kurang.datatables');
Route::get('/pembayaran/datatables-lebih','dataForDatatablesLebih')->name('pembayaran.lebih.datatables');
Route::put('/pembayaran/{pembayaran}', 'update')->name('pembayaran.update');