127 lines
6.5 KiB
PHP
127 lines
6.5 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Rentals')
|
|
|
|
@section('content')
|
|
<div class="flex justify-between items-center mb-6">
|
|
<div>
|
|
<h2 class="text-xl font-bold text-gray-800">Rentals</h2>
|
|
<p class="text-gray-500 text-sm">Manage rentals</p>
|
|
</div>
|
|
<a href="{{ route('rentals.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
|
|
<i class="fas fa-plus"></i> New Rental
|
|
</a>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50 border-b border-gray-200">
|
|
<tr>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Car</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Type</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Customer</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Dates</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Amount</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Status</th>
|
|
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
@forelse($rentals as $rental)
|
|
<tr class="hover:bg-gray-50">
|
|
<td class="px-5 py-4 text-gray-800 text-sm">{{ $rental->car->brand }} {{ $rental->car->model }}</td>
|
|
<td class="px-5 py-4">
|
|
<span class="px-2 py-1 rounded text-xs font-medium bg-blue-100 text-blue-700 capitalize">{{ $rental->rental_type }}</span>
|
|
</td>
|
|
<td class="px-5 py-4 text-gray-600 text-sm">{{ $rental->customer->name }}</td>
|
|
<td class="px-5 py-4 text-gray-600 text-sm">
|
|
@if($rental->pickup_time)
|
|
{{ $rental->start_date->format('M d') }} {{ $rental->pickup_time->format('H:i') }}
|
|
@else
|
|
{{ $rental->start_date->format('M d') }}
|
|
@endif
|
|
-
|
|
@if($rental->return_time)
|
|
{{ $rental->end_date->format('M d') }} {{ $rental->return_time->format('H:i') }}
|
|
@else
|
|
{{ $rental->end_date->format('M d, Y') }}
|
|
@endif
|
|
</td>
|
|
<td class="px-5 py-4 text-gray-800 font-medium text-sm"> BHD {{ number_format($rental->total_amount, 0) }}</td>
|
|
<td class="px-5 py-4">
|
|
<span class="px-2.5 py-1 rounded-full text-xs font-medium
|
|
{{ $rental->status == 'active' ? 'bg-green-100 text-green-700' :
|
|
($rental->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-gray-100 text-gray-600') }}">
|
|
{{ ucfirst($rental->status) }}
|
|
</span>
|
|
</td>
|
|
<td class="px-5 py-4">
|
|
<button type="button" class="text-blue-600 hover:text-blue-800 mr-2 text-sm" title="View Contract" onclick="showContractModal({{ $rental->id }})"><i class="fas fa-file-alt"></i></button>
|
|
<a href="{{ route('rentals.contract.download', $rental) }}" class="text-red-600 hover:text-red-800 mr-3 text-sm" title="Download PDF"><i class="fas fa-file-pdf"></i></a>
|
|
<a href="{{ route('rentals.show', $rental) }}" class="text-green-600 hover:text-green-800 mr-3 text-sm"><i class="fas fa-eye"></i></a>
|
|
<a href="{{ route('rentals.updateStatus', [$rental, 'completed']) }}"
|
|
class="text-green-600 hover:text-green-800 mr-2 text-sm"
|
|
title="Complete"
|
|
onclick="return confirm('Mark this rental as completed?')">
|
|
<i class="fas fa-check"></i>
|
|
</a>
|
|
<form action="{{ route('rentals.destroy', $rental) }}" method="POST" class="inline">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="text-red-600 hover:text-red-800 text-sm" onclick="return confirm('Cancel this rental?')"><i class="fas fa-trash"></i></button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="px-5 py-8 text-center text-gray-500">No rentals yet</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Contract Modal -->
|
|
<div id="contractModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50 flex items-center justify-center">
|
|
<div class="bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-hidden">
|
|
<div class="flex justify-between items-center px-6 py-4 border-b">
|
|
<h3 class="text-lg font-semibold">Rental Contract</h3>
|
|
<div>
|
|
<a id="modalDownloadBtn" href="#" class="text-red-600 hover:text-red-800 mr-4 text-sm"><i class="fas fa-download mr-1"></i> Download PDF</a>
|
|
<button type="button" onclick="closeContractModal()" class="text-gray-500 hover:text-gray-700"><i class="fas fa-times text-xl"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="p-0 overflow-auto max-h-[calc(90vh-80px)]">
|
|
<iframe id="contractFrame" src="" class="w-full h-[70vh] border-0"></iframe>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function showContractModal(rentalId) {
|
|
const modal = document.getElementById('contractModal');
|
|
const frame = document.getElementById('contractFrame');
|
|
const downloadBtn = document.getElementById('modalDownloadBtn');
|
|
|
|
frame.src = '/rentals/' + rentalId + '/contract';
|
|
downloadBtn.href = '/rentals/' + rentalId + '/contract/download';
|
|
modal.classList.remove('hidden');
|
|
}
|
|
|
|
function closeContractModal() {
|
|
document.getElementById('contractModal').classList.add('hidden');
|
|
document.getElementById('contractFrame').src = '';
|
|
}
|
|
|
|
// Close modal on outside click
|
|
document.getElementById('contractModal').addEventListener('click', function(e) {
|
|
if (e.target === this) closeContractModal();
|
|
});
|
|
|
|
// Close modal on Escape key
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Escape') closeContractModal();
|
|
});
|
|
</script>
|
|
@endsection
|