add module detail pembayaran

This commit is contained in:
daengdeni 2023-12-15 16:20:16 +07:00
parent 0ac8a9b80e
commit 32cb49f7df
16 changed files with 676 additions and 6 deletions

View File

@ -0,0 +1,91 @@
<?php
namespace Modules\Writeoff\DataTables;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Support\Number;
use Modules\Writeoff\Entities\DetailPembayaran;
use Nwidart\Modules\Facades\Module;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class DetailPembayaranDataTable extends DataTable
{
/**
* Build the DataTable class.
*
* @param QueryBuilder $query Results from query() method.
*/
public function dataTable(QueryBuilder $query)
: EloquentDataTable
{
return (new EloquentDataTable($query))->filter(function ($query) {
if (request()->has('search')) {
$search = request()->get('search');
$query->where('nomor_pinjaman', 'like', "%" . $search['value'] . "%");
}
})->addIndexColumn()->editColumn('tanggal_pembayaran', function ($row) {
$date = Carbon::create($row->tanggal_pembayaran);
return $date->locale('id')->translatedFormat('d F Y');
})->editColumn('nominal', function ($row) {
return Number::currency($row->nominal, 'IDR', 'id_ID');
})->setRowId('id');
}
/**
* Get the query source of dataTable.
*/
public function query(DetailPembayaran $model)
: QueryBuilder
{
return $model->newQuery();
}
/**
* Optional method if you want to use the html builder.
*/
public function html()
: HtmlBuilder
{
return $this->builder()
->setTableId('detail-pembayaran-table')
->columns($this->getColumns())
->minifiedAjax()
->stateSave(false)
->responsive()
->autoWidth(true)
->orderBy(1)
->parameters([
'scrollX' => false,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5')
->drawCallback("function() {" . file_get_contents(Module::getModulePath('writeoff').'Resources/views/pencatatan/detail_pembayaran/_draw-scripts.js') . "}");
}
/**
* Get the dataTable columns definition.
*/
public function getColumns()
: array
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('tanggal_pembayaran')->title('Tanggal Pembayaran'),
Column::make('nominal')->title('Nominal Pembayaran'),
Column::make('keterangan')->title('Keterangan'),
];
}
/**
* Get the filename for export.
*/
protected function filename()
: string
{
return 'Detail_Pembayaran_' . date('YmdHis');
}
}

View File

