Siopas Inventory PETI for ISTW Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
5.6 KiB

@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">Disposal Peti</h5>
</div>
</div>
</div>
<div class="card-body">
12 months ago
<form action="{{ route('dashboard.disposal.store') }}" method="POST" enctype="multipart/form-data"
id="disposalForm">
@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" 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>
12 months ago
<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>
12 months ago
<option disabled selected>Nama Customer akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($customer as $data_customer)
<option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option>
@endforeach
</select>
<label for="date_disposal" class="col-form-label">Tanggal Disposal: <span
class="text-danger">*</span></label>
<input class="form-control" name="date_disposal" type="date" id="date_disposal"
value="{{ old('date_disposal') }}" required>
12 months ago
<label for="warehouse_id" class="col-form-label">Asal Gudang: <span class="text-danger">*</span></label>
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required>
12 months ago
<option disabled selected>Asal gudang akan otomatis terpilih ketika memilih detail peti.</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
<label for="status_disposal" class="col-form-label">Status Peti: <span
12 months ago
class="text-danger">*</span></label>
<select class="form-control" name="status_disposal" id="status_disposal" required>
<option disabled selected>Pilih Jenis Status Peti</option>
<option value="AKTIF">AKTIF</option>
<option value="INAKTIF">INAKTIF</option>
</select>
12 months ago
<label for="description" class="col-form-label">Alasan Disposal: <span
12 months ago
class="text-danger">*</span></label>
<textarea class="form-control" name="description" id="description" placeholder="Masukan Alasan Disposal" required>{{ old('description') }}</textarea>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.disposal.index') }}" class="btn btn-secondary">Kembali</a>
<button type="submit" class="btn btn-primary" id="submitButton">Simpan</button>
</div>
</form>
</div>
</div>
<!-- auto disable form pada saat sudah di simpan-->
<script>
12 months ago
document.getElementById('disposalForm').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
12 months ago
const warehouseSelect = document.getElementById('warehouse_id');
12 months ago
// Mendapatkan elemen select Customer
const customerSelect = document.getElementById('customer_id');
// 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
12 months ago
warehouseSelect.value = warehouseId;
12 months ago
// Memilih customer berdasarkan data-customer-name
for (let i = 0; i < customerSelect.options.length; i++) {
if (customerSelect.options[i].text === customerName) {
customerSelect.selectedIndex = i;
break;
}
}
});
</script>
@endsection