Browse Source

Updat fitur table peminjaman,pencarian,showing

master
unknown 1 year ago
parent
commit
9348155efb
  1. 50
      app/Http/Controllers/PeminjamanController.php
  2. 55
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php
  3. 124
      resources/views/dashboard/Peminjaman/index.blade.php

50
app/Http/Controllers/PeminjamanController.php

@ -9,6 +9,7 @@ use App\Models\asset_status;
use App\Models\Kondisi_Peti; use App\Models\Kondisi_Peti;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Requests\ValidasiCreatePeminjaman; use App\Http\Requests\ValidasiCreatePeminjaman;
use App\Http\Requests\ValidasiUpdatePeminjaman; use App\Http\Requests\ValidasiUpdatePeminjaman;
@ -34,39 +35,58 @@ class PeminjamanController extends Controller
{ {
$perPage = $request->input('perPage', 5); $perPage = $request->input('perPage', 5);
$query = asset_status::orderBy('created_at', 'desc'); $query = asset_status::with(['customer', 'warehouseId', 'warehouse', 'warehouseEnter', 'kondisi_peti'])
// $query = asset_status::select(['asset_statuses.*', 'Petis.code_customer', 'customers.lot_no', 'type_petis.type', 'type_petis.size_peti', 'm_warehouses.name as warehouse_name']) ->orderBy('created_at', 'desc');
// ->join('Petis', 'peti.id', '=', 'asset_statuses.peti_id')
// ->join('type_petis', 'type_petis.id', '=', 'petis.tipe_peti_id')
// ->join('m_warehouses', 'm_warehouses.id', '=', 'petis.warehouse_id')
// ->join('kondisi_petis', 'kondisipeti_id', '=', 'petis.kondisipeti_id')
// ->orderBy('petis.created_at', 'desc');
// Tambahkan logika pencarian // Tambahkan logika pencarian
$search = $request->input('search') ?? ''; $search = $request->input('search') ?? '';
if ($search) { if ($search) {
$query->where(function ($q) use ($search) { $query->where(function ($q) use ($search) {
$q->where('mobile_id', 'like', "%$search%") $q->where('mobile_id', 'like', "%$search%")
->orWhereHas('peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('fix_lot', 'like', "%$search%");
})
->orWhere('exit_at', 'like', "%$search%") ->orWhere('exit_at', 'like', "%$search%")
->orWhere('est_pengembalian', 'like', "%$search%") ->orWhere('est_pengembalian', 'like', "%$search%")
->orWhere('exit_pic', 'like', "%$search%") ->orWhere('exit_pic', 'like', "%$search%")
->orWhere('customer_id', 'like', "%$search%") ->orWhereHas('customer', function ($warehouseQuery) use ($search) {
->orWhere('warehouse_id', 'like', "%$search%") $warehouseQuery->where('name', 'like', "%$search%");
->orWhere('exit_warehouse', 'like', "%$search%") })
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%")
->orWhere('address', 'like', "%$search%");
})
->orWhere('enter_at', 'like', "%$search%") ->orWhere('enter_at', 'like', "%$search%")
->orWhere('enter_pic', 'like', "%$search%") ->orWhere('enter_pic', 'like', "%$search%")
->orWhere('enter_warehouse', 'like', "%$search%") ->orWhereHas('warehouseEnter', function ($warehouseQuery) use ($search) {
->orWhere('kondisi_peti_id', 'like', "%$search%") $warehouseQuery->where('name', 'like', "%$search%");
})
->orWhereHas('kondisi_peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('nama_kondisi', 'like', "%$search%");
})
->orWhere('status', 'like', "%$search%") ->orWhere('status', 'like', "%$search%")
->orWhere('created_by', 'like', "%$search%") ->orWhere('created_by', 'like', "%$search%")
->orWhere('updated_by', 'like', "%$search%"); ->orWhere('updated_by', 'like', "%$search%");
}); });
} }
$peminjaman = $query->paginate($perPage); if ($perPage == 'Semua') {
$chunkSize = 100;
$stores = new Collection();
$currentPage = 1;
$query->chunk($chunkSize, function ($storesChunk) use ($stores, &$currentPage) {
foreach ($storesChunk as $store) {
$store->setAttribute('i', ($currentPage - 1) * $storesChunk->perPage() + 1);
$stores->push($store);
$currentPage++;
}
});
} else {
$stores = $query->paginate($perPage);
}
$data = [ $data = [
'peminjaman' => $peminjaman, 'peminjaman' => $stores,
'warehouse' => m_warehouse::get(), 'warehouse' => m_warehouse::get(),
'search' => $search, 'search' => $search,
'active' => 'menu-peminjaman', 'active' => 'menu-peminjaman',

55
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php

@ -45,32 +45,31 @@
<form method="GET" action="{{ route('dashboard.peti.index') }}"> <form method="GET" action="{{ route('dashboard.peti.index') }}">
<label for="perPage">Tampilkan:</label> <label for="perPage">Tampilkan:</label>
<select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()"> <select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()">
<option value="5" {{ request('perPage') == '5' ? 'selected' : '' }}>5</option> <option value="5" {{ request('perPage', 5) == '5' ? 'selected' : '' }}>5</option>
<option value="10" {{ request('perPage') == '10' ? 'selected' : '' }}>10 <option value="10" {{ request('perPage', 5) == '10' ? 'selected' : '' }}>10</option>
<option value="25" {{ request('perPage', 5) == '25' ? 'selected' : '' }}>25</option>
<option value="50" {{ request('perPage', 5) == '50' ? 'selected' : '' }}>50</option>
<option value="100" {{ request('perPage', 5) == '100' ? 'selected' : '' }}>100</option>
<option value="500" {{ request('perPage', 5) == '500' ? 'selected' : '' }}>500</option>
<option value="1000" {{ request('perPage', 5) == '1000' ? 'selected' : '' }}>1000</option>
<option value="2500" {{ request('perPage', 5) == '2500' ? 'selected' : '' }}>2500
</option> </option>
<option value="25" {{ request('perPage') == '25' ? 'selected' : '' }}>25 <option value="5000" {{ request('perPage', 5) == '5000' ? 'selected' : '' }}>5000
</option>
<option value="50" {{ request('perPage') == '50' ? 'selected' : '' }}>50
</option>
<option value="100" {{ request('perPage') == '100' ? 'selected' : '' }}>100
</option>
<option value="500" {{ request('perPage') == '500' ? 'selected' : '' }}>500
</option>
<option value="1000" {{ request('perPage') == '1000' ? 'selected' : '' }}>1000
</option>
<option value="2500" {{ request('perPage') == '2500' ? 'selected' : '' }}>2500
</option>
<option value="5000" {{ request('perPage') == '5000' ? 'selected' : '' }}>5000
</option> </option>
<option value="{{ $peti->total() }}" <option value="{{ $peti->total() }}"
{{ request('perPage') == $peti->total() ? 'selected' : '' }}>Semua</option> {{ request('perPage', 5) == $peti->total() ? 'selected' : '' }}>Semua</option>
</select> </select>
<input type="hidden" name="search" value="{{ $search }}">
<input type="hidden" name="page" value="{{ request('page', 1) }}">
</form> </form>
</div> </div>
<div class="col-6 d-flex justify-content-end"> <div class="col-6 d-flex justify-content-end mb-3">
<!-- Fitur search --> <!-- Fitur search -->
<form method="GET" action="{{ route('dashboard.peti.index') }}" class="form-inline"> <form method="GET" action="{{ route('dashboard.peti.index') }}" class="form-inline">
<input type="text" name="search" class="form-control mr-2" placeholder="Cari..."> <input type="text" name="search" class="form-control mr-2" placeholder="Cari..."
value="{{ $search }}">
<input type="hidden" name="page" value="1">
<input type="hidden" name="perPage" value="{{ request('perPage', 5) }}">
<button type="submit" class="btn btn-primary">Cari</button> <button type="submit" class="btn btn-primary">Cari</button>
</form> </form>
</div> </div>
@ -112,7 +111,8 @@
<!-- Tampilkan data pencarian --> <!-- Tampilkan data pencarian -->
<tr> <tr>
<td>{{ $i++ }}</td> <td>{{ $i++ }}</td>
<td><input type="checkbox" class="checkbox" value="{{ $data_peti->id }}"></td> <td><input type="checkbox" class="checkbox" value="{{ $data_peti->id }}">
</td>
<td>{{ $data_peti->fix_lot }}</td> <td>{{ $data_peti->fix_lot }}</td>
<td>{{ $data_peti->created_by }}</td> <td>{{ $data_peti->created_by }}</td>
<td>{{ $data_peti->customer->name }}</td> <td>{{ $data_peti->customer->name }}</td>
@ -189,29 +189,28 @@
</table> </table>
</div> </div>
<div class="row mt-3"> <div class="row mt-3">
<div class="col-4"> <div class="col-md-6">
<!-- Tampilkan jumlah data yang ditampilkan --> <!-- Tampilkan jumlah data yang ditampilkan -->
@if (!$peti->isEmpty()) @if (!$peti->isEmpty())
<p class="d-inline-block">Showing {{ $peti->firstItem() }} to <p class="mb-0">Showing {{ $peti->firstItem() }} to {{ $peti->lastItem() }} of
{{ $peti->lastItem() }} of
{{ $peti->total() }} entries</p> {{ $peti->total() }} entries</p>
@endif @endif
</div> </div>
<div class="col-8 d-flex justify-content-end"> <div class="col-md-6 d-flex justify-content-end">
@if ($peti->total() > $peti->perPage()) @if ($peti->total() > $peti->perPage())
<nav aria-label="Page navigation"> <nav aria-label="Page navigation">
<ul class="pagination justify-content-center"> <ul class="pagination justify-content-end mb-0">
<li class="page-item {{ $peti->onFirstPage() ? 'disabled' : '' }}"> <li class="page-item {{ $peti->onFirstPage() ? 'disabled' : '' }}">
<a class="page-link" <a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url(1) }}" href="{{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->url(1) }}"
aria-label="First"> aria-label="First">
<span aria-hidden="true">First</span> <span aria-hidden="true">First</span>
</a> </a>
</li> </li>
{{ $peti->appends(['perPage' => Request::get('perPage')])->links() }} {{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->links() }}
<li class="page-item {{ $peti->hasMorePages() ? '' : 'disabled' }}"> <li class="page-item {{ $peti->hasMorePages() ? '' : 'disabled' }}">
<a class="page-link" <a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url($peti->lastPage()) }}" href="{{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->url($peti->lastPage()) }}"
aria-label="Last"> aria-label="Last">
<span aria-hidden="true">Last</span> <span aria-hidden="true">Last</span>
</a> </a>
@ -221,6 +220,8 @@
@endif @endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>

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

