NIM_E31222518/resources/views/admin/transaksi/index.blade.php

121 lines
6.9 KiB
PHP

@extends('layouts.admin')
@section('content')
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-800">Daftar Transaksi</h1>
</div>
@if(session('success'))
<div class="mb-4 p-4 bg-green-100 border border-green-400 text-green-700 rounded">
{{ session('success') }}
</div>
@endif
<!-- Filter Section -->
<div class="bg-white p-4 rounded-lg shadow mb-6">
<form action="{{ route('admin.transaksi.index') }}" method="GET" class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label for="start_date" class="block text-sm font-medium text-gray-700">Tanggal Mulai</label>
<input type="date" name="start_date" id="start_date" value="{{ request('start_date') }}"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label for="end_date" class="block text-sm font-medium text-gray-700">Tanggal Akhir</label>
<input type="date" name="end_date" id="end_date" value="{{ request('end_date') }}"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label for="status" class="block text-sm font-medium text-gray-700">Status</label>
<select name="status" id="status" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
<option value="">Semua Status</option>
<option value="pending" {{ request('status') == 'pending' ? 'selected' : '' }}>Menunggu</option>
<option value="paid" {{ request('status') == 'paid' ? 'selected' : '' }}>Dibayar</option>
<option value="completed" {{ request('status') == 'completed' ? 'selected' : '' }}>Selesai</option>
<option value="cancelled" {{ request('status') == 'cancelled' ? 'selected' : '' }}>Dibatalkan</option>
</select>
</div>
<div class="md:col-span-3 flex justify-end">
<button type="submit" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700">
Filter
</button>
<a href="{{ route('admin.transaksi.index') }}" class="ml-2 bg-gray-500 text-white px-4 py-2 rounded-md hover:bg-gray-600">
Reset
</a>
</div>
</form>
</div>
<div class="bg-white rounded-lg shadow overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID Transaksi</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pelanggan</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID Pesanan</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Metode Pembayaran</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tanggal</th>
<th scope="col" 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($transaksi as $item)
<tr>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">#{{ $item->id }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">{{ $item->user->nama ?? $item->user->name }}</div>
<div class="text-xs text-gray-500">{{ $item->user->email }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">#{{ $item->pesanan->id }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">Rp {{ number_format($item->jumlah, 0, ',', '.') }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">{{ $item->metode_pembayaran }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
@if($item->status == 'pending')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
Menunggu
</span>
@elseif($item->status == 'paid')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">
Dibayar
</span>
@elseif($item->status == 'completed')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Selesai
</span>
@elseif($item->status == 'cancelled')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
Dibatalkan
</span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-500">{{ $item->created_at->format('d M Y H:i') }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<a href="{{ route('admin.transaksi.show', $item) }}" class="text-indigo-600 hover:text-indigo-900">
<i class="fas fa-eye"></i> Detail
</a>
</td>
</tr>
@empty
<tr>
<td colspan="8" class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-center">
Tidak ada data transaksi
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
@endsection