tambah fungsi add fasilitas
This commit is contained in:
374
Resources/views/pages/index_fasilitas.blade.php
Normal file
374
Resources/views/pages/index_fasilitas.blade.php
Normal file
@ -0,0 +1,374 @@
|
||||
<x-default-layout>
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
|
||||
<!--begin::Card-->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}" />
|
||||
<div class="card card-xxl-stretch mb-5 mb-xl-8">
|
||||
<!--begin::Card body-->
|
||||
<div class="card-body pt-6">
|
||||
<div class="d-flex justify-content-end ">
|
||||
<button type="button" class="btn btn-primary btn-sm " style="margin-right:35px" id="openModalBtn">
|
||||
<i class="ki-duotone ki-exit-down fs-2"><span class="path1"></span><span class="path2"></span></i>
|
||||
Tambah
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body pt-6">
|
||||
<div class="table-responsive " style="overflow-x:auto;">
|
||||
<div id="user_table">
|
||||
@include('konfirmasibank::pages.table_fasilitas')
|
||||
</div>
|
||||
<div class="d-flex justify-content-end ">
|
||||
<a href="{{ route($route[0] . '.index') }}" type="button" class="btn btn-danger btn-sm " style="">
|
||||
<i class="ki-duotone ki-exit-left fs-2"><span class="path1"></span><span
|
||||
class="path2"></span></i>
|
||||
Kembali
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end::Card body-->
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<!-- Modal header -->
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="myModalLabel">Tambah Fasilitas</h5>
|
||||
<button type="button" class="closeButton" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" id="myFormInput" action="{{ route($route[0] . '.postFasilitas') }}">
|
||||
@csrf
|
||||
<!-- Add your form fields here -->
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">No Rekening</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " name="nomor_rekening"
|
||||
placeholder="Nomor Rekening">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Jenis Fasilitas</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-select form-select-sm" aria-label="Small select example">
|
||||
<option selected>Pilih Jenis Fasilitas</option>
|
||||
@foreach ($data['limitReference'] as $item)
|
||||
<option value="{{$item->SHORT_NAME}}">{{$item->SHORT_NAME}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Saldo</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " name="saldo" placeholder="Saldo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Start Date</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="date" class="form-control form-control-sm " name="start_date"
|
||||
placeholder="Start Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Due Date</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="date" class="form-control form-control-sm " name="due_date"
|
||||
placeholder="Due Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Jangka Waktu</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " name="jangka_waktu"
|
||||
placeholder="Jangka Waktu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Fixed Rate</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " name="fixed_rate"
|
||||
placeholder="Fixed Rate">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Keterangan</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea type="text" class="form-control form-control-sm " name="keterangan"
|
||||
placeholder="Keterangan"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add more form fields here -->
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-sm closeButton"
|
||||
data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" id="submitFormBtn">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade myModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<!-- Modal header -->
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="myModalLabel">Tambah Fasilitas</h5>
|
||||
<button type="button" class="closeButton" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">
|
||||
<div id="errors"></div>
|
||||
<form class="form-horizontal" id="myFormUpdate" action="{{ route($route[0] . '.updateFasilitas') }}">
|
||||
@csrf
|
||||
<!-- Add your form fields here -->
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">No Rekening</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="hidden" class="form-control form-control-sm " id="id" name="id">
|
||||
<input type="text" class="form-control form-control-sm " id="norek" name="nomor_rekening"
|
||||
placeholder="Nomor Rekening">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Jenis Fasilitas</label>
|
||||
<div class="col-sm-9">
|
||||
{{-- <input type="text" class="form-control form-control-sm " id="jnsFasilitas" name="jenis_fasilitas" placeholder="Jenis Fasilitas"> --}}
|
||||
<select class="form-select form-select-sm" aria-label="Small select example"
|
||||
id="jnsFaasilitas-select" name="jenis_fasilitas">
|
||||
<option selected>Pilih Jenis Fasilitas</option>
|
||||
@foreach ($data['limitReference'] as $item)
|
||||
<option value="{{$item->SHORT_NAME}}">{{$item->SHORT_NAME}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Saldo</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " id="saldo" name="saldo"
|
||||
placeholder="Saldo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Start Date</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="date" class="form-control form-control-sm" id="startDate" name="start_date"
|
||||
placeholder="Start Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Due Date</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="date" class="form-control form-control-sm " id="dueDatae" name="due_date"
|
||||
placeholder="Due Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Jangka Waktu</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " id="jangkaWaktu" name="jangka_waktu"
|
||||
placeholder="Jangka Waktu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Fixed Rate</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control form-control-sm " id="fixedRate" name="fixed_rate"
|
||||
placeholder="Fixed Rate">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputName" class="col-sm-3 col-form-label">Keterangan</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea type="text" class="form-control form-control-sm " id="ket" name="keterangan"
|
||||
placeholder="Keterangan"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add more form fields here -->
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-sm closeButton2"
|
||||
data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" id="submitFormUpdate">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('customscript')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Open the modal when the "Open Modal" button is clicked
|
||||
$("#openModalBtn").click(function() {
|
||||
$("#myModal").modal('show');
|
||||
});
|
||||
$(".closeButton").click(function() {
|
||||
$("#myModal").modal('hide');
|
||||
});
|
||||
$(".closeButton2").click(function() {
|
||||
$(".myModalEdit").modal('hide');
|
||||
});
|
||||
|
||||
// Handle form submission when the "Submit" button inside the modal is clicked
|
||||
$("#submitFormBtn").click(function(e) {
|
||||
// Serialize the form data
|
||||
e.preventDefault();
|
||||
var formData = $("#myFormInput").serialize();
|
||||
// Send an AJAX request to the form submission route
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "{{ route('konfirmasibank.postFasilitas') }}",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
// Handle success response (e.g., show a success message)
|
||||
var _data = JSON.parse(data);
|
||||
toastr.success(_data.message);
|
||||
form[0].reset();
|
||||
$('#table4').ajax.reload();
|
||||
// Optionally, close the modal
|
||||
$("#myModal").modal('hide');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response (if applicable)
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function(key, value) {
|
||||
toastr.error(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(".btnEdit").click(function(e) {
|
||||
// Serialize the form data
|
||||
e.preventDefault();
|
||||
var id = $(this).data('id');
|
||||
var dataToSend = {
|
||||
_token: $('meta[name="csrf-token"]').attr('content'),
|
||||
id: id
|
||||
};
|
||||
// Send an AJAX request to the form submission route
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "{{ route('konfirmasibank.editFasilitas') }}",
|
||||
data: dataToSend,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$('#jnsFaasilitas-select option[value="' + response.jenis_fasilitas + '"]').prop(
|
||||
'selected', true);
|
||||
$('input[name="nomor_rekening"]').val(response.nomor_rekening);
|
||||
$('input[name="jenis_fasilitas"]').val(response.jenis_fasilitas);
|
||||
$('input[name="saldo"]').val(response.saldo);
|
||||
$('input[name="start_date"]').val(response.start_date);
|
||||
$('input[name="due_date"]').val(response.due_date);
|
||||
$('input[name="jangka_waktu"]').val(response.jangka_waktu);
|
||||
$('input[name="fixed_rate"]').val(response.fixed_rate);
|
||||
$('#ket').val(response.keterangan);
|
||||
$('#id').val(response.id);
|
||||
$("#myModalEdit").modal('show');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response (if applicable)
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function(key, value) {
|
||||
toastr.error(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$("#submitFormUpdate").click(function(e) {
|
||||
// Serialize the form data
|
||||
e.preventDefault();
|
||||
var formData = $("#myFormUpdate").serialize();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{{ route('konfirmasibank.updateFasilitas') }}",
|
||||
data: formData, // serializes the form's elements.
|
||||
success: function(data) {
|
||||
$(".myModalEdit").modal('hide');
|
||||
var _data = JSON.parse(data);
|
||||
toastr.success(_data.message);
|
||||
location.reload();
|
||||
|
||||
},
|
||||
error: function(data, textStatus, errorThrown) {
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function(key, value) {
|
||||
toastr.error(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(".btnDelete").click(function(e) {
|
||||
// var form = $(this).closest("form");
|
||||
var id = $(this).data('id');
|
||||
var dataToSend = {
|
||||
_token: $('meta[name="csrf-token"]').attr('content'),
|
||||
id: id
|
||||
};
|
||||
e.preventDefault();
|
||||
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) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{{ route('konfirmasibank.destroyFasilitas') }}",
|
||||
data: dataToSend, // serializes the form's elements.
|
||||
success: function(data) {
|
||||
toastr.success('has been deleted.', 'Success!', {
|
||||
timeOut: 5000
|
||||
});
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
|
||||
</x-default-layout>
|
Reference in New Issue
Block a user