add module debitur
This commit is contained in:
parent
4215c97403
commit
10f37b372e
99
DataTables/DebiturDataTable.php
Normal file
99
DataTables/DebiturDataTable.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\DataTables;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
use Modules\Writeoff\Entities\Debitur;
|
||||
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 DebiturDataTable 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('kode', 'like', "%" . $search['value'] . "%")
|
||||
->orWhere('name', 'like', "%" . $search['value'] . "%");
|
||||
}
|
||||
})->addIndexColumn()->editColumn('registered_at', function ($row) {
|
||||
return $row->registered_at->locale('id')->translatedFormat('d F Y H:i:s');
|
||||
})->editColumn('cabang', function ($row) {
|
||||
return $row->branch_id ? Branch::find($row->branch_id)->name : '-';
|
||||
})->editColumn('status', function ($row) {
|
||||
$status = $row->status=='A' ? '<span class="badge badge-light-success">Aktif</span>' : '<span class="badge badge-light-danger">Tidak Aktif</span>';
|
||||
$oto = $row->authorized_at !== null ? '<span class="badge badge-light-success">Authorised</span>' : '<span class="badge badge-light-danger">Not Authorised</span>';
|
||||
return $status.' '.$oto;
|
||||
})->rawColumns(['action'])->addColumn('action', function ($debitur) {
|
||||
return view('writeoff::parameter.debitur._actions', compact('debitur'));
|
||||
})->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(Debitur $model)
|
||||
: QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html()
|
||||
: HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('debitur-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/parameter/debitur/_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('kode')->title('Kode Debitur'),
|
||||
Column::make('name')->title('Nama Debitur'),
|
||||
Column::make('cabang')->title('Cabang'),
|
||||
Column::make('registered_at')->title('Tanggal Jadi Nasabah'),
|
||||
Column::make('status')->title('Status'),
|
||||
Column::computed('action')->exportable(false)->printable(false)->width(60)->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename()
|
||||
: string
|
||||
{
|
||||
return 'Debitur_' . date('YmdHis');
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('debitur', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Branch::class)->constrained()->onDelete('cascade');
|
||||
$table->string('kode',4)->unique();
|
||||
$table->string('name');
|
||||
$table->timestamp('registered_at')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('npwp',16)->nullable();
|
||||
$table->char('status', 1)->default('A');
|
||||
$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('debitur');
|
||||
}
|
||||
};
|
21
Entities/Debitur.php
Normal file
21
Entities/Debitur.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\Entities;
|
||||
|
||||
class Debitur extends BaseModel
|
||||
{
|
||||
protected $table = 'debitur';
|
||||
protected $fillable = [
|
||||
'branch_id',
|
||||
'kode',
|
||||
'name',
|
||||
'address',
|
||||
'npwp',
|
||||
'status',
|
||||
'registered_at',
|
||||
'authorized_at',
|
||||
'authorized_status',
|
||||
'authorized_by',
|
||||
];
|
||||
|
||||
}
|
37
Http/Controllers/DebiturController.php
Normal file
37
Http/Controllers/DebiturController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Writeoff\DataTables\DebiturDataTable;
|
||||
|
||||
class DebiturController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::guard('web')->user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the Debiturs.
|
||||
*
|
||||
* @param \Modules\Writeoff\DataTables\DebiturDataTable $dataTable
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(DebiturDataTable $dataTable, Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('master.read')) {
|
||||
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
|
||||
}
|
||||
|
||||
return $dataTable->render('writeoff::parameter.debitur.index');
|
||||
}
|
||||
}
|
85
Http/Requests/Debitur/StoreDebiturRequest.php
Normal file
85
Http/Requests/Debitur/StoreDebiturRequest.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\Http\Requests\Debitur;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class StoreDebiturRequest 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 [
|
||||
'kode' => 'required|string|max:9|min:9|unique:debitur,kode',
|
||||
'name' => 'required|string|max:100',
|
||||
'branch_id' => 'required|integer|exists:branches,id',
|
||||
'status' => 'required|string|max:1|min:1|in:A,I',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'npwp' => 'nullable|string|max:16|min:16',
|
||||
'registered_at' => 'nullable|date_format:Y-m-d'
|
||||
];
|
||||
}
|
||||
|
||||
public function ignored()
|
||||
: string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance.
|
||||
*/
|
||||
public function withValidator(Validator $validator)
|
||||
: void
|
||||
{
|
||||
$validator->after(function (Validator $validator) {
|
||||
if ($validator->errors()->any()) {
|
||||
$errors = json_decode($validator->errors()->toJson(), true);
|
||||
|
||||
|
||||
foreach ($errors as $key => $value) {
|
||||
flash($value[0]);
|
||||
}
|
||||
return redirect()->route('parameter.debitur.index')->with('error', 'Debitur created failed.');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected function failedValidation(Validator|\Illuminate\Contracts\Validation\Validator $validator)
|
||||
: JsonResponse
|
||||
{
|
||||
$errors = (new ValidationException($validator))->errors();
|
||||
|
||||
throw new HttpResponseException(response()->json([
|
||||
'success' => false,
|
||||
'errors' => $errors,
|
||||
'messages' => 'Debitur created failed.'
|
||||
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? 'A' : 'I'
|
||||
]);
|
||||
}
|
||||
}
|
82
Http/Requests/Debitur/UpdateDebiturRequest.php
Normal file
82
Http/Requests/Debitur/UpdateDebiturRequest.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\Http\Requests\Debitur;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class UpdateDebiturRequest extends FormRequest
|
||||
{
|
||||
|
||||
public $_id;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$this->_id = json_decode(json_decode(file_get_contents('php://input'))->components[0]->snapshot)->data->id;
|
||||
|
||||
return [
|
||||
'kode' => 'required|string|max:9|min:9|unique:debitur,kode,' . $this->_id,
|
||||
'name' => 'required|string|max:100',
|
||||
'branch_id' => 'required|integer|exists:branches,id',
|
||||
'status' => 'required|string|max:1|min:1|in:A,I|default:A',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'npwp' => 'nullable|string|max:16|min:16',
|
||||
'registered_at' => 'nullable|date_format:Y-m-d'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance.
|
||||
*/
|
||||
public function withValidator(Validator $validator)
|
||||
: void
|
||||
{
|
||||
$validator->after(function (Validator $validator) {
|
||||
if ($validator->errors()->any()) {
|
||||
$error = json_decode($validator->errors()->toJson(), true);
|
||||
foreach ($error as $key => $value) {
|
||||
flash($value[0]);
|
||||
}
|
||||
|
||||
return redirect()->route('parameter.debitur.index')->with('error', 'Debitur updated failed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function failedValidation(Validator|\Illuminate\Contracts\Validation\Validator $validator)
|
||||
: JsonResponse
|
||||
{
|
||||
$errors = (new ValidationException($validator))->errors();
|
||||
|
||||
throw new HttpResponseException(response()->json([
|
||||
'success' => false,
|
||||
'errors' => $errors,
|
||||
'messages' => 'Debitur updated failed.'
|
||||
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? 'A' : 'I'
|
||||
]);
|
||||
}
|
||||
}
|
116
Livewire/Debitur/DebiturModal.php
Normal file
116
Livewire/Debitur/DebiturModal.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Writeoff\Livewire\Debitur;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
use Modules\Writeoff\Entities\Branch;
|
||||
use Modules\Writeoff\Entities\Debitur;
|
||||
use Modules\Writeoff\Http\Requests\Debitur\StoreDebiturRequest;
|
||||
use Modules\Writeoff\Http\Requests\Debitur\UpdateDebiturRequest;
|
||||
|
||||
class DebiturModal extends Component
|
||||
{
|
||||
public $id;
|
||||
public $kode;
|
||||
public $name;
|
||||
public $branch_id;
|
||||
public $status;
|
||||
public $address;
|
||||
public $npwp;
|
||||
public $registered_at;
|
||||
|
||||
public $edit_mode = false;
|
||||
|
||||
protected $listeners = [
|
||||
'delete' => 'delete',
|
||||
'update' => 'update',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$cabang = Branch::all();
|
||||
return view('writeoff::livewire.debitur.debitur-modal', compact('cabang'));
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
// Validate the form input data
|
||||
DB::transaction(function () {
|
||||
// Prepare the data for creating a new user
|
||||
$data = [
|
||||
'kode' => $this->kode,
|
||||
'name' => $this->name,
|
||||
'branch_id' => $this->branch_id,
|
||||
'status' => $this->status,
|
||||
'address' => $this->address,
|
||||
'npwp' => $this->npwp,
|
||||
'registered_at' => $this->registered_at,
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
if ($this->edit_mode) {
|
||||
// Emit a success event with a message
|
||||
$debitur = Debitur::find($this->id);
|
||||
$debitur->update($data);
|
||||
|
||||
$this->dispatch('success', __('Debitur updated'));
|
||||
} else {
|
||||
// Emit a success event with a message
|
||||
Debitur::create($data);
|
||||
$this->dispatch('success', __('New Debitur created'));
|
||||
}
|
||||
});
|
||||
|
||||
// Reset the form fields after successful submission
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->edit_mode = true;
|
||||
|
||||
$debitur = Debitur::find($id);
|
||||
|
||||
$this->id = $debitur->id;
|
||||
$this->kode = $debitur->kode;
|
||||
$this->name = $debitur->name;
|
||||
$this->branch_id = $debitur->branch_id;
|
||||
$this->status = $debitur->status;
|
||||
$this->address = $debitur->address;
|
||||
$this->npwp = $debitur->npwp;
|
||||
$this->registered_at = $debitur->registered_at;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Debitur::destroy($id);
|
||||
|
||||
// Emit a success event with a message
|
||||
$this->dispatch('success', 'Debitur successfully deleted');
|
||||
}
|
||||
|
||||
public function hydrate()
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->resetValidation();
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
if ($this->edit_mode) {
|
||||
$request = new UpdateDebiturRequest();
|
||||
} else {
|
||||
$request = new StoreDebiturRequest();
|
||||
}
|
||||
|
||||
dd($request->rules());
|
||||
|
||||
return $request->rules();
|
||||
}
|
||||
}
|
||||
|
132
Resources/views/livewire/debitur/debitur-modal.blade.php
Normal file
132
Resources/views/livewire/debitur/debitur-modal.blade.php
Normal file
@ -0,0 +1,132 @@
|
||||
<div class="modal fade" id="kt_modal_add_debitur" 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_debitur_header">
|
||||
<!--begin::Modal title-->
|
||||
<h2 class="fw-bold">Add Debitur</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_debitur_form" 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_debitur_scroll" data-kt-scroll="true" data-kt-scroll-activate="true" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_debitur_header" data-kt-scroll-wrappers="#kt_modal_add_debitur_scroll" data-kt-scroll-offset="300px">
|
||||
|
||||
<!--begin::Input group-->
|
||||
<div class="fv-row mb-7">
|
||||
<!--begin::Label-->
|
||||
<label class="required fw-semibold fs-6 mb-2">Kode Debitur</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<input type="text" wire:model.defer="kode" name="kode" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Kode Debitur"/>
|
||||
<!--end::Input-->
|
||||
@error('kode')
|
||||
<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">Cabang</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<select wire:model.defer="branch_id" name="branch_id" class="form-control form-control-solid mb-3 mb-lg-0">
|
||||
<option value="">Pilih Cabang</option>
|
||||
@foreach($cabang as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->kode }} - {{ $item->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<!--end::Input-->
|
||||
@error('branch_id')
|
||||
<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">Nama Debitur</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<input type="text" wire:model.defer="name" name="name" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Nama Debitur"/>
|
||||
<!--end::Input-->
|
||||
@error('name')
|
||||
<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">Tanggal Jadi Nasabah</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<input type="date" wire:model.defer="registered_at" name="registered_at" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Tanggal Jadi Nasabah"/>
|
||||
<!--end::Input-->
|
||||
@error('registered_at')
|
||||
<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">Alamat Debitur</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<textarea wire:model.defer="address" name="address" class="form-control form-control-solid mb-3 mb-lg-0"></textarea>
|
||||
<!--end::Input-->
|
||||
@error('address')
|
||||
<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">NPWP Debitur</label>
|
||||
<!--end::Label-->
|
||||
<!--begin::Input-->
|
||||
<input type="text" wire:model.defer="npwp" name="npwp" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="NPWP Debitur"/>
|
||||
<!--end::Input-->
|
||||
@error('npwp')
|
||||
<span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
|
||||
<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" name="status" value="A"/>
|
||||
<label class="form-check-label" for="status">
|
||||
Aktif
|
||||
</label>
|
||||
</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-debitures-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>
|
23
Resources/views/parameter/debitur/_actions.blade.php
Normal file
23
Resources/views/parameter/debitur/_actions.blade.php
Normal file
@ -0,0 +1,23 @@
|
||||
<a href="#" class="btn btn-light btn-active-light-primary btn-flex btn-center btn-sm" data-kt-menu-trigger="click" data-kt-menu-placement="bottom-end">
|
||||
Actions
|
||||
<i class="ki-duotone ki-down fs-5 ms-1"></i>
|
||||
</a>
|
||||
<!--begin::Menu-->
|
||||
<div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-600 menu-state-bg-light-primary fw-semibold fs-7 w-125px py-4" data-kt-menu="true">
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-id="{{ $debitur->id }}" data-bs-toggle="modal" data-bs-target="#kt_modal_add_debitur" data-kt-action="update_row">
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-id="{{ $debitur->id }}" data-kt-action="delete_row">
|
||||
Delete
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
</div>
|
||||
<!--end::Menu-->
|
37
Resources/views/parameter/debitur/_draw-scripts.js
Normal file
37
Resources/views/parameter/debitur/_draw-scripts.js
Normal 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['debitur-table'].ajax.reload();
|
||||
});
|
72
Resources/views/parameter/debitur/index.blade.php
Normal file
72
Resources/views/parameter/debitur/index.blade.php
Normal file
@ -0,0 +1,72 @@
|
||||
<x-default-layout>
|
||||
|
||||
@section('title')
|
||||
Cabang
|
||||
@endsection
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('parameter.debitur') }}
|
||||
@endsection
|
||||
|
||||
<div class="card">
|
||||
<!--begin::Card header-->
|
||||
<div class="card-header border-0 pt-6">
|
||||
<!--begin::Card title-->
|
||||
<div class="card-title">
|
||||
<!--begin::Search-->
|
||||
<div class="d-flex align-items-center position-relative my-1">
|
||||
{!! getIcon('magnifier', 'fs-3 position-absolute ms-5') !!}
|
||||
<input type="text" data-kt-debitur-table-filter="search" class="form-control form-control-solid w-250px ps-13" placeholder="Search debitur" id="mySearchInput"/>
|
||||
</div>
|
||||
<!--end::Search-->
|
||||
</div>
|
||||
<!--begin::Card title-->
|
||||
|
||||
<!--begin::Card toolbar-->
|
||||
<div class="card-toolbar">
|
||||
<!--begin::Toolbar-->
|
||||
<div class="d-flex justify-content-end" data-kt-debitur-table-toolbar="base">
|
||||
<!--begin::Add debitur-->
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_add_debitur">
|
||||
{!! getIcon('plus', 'fs-2', '', 'i') !!}
|
||||
Add Debitur
|
||||
</button>
|
||||
<!--end::Add debitur-->
|
||||
</div>
|
||||
<!--end::Toolbar-->
|
||||
|
||||
<!--begin::Modal-->
|
||||
<livewire:writeoff::debitur.debitur-modal/>
|
||||
<!--end::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.getElementById('mySearchInput').addEventListener('keyup', function () {
|
||||
window.LaravelDataTables['debitur-table'].search(this.value).draw();
|
||||
});
|
||||
document.addEventListener('livewire:initialized', function () {
|
||||
Livewire.on('success', function () {
|
||||
$('#kt_modal_add_debitur').modal('hide');
|
||||
window.LaravelDataTables['debitur-table'].ajax.reload();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
</x-default-layout>
|
Loading…
Reference in New Issue
Block a user