|
|
|
@extends('layouts.main')
|
|
|
|
@section('title', 'Tambah Peminjaman')
|
|
|
|
@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">Tambah Peminjaman</h5>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data"
|
|
|
|
id="peminjamanForm">
|
|
|
|
@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_block 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="name" class="col-form-label">Customer:<span class="text-danger">*</span></label>
|
|
|
|
<input class="form-control" name="name" type="text" id="name" placeholder="Nama Customer">
|
|
|
|
|
|
|
|
<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="{{ old('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" required>
|
|
|
|
|
|
|
|
<label for="warehouse" class="col-form-label">Asal Gudang:</label>
|
|
|
|
<select class="form-control" name="warehouse" type="text" id="warehouse" required>
|
|
|
|
<option disabled selected>Pilih Asal Gudang</option>
|
|
|
|
@foreach ($warehouse as $data)
|
|
|
|
<option value="{{ $data->id }}">{{ $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 }}">{{ $data->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
|
|
|
|
<!-- auto disable form pada saat sudah di simpan-->
|
|
|
|
<script>
|
|
|
|
document.getElementById('peminjamanForm').addEventListener('submit', function() {
|
|
|
|
document.getElementById('submitButton').setAttribute('disabled', 'true');
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- otomatis tgl otomatis 1 minggu setelah pembuatan peminjaman -->
|
|
|
|
<script>
|
|
|
|
// Mendapatkan elemen input tanggal peminjaman
|
|
|
|
const exitDateInput = document.getElementById('exit_at');
|
|
|
|
|
|
|
|
// Mendapatkan elemen input estimasi tanggal pengembalian
|
|
|
|
const estimatedReturnDateInput = document.getElementById('est_pengembalian');
|
|
|
|
|
|
|
|
// Menambahkan event listener ke input tanggal peminjaman
|
|
|
|
exitDateInput.addEventListener('input', function() {
|
|
|
|
// Mendapatkan tanggal peminjaman dalam format tanggal JavaScript
|
|
|
|
const exitDate = new Date(this.value);
|
|
|
|
|
|
|
|
// Menghitung tanggal estimasi pengembalian (7 hari setelah tanggal peminjaman)
|
|
|
|
const estimatedReturnDate = new Date(exitDate);
|
|
|
|
estimatedReturnDate.setDate(exitDate.getDate() + 7);
|
|
|
|
|
|
|
|
// Mengisi nilai estimasi tanggal pengembalian
|
|
|
|
estimatedReturnDateInput.valueAsDate = estimatedReturnDate;
|
|
|
|
});
|
|
|
|
</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 exitWarehouseSelect = document.getElementById('warehouse');
|
|
|
|
|
|
|
|
// Mendapatkan elemen input Customer
|
|
|
|
const nameInput = document.getElementById('name');
|
|
|
|
|
|
|
|
// 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
|
|
|
|
exitWarehouseSelect.value = warehouseId;
|
|
|
|
|
|
|
|
// Mengisi input Customer dengan nama pelanggan
|
|
|
|
nameInput.value = customerName;
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
@endsection
|