@ -0,0 +1,40 @@
<?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::create('detail_pembayaran', function (Blueprint $table) {
$table->id();
$table->string('nomor_pinjaman');
$table->string('kode_pembayaran');
$table->date('tanggal_pembayaran');
$table->double('nominal', 20, 2);
$table->string('keterangan')->nullable();
$table->boolean('status')->default(true)->nullable();
$table->timestamps();
$table->timestamp('authorized_at')->nullable();
$table->char('authorized_status', 1)->nullable();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
$table->unsignedBigInteger('authorized_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('detail_pembayaran');
}
};

View File

@ -0,0 +1,20 @@
<?php
namespace Modules\Writeoff\Entities;
class DetailPembayaran extends BaseModel
{
protected $table = 'detail_pembayaran';
protected $fillable = [
'nomor_pinjaman',
'kode_pembayaran',
'tanggal_pembayaran',
'nominal',
'keterangan',
'status',
'authorized_at',
'authorized_status',
'authorized_by',
];
}

View File

@ -0,0 +1,63 @@
<?php
namespace Modules\Writeoff\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Modules\Writeoff\DataTables\DetailPembayaranDataTable;
use Modules\Writeoff\Entities\Branch;
use Modules\Writeoff\Entities\HapusBuku;
class DetailPembayaranController extends Controller
{
public $user;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
public function index()
{
return view('writeoff::pencatatan.detail_pembayaran.index');
}
public function store(Request $request)
{
$hapusbuku = HapusBuku::where('nomor_pinjaman', $request->nomor_pinjaman)->first();
if ($hapusbuku) {
echo json_encode(['status' => 'success',
'message' => 'Nomor Pinjaman ditemukan.',
'redirect' => route('pencatatan.detail_pembayaran.show', ['nomor_pinjaman' => $request->nomor_pinjaman])
]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Nomor Pinjaman tidak ditemukan.']);
}
}
public function show(DetailPembayaranDataTable $dataTable, $nomor_pinjaman)
{
if (is_null($this->user) || !$this->user->can('master.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
session_start();
$_SESSION['nomor_pinjaman']= $nomor_pinjaman;
$hapusbuku = HapusBuku::where('nomor_pinjaman', $nomor_pinjaman)->first();
if ($hapusbuku) {
$cabang = Branch::where('kode', $hapusbuku->kode_cabang)->first();
return $dataTable->render('writeoff::pencatatan.detail_pembayaran.show', compact('hapusbuku', 'cabang'));
} else {
return redirect()
->route('pencatatan.detail_pembayaran.index')
->with('error', 'Nomor Pinjaman tidak ditemukan.');
}
}
}

View File

@ -33,7 +33,7 @@
'guarantee_type_id' => 'required',
'nomor_jaminan' => 'nullable',
'nilai_jaminan' => 'nullable|numeric',
'status' => 'nullable|boolean',
'status' => 'nullable',
];
}
@ -45,7 +45,7 @@
protected function prepareForValidation()
{
$this->merge([
'id_detail_jaminan' => round(microtime(true) * 100)
'id_detail_jaminan' => round(microtime(true) * 100),
]);
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Modules\Writeoff\Http\Requests\DetailPembayaran;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Validation\ValidationException;
use Illuminate\Validation\Validator;
use Symfony\Component\HttpFoundation\JsonResponse;
class StoreDetailPembayaranRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize()
: bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules()
: array
{
return [
'nomor_pinjaman' => 'nullable|string',
'tanggal_pembayaran'=> 'required|date',
'nominal' => 'required|numeric',
'keterangan' => 'nullable|string',
'status' => 'nullable',
];
}
public function ignored(): string
{
return $this->id;
}
protected function prepareForValidation()
{
$this->merge([
'nomor_pinjaman' => $_SESSION['nomor_pinjaman'],
]);
}
}

View File

@ -6,7 +6,7 @@
use Livewire\Component;
use Modules\Writeoff\Entities\DetailJaminan;
use Modules\Writeoff\Entities\GuaranteeType;
use Modules\Writeoff\Http\Requests\DetailJaminan\StoreDetailJaminanRequest;
use Modules\Writeoff\Http\Requests\DetailJaminan\StoreDetailPembayaranRequest;
use Request;
class DetailJaminanModal extends Component
@ -62,7 +62,7 @@
protected function rules()
{
$request = new StoreDetailJaminanRequest();
$request = new StoreDetailPembayaranRequest();
return $request->rules();
}

View File

@ -0,0 +1,67 @@
<?php
namespace Modules\Writeoff\Livewire\DetailPembayaran;
use Illuminate\Support\Facades\DB;
use Livewire\Component;
use Modules\Writeoff\Entities\DetailPembayaran;
use Modules\Writeoff\Http\Requests\DetailPembayaran\StoreDetailPembayaranRequest;
use Request;
class DetailPembayaranModal extends Component
{
public $id;
public $nomor_pinjaman;
public $tanggal_pembayaran;
public $nominal;
public $keterangan;
public $status;
public $pinjaman;
public function render()
{
$this->pinjaman = request()->segment(3);
$this->nomor_pinjaman = $this->pinjaman;
return view('writeoff::livewire.detail-pembayaran.detail-pembayaran-modal');
}
public function submit()
{
$this->validate();
session_start();
// Validate the form input data
DB::transaction(function () {
// Prepare the data for creating a new user
$data = [
'nomor_pinjaman' => $_SESSION['nomor_pinjaman'],
'kode_pembayaran' => round(microtime(true) * 100),
'tanggal_pembayaran' => $this->tanggal_pembayaran,
'nominal' => $this->nominal,
'keterangan' => $this->keterangan,
'status' => $this->status,
];
DetailPembayaran::create($data);
$this->dispatch('success', __('Data Detail Pembayaran berhasil ditambahkan'));
});
// Reset the form fields after successful submission
$this->reset();
$this->nomor_pinjaman = request()->segment(3);
}
public function hydrate()
{
$this->resetErrorBag();
$this->resetValidation();
}
protected function rules()
{
$request = new StoreDetailPembayaranRequest();
return $request->rules();
}
}

View File

@ -6,7 +6,7 @@
<!--begin::Modal header-->
<div class="modal-header" id="kt_modal_add_detail_jaminan_header">
<!--begin::Modal title-->
<h2 class="fw-bold">Add Detail Jaminan</h2>
<h2 class="fw-bold">Add Detail Jaminan }}</h2>
<!--end::Modal title-->
<!--begin::Close-->
<div class="btn btn-icon btn-sm btn-active-icon-primary" data-bs-dismiss="modal" aria-label="Close">
@ -22,7 +22,7 @@
<!--begin::Scroll-->
<div class="d-flex flex-column scroll-y px-5 px-lg-10" id="kt_modal_add_detail_jaminan_scroll" data-kt-scroll="true" data-kt-scroll-activate="true" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_detail_jaminan_header" data-kt-scroll-wrappers="#kt_modal_add_detail_jaminan_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<input type="text" wire:model.defer="nomor_pinjaman" name="nomor_pinjaman" id="nomor_pinjaman" value="{{ request()->segment(3) }}">
<input type="hidden" wire:model.defer="nomor_pinjaman" name="nomor_pinjaman" id="nomor_pinjaman" value="{{ request()->segment(3) }}">
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-semibold fs-6 mb-2">Jenis Jaminan</label>

