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