This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
Dashboard
|
||||
Dashboard
|
||||
@endsection
|
||||
|
||||
@section('admin-content')
|
||||
<script src="https://cdn.jsdelivr.net/npm/autonumeric@4.6.0/dist/autoNumeric.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
@@ -45,7 +46,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-body">
|
||||
<form id="expense-form" method="POST" action="{{ route('forms.other.store') }}" enctype="multipart/form-data">
|
||||
<form id="expense-form" method="POST" action="{{ route('forms.other.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="row">
|
||||
@@ -82,7 +83,7 @@
|
||||
<div class="mb-3">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<label class="form-label mb-0">Lampiran</label>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="other-add-attachment-row">
|
||||
<button type="button" class="btn btn-slate-custom btn-outline-primary btn-sm" id="other-add-attachment-row">
|
||||
<i class="fas fa-plus mr-1"></i> Tambah Lampiran
|
||||
</button>
|
||||
</div>
|
||||
@@ -113,7 +114,7 @@
|
||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
@include('backend.components.attachment-preview-modal', [
|
||||
'modalId' => 'otherAttachmentPreviewModal',
|
||||
@@ -133,19 +134,44 @@
|
||||
</section>
|
||||
|
||||
<script>
|
||||
new AutoNumeric('#total', {
|
||||
// 1. Inisialisasi AutoNumeric dengan batasan angka minimum nol
|
||||
const totalAutoNumeric = new AutoNumeric('#total', {
|
||||
digitGroupSeparator: '.',
|
||||
decimalCharacter: ',',
|
||||
currencySymbol: 'Rp.',
|
||||
decimalPlaces: 0,
|
||||
minimumValue: '0',
|
||||
unformatOnSubmit: true
|
||||
});
|
||||
|
||||
// 2. Mematikan sliding wheel mouse (scrolling) pada kolom input nominal angka
|
||||
document.getElementById('total').addEventListener('wheel', function (e) {
|
||||
e.preventDefault();
|
||||
this.blur();
|
||||
});
|
||||
|
||||
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function () {
|
||||
spinnerOverlay.classList.remove('d-none');
|
||||
spinnerOverlay.classList.add('d-flex');
|
||||
// 3. Interseptor Validasi Submit Form dengan Batasan Nilai Rp 1.000.000 bersih
|
||||
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||
// Mengambil angka murni tanpa format simbol dari instance AutoNumeric
|
||||
const rawTotalValue = totalAutoNumeric.getNumber() || 0;
|
||||
|
||||
if (rawTotalValue > 1000000) {
|
||||
e.preventDefault(); // Batalkan pengiriman form ke route backend
|
||||
|
||||
Swal.fire({
|
||||
title: 'Batas Angka Terlampaui!',
|
||||
text: 'Pengajuan nominal Expense Other tidak diperbolehkan melebihi batas Rp 1.000.000. Mohon periksa kembali input Anda.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#d33',
|
||||
confirmButtonText: 'Revisi Data'
|
||||
});
|
||||
} else {
|
||||
// Lolos validasi, aktifkan spinner overlay UI
|
||||
spinnerOverlay.classList.remove('d-none');
|
||||
spinnerOverlay.classList.add('d-flex');
|
||||
}
|
||||
});
|
||||
|
||||
const attachmentCategories = @json($attachmentCategories ?? ($otherAttachmentCategories ?? []));
|
||||
@@ -394,4 +420,4 @@
|
||||
addOtherAttachmentRow();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
Reference in New Issue
Block a user