View File

@ -0,0 +1,98 @@
<div class="modal fade" id="kt_modal_add_detail_pembayaran" tabindex="-1" aria-hidden="true" wire:ignore.self>
<!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered mw-650px">
<!--begin::Modal content-->
<div class="modal-content">
<!--begin::Modal header-->
<div class="modal-header" id="kt_modal_add_detail_pembayaran_header">
<!--begin::Modal title-->
<h2 class="fw-bold">Add Detail Pembayaran</h2>
<!--end::Modal title-->
<!--begin::Close-->
<div class="btn btn-icon btn-sm btn-active-icon-primary" data-bs-dismiss="modal" aria-label="Close">
{!! getIcon('cross','fs-1') !!}
</div>
<!--end::Close-->
</div>
<!--end::Modal header-->
<!--begin::Modal body-->
<div class="modal-body px-5 my-7">
<!--begin::Form-->
<form id="kt_modal_add_detail_pembayaran" class="form" action="#" wire:submit.prevent="submit">
<!--begin::Scroll-->
<div class="d-flex flex-column scroll-y px-5 px-lg-10" id="kt_modal_add_detail_pembayaran_scroll" data-kt-scroll="true" data-kt-scroll-activate="true" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_detail_pembayaran_header" data-kt-scroll-wrappers="#kt_modal_add_detail_pembayaran_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<input type="text" wire:model.defer="nomor_pinjaman" name="nomor_pinjaman" id="nomor_pinjaman" value="{{ request()->segment(3) }}">
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-semibold fs-6 mb-2">Tanggal Pembayaran</label>
<!--end::Label-->
<!--begin::Input-->
<input type="date" wire:model.defer="tanggal_pembayaran" name="tanggal_pembayaran" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Nomor Jaminan"/>
<!--end::Input-->
@error('tanggal_pembayaran')
<span class="text-danger">{{ $message }}</span> @enderror
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-semibold fs-6 mb-2">Nominal</label>
<!--end::Label-->
<!--begin::Input-->
<input type="text" data-inputmask="'alias': 'currency'" wire:model.defer="nominal" name="nominal" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Nilai Jaminan"/>
<!--end::Input-->
@error('nominal')
<span class="text-danger">{{ $message }}</span> @enderror
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-semibold fs-6 mb-2">Keterangan</label>
<!--end::Label-->
<!--begin::Input-->
<textarea wire:model.defer="keterangan" name="keterangan" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Keterangan"></textarea>
<!--end::Input-->
@error('keterangan')
<span class="text-danger">{{ $message }}</span> @enderror
</div>
<!--end::Input group-->
<div class="fv-row mb-7">
<label class="fw-semibold fs-6 mb-2">Status Data</label>
<div class="form-check form-switch form-check-custom form-check-solid" style="display: block!important;">
<input class="form-check-input h-20px w-30px me-5" type="checkbox" wire:model.defer="status" id="status" name="status"/>
<label class="form-check-label" for="status">
Aktif
</label>
@error('status')
<span class="text-danger">{{ $message }}</span> @enderror
</div>
</div>
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-bs-dismiss="modal" aria-label="Close" wire:loading.attr="disabled">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-detail_pembayaran-modal-action="submit">
<span class="indicator-label" wire:loading.remove>Submit</span>
<span class="indicator-progress" wire:loading wire:target="submit">
Please wait...
<span class="spinner-border spinner-border-sm align-middle ms-2"></span>
</span>
</button>
</div>
<!--end::Actions-->
</form>
<!--end::Form-->
</div>
<!--end::Modal body-->
</div>
<!--end::Modal content-->
</div>
<!--end::Modal dialog-->
</div>

