MIF_E31220412/resources/views/sewa/riwayat.blade.php

120 lines
6.5 KiB
PHP

@extends('layouts.app')
@section('title', 'Riwayat Sewa - INUFA')
@section('header', 'Riwayat Sewa')
@section('content')
<div class="container mx-auto px-4 py-8">
@if(session('success'))
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-4 rounded">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4 rounded">
{{ session('error') }}
</div>
@endif
<!-- Riwayat Sewa Table -->
<div class="bg-white rounded-lg shadow-lg overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">No</th>
@if($showDetailPenyewa)
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Penyewa</th>
@endif
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Paket</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tanggal Sewa</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total Harga</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($sewas as $index => $sewa)
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $index + 1 }}
</td>
@if($showDetailPenyewa)
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $sewa->user->nama }}</div>
<div class="text-sm text-gray-500">{{ $sewa->user->email }}</div>
</td>
@endif
<td class="px-6 py-4">
<div class="text-sm font-medium text-gray-900">{{ $sewa->paket->nama_paket }}</div>
<div class="text-sm text-gray-500">{{ ucfirst($sewa->paket->jenis_paket) }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">{{ \Carbon\Carbon::parse($sewa->tanggal_sewa)->format('d M Y') }}</div>
<div class="text-sm text-gray-500">{{ $sewa->durasi_sewa }} hari</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
@if($sewa->status === 'pending')
bg-yellow-100 text-yellow-800
@elseif($sewa->status === 'confirmed')
bg-green-100 text-green-800
@elseif($sewa->status === 'ongoing')
bg-blue-100 text-blue-800
@elseif($sewa->status === 'selesai')
bg-purple-100 text-purple-800
@else
bg-red-100 text-red-800
@endif">
{{ ucfirst($sewa->status) }}
</span>
@if($sewa->status === 'ditolak' && $sewa->catatan)
<button type="button" class="ml-2 text-xs text-blue-600 underline lihat-penolakan-btn" data-alasan="{{ $sewa->catatan }}">Lihat Penolakan</button>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
Rp {{ number_format($sewa->total_harga, 0, ',', '.') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<a href="{{ route('sewa.show', $sewa->id) }}"
class="text-blue-600 hover:text-blue-900">
<i class="fas fa-eye mr-1"></i>Detail
</a>
</td>
</tr>
@empty
<tr>
<td colspan="{{ $showDetailPenyewa ? 7 : 6 }}" class="px-6 py-4 text-center text-gray-500">
Tidak ada riwayat sewa
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- Modal Alasan Penolakan -->
<div id="modalPenolakan" class="fixed inset-0 flex items-center justify-center z-50 hidden bg-black bg-opacity-40">
<div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-md">
<h3 class="text-lg font-bold mb-4">Alasan Penolakan</h3>
<div id="alasanPenolakanText" class="mb-4 text-gray-700"></div>
<div class="flex justify-end">
<button type="button" id="closeModalPenolakan" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Tutup</button>
</div>
</div>
</div>
<script>
document.querySelectorAll('.lihat-penolakan-btn').forEach(btn => {
btn.addEventListener('click', function() {
document.getElementById('alasanPenolakanText').innerText = this.getAttribute('data-alasan');
document.getElementById('modalPenolakan').classList.remove('hidden');
});
});
document.getElementById('closeModalPenolakan').onclick = function() {
document.getElementById('modalPenolakan').classList.add('hidden');
};
</script>
@endsection