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.

102 lines
5.3 KiB

@extends('layouts.main')
@section('title', 'Edit Peminjaman')
@section('content')
1 year ago
@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">Edit Peminjaman</h5>
</div>
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.peminjaman.update', $peminjaman->id) }}" method="POST"
enctype="multipart/form-data" id="editForm">
@csrf
@method('PUT')
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span class="text-danger">*</span></label>
<input type="hidden" name="peti_id" value="{{ $peminjaman->peti_id }}">
<input class="form-control" name="coba"value="{{ $peminjaman->peti->fix_lot }}" @readonly(true)>
{{-- <select class="form-control" name="peti_id" id="peti_id">
<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_peti->id == $peminjaman->peti_id ? 'selected' : '' }}>
{{ $data_peti->fix_lot }}
</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_customer)
<option value="{{ $data_customer->id }}"
@if ($data_customer->id == $peminjaman->customer_id) selected
@else @endif>
{{ $data_customer->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="{{ $peminjaman->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"
value="{{ $peminjaman->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 }}" @if ($data->id == $peminjaman->warehouse_id) selected @else @endif>
{{ $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 }}" @if ($data->id == $peminjaman->exit_warehouse) selected @else @endif>
{{ $data->name }}</option>
@endforeach
</select>
<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>
<script>
document.addEventListener('DOMContentLoaded', function() {
const petiSelect = document.getElementById('peti_id');
const exitWarehouseSelect = document.getElementById('exit_warehouse');
// Saat pilihan Detail Peti berubah
petiSelect.addEventListener('change', function() {
const selectedOption = petiSelect.options[petiSelect.selectedIndex];
const warehouseId = selectedOption.getAttribute('data-warehouse-id');
// Atur indeks pilihan Asal Gudang sesuai dengan data peti yang dipilih
if (warehouseId) {
exitWarehouseSelect.selectedIndex = [...exitWarehouseSelect.options].findIndex(option =>
option.value === warehouseId);
}
});
});
</script>
<script>
document.getElementById('editForm').addEventListener('submit', function() {
document.getElementById('submitButton').setAttribute('disabled', 'true');
});
</script>
@endsection