diff --git a/DataTables/HapusBukuDataTable.php b/DataTables/HapusBukuDataTable.php new file mode 100644 index 0000000..f53d51c --- /dev/null +++ b/DataTables/HapusBukuDataTable.php @@ -0,0 +1,149 @@ +filter(callback: function ($query) { + if (request()->has('search')) { + $search = request()->get('search'); + $query->where('nomor_pinjaman', 'like', "%" . $search['value'] . "%") + ->orWhere('kode_jenis_pinjaman', 'like', "%" . $search['value'] . "%") + ->orWhere('kode_debitur', 'like', "%" . $search['value'] . "%") + ->orWhere('alamat_debitur', 'like', "%" . $search['value'] . "%") + ->orWhere('npwp_debitur', 'like', "%" . $search['value'] . "%") + ->orWhere('kode_cabang', 'like', "%" . $search['value'] . "%") + ->orWhere('kode_mata_uang', 'like', "%" . $search['value'] . "%") + ->orWhere('tanggal_hapus_buku', 'like', "%" . $search['value'] . "%") + ->orWhere('nomor_fasilitas', 'like', "%" . $search['value'] . "%") + ->orWhere('kode_jenis_fasilitas', 'like', "%" . $search['value'] . "%") + ->orWhere('nilai_plafond_awal', 'like', "%" . $search['value'] . "%") + ->orWhere('suku_bunga', 'like', "%" . $search['value'] . "%") + ->orWhere('baki_debet', 'like', "%" . $search['value'] . "%") + ->orWhere('jumlah_bunga', 'like', "%" . $search['value'] . "%") + ->orWhere('jumlah_kewajiban_lain', 'like', "%" . $search['value'] . "%") + ->orWhere('total_kewajiban', 'like', "%" . $search['value'] . "%") + ->orWhere('total_bunga_extra', 'like', "%" . $search['value'] . "%") + ->orWhere('bunga_ekstra', 'like', "%" . $search['value'] . "%") + ->orWhere('bunga_non_ekstra', 'like', "%" . $search['value'] . "%") + ->orWhere('denda', 'like', "%" . $search['value'] . "%") + ->orWhere('tagihan_lain', 'like', "%" . $search['value'] . "%") + ->orWhere('biaya_lain', 'like', "%" . $search['value'] . "%") + ->orWhere('total_all_kewajiban', 'like', "%" . $search['value'] . "%") + ->orWhere('memo_persetujuan', 'like', "%" . $search['value'] . "%") + ->orWhere('lama_hari', 'like', "%" . $search['value'] . "%") + ->orWhere('proses_hukum', 'like', "%" . $search['value'] . "%") + ->orWhere('komitmen_debitur', 'like', "%" . $search['value'] . "%") + ->orWhere('keterangan', 'like', "%" . $search['value'] . "%") + ->orWhere('status', 'like', "%" . $search['value'] . "%"); + } + })->addIndexColumn()->editColumn('tanggal_hapus_buku', function ($row) { + $date = Carbon::create($row->tanggal_hapus_buku); + return $date->locale('id')->translatedFormat('d F Y'); + })->editColumn('cabang', function ($row) { + return Branch::where('kode', $row->kode_cabang)->first()->name; + })->editColumn('jenis_pinjaman', function ($row) { + return LoanType::where('kode', $row->kode_jenis_pinjaman)->first()->name; + })->editColumn('jenis_fasilitas', function ($row) { + return FacilityType::where('kode', $row->kode_jenis_fasilitas)->first()->name; + })->editColumn('updated_at', function ($row) { + return $row->updated_at->locale('id')->translatedFormat('d F Y H:i:s'); + })->editColumn('total_kewajiban', function ($row) { + return Number::currency($row->total_kewajiban,'IDR','id_ID'); + })->editColumn('status', function ($row) { + $status = $row->status ? 'Aktif' : 'Tidak Aktif'; + $oto = $row->authorized_at !== null ? 'Authorised' : 'Not Authorised'; + return $status . ' ' . $oto; + })->rawColumns(['action', 'status'])->addColumn('action', function ($hapus_buku) { + return view('writeoff::pencatatan.hapus_buku._actions', compact('hapus_buku')); + })->setRowId('id'); + } + + private function rupiah($expression) + { + return "Rp. " . number_format($expression, 2, ',', '.'); + } + + /** + * Get the query source of dataTable. + */ + public function query(HapusBuku $model) + : QueryBuilder + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use the html builder. + */ + public function html() + : HtmlBuilder + { + return $this->builder() + ->setTableId('hapus-buku-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/hapus_buku/_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('nomor_pinjaman')->title('Nomor Pinjaman'), + Column::make('debitur')->title('Debitur'), + Column::make('cabang')->title('Cabang'), + Column::make('jenis_pinjaman')->title('Jenis Pinjaman'), + Column::make('jenis_fasilitas')->title('Jenis Fasilitas'), + Column::make('tanggal_hapus_buku')->title('Tanggal Hapus Buku'), + Column::make('total_kewajiban')->title('Total Kewajiban'), + Column::make('memo_persetujuan')->title('Memo Persetujuan'), + Column::make('keterangan')->title('Keterangan'), + 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 'HapusBuku_' . date('YmdHis'); + } + } diff --git a/DataTables/SubrogasiJamkrindoDataTable.php b/DataTables/SubrogasiJamkrindoDataTable.php index e28b4f1..de8591d 100644 --- a/DataTables/SubrogasiJamkrindoDataTable.php +++ b/DataTables/SubrogasiJamkrindoDataTable.php @@ -10,6 +10,7 @@ use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; use Yajra\DataTables\Services\DataTable; + use Illuminate\Support\Number; class SubrogasiJamkrindoDataTable extends DataTable { @@ -44,11 +45,11 @@ $date = Carbon::create($row->tanggal_pengajuan_klaim); return $date->locale('id')->translatedFormat('d F Y'); })->editColumn('plafond', function ($row) { - return $this->rupiah($row->plafond); + return Number::currency($row->plafond,'IDR','id_ID'); })->editColumn('piutang_subrogasi', function ($row) { - return $this->rupiah($row->piutang_subrogasi); + return Number::currency($row->piutang_subrogasi,'IDR','id_ID'); })->editColumn('sisa_piutang_subrogasi', function ($row) { - return $this->rupiah($row->sisa_piutang_subrogasi); + return Number::currency($row->sisa_piutang_subrogasi,'IDR','id_ID'); })->editColumn('is_lunas_subrogasi', function ($row) { return $row->is_lunas_subrogasi ? 'Lunas' : 'Belum Lunas'; })->editColumn('updated_at', function ($row) { @@ -58,11 +59,6 @@ })->setRowId('id'); } - private function rupiah($expression) - { - return "Rp. " . number_format($expression, 2, ',', '.'); - } - /** * Get the query source of dataTable. */ diff --git a/Database/Migrations/2023_12_05_033249_create_hapus_buku_table.php b/Database/Migrations/2023_12_05_033249_create_hapus_buku_table.php index a0d5669..934a2b3 100644 --- a/Database/Migrations/2023_12_05_033249_create_hapus_buku_table.php +++ b/Database/Migrations/2023_12_05_033249_create_hapus_buku_table.php @@ -17,6 +17,7 @@ $table->string('nomor_pinjaman', 20); $table->integer('kode_jenis_pinjaman', false, true); $table->integer('kode_debitur', false, true); + $table->string('nama_debitur'); $table->text('alamat_debitur')->nullable(); $table->string('npwp_debitur', 16)->nullable(); $table->string('kode_cabang', 11); diff --git a/Entities/HapusBuku.php b/Entities/HapusBuku.php index 2280d14..95fbc8f 100644 --- a/Entities/HapusBuku.php +++ b/Entities/HapusBuku.php @@ -10,6 +10,7 @@ 'nomor_pinjaman', 'kode_jenis_pinjaman', 'kode_debitur', + 'nama_debitur', 'alamat_debitur', 'npwp_debitur', 'kode_cabang', diff --git a/Http/Controllers/HapusBukuController.php b/Http/Controllers/HapusBukuController.php new file mode 100644 index 0000000..f5575b5 --- /dev/null +++ b/Http/Controllers/HapusBukuController.php @@ -0,0 +1,37 @@ +middleware(function ($request, $next) { + $this->user = Auth::guard('web')->user(); + return $next($request); + }); + } + + /** + * Display a listing of the SubrogasiJamkrindos. + * + * @param \Modules\Writeoff\DataTables\HapusBukuDataTable $dataTable + * + * @return mixed + */ + public function index(HapusBukuDataTable $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::pencatatan.hapus_buku.index'); + } + } diff --git a/Http/Requests/HapusBuku/StoreHapusBukuRequest.php b/Http/Requests/HapusBuku/StoreHapusBukuRequest.php index 3e9bc6b..5172a9e 100644 --- a/Http/Requests/HapusBuku/StoreHapusBukuRequest.php +++ b/Http/Requests/HapusBuku/StoreHapusBukuRequest.php @@ -31,6 +31,7 @@ 'nomor_pinjaman' => 'required|integer', 'kode_jenis_pinjaman' => 'required|integer', 'kode_debitur' => 'required|integer', + 'nama_debitur' => 'required|string', 'alamat_debitur' => 'nullable|string', 'npwp_debitur' => 'nullable|string', 'kode_cabang' => 'required|string', diff --git a/Http/Requests/HapusBuku/UpdateHapusBukuRequest.php b/Http/Requests/HapusBuku/UpdateHapusBukuRequest.php index 9a23450..cebbdd6 100644 --- a/Http/Requests/HapusBuku/UpdateHapusBukuRequest.php +++ b/Http/Requests/HapusBuku/UpdateHapusBukuRequest.php @@ -1,6 +1,6 @@ 'required|integer', - 'kode_debitur' => 'required|integer', - 'nama_debitur' => 'required|string', - 'kode_cabang' => 'required|string', - 'nama_cabang' => 'required|string', - 'nomor_rekening' => 'required|integer', - 'nama_rekening' => 'required|string', - 'plafond' => 'required|numeric', - 'tenor' => 'required|integer', - 'tanggal_pengajuan_klaim' => 'required|date', - 'piutang_subrogasi' => 'required|numeric', - 'total_bayar_subrogasi' => 'required|numeric', - 'sisa_piutang_subrogasi' => 'required|numeric', - 'is_lunas_subrogasi' => 'required|boolean', - 'keterangan' => 'nullable|string', - 'status' => 'nullable|boolean', + 'nomor_pinjaman' => 'required|integer', + 'kode_jenis_pinjaman' => 'required|integer', + 'kode_debitur' => 'required|integer', + 'nama_debitur' => 'required|string', + 'alamat_debitur' => 'nullable|string', + 'npwp_debitur' => 'nullable|string', + 'kode_cabang' => 'required|string', + 'kode_mata_uang' => 'required|string', + 'tanggal_hapus_buku' => 'required|date', + 'nomor_fasilitas' => 'required|string', + 'kode_jenis_fasilitas' => 'required|integer', + 'nilai_plafond_awal' => 'required|numeric', + 'suku_bunga' => 'required|integer', + 'baki_debet' => 'required|numeric', + 'jumlah_bunga' => 'required|numeric', + 'jumlah_kewajiban_lain' => 'nullable|numeric', + 'total_kewajiban' => 'nullable|numeric', + 'total_bunga_extra' => 'required|numeric', + 'bunga_ekstra' => 'nullable|numeric', + 'bunga_non_ekstra' => 'required|numeric', + 'denda' => 'nullable|numeric', + 'tagihan_lain' => 'required|numeric', + 'biaya_lain' => 'required|numeric', + 'total_all_kewajiban' => 'nullable|numeric', + 'memo_persetujuan' => 'nullable|string', + 'lama_hari' => 'nullable|integer', + 'proses_hukum' => 'nullable|string', + 'komitmen_debitur' => 'nullable|string', + 'keterangan' => 'nullable|string', + 'status' => 'nullable|boolean', ]; } @@ -61,8 +75,8 @@ } return redirect() - ->route('pencatatan.subrogasi_jamkrindo.index') - ->with('error', 'Subrogasi Jamkrindo updated failed.'); + ->route('pencatatan.hapus_buku.index') + ->with('error', 'Hapus Buku updated failed.'); } }); } @@ -75,7 +89,7 @@ throw new HttpResponseException(response()->json([ 'success' => false, 'errors' => $errors, - 'messages' => 'Subrogasi Jamkrindo updated failed.' + 'messages' => 'Hapus Buku updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } } diff --git a/Livewire/HapusBuku/HapusBukuModal.php b/Livewire/HapusBuku/HapusBukuModal.php new file mode 100644 index 0000000..aa292ed --- /dev/null +++ b/Livewire/HapusBuku/HapusBukuModal.php @@ -0,0 +1,200 @@ + 'delete', + 'update' => 'update', + ]; + + public function render() + { + $branch = Branch::all(); + $loan_type = LoanType::all(); + $facility_type = FacilityType::all(); + + return view('writeoff::livewire.hapus-buku.hapus-buku-modal', compact('branch', 'loan_type', 'facility_type')); + } + + public function submit() + { + $this->validate(); + + // Validate the form input data + DB::transaction(function () { + // Prepare the data for creating a new user + $data = [ + 'nomor_pinjaman' => $this->nomor_pinjaman, + 'kode_jenis_pinjaman' => $this->kode_jenis_pinjaman, + 'kode_debitur' => $this->kode_debitur, + 'nama_debitur' => $this->nama_debitur, + 'alamat_debitur' => $this->alamat_debitur, + 'npwp_debitur' => $this->npwp_debitur, + 'kode_cabang' => $this->kode_cabang, + 'kode_mata_uang' => $this->kode_mata_uang, + 'tanggal_hapus_buku' => $this->tanggal_hapus_buku, + 'nomor_fasilitas' => $this->nomor_fasilitas, + 'kode_jenis_fasilitas' => $this->kode_jenis_fasilitas, + 'nilai_plafond_awal' => $this->nilai_plafond_awal, + 'suku_bunga' => $this->suku_bunga, + 'baki_debet' => $this->baki_debet, + 'jumlah_bunga' => $this->jumlah_bunga, + 'jumlah_kewajiban_lain' => $this->jumlah_kewajiban_lain, + 'total_kewajiban' => $this->total_kewajiban, + 'total_bunga_extra' => $this->total_bunga_extra, + 'bunga_ekstra' => $this->bunga_ekstra, + 'bunga_non_ekstra' => $this->bunga_non_ekstra, + 'denda' => $this->denda, + 'tagihan_lain' => $this->tagihan_lain, + 'biaya_lain' => $this->biaya_lain, + 'total_all_kewajiban' => $this->total_all_kewajiban, + 'memo_persetujuan' => $this->memo_persetujuan, + 'lama_hari' => $this->lama_hari, + 'proses_hukum' => $this->proses_hukum, + 'komitmen_debitur' => $this->komitmen_debitur, + 'keterangan' => $this->keterangan, + 'status' => $this->status + ]; + + if ($this->edit_mode) { + // Emit a success event with a message + $hapus_buku = HapusBuku::find($this->id); + $hapus_buku->update($data); + + $this->dispatch('success', __('Hapus Buku updated')); + } else { + // Emit a success event with a message + HapusBuku::create($data); + $this->dispatch('success', __('New Hapus Buku created')); + } + }); + + // Reset the form fields after successful submission + //$this->reset(); + + } + + public function update($id) + { + $this->edit_mode = true; + + $hapus_buku = HapusBuku::find($id); + + $this->id = $hapus_buku->id; + $this->nomor_pinjaman = $hapus_buku->nomor_pinjaman; + $this->kode_jenis_pinjaman = $hapus_buku->kode_jenis_pinjaman; + $this->kode_debitur = $hapus_buku->kode_debitur; + $this->nama_debitur = $hapus_buku->nama_debitur; + $this->alamat_debitur = $hapus_buku->alamat_debitur; + $this->npwp_debitur = $hapus_buku->npwp_debitur; + $this->kode_cabang = $hapus_buku->kode_cabang; + $this->kode_mata_uang = $hapus_buku->kode_mata_uang; + $this->tanggal_hapus_buku = $hapus_buku->tanggal_hapus_buku; + $this->nomor_fasilitas = $hapus_buku->nomor_fasilitas; + $this->kode_jenis_fasilitas = $hapus_buku->kode_jenis_fasilitas; + $this->nilai_plafond_awal = $hapus_buku->nilai_plafond_awal; + $this->suku_bunga = $hapus_buku->suku_bunga; + $this->baki_debet = $hapus_buku->baki_debet; + $this->jumlah_bunga = $hapus_buku->jumlah_bunga; + $this->jumlah_kewajiban_lain = $hapus_buku->jumlah_kewajiban_lain; + $this->total_kewajiban = $hapus_buku->total_kewajiban; + $this->total_bunga_extra = $hapus_buku->total_bunga_extra; + $this->bunga_ekstra = $hapus_buku->bunga_ekstra; + $this->bunga_non_ekstra = $hapus_buku->bunga_non_ekstra; + $this->denda = $hapus_buku->denda; + $this->tagihan_lain = $hapus_buku->tagihan_lain; + $this->biaya_lain = $hapus_buku->biaya_lain; + $this->total_all_kewajiban = $hapus_buku->total_all_kewajiban; + $this->memo_persetujuan = $hapus_buku->memo_persetujuan; + $this->lama_hari = $hapus_buku->lama_hari; + $this->proses_hukum = $hapus_buku->proses_hukum; + $this->komitmen_debitur = $hapus_buku->komitmen_debitur; + $this->keterangan = $hapus_buku->keterangan; + $this->status = $hapus_buku->status == 1; + } + + public function getDebitur() + { + $debitur = Debitur::where('kode', $this->kode_debitur)->first(); + if ($debitur) { + $this->nama_debitur = $debitur->name; + } else { + $this->nama_debitur = ''; + $this->addError('nama_debitur', 'Debitur Tidak Ditemukan'); + } + } + + public function delete($id) + { + HapusBuku::destroy($id); + + // Emit a success event with a message + $this->dispatch('success', 'Hapus Buku successfully deleted'); + } + + public function hydrate() + { + $this->resetErrorBag(); + $this->resetValidation(); + } + + protected function rules() + { + + if ($this->edit_mode) { + $request = new UpdateHapusBukuRequest(); + } else { + $request = new StoreHapusBukuRequest(); + } + + + return $request->rules(); + } + } + diff --git a/Resources/views/livewire/hapus-buku/hapus-buku-modal.blade.php b/Resources/views/livewire/hapus-buku/hapus-buku-modal.blade.php new file mode 100644 index 0000000..dd48483 --- /dev/null +++ b/Resources/views/livewire/hapus-buku/hapus-buku-modal.blade.php @@ -0,0 +1,72 @@ + diff --git a/Resources/views/partials/menu/_app.blade.php b/Resources/views/partials/menu/_app.blade.php index de72025..e6d599a 100644 --- a/Resources/views/partials/menu/_app.blade.php +++ b/Resources/views/partials/menu/_app.blade.php @@ -95,6 +95,15 @@