Feature #7 : Module Debitur
This commit is contained in:
parent
c31399e6a2
commit
5c4285c77e
81
app/Exports/DebitureExport.php
Normal file
81
app/Exports/DebitureExport.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class DebitureExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
return Debiture::with('branch', 'province', 'city', 'district', 'village')->get();
|
||||
}
|
||||
|
||||
public function map($row)
|
||||
: array
|
||||
{
|
||||
return [
|
||||
$row->id,
|
||||
$row->branch->name .
|
||||
$row->cif,
|
||||
$row->nomor_rekening,
|
||||
$row->name,
|
||||
$row->npwp,
|
||||
$row->nomor_id,
|
||||
$row->email,
|
||||
$row->phone,
|
||||
$row->province->name,
|
||||
$row->city->name,
|
||||
$row->district->name,
|
||||
$row->village->name,
|
||||
$row->postal_code,
|
||||
$row->address,
|
||||
$row->registered_at,
|
||||
$row->created_at
|
||||
];
|
||||
}
|
||||
|
||||
public function headings()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'Branch',
|
||||
'CIF',
|
||||
'Nomor Rekening',
|
||||
'Name',
|
||||
'NPWP',
|
||||
'Nomor ID',
|
||||
'Email',
|
||||
'Phone',
|
||||
'Province',
|
||||
'City',
|
||||
'District',
|
||||
'Village',
|
||||
'Postal Code',
|
||||
'Address',
|
||||
'Registered At',
|
||||
'Created At'
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_NUMBER,
|
||||
'C' => NumberFormat::FORMAT_NUMBER,
|
||||
'D' => NumberFormat::FORMAT_NUMBER,
|
||||
'F' => NumberFormat::FORMAT_NUMBER,
|
||||
'G' => NumberFormat::FORMAT_NUMBER,
|
||||
'P' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||
'Q' => NumberFormat::FORMAT_DATE_DATETIME
|
||||
|
||||
];
|
||||
}
|
||||
}
|
169
app/Http/Controllers/DebitureController.php
Normal file
169
app/Http/Controllers/DebitureController.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Exports\DebitureExport;
|
||||
use Modules\Lpj\Http\Requests\DebitureRequest;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
|
||||
class DebitureController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::debitur.index');
|
||||
}
|
||||
|
||||
public function store(DebitureRequest $request)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
Debiture::create($validate);
|
||||
return redirect()
|
||||
->route('debitur.index')
|
||||
->with('success', 'Debitur created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('debitur.create')
|
||||
->with('error', 'Failed to create debitur');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$branches = Branch::all();
|
||||
$provinces = Province::all();
|
||||
return view('lpj::debitur.create', compact('branches', 'provinces'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$debitur = Debiture::find($id);
|
||||
$branches = Branch::all();
|
||||
$provinces = Province::all();
|
||||
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||
return view('lpj::debitur.create', compact('debitur', 'branches', 'provinces', 'cities', 'districts', 'villages'));
|
||||
}
|
||||
|
||||
public function update(DebitureRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
$debitur = Debiture::find($id);
|
||||
$debitur->update($validate);
|
||||
return redirect()
|
||||
->route('debitur.index')
|
||||
->with('success', 'Debitur updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('debitur.edit', $id)
|
||||
->with('error', 'Failed to update debitur');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Delete from database
|
||||
$debitur = Debiture::find($id);
|
||||
$debitur->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Debitur deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete debitur']);
|
||||
}
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Debiture::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('cif', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', "%$search%");
|
||||
$q->orWhere('address', 'LIKE', "%$search%");
|
||||
$q->orWhere('npwp', 'LIKE', "%$search%");
|
||||
$q->orWhere('nomor_id', 'LIKE', "%$search%");
|
||||
$q->orWhere('email', 'LIKE', "%$search%");
|
||||
$q->orWhere('phone', 'LIKE', "%$search%");
|
||||
$q->orWhere('nomor_rekening', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with('branch')->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
return Excel::download(new DebitureExport, 'debitur.xlsx');
|
||||
}
|
||||
}
|
50
app/Http/Requests/DebitureRequest.php
Normal file
50
app/Http/Requests/DebitureRequest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DebitureRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'branch_id' => 'required|exists:branches,id',
|
||||
'province_code' => 'nullable|exists:provinces,code',
|
||||
'city_code' => 'nullable|exists:cities,code',
|
||||
'district_code' => 'nullable|exists:districts,code',
|
||||
'village_code' => 'nullable|exists:villages,code',
|
||||
'nomor_rekening' => 'nullable|string|max:50',
|
||||
'name' => 'required',
|
||||
'registered_at' => 'nullable|date',
|
||||
'npwp' => 'nullable|string|max:16',
|
||||
'nomor_id' => 'nullable|string|max:16',
|
||||
'email' => 'nullable|email',
|
||||
'phone' => 'nullable|string|max:15',
|
||||
'address' => 'nullable|string',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'status' => 'nullable|boolean'
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['cif'] = 'required|unique:debitures,cif,' . $this->id;
|
||||
} else {
|
||||
$rules['cif'] = 'required|unique:debitures,cif';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
60
app/Models/Debiture.php
Normal file
60
app/Models/Debiture.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
|
||||
class Debiture extends Base
|
||||
{
|
||||
protected $table = 'debitures';
|
||||
protected $fillable = [
|
||||
'branch_id',
|
||||
'cif',
|
||||
'name',
|
||||
'registered_at',
|
||||
'npwp',
|
||||
'nomor_id',
|
||||
'email',
|
||||
'phone',
|
||||
'nomor_rekening',
|
||||
'province_code',
|
||||
'city_code',
|
||||
'district_code',
|
||||
'village_code',
|
||||
'postal_code',
|
||||
'address',
|
||||
'status',
|
||||
'authorized_at',
|
||||
'authorized_status',
|
||||
'authorized_by'
|
||||
];
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id', 'id');
|
||||
}
|
||||
|
||||
public function province()
|
||||
{
|
||||
return $this->belongsTo(Province::class, 'province_code', 'code');
|
||||
}
|
||||
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(City::class, 'city_code', 'code');
|
||||
}
|
||||
|
||||
public function district()
|
||||
{
|
||||
return $this->belongsTo(District::class, 'district_code', 'code');
|
||||
}
|
||||
|
||||
public function village()
|
||||
{
|
||||
return $this->belongsTo(Village::class, 'village_code', 'code');
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
: void
|
||||
{
|
||||
Schema::create('debitures', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Branch::class)->constrained()->onDelete('cascade');
|
||||
$table->string('cif', 10)->unique();
|
||||
$table->string('name');
|
||||
$table->date('registered_at')->nullable();
|
||||
$table->string('npwp', 16)->nullable();
|
||||
$table->string('nomor_id', 16)->nullable();
|
||||
$table->string('email', 100)->nullable();
|
||||
$table->string('phone', 15)->nullable();
|
||||
$table->string('nomor_rekening', 50)->nullable();
|
||||
$table->string('province_code')->index();
|
||||
$table->string('city_code')->index();
|
||||
$table->string('district_code')->index();
|
||||
$table->string('village_code')->index();
|
||||
$table->string('postal_code', 5)->nullable();
|
||||
$table->text('address')->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('debitures');
|
||||
}
|
||||
};
|
60
module.json
60
module.json
@ -35,47 +35,24 @@
|
||||
},
|
||||
{
|
||||
"title": "Data Debitur",
|
||||
"path": "",
|
||||
"path": "debitur",
|
||||
"icon": "ki-filled ki-people text-lg",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"Administrator"
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"title": "Debitur",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
},
|
||||
{
|
||||
"title": "Pemilik Jaminan",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
},
|
||||
{
|
||||
"title": "Jaminan",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
},
|
||||
{
|
||||
"title": "Dokumen Jaminan",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Authorization",
|
||||
"path": "",
|
||||
"icon": "ki-filled ki-some-files text-lg",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"Administrator"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -109,21 +86,16 @@
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"title": "Mata Uang",
|
||||
"path": "basicdata.currency",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
}, {
|
||||
"title": "Debitur",
|
||||
"path": "",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": []
|
||||
},{
|
||||
},
|
||||
{
|
||||
"title": "Jenis Fasilitas Kredit",
|
||||
"path": "basicdata.jenis-fasilitas-kredit",
|
||||
"classes": "",
|
||||
|
242
resources/views/debitur/create.blade.php
Normal file
242
resources/views/debitur/create.blade.php
Normal file
@ -0,0 +1,242 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
@if(isset($debitur->id))
|
||||
<form action="{{ route('debitur.update', $debitur->id) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $debitur->id }}">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('debitur.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($debitur->id) ? 'Edit' : 'Tambah' }} Debitur
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('debitur.index') }}" class="btn btn-xs btn-info">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Cabang
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="input tomselect w-full @error('branch_id') border-danger @enderror" name="branch_id" id="branch_id">
|
||||
<option value="">Pilih Cabang</option>
|
||||
@foreach($branches as $branch)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $branch->id }}" {{ $branch->id == $debitur->branch_id ? 'selected' : '' }}>{{ $branch->name }}</option>
|
||||
@else
|
||||
<option value="{{ $branch->id }}">{{ $branch->name }}</option>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
@error('branch_id')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
CIF
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('cif') border-danger @enderror" type="number" name="cif" value="{{ $debitur->cif ?? '' }}">
|
||||
@error('cif')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nomor Rekening
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('nomor_rekening') border-danger @enderror" type="number" name="nomor_rekening" value="{{ $debitur->nomor_rekening ?? '' }}">
|
||||
@error('nomor_rekening')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nama Debitur
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger @enderror" type="text" name="name" value="{{ $debitur->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nomor ID/KTP
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('nomor_id') border-danger @enderror" type="number" name="nomor_id" value="{{ $debitur->nomor_id ?? '' }}">
|
||||
@error('nomor_id')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
NPWP
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('npwp') border-danger @enderror" type="number" name="npwp" value="{{ $debitur->npwp ?? '' }}">
|
||||
@error('npwp')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Email
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('email') border-danger @enderror" type="email" name="email" value="{{ $debitur->email ?? '' }}">
|
||||
@error('email')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
No Handphone
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('phone') border-danger @enderror" type="number" name="phone" value="{{ $debitur->phone ?? '' }}">
|
||||
@error('phone')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Address
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex flex-col lg:flex-row gap-2 w-full">
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select id="province_code" name="province_code" class="select w-full @error('province_code') border-danger @enderror">
|
||||
<option value="">Select Province</option>
|
||||
@foreach($provinces as $province)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $province->code }}" {{ isset($debitur->province_code) && $debitur->province_code == $province->code?'selected' : '' }}>
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $province->code }}">
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
@error('province_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select id="city_code" name="city_code" class="select w-full @error('city_code') border-danger @enderror">
|
||||
<option value="">Select City</option>
|
||||
@if(isset($cities))
|
||||
@foreach($cities as $city)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $city->code }}" {{ isset($debitur->city_code) && $debitur->city_code == $city->code?'selected' : '' }}>
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $city->code }}">
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
</select>
|
||||
@error('city_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col lg:flex-row gap-2 w-full mt-2 lg:mt-5">
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select id="district_code" name="district_code" class="select w-full @error('district_code') border-danger @enderror">
|
||||
<option value="">Select District</option>
|
||||
@if(isset($districts))
|
||||
@foreach($districts as $district)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $district->code }}" {{ isset($debitur->district_code) && $debitur->district_code == $district->code?'selected' : '' }}>
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $district->code }}">
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
</select>
|
||||
@error('district_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select id="village_code" name="village_code" class="select w-full @error('district_code') border-danger @enderror">
|
||||
<option value="">Select Village</option>
|
||||
@if(isset($villages))
|
||||
@foreach($villages as $village)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $village->code }}" {{ isset($debitur->village_code) && $debitur->village_code == $village->code?'selected' : '' }}>
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $village->code }}">
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
</select>
|
||||
@error('district_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('postal_code') border-danger @enderror" type="number" id="postal_code" name="postal_code" value="{{ $debitur->postal_code ?? '' }}" placeholder="Postal Code">
|
||||
@error('postal_code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row w-full mt-2 lg:mt-5">
|
||||
<textarea class="textarea @error('address') border-danger @enderror" rows="3" type="number" id="address" name="address">{{ $debitur->address ?? '' }}</textarea>
|
||||
@error('address')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
201
resources/views/debitur/index.blade.php
Normal file
201
resources/views/debitur/index.blade.php
Normal file
@ -0,0 +1,201 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('debitur') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="debitur-table" data-api-url="{{ route('debitur.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Debitur
|
||||
</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 Debitur" 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="{{ route('debitur.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('debitur.create') }}"> Tambah Debitur </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-[50px]" data-datatable-column="cif">
|
||||
<span class="sort"> <span class="sort-label"> Cif </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="nomor_rekening">
|
||||
<span class="sort"> <span class="sort-label"> Nomor Rekening </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="name">
|
||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="branch">
|
||||
<span class="sort"> <span class="sort-label"> Cabang </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="nomor_id">
|
||||
<span class="sort"> <span class="sort-label"> Nomor ID </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="npwp">
|
||||
<span class="sort"> <span class="sort-label"> NPWP </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="email">
|
||||
<span class="sort"> <span class="sort-label"> Email </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="phone">
|
||||
<span class="sort"> <span class="sort-label"> Phone </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px]" data-datatable-column="address">
|
||||
<span class="sort"> <span class="sort-label"> Alamat </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
||||
<div class="flex items-center gap-2">
|
||||
Show
|
||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<span data-datatable-info="true"> </span>
|
||||
<div class="pagination" data-datatable-pagination="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script type="text/javascript">
|
||||
function deleteData(data) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax(`debitur/${data}`, {
|
||||
type: 'DELETE'
|
||||
}).then((response) => {
|
||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#debitur-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();
|
||||
},
|
||||
},
|
||||
cif: {
|
||||
title: 'CIF',
|
||||
},
|
||||
nomor_rekening: {
|
||||
title: 'Nomor Rekening',
|
||||
},
|
||||
name: {
|
||||
title: 'Debitur',
|
||||
},
|
||||
branch: {
|
||||
title: 'Cabang',
|
||||
render: (item, data, context) => {
|
||||
return `${data.branch_name}`;
|
||||
},
|
||||
},
|
||||
nomor_id: {
|
||||
title: 'Nomor ID',
|
||||
},
|
||||
npwp: {
|
||||
title: 'NPWP',
|
||||
},
|
||||
email: {
|
||||
title: 'Email',
|
||||
},
|
||||
phone: {
|
||||
title: 'Phone',
|
||||
},
|
||||
address: {
|
||||
title: 'Alamat',
|
||||
},
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="/debitur/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
dataTable.showSpinner();
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -98,3 +98,17 @@
|
||||
$trail->push('Edit Cabang');
|
||||
});
|
||||
|
||||
Breadcrumbs::for('debitur', function (BreadcrumbTrail $trail) {
|
||||
$trail->push('Debitur', route('debitur.index'));
|
||||
});
|
||||
|
||||
Breadcrumbs::for('debitur.create', function (BreadcrumbTrail $trail) {
|
||||
$trail->parent('debitur');
|
||||
$trail->push('Tambah Debitur', route('debitur.create'));
|
||||
});
|
||||
|
||||
Breadcrumbs::for('debitur.edit', function (BreadcrumbTrail $trail) {
|
||||
$trail->parent('basicdata.branch');
|
||||
$trail->push('Edit Debitur');
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Lpj\Http\Controllers\BranchController;
|
||||
use Modules\Lpj\Http\Controllers\CurrencyController;
|
||||
use Modules\Lpj\Http\Controllers\DebitureController;
|
||||
use Modules\Lpj\Http\Controllers\JenisAsetController;
|
||||
use Modules\Lpj\Http\Controllers\JenisFasilitasKreditController;
|
||||
use Modules\Lpj\Http\Controllers\JenisJaminanController;
|
||||
@ -91,4 +92,13 @@
|
||||
]
|
||||
]);
|
||||
});
|
||||
|
||||
Route::name('debitur.')->prefix('debitur')->group(function () {
|
||||
Route::get('restore/{id}', [DebitureController::class, 'restore'])->name('restore');
|
||||
Route::get('datatables', [DebitureController::class, 'dataForDatatables'])
|
||||
->name('datatables');
|
||||
Route::get('export', [DebitureController::class, 'export'])->name('export');
|
||||
});
|
||||
|
||||
Route::resource('debitur', DebitureController::class);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user