View File

@ -138,6 +138,19 @@
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item ">
<!--begin:Menu link-->
<a class="menu-link {{ isset($route[1]) && $route[1] == 'detail_pembayaran' ? 'active' : '' }}" href="{{ route('pencatatan.detail_pembayaran.index') }}">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Detail Pembayaran</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
</div>
</div>
@endcanany

View File

@ -0,0 +1,37 @@
// Initialize KTMenu
KTMenu.init();
// Add click event listener to delete buttons
document.querySelectorAll('[data-kt-action="delete_row"]').forEach(function (element) {
element.addEventListener('click', function () {
Swal.fire({
text: 'Are you sure you want to remove?',
icon: 'warning',
buttonsStyling: false,
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No',
customClass: {
confirmButton: 'btn btn-danger',
cancelButton: 'btn btn-secondary',
}
}).then((result) => {
if (result.isConfirmed) {
Livewire.dispatch('delete', { id : this.getAttribute('data-kt-id') });
}
});
});
});
// Add click event listener to update buttons
document.querySelectorAll('[data-kt-action="update_row"]').forEach(function (element) {
element.addEventListener('click', function () {
Livewire.dispatch('update', { id : this.getAttribute('data-kt-id') });
});
});
// Listen for 'success' event emitted by Livewire
Livewire.on('success', (message) => {
// Reload the users-table datatable
LaravelDataTables['detail_pembayaran-table'].ajax.reload();
});

View File

@ -0,0 +1,74 @@
<x-default-layout>
@section('title')
Detail Pembayaran Pinjaman Write-off
@endsection
@section('breadcrumbs')
{{ Breadcrumbs::render('detail.pembayaran') }}
@endsection
<div class="card">
<!--begin::Card body-->
<div class="card-body py-4">
<form id="form_jaminan" class="form" action="{{ route('pencatatan.detail_pembayaran.store') }}" method="POST" >
@csrf
<!--begin::Scroll-->
<div class="d-flex flex-column px-5 px-lg-10">
<!--begin::Input group-->
<div class="fv-row mb-7">
<label class="required fw-semibold fs-6 mb-2">Nomor Pinjaman</label>
<!--end::Label-->
<!--begin::Input-->
<input type="number" name="nomor_pinjaman" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Nomor Pinjaman"/>
<!--end::Input-->
@error('nomor_pinjaman')
<span class="text-danger">{{ $message }}</span> @enderror
</div>
</div>
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-bs-dismiss="modal" aria-label="Close">Discard</button>
<button type="submit" class="btn btn-primary" data-kt-hapus_bukues-modal-action="submit">
<span class="indicator-label">Submit</span>
</button>
</div>
<!--end::Actions-->
</form>
</div>
<!--end::Card body-->
</div>
@push('scripts')
<script>
$(function () {
$("#form_jaminan").on('submit',function (e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
var form = $(this);
var actionUrl = form.attr('action');
$.ajax({
type: "POST",
url: actionUrl,
data: form.serialize(),
success: function (data) {
var _data = JSON.parse(data);
if(_data.status === 'error'){
toastr.error(_data.message);
return false;
} else{
toastr.success(_data.message);
window.location.href = _data.redirect;
}
},
error: function (data, textStatus, errorThrown) {
var _data = JSON.parse(data);
toastr.error(_data.message);
}
});
});
})
</script>
@endpush
</x-default-layout>

View File

