|
|
|
@extends('layouts.main')
|
|
|
|
@section('content')
|
|
|
|
@include('layouts.components.alert-prompt')
|
|
|
|
<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">Transfer Peti</h5>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<form action="{{ route('dashboard.transfer.store') }}" method="POST" enctype="multipart/form-data"
|
|
|
|
id="transferForm">
|
|
|
|
@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="searchPeti" name="peti_id"></select>
|
|
|
|
{{-- <select class="form-control" name="peti_id" type="text" id="peti_id" required>
|
|
|
|
<option disabled selected>Pilih Detail Peti</option>
|
|
|
|
@foreach ($peti as $data_peti)
|
|
|
|
<option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}"
|
|
|
|
data-customer-name="{{ $data_peti->customer->name }}">
|
|
|
|
{{ $data_peti->fix_lot }}
|
|
|
|
</option>
|
|
|
|
@endforeach
|
|
|
|
</select> --}}
|
|
|
|
|
|
|
|
<label for="date" class="col-form-label">Tanggal Transfer: <span
|
|
|
|
class="text-danger">*</span></label>
|
|
|
|
<input class="form-control" name="date" type="date" id="date" value="{{ old('date') }}"
|
|
|
|
required>
|
|
|
|
|
|
|
|
<label for="name_customer" class="col-form-label">Customer: <span class="text-danger">*</span></label>
|
|
|
|
<select class="form-control" name="name_customer" type="text" id="name_customer" required>
|
|
|
|
<option disabled selected>Pilih Nama Customer</option>
|
|
|
|
@foreach ($customer as $data_customer)
|
|
|
|
<option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<label for="source_warehouse" class="col-form-label">Asal Gudang: <span
|
|
|
|
class="text-danger">*</span></label>
|
|
|
|
<select class="form-control" name="source_warehouse" type="text" id="source_warehouse" required>
|
|
|
|
<option disabled selected>Pilih Asal gudang</option>
|
|
|
|
@foreach ($warehouse as $data)
|
|
|
|
<option value="{{ $data->id }}">{{ $data->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<label for="destination_warehouse" class="col-form-label">Tujuan Gudang: <span
|
|
|
|
class="text-danger">*</span></label>
|
|
|
|
<select class="form-control" name="destination_warehouse" type="text" 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.transfer.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.transfer.autoCompleteSearch') }}";
|
|
|
|
|
|
|
|
$('#searchPeti').select2({
|
|
|
|
placeholder: 'Pilih Detail Peti',
|
|
|
|
ajax: {
|
|
|
|
url: path,
|
|
|
|
dataType: 'json',
|
|
|
|
delay: 250,
|
|
|
|
processResults: function(data) {
|
|
|
|
return {
|
|
|
|
results: $.map(data.peti, function(item) {
|
|
|
|
return {
|
|
|
|
text: item.fix_lot,
|
|
|
|
id: item.id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
},
|
|
|
|
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-->
|
|
|
|
<script>
|
|
|
|
document.getElementById('transferForm').addEventListener('submit', function() {
|
|
|
|
document.getElementById('submitButton').setAttribute('disabled', 'true');
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- otomatis asal gudang dan Customer berdasarkan detail peti -->
|
|
|
|
<script>
|
|
|
|
// Mendapatkan elemen select detail peti
|
|
|
|
const petiSelect = document.getElementById('peti_id');
|
|
|
|
|
|
|
|
// Mendapatkan elemen select asal gudang
|
|
|
|
const source_warehouseSelect = document.getElementById('source_warehouse');
|
|
|
|
|
|
|
|
// Mendapatkan elemen select Customer
|
|
|
|
// const name_customerSelect = document.getElementById('name_customer');
|
|
|
|
|
|
|
|
// Menambahkan event listener ke select detail peti
|
|
|
|
petiSelect.addEventListener('change', function() {
|
|
|
|
// Mendapatkan data-warehouse-id dari option yang dipilih
|
|
|
|
const selectedOption = this.options[this.selectedIndex];
|
|
|
|
const warehouseId = selectedOption.getAttribute('data-warehouse-id');
|
|
|
|
|
|
|
|
// Mendapatkan data-customer-name dari option yang dipilih
|
|
|
|
// const customerName = selectedOption.getAttribute('data-customer-name');
|
|
|
|
|
|
|
|
// Memilih asal gudang berdasarkan data-warehouse-id
|
|
|
|
source_warehouseSelect.value = warehouseId;
|
|
|
|
|
|
|
|
// Memilih customer berdasarkan data-customer-name
|
|
|
|
// for (let i = 0; i < name_customerSelect.options.length; i++) {
|
|
|
|
// if (name_customerSelect.options[i].text === customerName) {
|
|
|
|
// name_customerSelect.selectedIndex = i;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@endsection
|