Browse Source

pagenation untuk pengembalian

master
Gunawan19621 1 year ago
parent
commit
ca33814cd1
  1. 3
      app/Exports/CustomerExport.php
  2. 3
      app/Exports/KondisiPetiExport.php
  3. 3
      app/Exports/TipePetiExport.php
  4. 3
      app/Exports/WarehouseExport.php
  5. 2
      app/Http/Controllers/DisposalController.php
  6. 1
      app/Http/Controllers/HistoryController.php
  7. 14
      app/Http/Controllers/HomeController.php
  8. 1
      app/Http/Controllers/KondisiPetiController.php
  9. 60
      app/Http/Controllers/PeminjamanController.php
  10. 110
      app/Http/Controllers/PengembalianController.php
  11. 6
      app/Http/Controllers/PetiController.php
  12. 61
      app/Http/Controllers/ProfileController.php
  13. 65
      app/Http/Controllers/RecycleDataController.php
  14. 8
      app/Http/Controllers/Report/PetternLotPetiController.php
  15. 27
      app/Http/Controllers/RoleController.php
  16. 25
      app/Http/Controllers/WarehouseController.php
  17. 4
      app/Http/Requests/Disposal/ValidasiUpdateDisposal.php
  18. 1
      app/Http/Requests/ValidasiCreateCustomer.php
  19. 2
      app/Models/Customer.php
  20. 5
      app/Models/asset_status.php
  21. 10
      resources/views/dashboard/Peminjaman/index.blade.php
  22. 251
      resources/views/dashboard/Pengembalian/index.blade.php

3
app/Exports/CustomerExport.php