@ -31,35 +31,35 @@
<form method="GET" action="{{ route('dashboard.peminjaman.index') }}"> <form method="GET" action="{{ route('dashboard.peminjaman.index') }}">
<label for="perPage">Tampilkan:</label> <label for="perPage">Tampilkan:</label>
<select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()"> <select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()">
<option value="5" {{ request('perPage') == '5' ? 'selected' : '' }}>5</option> <option value="5" {{ request('perPage', 5) == '5' ? 'selected' : '' }}>5</option>
<option value="10" {{ request('perPage') == '10' ? 'selected' : '' }}>10 <option value="10" {{ request('perPage', 5) == '10' ? 'selected' : '' }}>10</option>
<option value="25" {{ request('perPage', 5) == '25' ? 'selected' : '' }}>25</option>
<option value="50" {{ request('perPage', 5) == '50' ? 'selected' : '' }}>50</option>
<option value="100" {{ request('perPage', 5) == '100' ? 'selected' : '' }}>100</option>
<option value="500" {{ request('perPage', 5) == '500' ? 'selected' : '' }}>500</option>
<option value="1000" {{ request('perPage', 5) == '1000' ? 'selected' : '' }}>1000</option>
<option value="2500" {{ request('perPage', 5) == '2500' ? 'selected' : '' }}>2500
</option> </option>
<option value="25" {{ request('perPage') == '25' ? 'selected' : '' }}>25 <option value="5000" {{ request('perPage', 5) == '5000' ? 'selected' : '' }}>5000
</option>
<option value="50" {{ request('perPage') == '50' ? 'selected' : '' }}>50
</option>
<option value="100" {{ request('perPage') == '100' ? 'selected' : '' }}>100
</option>
<option value="500" {{ request('perPage') == '500' ? 'selected' : '' }}>500
</option>
<option value="1000" {{ request('perPage') == '1000' ? 'selected' : '' }}>1000
</option>
<option value="2500" {{ request('perPage') == '2500' ? 'selected' : '' }}>2500
</option>
<option value="5000" {{ request('perPage') == '5000' ? 'selected' : '' }}>5000
</option> </option>
<option value="{{ $peminjaman->total() }}" <option value="{{ $peminjaman->total() }}"
{{ request('perPage') == $peminjaman->total() ? 'selected' : '' }}>Semua</option> {{ request('perPage', 5) == $peminjaman->total() ? 'selected' : '' }}>Semua</option>
</select> </select>
<input type="hidden" name="search" value="{{ $search }}">
<input type="hidden" name="page" value="{{ request('page', 1) }}">
</form> </form>
</div> </div>
<div class="col-6 d-flex justify-content-end"> <div class="col-6 d-flex justify-content-end mb-3">
<!-- Fitur search --> <!-- Fitur search -->
<form method="GET" action="{{ route('dashboard.peminjaman.index') }}" class="form-inline"> <form method="GET" action="{{ route('dashboard.peminjaman.index') }}" class="form-inline">
<input type="text" name="search" class="form-control mr-2" placeholder="Cari..."> <input type="text" name="search" class="form-control mr-2" placeholder="Cari..."
value="{{ $search }}">
<input type="hidden" name="page" value="1">
<input type="hidden" name="perPage" value="{{ request('perPage', 5) }}">
<button type="submit" class="btn btn-primary">Cari</button> <button type="submit" class="btn btn-primary">Cari</button>
</form> </form>
</div> </div>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered" width="100%" cellspacing="0"> <table class="table table-bordered" width="100%" cellspacing="0">
@ -75,97 +75,12 @@
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
{{-- <tbody>
@php
$no_peminjaman = 1;
@endphp
@forelse ($peminjaman as $data_peminjaman)
@if ($data_peminjaman->enter_warehouse == null)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->fix_lot }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }}</td>
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td class="text-center">
<a href="{{ route('dashboard.peminjaman.pengembalian', $data_peminjaman->id) }}"
title="Pengembalian">
<i class="fa fa-reply mr-2" style="font-size: 20px"></i>
</a>
<a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}"
title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="{{ route('dashboard.peminjaman.destroy', $data_peminjaman->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
<button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
title="Delete" style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button>
</form>
</td>
</tr>
@endif
@empty
<tr>
<td colspan="8" class="text-center">Data Kosong</td>
</tr>
@endforelse
</tbody> --}}
<tbody> <tbody>
@php @php
$no_peminjaman = 1; $no_peminjaman = 1;
@endphp @endphp
@forelse ($peminjaman as $data_peminjaman) @forelse ($peminjaman as $data_peminjaman)
@if ($search)
@if (stripos($data_peminjaman->peti->fix_lot, $search) !== false ||
stripos($data_peminjaman->peti->customer->name, $search) !== false ||
stripos($data_peminjaman->peti->customer->code_customer, $search) !== false ||
stripos($data_peminjaman->peti->tipe_peti->type, $search) !== false ||
stripos($data_peminjaman->exit_at, $search) !== false ||
stripos($data_peminjaman->exit_pic, $search) !== false ||
stripos($data_peminjaman->warehouse->name, $search) !== false)
<!-- Tampilkan data pencarian -->
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->fix_lot }}</td>
<td>{{ $data_peminjaman->peti->customer->name }}</td>
<td>{{ $data_peminjaman->peti->customer->code_customer }} -
{{ $data_peminjaman->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d/m/Y') }}</td>
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td class="text-center">
<a href="{{ route('dashboard.peminjaman.pengembalian', $data_peminjaman->id) }}"
title="Pengembalian">
<i class="fa fa-reply mr-2" style="font-size: 20px"></i>
</a>
<a href="{{ route('dashboard.peminjaman.edit', $data_peminjaman->id) }}"
title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form
action="{{ route('dashboard.peminjaman.destroy', $data_peminjaman->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
<button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
title="Delete" style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button>
</form>
</td>
</tr>
@endif
@else
<!-- Tampilkan semua data jika tidak ada pencarian -->
<tr> <tr>
<td class="text-center">{{ $no_peminjaman++ }}</td> <td class="text-center">{{ $no_peminjaman++ }}</td>
<td>{{ $data_peminjaman->peti->fix_lot }}</td> <td>{{ $data_peminjaman->peti->fix_lot }}</td>
@ -196,7 +111,6 @@
</form> </form>
</td> </td>
</tr> </tr>
@endif
@empty @empty
<tr> <tr>
<td colspan="8" class="text-center">Data Kosong</td> <td colspan="8" class="text-center">Data Kosong</td>

Loading…
Cancel
Save