Browse Source

update tambahan peti

master
Gunawan19621 1 year ago
parent
commit
223c76ea4c
  1. 7
      app/Http/Controllers/PeminjamanController.php
  2. 6
      app/Http/Controllers/PengembalianController.php
  3. 7
      resources/views/dashboard/Peminjaman/create.blade.php
  4. 67
      resources/views/dashboard/Peminjaman/edit.blade.php
  5. 39
      resources/views/dashboard/Peminjaman/index.blade.php
  6. 58
      resources/views/dashboard/Pengembalian/edit.blade.php
  7. 41
      resources/views/dashboard/Pengembalian/index.blade.php

7
app/Http/Controllers/PeminjamanController.php

@ -86,7 +86,7 @@ class PeminjamanController extends Controller
public function edit($id) public function edit($id)
{ {
$data = [ $data = [
'asset' => m_asset::all(), 'peti' => Peti::all(),
'peminjaman' => asset_status::find($id), 'peminjaman' => asset_status::find($id),
'warehouse' => m_warehouse::get(), 'warehouse' => m_warehouse::get(),
'active' => 'menu-peminjaman', 'active' => 'menu-peminjaman',
@ -100,10 +100,11 @@ class PeminjamanController extends Controller
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
// dd('oke'); // dd('oke');
// dd($request->all());
$request->validate([ $request->validate([
'asset_id' => 'required', 'peti_id' => 'required',
'exit_at' => 'required', 'exit_at' => 'required',
'exit_pic' => 'required', 'est_pengembalian' => 'required',
'exit_warehouse' => 'required', 'exit_warehouse' => 'required',
]); ]);
// dd($request); // dd($request);

6
app/Http/Controllers/PengembalianController.php

@ -2,9 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\asset_status; use App\Models\Peti;
use App\Models\m_asset; use App\Models\m_asset;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use App\Models\asset_status;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -13,7 +14,7 @@ class PengembalianController extends Controller
public function index() public function index()
{ {
$data = [ $data = [
'peminjaman' => asset_status::get(), 'peminjaman' => asset_status::all(),
'active' => 'menu-pengembalian', 'active' => 'menu-pengembalian',
]; ];
return view('dashboard.Pengembalian.index', $data); return view('dashboard.Pengembalian.index', $data);
@ -48,6 +49,7 @@ class PengembalianController extends Controller
public function edit($id) public function edit($id)
{ {
$data = [ $data = [
'peti' => Peti::get(),
'peminjaman' => asset_status::findOrFail($id), 'peminjaman' => asset_status::findOrFail($id),
'warehouse' => m_warehouse::get(), 'warehouse' => m_warehouse::get(),
'active' => 'menu-pengembalian', 'active' => 'menu-pengembalian',

7
resources/views/dashboard/Peminjaman/create.blade.php

@ -13,13 +13,6 @@
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data"> <form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data">
@csrf @csrf
<div class="form-group"> <div class="form-group">
{{-- <label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="peti_id" type="text" id="peti_id">
<option disabled selected>Pilih Detail Peti</option>
@foreach ($peti as $data_peti)
<option value="{{ $data_peti->id }}">{{ $data_peti->fix_lot }}</option>
@endforeach
</select> --}}
<label for="peti_id" class="col-form-label">Pilih Detail Peti:</label> <label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="peti_id" type="text" id="peti_id"> <select class="form-control" name="peti_id" type="text" id="peti_id">
<option disabled selected>Pilih Detail Peti</option> <option disabled selected>Pilih Detail Peti</option>

67
resources/views/dashboard/Peminjaman/edit.blade.php

@ -15,34 +15,39 @@
@csrf @csrf
@method('PUT') @method('PUT')
<div class="form-group"> <div class="form-group">
<label for="asset_id" class="col-form-label">Nama Asset:</label> <label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="asset_id" type="text" id="asset_id"> <select class="form-control" name="peti_id" id="peti_id">
<option disabled selected>Pilih Nama Asset</option> <option disabled selected>Pilih Detail Peti</option>
@foreach ($asset as $data_asset) @foreach ($peti as $data_peti)
<option value="{{ $data_asset->id }}" <option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}"
@if ($data_asset->id == $peminjaman->id) selected {{ $data_peti->id == $peminjaman->peti_id ? 'selected' : '' }}>
@else @endif> {{ $data_peti->fix_lot }}
{{ $data_asset->name }}</option> </option>
@endforeach @endforeach
</select> </select>
<label for="exit_at" class="col-form-label">Tanggal:</label> </div>
<div class="form-group">
<label for="exit_at" class="col-form-label">Tanggal Peminjaman:</label>
<input class="form-control" name="exit_at" type="date" id="exit_at" <input class="form-control" name="exit_at" type="date" id="exit_at"
value="{{ \Carbon\Carbon::parse($peminjaman->exit_at)->format('Y-m-d') }}" value="{{ $peminjaman->exit_at }}" required>
placeholder="Masukan Tanggal Keluar" required> </div>
<label for="exit_pic" class="col-form-label">PJ Keluar:</label> <div class="form-group">
<input class="form-control" name="exit_pic" type="text" id="exit_pic" <label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
value="{{ $peminjaman->exit_pic }}" placeholder="Masukan Nama PJ Keluar" pattern="[^0-9]+" <input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
oninput="this.value=this.value.replace(/[0-9]/g,'');" required> value="{{ $peminjaman->est_pengembalian }}" required>
</div>
<div class="form-group">
<label for="exit_warehouse" class="col-form-label">Asal Gudang:</label> <label for="exit_warehouse" class="col-form-label">Asal Gudang:</label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse"> <select class="form-control" name="exit_warehouse" id="exit_warehouse">
<option disabled selected>Pilih Nama Asset</option> <option disabled selected>Pilih Asal Gudang</option>
@foreach ($warehouse as $data_warehouse) @foreach ($warehouse as $data)
<option value="{{ $data_warehouse->id }}" <option value="{{ $data->id }}"
@if ($data_warehouse->id == $peminjaman->id) selected {{ $data->id == $peminjaman->exit_warehouse ? 'selected' : '' }}>
@else @endif> {{ $data->name }}
{{ $data_warehouse->name }}</option> </option>
@endforeach @endforeach
</select> </select>
</div> </div>
@ -53,4 +58,22 @@
</form> </form>
</div> </div>
</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>
@endsection @endsection

39
resources/views/dashboard/Peminjaman/index.blade.php

@ -24,7 +24,7 @@
<th>Kode Peti</th> <th>Kode Peti</th>
<th>Nama Customer</th> <th>Nama Customer</th>
<th>Tgl Peminjaman</th> <th>Tgl Peminjaman</th>
<th>PJ Keluar</th> <th>PJ Peminjaman</th>
<th>Asal Gudang</th> <th>Asal Gudang</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
@ -35,29 +35,19 @@
@endphp @endphp
@forelse ($peminjaman as $data_peminjaman) @forelse ($peminjaman as $data_peminjaman)
<tr> <tr>
<td>{{ $no_peminjaman++ }}</td> <td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} - <td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td> {{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td> <td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->exit_at }}</td> <td>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }}</td>
</tr> <td>{{ $data_peminjaman->exit_pic }}</td>
@empty <td>{{ $data_peminjaman->warehouse->name }}</td>
<p>Data Kosong</p>
@endforelse
{{--
@foreach ($peminjaman as $data)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data->asset->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>{{ $data->warehouse->name }}</td>
<td class="text-center"> <td class="text-center">
<a href="{{ route('dashboard.peminjaman.edit', $data->id) }}" title="Edit"> <a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i> <i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a> </a>
<form action="{{ route('dashboard.peminjaman.destroy', $data->id) }}" method="POST" <form action="{{ route('dashboard.peminjaman.destroy', $data_peminjaman->id) }}"
style="display: inline;"> method="POST" style="display: inline;">
@csrf @csrf
@method('DELETE') @method('DELETE')
<button type="submit" <button type="submit"
@ -68,6 +58,19 @@
</form> </form>
</td> </td>
</tr> </tr>
@empty
<p>Data Kosong</p>
@endforelse
{{--
@foreach ($peminjaman as $data)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data->asset->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>{{ $data->warehouse->name }}</td>
</tr>
@endforeach --}} @endforeach --}}
</tbody> </tbody>
</table> </table>

58
resources/views/dashboard/Pengembalian/edit.blade.php

@ -1,18 +1,46 @@
@extends('layouts.main') @extends('layouts.main')
@section('title', 'Update Data Pengembalian') @section('title', 'Update Data Pengembalian')
@section('content') @section('content')
<div class="card m-3"> <div class="card shadow mb-4">
<div class="card-body m-2"> <div class="card-header py-3">
<h3>Data Pengembalian</h3> <div class="row">
<hr class="border"> <div class="col-6">
<h5 class="m-0 font-weight-bold text-primary mt-2">Update Pengembalian</h5>
</div>
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.pengembalian.update', [$peminjaman->id]) }}" method="POST" <form action="{{ route('dashboard.pengembalian.update', [$peminjaman->id]) }}" method="POST"
enctype="multipart/form-data"> enctype="multipart/form-data">
@csrf @csrf
@method('PUT') @method('PUT')
<div class="form-group"> <div class="form-group">
<!-- Input tersembunyi untuk menyimpan ID aset --> <label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<input type="hidden" name="asset_id" value="{{ $peminjaman->asset_id }}"> <select class="form-control" name="peti_id" type="text" 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->fix_lot }}
</option>
@endforeach
</select>
<label for="exit_at" class="col-form-label">Tanggal Peminjaman:</label>
<input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}"
placeholder="Masukan Tanggal Peminjaman" required>
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
value="{{ old('est_pengembalian') }}" placeholder="Masukan Estimasi Tanggal Peminjaman" required>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse">
<option disabled selected>Pilih Asal Gudang</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
</div>
{{--
<!-- Elemen input readonly untuk menampilkan nama aset --> <!-- Elemen input readonly untuk menampilkan nama aset -->
<label for="asset_name" class="col-form-label">Nama Asset:</label> <label for="asset_name" class="col-form-label">Nama Asset:</label>
<input class="form-control" name="asset_name" type="text" id="asset_name" <input class="form-control" name="asset_name" type="text" id="asset_name"
@ -28,20 +56,9 @@
value="{{ $peminjaman->exit_pic }}" placeholder="Masukan Nama PJ Keluar" readonly required> value="{{ $peminjaman->exit_pic }}" placeholder="Masukan Nama PJ Keluar" readonly required>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label> <label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
{{-- <select class="form-control" name="enter_warehouse" id="enter_warehouse" required>
<option disabled selected>Pilih Nama Asset</option>
@foreach ($warehouse as $data_warehouse)
<option value="{{ $data_warehouse->id }}"
{{ $data_warehouse->id == $peminjaman->enter_warehouse ? 'selected' : '' }}>
{{ $data_warehouse->name }}
</option>
@endforeach
</select> --}}
<input type="hidden" name="exit_warehouse" id="exit_warehouse" <input type="hidden" name="exit_warehouse" id="exit_warehouse"
value="{{ $peminjaman->exit_warehouse }}"> value="{{ $peminjaman->exit_warehouse }}">
<input class="form-control" type="text" value="{{ $peminjaman->warehouse->name }}" readonly required> <input class="form-control" type="text" value="{{ $peminjaman->warehouse->name }}" readonly required>
{{-- <input class="form-control" name="exit_warehouse" type="text" id="exit_warehouse"
value="{{ $peminjaman->warehouse->id }}" placeholder="Masukan Nama PJ Keluar" readonly required> --}}
<label for="enter_at" class="col-form-label">Tanggal Pengembalian:</label> <label for="enter_at" class="col-form-label">Tanggal Pengembalian:</label>
<input class="form-control" name="enter_at" type="date" id="enter_at" <input class="form-control" name="enter_at" type="date" id="enter_at"
@ -63,10 +80,9 @@
{{ $data_warehouse->name }}</option> {{ $data_warehouse->name }}</option>
@endforeach @endforeach
</select> </select>
</div> </div> --}}
<div class="modal-footer"> <div class="modal-footer d-flex justify-content-center">
<button type="button" class="btn btn-secondary" <a href="{{ route('dashboard.peminjaman.index') }}" class="btn btn-secondary">Kembali</a>
onclick="window.location.href = '{{ route('dashboard.pengembalian.index') }}'">Kembali</button>
<button type="submit" class="btn btn-primary">Simpan</button> <button type="submit" class="btn btn-primary">Simpan</button>
</div> </div>
</form> </form>

41
resources/views/dashboard/Pengembalian/index.blade.php

@ -1,8 +1,15 @@
@extends('layouts.main') @extends('layouts.main')
@section('title', 'Pengembalian')
@section('content') @section('content')
<style>
.table th {
white-space: nowrap;
}
.table td {
white-space: nowrap;
}
</style>
<div class="container-fluid"> <div class="container-fluid">
<!-- <h1 class="h3 mb-2 text-gray-800">Tabel Pengembalian</h1> -->
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<div class="card-header py-3"> <div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Data Pengembalian</h6> <h6 class="m-0 font-weight-bold text-primary">Data Pengembalian</h6>
@ -13,13 +20,14 @@
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
<th>Nama Asset</th> <th>Kode Peti</th>
<th>Tgl Peinjaman</th> <th>Tgl Peinjaman</th>
<th>PJ Peinjaman</th> <th>PJ Peminjaman</th>
<th>Asal Gudang</th> <th>Asal WH Peminjaman</th>
<th>Tgl Pengembalian</th> <th>Tgl Pengembalian</th>
<th>PJ Pengembalian</th> <th>PJ Pengembalian</th>
<th>Tujuan Gudang</th> <th>Tujuan WH Pengembalian</th>
<th>Kondisi Peti</th>
<th>Status</th> <th>Status</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
@ -28,11 +36,15 @@
@php @php
$no_peminjaman = 1; $no_peminjaman = 1;
@endphp @endphp
@foreach ($peminjaman as $data) {{-- @foreach ($peminjaman as $data)
@endforeach --}}
@forelse ($peminjaman as $data)
<tr> <tr>
<td>{{ $no_peminjaman++ }}</td> <td>{{ $no_peminjaman++ }}</td>
<td>{{ $data->asset->name }}</td> <td>{{ $data->peti->customer->code_customer }} -
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }}</td> {{ $data->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }}</td>
<td>{{ $data->exit_pic }}</td> <td>{{ $data->exit_pic }}</td>
<td>{{ $data->warehouse->name }}</td> <td>{{ $data->warehouse->name }}</td>
<td> <td>
@ -56,6 +68,13 @@
<p class="text-center font-weight-bold">-</p> <p class="text-center font-weight-bold">-</p>
@endif @endif
</td> </td>
<td>
@if ($data->kondisi_peti)
{{ $data->kondisi_peti }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td> <td>
@if ($data->enter_warehouse === null) @if ($data->enter_warehouse === null)
Not Return Not Return
@ -69,7 +88,9 @@
</a> </a>
</td> </td>
</tr> </tr>
@endforeach @empty
<p>Data Kosong</p>
@endforelse
</tbody> </tbody>
</table> </table>
</div> </div>

Loading…
Cancel
Save