|
|
|
@ -88,15 +88,8 @@
|
|
|
|
|
<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> |
|
|
|
|
<select class="form-control" id="searchPeti" 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> |
|
|
|
@ -104,6 +97,7 @@
|
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option> |
|
|
|
|
@endforeach |
|
|
|
|
</select> |
|
|
|
|
{{-- <select class="form-control" id="searchCustomer" name="customer_id"></select> --}} |
|
|
|
|
|
|
|
|
|
<label for="exit_at" class="col-form-label">Tanggal Peminjaman: <span |
|
|
|
|
class="text-danger">*</span></label> |
|
|
|
@ -146,7 +140,7 @@
|
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
var path = "{{ route('dashboard.peminjaman.autoCompleteSearch') }}"; |
|
|
|
|
|
|
|
|
|
$('#search').select2({ |
|
|
|
|
$('#searchPeti').select2({ |
|
|
|
|
placeholder: 'Pilih Detail Peti', |
|
|
|
|
ajax: { |
|
|
|
|
url: path, |
|
|
|
@ -154,7 +148,7 @@
|
|
|
|
|
delay: 250, |
|
|
|
|
processResults: function(data) { |
|
|
|
|
return { |
|
|
|
|
results: $.map(data, function(item) { |
|
|
|
|
results: $.map(data.peti, function(item) { |
|
|
|
|
return { |
|
|
|
|
text: item.fix_lot, |
|
|
|
|
id: item.id |
|
|
|
@ -165,6 +159,27 @@
|
|
|
|
|
cache: true |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Inisialisasi select2 untuk customer |
|
|
|
|
// $('#searchCustomer').select2({ |
|
|
|
|
// placeholder: 'Pilih Detail Customer', |
|
|
|
|
// ajax: { |
|
|
|
|
// url: path, |
|
|
|
|
// dataType: 'json', |
|
|
|
|
// delay: 250, |
|
|
|
|
// processResults: function(data) { |
|
|
|
|
// return { |
|
|
|
|
// results: $.map(data.customer, function(item) { |
|
|
|
|
// return { |
|
|
|
|
// text: item.name, |
|
|
|
|
// id: item.id |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
// }; |
|
|
|
|
// }, |
|
|
|
|
// cache: true |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<!-- auto disable form pada saat sudah di simpan--> |
|
|
|
@ -222,29 +237,34 @@
|
|
|
|
|
customerSelect.value = customerId; |
|
|
|
|
}); |
|
|
|
|
</script> --}} |
|
|
|
|
|
|
|
|
|
<!-- Penambahan cara baru --> |
|
|
|
|
{{-- <script> |
|
|
|
|
// Mendapatkan elemen select detail peti |
|
|
|
|
const petiSelect = $('#search'); |
|
|
|
|
|
|
|
|
|
// Mendapatkan elemen select customer |
|
|
|
|
const customerSelect = $('#customer_id'); |
|
|
|
|
const petiSelect = $('#searchPeti'); |
|
|
|
|
|
|
|
|
|
// Mendapatkan elemen select asal gudang |
|
|
|
|
// Mendapatkan elemen select warehouse |
|
|
|
|
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'); |
|
|
|
|
petiSelect.on('change', function() { |
|
|
|
|
// Mendapatkan nilai peti_id yang terpilih |
|
|
|
|
const selectedPetiId = $(this).val(); |
|
|
|
|
|
|
|
|
|
// Memilih warehouse berdasarkan peti_id yang terpilih |
|
|
|
|
$.ajax({ |
|
|
|
|
url: `/api/peti/${selectedPetiId}/warehouse`, // Gantilah dengan URL endpoint yang sesuai |
|
|
|
|
method: 'GET', |
|
|
|
|
success: function(warehouseData) { |
|
|
|
|
// Mengisi opsi warehouse |
|
|
|
|
const warehouseOption = new Option(warehouseData.name, warehouseData.id, true, |
|
|
|
|
true); |
|
|
|
|
warehouseSelect.html('').append(warehouseOption).trigger('change'); |
|
|
|
|
}, |
|
|
|
|
error: function(error) { |
|
|
|
|
console.error(error); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
</script> --}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@endsection |
|
|
|
|