|
|
|
@ -2,7 +2,8 @@
|
|
|
|
|
@section('title', 'Tambah Peminjaman') |
|
|
|
|
@section('content') |
|
|
|
|
@include('layouts.components.alert-prompt') |
|
|
|
|
<div class="card shadow mb-4"> |
|
|
|
|
<!-- Cara Lama --> |
|
|
|
|
{{-- <div class="card shadow mb-4"> |
|
|
|
|
<div class="card-header py-3"> |
|
|
|
|
<div class="row"> |
|
|
|
|
<div class="col-6"> |
|
|
|
@ -15,6 +16,7 @@
|
|
|
|
|
id="peminjamanForm"> |
|
|
|
|
@csrf |
|
|
|
|
<div class="form-group"> |
|
|
|
|
|
|
|
|
|
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
|
<select class="form-control" name="peti_id" id="peti_id" required> |
|
|
|
@ -68,8 +70,103 @@
|
|
|
|
|
</div> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
</div> --}} |
|
|
|
|
|
|
|
|
|
<!-- Cara Baru --> |
|
|
|
|
<div class="card shadow mb-4"> |
|
|
|
|
<div class="card-header py-3"> |
|
|
|
|
<div class="row"> |
|
|
|
|
<div class="col-6"> |
|
|
|
|
<h5 class="m-0 font-weight-bold text-primary mt-2">Tambah Peminjaman</h5> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="card-body"> |
|
|
|
|
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data" |
|
|
|
|
id="peminjamanForm"> |
|
|
|
|
@csrf |
|
|
|
|
<div class="form-group"> |
|
|
|
|
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
|
<select class="form-control" id="search" name="peti_id"></select> |
|
|
|
|
|
|
|
|
|
{{-- <label for="customer_id" class="col-form-label">Customer:<span class="text-danger">*</span></label> |
|
|
|
|
<select class="form-control" name="customer_id" type="text" id="customer_id" required> |
|
|
|
|
<option disabled selected>Pilih Nama Customer</option> |
|
|
|
|
@foreach ($customer as $data) |
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option> |
|
|
|
|
@endforeach |
|
|
|
|
</select> --}} |
|
|
|
|
<label for="customer_id" class="col-form-label">Customer:<span class="text-danger">*</span></label> |
|
|
|
|
<select class="form-control" name="customer_id" type="text" id="customer_id" required> |
|
|
|
|
<option disabled selected>Pilih Nama Customer</option> |
|
|
|
|
@foreach ($customer as $data) |
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option> |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<label for="exit_at" class="col-form-label">Tanggal Peminjaman: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
|
<input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}" |
|
|
|
|
required> |
|
|
|
|
|
|
|
|
|
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
|
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian" required> |
|
|
|
|
|
|
|
|
|
<label for="warehouse_id" class="col-form-label">Asal Gudang:</label> |
|
|
|
|
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required> |
|
|
|
|
<option disabled selected>Pilih Asal Gudang</option> |
|
|
|
|
@foreach ($warehouse as $data) |
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option> |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<label for="exit_warehouse" class="col-form-label">Tujuan Gudang: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
|
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse" required> |
|
|
|
|
<option disabled selected>Pilih Tujuan Gudang</option> |
|
|
|
|
@foreach ($warehouse as $data) |
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option> |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
</div> |
|
|
|
|
<div class="modal-footer d-flex justify-content-center"> |
|
|
|
|
<a href="{{ route('dashboard.peminjaman.index') }}" class="btn btn-secondary">Kembali</a> |
|
|
|
|
<button type="submit" class="btn btn-primary" id="submitButton">Simpan</button> |
|
|
|
|
</div> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" /> |
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> |
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script> |
|
|
|
|
{{-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> --}} |
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
var path = "{{ route('dashboard.peminjaman.autoCompleteSearch') }}"; |
|
|
|
|
|
|
|
|
|
$('#search').select2({ |
|
|
|
|
placeholder: 'Pilih Detail Peti', |
|
|
|
|
ajax: { |
|
|
|
|
url: path, |
|
|
|
|
dataType: 'json', |
|
|
|
|
delay: 250, |
|
|
|
|
processResults: function(data) { |
|
|
|
|
return { |
|
|
|
|
results: $.map(data, function(item) { |
|
|
|
|
return { |
|
|
|
|
text: item.fix_lot, |
|
|
|
|
id: item.id |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
cache: true |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<!-- auto disable form pada saat sudah di simpan--> |
|
|
|
|
<script> |
|
|
|
|
document.getElementById('peminjamanForm').addEventListener('submit', function() { |
|
|
|
@ -100,7 +197,7 @@
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<!-- otomatis asal gudang dan Customer berdasarkan detail peti --> |
|
|
|
|
<script> |
|
|
|
|
{{-- <script> |
|
|
|
|
// Mendapatkan elemen select detail peti |
|
|
|
|
const petiSelect = document.getElementById('peti_id'); |
|
|
|
|
|
|
|
|
@ -124,6 +221,30 @@
|
|
|
|
|
// Memilih customer berdasarkan data-customer-id |
|
|
|
|
customerSelect.value = customerId; |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
</script> --}} |
|
|
|
|
{{-- <script> |
|
|
|
|
// Mendapatkan elemen select detail peti |
|
|
|
|
const petiSelect = $('#search'); |
|
|
|
|
|
|
|
|
|
// Mendapatkan elemen select customer |
|
|
|
|
const customerSelect = $('#customer_id'); |
|
|
|
|
|
|
|
|
|
// Mendapatkan elemen select asal gudang |
|
|
|
|
const warehouseSelect = $('#warehouse_id'); |
|
|
|
|
|
|
|
|
|
// Menambahkan event listener ke select detail peti |
|
|
|
|
petiSelect.on('select2:select', function(e) { |
|
|
|
|
// Mendapatkan data tambahan dari opsi yang dipilih |
|
|
|
|
const warehouseId = e.params.data.warehouseId; |
|
|
|
|
const customerId = e.params.data.customerId; |
|
|
|
|
|
|
|
|
|
// Memilih asal gudang berdasarkan data-warehouse-id |
|
|
|
|
warehouseSelect.val(warehouseId).trigger('change'); |
|
|
|
|
|
|
|
|
|
// Memilih customer berdasarkan data-customer-id |
|
|
|
|
customerSelect.val(customerId).trigger('change'); |
|
|
|
|
}); |
|
|
|
|
</script> --}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@endsection |
|
|
|
|