@ -23,9 +23,6 @@ class CustomerExport implements FromCollection, WithHeadings
'address'
)->get();
// Inisialisasi nomor awal
// $nomor = 1;
// Modifikasi data dan tambahkan nomor
$data = $customers->map(function ($customer) use (&$nomor) {
return [

3
app/Exports/KondisiPetiExport.php

@ -20,9 +20,6 @@ class KondisiPetiExport implements FromCollection, WithHeadings
'deskripsi_kondisi',
)->get();
// Inisialisasi nomor awal
// $nomor = 1;
// Modifikasi data dan tambahkan nomor
$data = $kondisipetis->map(function ($kondisipeti) use (&$nomor) {
return [

3
app/Exports/TipePetiExport.php

@ -21,9 +21,6 @@ class TipePetiExport implements FromCollection, WithHeadings
'description',
)->get();
// Inisialisasi nomor awal
// $nomor = 1;
// Modifikasi data dan tambahkan nomor
$data = $tipepetis->map(function ($tipepeti) use (&$nomor) {
return [

3
app/Exports/WarehouseExport.php

@ -21,9 +21,6 @@ class WarehouseExport implements FromCollection, WithHeadings
'address',
)->get();
// Inisialisasi nomor awal
// $nomor = 1;
// Modifikasi data dan tambahkan nomor
$data = $warehouses->map(function ($warehouse) use (&$nomor) {
return [

2
app/Http/Controllers/DisposalController.php

@ -89,7 +89,6 @@ class DisposalController extends Controller
*/
public function edit($id)
{
// $jenis_disposal = ['Pemusnaan', 'Perbaikan'];
$data = [
'disposal' => Disposal::findOrFail($id),
'peti' => Peti::get(),
@ -105,7 +104,6 @@ class DisposalController extends Controller
*/
public function update(ValidasiUpdateDisposal $request, $id)
{
// dd($request->all());
// dd("oke");
try {
// Mendapatkan informasi pengguna yang sedang login

1
app/Http/Controllers/HistoryController.php

@ -13,7 +13,6 @@ class HistoryController extends Controller
{
$data = [
// 'peminjaman' => asset_status::get(),
'peminjaman' => asset_status::withTrashed()->orderBy('created_at', 'desc')->get(),
'warehouse' => m_warehouse::get(),
'active' => 'history-peminjaman',

14
app/Http/Controllers/HomeController.php

@ -21,20 +21,6 @@ class HomeController extends Controller
return view('dashboard.index', $data);
}
//halaman User
// public function indexUser()
// {
// $data = [
// 'reminder' => \App\Models\asset_status::whereNull('enter_at')->count(),
// 'jumlahPeti' => \App\Models\Peti::count(),
// 'jumlahPeminjaman' => \App\Models\asset_status::count(),
// 'jumlahPengembalian' => \App\Models\asset_status::whereNotNull('enter_at')->count(),
// 'active' => 'menu-admin',
// ];
// return view('pages.user.index', $data);
// }
public function notification()
{
$notification = \App\Models\asset_status::whereNull('enter_at')

1
app/Http/Controllers/KondisiPetiController.php

@ -24,7 +24,6 @@ class KondisiPetiController extends Controller
public function store(ValidasiCreateKondisiPeti $request)
{
// dd('oke');
// dd($request);
try {
$currentUser = Auth::user();
$validatedData = $request->except('_token');

60
app/Http/Controllers/PeminjamanController.php

@ -11,6 +11,7 @@ use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\ValidasiCreatePeminjaman;
use App\Http\Requests\ValidasiUpdatePeminjaman;
@ -28,7 +29,7 @@ class PeminjamanController extends Controller
->where('status', '=', 0)
->orderBy('created_at', 'desc');
// Tambahkan logika pencarian
//logika pencarian
$search = $request->input('search') ?? '';
if ($search) {
$query->where(function ($q) use ($search) {
@ -36,27 +37,59 @@ class PeminjamanController extends Controller
->orWhereHas('peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('fix_lot', 'like', "%$search%");
})
->orWhere('exit_at', 'like', "%$search%")
->orWhere('est_pengembalian', 'like', "%$search%")
->orWhere('exit_pic', 'like', "%$search%")
->orWhereHas('customer', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%");
})
->orWhereHas('peti.customer', function ($customerQuery) use ($search) {
$customerQuery->where('code_customer', 'like', "%$search%");
})
->orWhereHas('peti.tipe_peti', function ($tipePetiQuery) use ($search) {
$tipePetiQuery->where('type', 'like', "%$search%");
})
->orWhere(function ($combinedQuery) use ($search) {
// Pisahkan code customer dan tipe peti dari pencarian
list($codeCustomer, $typePeti) = explode(' - ', $search);
// Cek kesamaan code customer dan tipe peti
$combinedQuery->whereHas('peti.customer', function ($customerQuery) use ($codeCustomer) {
$customerQuery->where('code_customer', 'like', "%$codeCustomer%");
})->whereHas('peti.tipe_peti', function ($tipePetiQuery) use ($typePeti) {
$tipePetiQuery->where('type', 'like', "%$typePeti%");
});
})
->orWhere('exit_pic', 'like', "%$search%")
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%")
->orWhere('address', 'like', "%$search%");
})
->orWhere('enter_at', 'like', "%$search%")
->orWhere('enter_pic', 'like', "%$search%")
->orWhereHas('warehouseEnter', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%");
->orWhere(function ($dateQuery) use ($search) {
try {
// Format tanggal yang diharapkan dari input pengguna
$formattedDate = \Carbon\Carbon::createFromFormat('d-m-Y', $search)->format('Y-m-d');
// Cek kesamaan tanggal
$dateQuery->whereDate('exit_at', $formattedDate);
} catch (\Exception $e) {
Log::error('Error parsing date: ' . $e->getMessage());
}
})
->orWhereHas('kondisi_peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('nama_kondisi', 'like', "%$search%");
->orWhere(function ($dateQuery) use ($search) {
try {
// Format tanggal yang diharapkan dari input pengguna
$formattedDate = \Carbon\Carbon::createFromFormat('d-m-Y', $search)->format('Y-m-d');
// Cek kesamaan tanggal
$dateQuery->whereDate('est_pengembalian', $formattedDate);
} catch (\Exception $e) {
Log::error('Error parsing date: ' . $e->getMessage());
}
})
->orWhere('status', 'like', "%$search%")
->orWhere('created_by', 'like', "%$search%")
->orWhere('updated_by', 'like', "%$search%");
->orWhere('exit_pic', 'like', "%$search%")
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%")
->orWhere('address', 'like', "%$search%");
});
});
}
@ -79,6 +112,7 @@ class PeminjamanController extends Controller
$data = [
'peminjaman' => $stores,
'warehouse' => m_warehouse::get(),
'i' => ($stores->currentPage() - 1) * $stores->perPage() + 1,
'search' => $search,
'active' => 'menu-peminjaman',
];

110
app/Http/Controllers/PengembalianController.php

@ -2,28 +2,130 @@
namespace App\Http\Controllers;
use App\Http\Requests\ValidasiUpdatePengembalian;
use App\Models\Peti;
use App\Models\m_warehouse;
use App\Models\asset_status;
use App\Models\Kondisi_Peti;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\ValidasiUpdatePengembalian;
class PengembalianController extends Controller
{
public function index()
public function index(Request $request)
{
$pengembalian = asset_status::orderBy('created_at', 'desc')->get();
$perPage = $request->input('perPage', 5);
$query = asset_status::with(['customer', 'warehouseId', 'warehouse', 'warehouseEnter', 'kondisi_peti'])
->where('status', '=', 1)
->orderBy('created_at', 'desc');
// Logika pencarian
$search = $request->input('search') ?? '';
if ($search) {
$query->where(function ($q) use ($search) {
$q->where('mobile_id', 'like', "%$search%")
->orWhereHas('peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('fix_lot', 'like', "%$search%");
}) // sudah cari fix lot
->orWhereHas('customer', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%");
}) // sudah cari nama customer
->orWhere(function ($dateQuery) use ($search) {
try {
// Format tanggal yang diharapkan dari input pengguna
$formattedDate = \Carbon\Carbon::createFromFormat('d-m-Y', $search)->format('Y-m-d');
// Cek kesamaan tanggal
$dateQuery->whereDate('exit_at', $formattedDate);
} catch (\Exception $e) {
Log::error('Error parsing date: ' . $e->getMessage());
}
})
->orWhere(function ($dateQuery) use ($search) {
try {
// Format tanggal yang diharapkan dari input pengguna
$formattedDate = \Carbon\Carbon::createFromFormat('d-m-Y', $search)->format('Y-m-d');
// Cek kesamaan tanggal
$dateQuery->whereDate('est_pengembalian', $formattedDate);
} catch (\Exception $e) {
Log::error('Error parsing date: ' . $e->getMessage());
}
}) // sudah cari est pengembalian (tanggal pengembalian)
->orWhere('exit_pic', 'like', "%$search%") // sudah cari exit pic (nama peminjam)
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%")
->orWhere('address', 'like', "%$search%");
}) // sudah cari warehouse (lokasi peminjaman)
->orWhere(function ($dateQuery) use ($search) {
try {
// Format tanggal yang diharapkan dari input pengguna
$formattedDate = \Carbon\Carbon::createFromFormat('d-m-Y', $search)->format('Y-m-d');
// Cek kesamaan tanggal
$dateQuery->whereDate('enter_at', $formattedDate);
} catch (\Exception $e) {
Log::error('Error parsing date: ' . $e->getMessage());
}
}) // sudah cari enter at (tanggal pengembalian)
->orWhere('enter_pic', 'like', "%$search%") // sudah cari enter pic (nama pengembali)
->orWhereHas('warehouseEnter', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%");
}) // sudah cari warehouse enter (lokasi pengembalian)
->orWhereHas('kondisi_peti', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('nama_kondisi', 'like', "%$search%");
}) // sudah cari kondisi peti
->orWhere(function ($statusQuery) use ($search) {
if (strtolower($search) === 'return') {
$statusQuery->where('status', 1);
} else {
$statusQuery->where('status', 'like', "%$search%");
}
}); // sudah cari status
});
}
// Periksa apakah perPage adalah 'Semua'
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() + $store->getQueueableId());
$stores->push($store);
$currentPage++;
}
});
} else {
// Hitung halaman berdasarkan parameter halaman yang diberikan atau default ke halaman pertama
$page = $request->input('page') ?? 1;
// Paginasi dengan parameter halaman
$stores = $query->paginate($perPage, ['*'], 'page', $page);
// Hitung nomor urutan untuk setiap item di halaman
$stores->each(function ($store) use ($page, $perPage) {
$store->setAttribute('i', ($page - 1) * $perPage + $store->getQueueableId());
});
}
$data = [
'peminjaman' => $pengembalian,
'peminjaman' => $stores,
'warehouse' => m_warehouse::get(),
'i' => ($stores->currentPage() - 1) * $stores->perPage() + 1,
'search' => $search,
'active' => 'menu-pengembalian',
];
return view('dashboard.Pengembalian.index', $data);
}
/**
* Show the form for creating a new resource.
*/

6
app/Http/Controllers/PetiController.php

@ -32,8 +32,6 @@ class PetiController extends Controller
->orderBy('created_at', 'desc');
// Tambahkan logika pencarian
$search = $request->input('search') ?? '';
// Tambahkan logika pencarian
$search = $request->input('search') ?? '';
if ($search) {
$query->where(function ($q) use ($search) {
$q->where('fix_lot', 'like', "%$search%")
@ -114,7 +112,9 @@ class PetiController extends Controller
// Ambil nomor urutan otomatis untuk packing_no
$latestPackingNo = Peti::max('packing_no');
$nextPackingNo = $latestPackingNo + 1;
$validatedData['packing_no'] = $nextPackingNo;
// $validatedData['packing_no'] = $nextPackingNo;
$validatedData['packing_no'] = '0' . $nextPackingNo;
// $validatedData['packing_no'] = str_pad($nextPackingNo, 3, '0', STR_PAD_LEFT); // cara untuk menambahkan total digitnya adalah 3
$code_customer = Customer::where('id', $validatedData['customer_id'])->first()->code_customer;
$type = Type_peti::where('id', $validatedData['tipe_peti_id'])->first()->type;

61
app/Http/Controllers/ProfileController.php

@ -59,11 +59,6 @@ class ProfileController extends Controller
if ($pengguna->foto) {
Storage::delete('public/' . $pengguna->foto);
}
// Generate nama file acak
// $randomFileName = Str::random(20) . '.' . $request->file('foto')->getClientOriginalExtension();
// $fotoPath = $request->file('foto')->storeAs('public/Profile_foto', $randomFileName);
// $pengguna->foto = $randomFileName;
$randomFileName = Str::random(20); // Menghasilkan nama file acak dengan panjang 20 karakter
$fotoPath = $request->file('foto')->storeAs('public/Profile_foto', $randomFileName);
$pengguna->foto = str_replace('public/', '', $fotoPath);
@ -86,22 +81,6 @@ class ProfileController extends Controller
}
}
//Proses update Profile Photo
// public function updatePhoto(Request $request)
// {
// // dd('okr');
// $user = User::find(auth()->user()->id);
// if ($request->hasFile('foto')) {
// // Mengunggah file foto profil
// $file = $request->file('foto');
// $foto = $file->store('profile-fotos');
// $user->update(['foto' => $foto]);
// }
// // Logika lain yang diperlukan setelah update foto profil
// return redirect()->back()->with('success', 'Foto profil berhasil diperbarui.');
// }
//Proses update Profile Informasi
public function update(ProfileUpdateRequest $request): RedirectResponse
{
@ -115,44 +94,4 @@ class ProfileController extends Controller
return Redirect::back()->with('status', 'profile-updated');
}
/**
* Delete the user's account.
*/
// public function destroy(Request $request)
// {
// $user = Auth::user();
// // Validasi password
// if (!Hash::check($request->password, $user->password)) {
// return back()->withErrors([
// 'password' => 'The provided password does not match your current password.',
// ]);
// }
// // Hapus akun
// $user->delete();
// // Logout
// Auth::logout();
// return redirect('/');
// }
// public function destroy(Request $request): RedirectResponse
// {
// $request->validateWithBag('userDeletion', [
// 'password' => ['required', 'current_password'],
// ]);
// $user = $request->user();
// Auth::logout();
// $user->delete();
// $request->session()->invalidate();
// $request->session()->regenerateToken();
// return Redirect::to('/');
// }
}

65
app/Http/Controllers/RecycleDataController.php

@ -25,71 +25,6 @@ class RecycleDataController extends Controller
return view('dashboard.Master_Data.Recycle_Data.index', $data);
}
// public function pulihkanData($id)
// {
// // dd('oke');
// $peti = Customer::withTrashed()->find($id);
// if ($peti) {
// $peti->restore();
// return redirect()->back()->with('success', 'Data berhasil dipulihkan.');
// } else {
// return redirect()->back()->with('error', 'Data tidak ditemukan.');
// }
// }
// public function hapusPermanenData($id)
// {
// // dd('oke');
// $peti = Peti::withTrashed()->find($id);
// if ($peti) {
// $peti->forceDelete();
// return redirect()->back()->with('success', 'Data berhasil dihapus permanen.');
// } else {
// return redirect()->back()->with('error', 'Data tidak ditemukan.');
// }
// }
// public function pulihkanData(Request $request)
// {
// $peti = Peti::withTrashed()
// ->where('id', '=', $request->id)
// ->first();
// $customer = Customer::withTrashed()
// ->where('id', '=', $request->id)
// ->first();
// if ($peti) {
// $peti->restore();
// return redirect()->back()->with('success', 'Data Peti berhasil dipulihkan.');
// } elseif ($customer) {
// $customer->restore();
// return redirect()->back()->with('success', 'Data Customer berhasil dipulihkan.');
// } else {
// return redirect()->back()->with('error', 'Data tidak ditemukan.');
// }
// }
// public function hapusPermanenData($id)
// {
// $peti = Peti::withTrashed()->find($id);
// $customer = Customer::withTrashed()->find($id);
// if ($peti) {
// $peti->forceDelete();
// return redirect()->back()->with('success', 'Data Peti berhasil dihapus permanen.');
// } elseif ($customer) {
// $customer->forceDelete();
// return redirect()->back()->with('success', 'Data Customer berhasil dihapus permanen.');
// } else {
// return redirect()->back()->with('error', 'Data tidak ditemukan.');
// }
// }
public function pulihkanData(Request $request, $model, $id)
{
$data = null;

8
app/Http/Controllers/Report/PetternLotPetiController.php

@ -12,14 +12,6 @@ use App\Exports\PetternLotPetiExport;
class PetternLotPetiController extends Controller
{
// public function index()
// {
// $data = [
// 'peti' => Peti::withTrashed()->get(),
// 'active' => 'menu-Pettern_Lot_Peti'
// ];
// return view('dashboard.Master_Data.Report.Pattern_lot_peti.index', $data);
// }
public function index(Request $request)
{
$perPage = $request->input('perPage', 5);

27
app/Http/Controllers/RoleController.php

@ -22,14 +22,6 @@ class RoleController extends Controller
return view('dashboard.Master_Data.Role.index', $data);
}
/**
* Show the form for creating a new resource.
*/
// public function create()
// {
// return view('MasterData.role.create');
// }
/**
* Store a newly created resource in storage.
*/
@ -47,25 +39,6 @@ class RoleController extends Controller
}
}
/**
* Display the specified resource.
*/
// public function show($id)
// {
// // dd('oke');
// return view('MasterData.role.show');
// }
/**
* Show the form for editing the specified resource.
*/
// public function edit($id)
// {
// // dd('oke');
// $role = m_role::find($id);
// return view('dashboard.Master_Data.Role.edit', compact('role'));
// }
/**
* Update the specified resource in storage.
*/

25
app/Http/Controllers/WarehouseController.php

@ -26,13 +26,6 @@ class WarehouseController extends Controller
];
return view('dashboard.Master_Data.Warehouse.index', $data);
}
/**
* Show the form for creating a new resource.
*/
// public function create()
// {
// // return view('dashboard.Master_Data.Warehouse.create');
// }
/**
* Store a newly created resource in storage.
@ -54,24 +47,6 @@ class WarehouseController extends Controller
}
}
/**
* Display the specified resource.
*/
// public function show($id)
// {
// // dd('oke');
// // return view('dashboard.Master_Data.Warehouse.show');
// }
/**
* Show the form for editing the specified resource.
*/
// public function edit()
// {
// // dd('oke');
// // return view('dashboard.Master_Data.Warehouse.edit');
// }
/**
* Update the specified resource in storage.
*/