@ -0,0 +1,108 @@
<x-default-layout>
@section('title')
Detail Pembayaran Pinjaman Write-off
@endsection
@section('breadcrumbs')
{{ Breadcrumbs::render('detail.pembayaran') }}
@endsection
<div class="card">
<!--begin::Card header-->
<div class="card-header border-0 pt-6">
<!--begin::Card title-->
<div class="card-title">
<div class="d-flex flex-column px-5 px-lg-10">
<!--begin::Input group-->
<div class="fv-row mb-7">
<label class="fw-semibold fs-6 mb-2">Nomor Pinjaman</label>
<!--end::Label-->
<br>
<!--end::Label-->
{{ $hapusbuku->nomor_pinjaman}}
</div>
</div>
<div class="d-flex flex-column px-5 px-lg-10">
<!--begin::Input group-->
<div class="fv-row mb-7">
<label class="fw-semibold fs-6 mb-2">Debitur</label><br>
<!--end::Label-->
{{ $hapusbuku->kode_debitur.'/'.$hapusbuku->nama_debitur }}
</div>
</div>
<div class="d-flex flex-column px-5 px-lg-10">
<!--begin::Input group-->
<div class="fv-row mb-7">
<label class="fw-semibold fs-6 mb-2">Cabang</label><br>
<!--end::Label-->
{{ $hapusbuku->kode_cabang.'/'.$cabang->name }}
</div>
</div>
</div>
<!--begin::Card title-->
<!--begin::Card toolbar-->
<div class="card-toolbar">
<!--begin::Toolbar-->
<div class="d-flex justify-content-end" data-kt-hapus_buku-table-toolbar="base">
<!--begin::Add hapus_buku-->
<button type="button" id="showModal" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_add_detail_pembayaran">
{!! getIcon('plus', 'fs-2', '', 'i') !!}
Add Detail Pembayaran
</button>
<!--end::Add hapus_buku-->
</div>
<!--end::Toolbar-->
<!--begin::Modal-->
<livewire:writeoff::detail-pembayaran.detail-pembayaran-modal/>
</div>
<!--end::Card toolbar-->
</div>
<!--end::Card header-->
<!--begin::Card body-->
<div class="card-body py-4">
<!--begin::Table-->
<div class="table-responsive">
{{ $dataTable->table() }}
</div>
<!--end::Table-->
</div>
<!--end::Card body-->
</div>
@push('scripts')
{{ $dataTable->scripts() }}
<script>
document.addEventListener('livewire:initialized', function () {
Livewire.on('success', function () {
$('#kt_modal_add_detail_pembayaran').modal('hide');
window.LaravelDataTables['detail-pembayaran-table'].ajax.reload();
});
});
Inputmask.extendAliases({
'currency': {
autoUnmask: true,
allowPlus: true,
allowMinus: true,
}
});
$(function () {
$('#kt_modal_add_detail_pembayaran').on('hidden.bs.modal', function () {
$(this).find('form').trigger('reset');
$("#nomor_pinjaman").val("{{ request()->segment(3) }}");
});
$("#showModal").on('click',function(){
$("#nomor_pinjaman").val("{{ request()->segment(3) }}");
});
});
</script>
@endpush
</x-default-layout>

View File

@ -71,3 +71,8 @@
$trail->parent('detail');
$trail->push('Detail Jaminan Pinjaman Write-off', route('pencatatan.detail_jaminan.index'));
});
Breadcrumbs::for('detail.pembayaran', function (BreadcrumbTrail $trail) {
$trail->parent('detail');
$trail->push('Detail Pembayaran Pinjaman Write-off', route('pencatatan.detail_pembayaran.index'));
});

View File

@ -31,4 +31,8 @@ Route::name('parameter.')->prefix('parameter')->group(function() {
Route::get('detail-jaminan', 'DetailJaminanController@index')->name('detail_jaminan.index');
Route::post('detail-jaminan', 'DetailJaminanController@store')->name('detail_jaminan.store');
Route::get('detail-jaminan/{nomor_pinjaman}', 'DetailJaminanController@show')->name('detail_jaminan.show');
Route::get('detail-pembayaran', 'DetailPembayaranController@index')->name('detail_pembayaran.index');
Route::post('detail-pembayaran', 'DetailPembayaranController@store')->name('detail_pembayaran.store');
Route::get('detail-pembayaran/{nomor_pinjaman}', 'DetailPembayaranController@show')->name('detail_pembayaran.show');
});