4
app/Http/Requests/Disposal/ValidasiUpdateDisposal.php

@ -22,20 +22,16 @@ class ValidasiUpdateDisposal extends FormRequest
public function rules(): array
{
return [
// 'peti_id' => 'required|integer',
'customer_id' => 'required|integer',
'warehouse_id' => 'required|integer',
'date_disposal' => 'nullable|date',
'description' => 'nullable|string',
// 'status_disposal' => 'nullable',
];
}
public function messages(): array
{
return [
// 'peti_id.required' => 'Peti harus dipilih.',
// 'peti_id.integer' => 'Peti harus berupa angka.',
'customer_id.required' => 'Customer harus dipilih.',
'customer_id.integer' => 'Customer harus berupa angka.',
'warehouse_id.required' => 'Gudang harus dipilih.',

1
app/Http/Requests/ValidasiCreateCustomer.php

@ -43,7 +43,6 @@ class ValidasiCreateCustomer extends FormRequest
'lot_no.required' => 'Kolom lot_no wajib diisi.',
'lot_no.string' => 'Kolom lot_no harus berupa teks.',
'no_tlp.required' => 'Kolom no_tlp wajib diisi.',
// 'no_tlp.numeric' => 'Kolom no_tlp harus berisi angka.',
'no_tlp.max' => 'Kolom no_tlp tidak boleh lebih dari :max karakter.',
'address.required' => 'Kolom address wajib diisi.',
'address.string' => 'Kolom address harus berupa teks.',

2
app/Models/Customer.php

@ -2,6 +2,8 @@
namespace App\Models;
use App\Models\Peti;
use App\Models\Type_peti;
use App\Traits\UUID;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

5
app/Models/asset_status.php

@ -33,11 +33,6 @@ class asset_status extends Model
'updated_by',
];
// public function asset()
// {
// return $this->belongsTo(m_asset::class, 'asset_id')->withTrashed();
// }
public function warehouseId()
{
return $this->belongsTo(m_warehouse::class, 'warehouse_id')->select('id', 'name', 'address')->withTrashed();

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

@ -70,6 +70,7 @@
<th>Nama Customer</th>
<th>Kode</th>
<th>Tgl Peminjaman</th>
<th>Est Pengembalian</th>
<th>PJ Peminjaman</th>
<th>Tujuan WH Peminjam</th>
<th class="text-center">Action</th>
@ -77,17 +78,16 @@
</thead>
<tbody>
@php
$no_peminjaman = 1;
@endphp
@forelse ($peminjaman as $data_peminjaman)
<tr>
<td class="text-center">{{ $no_peminjaman++ }}</td>
{{-- <td class="text-center">{{ $no_peminjaman++ }}</td> --}}
<td class="text-center">{{ $i++ }}</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>{{ \Carbon\Carbon::parse($data_peminjaman->exit_at)->format('d-m-Y') }}</td>
<td>{{ \Carbon\Carbon::parse($data_peminjaman->est_pengembalian)->format('d-m-Y') }}</td>
<td>{{ $data_peminjaman->exit_pic }}</td>
<td>{{ $data_peminjaman->warehouse->name }}</td>
<td class="text-center">

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

@ -19,8 +19,38 @@
</div>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-6">
<!-- Fitur page -->
<form method="GET" action="{{ route('dashboard.pengembalian.index') }}">
<label for="perPage">Tampilkan:</label>
<select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()">
<option value="5" {{ request('perPage', 5) == '5' ? 'selected' : '' }}>5</option>
<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="{{ $peminjaman->total() }}"
{{ request('perPage', 5) == $peminjaman->total() ? 'selected' : '' }}>Semua</option>
</select>
<input type="hidden" name="search" value="{{ $search }}">
<input type="hidden" name="page" value="{{ request('page', 1) }}">
</form>
</div>
<div class="col-6 d-flex justify-content-end mb-3">
<!-- Fitur search -->
<form method="GET" action="{{ route('dashboard.pengembalian.index') }}" class="form-inline">
<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>
</form>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0">
<table class="table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>No</th>
@ -39,136 +69,111 @@
</tr>
</thead>
<tbody>
@php
{{-- @php
$shownPeti = []; // Array untuk melacak peti yang telah ditampilkan
$no_peminjaman = 1; // Inisialisasi nomor peminjaman
@endphp
@endphp --}}
@forelse ($peminjaman as $data)
@if ($data->enter_warehouse !== null && !in_array($data->peti->fix_lot, $shownPeti))
@php
{{-- @if (!in_array($data->peti->fix_lot, $shownPeti)) --}}
{{-- @php
$shownPeti[] = $data->peti->fix_lot; // Menambahkan peti ke dalam array
@endphp
<tr>
<td>{{ $no_peminjaman++ }}</td>
<td>{{ $data->peti->fix_lot }}</td>
<td>{{ $data->peti->customer->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }}</td>
<td>{{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d/m/Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>
@if ($data->exit_warehouse)
{{ $data->warehouse->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_at)
{{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_pic)
{{ $data->enter_pic }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_warehouse)
{{ $data->warehouseEnter->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->kondisi_peti)
{{ $data->kondisi_peti->nama_kondisi }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_warehouse === null)
Not Return
@else
Return
@endif
</td>
<td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
</td>
</tr>
@endif
@endphp --}}
<tr>
<td>{{ $i++ }}</td>
<td>{{ $data->peti->fix_lot }}</td>
<td>{{ $data->peti->customer->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d-m-Y') }}</td>
<td>{{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d-m-Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>
@if ($data->exit_warehouse)
{{ $data->warehouse->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_at)
{{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_pic)
{{ $data->enter_pic }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_warehouse)
{{ $data->warehouseEnter->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->kondisi_peti)
{{ $data->kondisi_peti->nama_kondisi }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->status == 1)
Return
@elseif($data->status == 0)
Not Return
@endif
</td>
<td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
</td>
</tr>
{{-- @endif --}}
@empty
<tr>
<td colspan="13" class="text-center">Data Kosong</td>
</tr>
@endforelse
{{-- @forelse ($peminjaman as $data)
@if ($data->enter_warehouse !== null)
<tr>
<td>{{ $no_peminjaman++ }}</td>
<td>{{ $data->peti->fix_lot }}</td>
<td>{{ $data->peti->customer->name }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }}</td>
<td>{{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d/m/Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>
@if ($data->exit_warehouse)
{{ $data->warehouse->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_at)
{{ \Carbon\Carbon::parse($data->enter_at)->format('d-m-Y') }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_pic)
{{ $data->enter_pic }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_warehouse)
{{ $data->warehouseEnter->name }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->kondisi_peti)
{{ $data->kondisi_peti->nama_kondisi }}
@else
<p class="text-center font-weight-bold">-</p>
@endif
</td>
<td>
@if ($data->enter_warehouse === null)
Not Return
@else
Return
@endif
</td>
<td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
</td>
</tr>
@endif
@empty
@endforelse --}}
</tbody>
</table>
</div>
<div class="row mt-3">
<div class="col-4">
<!-- Tampilkan jumlah data yang ditampilkan -->
@if (!$peminjaman->isEmpty())
<p class="d-inline-block">Showing {{ $peminjaman->firstItem() }} to
{{ $peminjaman->lastItem() }} of
{{ $peminjaman->total() }} entries</p>
@endif
</div>
<div class="col-8 d-flex justify-content-end">
@if ($peminjaman->total() > $peminjaman->perPage())
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
<li class="page-item {{ $peminjaman->onFirstPage() ? 'disabled' : '' }}">
<a class="page-link"
href="{{ $peminjaman->appends(['perPage' => Request::get('perPage')])->url(1) }}"
aria-label="First">
<span aria-hidden="true">First</span>
</a>
</li>
{{ $peminjaman->appends(['perPage' => Request::get('perPage')])->links() }}
<li class="page-item {{ $peminjaman->hasMorePages() ? '' : 'disabled' }}">
<a class="page-link"
href="{{ $peminjaman->appends(['perPage' => Request::get('perPage')])->url($peminjaman->lastPage()) }}"
aria-label="Last">
<span aria-hidden="true">Last</span>
</a>
</li>
</ul>
</nav>
@endif
</div>
</div>
</div>
</div>
@endsection

Loading…
Cancel
Save