@extends('layouts.master')
@section('title', 'Payments')
@section('content')
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">Payment List</h5>
<a href="{{ route(
([
1 => 'admin',
2 => 'manager',
3 => 'account',
4 => 'user',
][auth()->user()->role] ??
'user') .
'.payment.create',
) }}"
class="btn btn-primary btn-sm">+ Make payment</a>
</div>
<div class="card-body">
{{-- Table --}}
<table id="paymentsTable" class="table text-center text-capitalize">
<thead>
<tr>
<th>#</th>
<th>Agency Name</th>
<th>User Name</th>
<th>Payment Method</th>
<th>Bank Details</th>
<th>Currency</th>
<th>Payment Date</th>
<th>Proof</th>
<th>Payment Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($payments as $key => $payment)
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $payment->agency->name }}</td>
<td>{{ $payment->user->name }} <br /> {{ $payment->user->phone }}</td>
<td>{{ $payment->type }}</td>
<td style="text-align: left">
{{ $payment->bank_name }} <br /> {{ $payment->transaction_id }}
</td>
<td>{{ $payment->total_amount }} {{ $payment->currency }}</td>
<td>{{ $payment->paid->format('d-m-Y') }}</td>
<td>
@if ($payment->proof)
<a href="{{ asset('storage/' . $payment->proof) }}" target="_blank">View Proof</a>
@else
No file
@endif
</td>
<td>
@php
$statusClasses = [
0 => 'warning',
1 => 'success',
2 => 'danger',
3 => 'secondary',
4 => 'info',
];
$statusLabels = [
0 => 'Pending',
1 => 'Approved',
2 => 'Rejected',
3 => 'Cancelled',
4 => 'Enable Edit',
];
@endphp
<span class="badge text-bg-{{ $statusClasses[$payment->status] ?? 'secondary' }}">
{{ $statusLabels[$payment->status] ?? 'Unknown' }}
</span>
</td>
<td>
@if ($payment->status == 4 && auth()->user()->role == 4)
<a href="{{ route(
([
4 => 'user',
][auth()->user()->role] ??
'user') .
'.payment.edit',
$payment,
) }}"
class="btn btn-warning btn-sm">
<i class="bi bi-pencil-square"></i> Edit
</a>
@elseif (auth()->user()->role == 4)
<span class="text-muted">No actions available</span>
@endif
@if (auth()->user()->role == 1 || auth()->user()->role == 2 || auth()->user()->role == 3)
<a href="{{ route(
([
1 => 'admin',
2 => 'manager',
3 => 'account',
4 => 'user',
][auth()->user()->role] ??
'user') .
'.payment.edit',
$payment,
) }}"
class="btn btn-info btn-sm">
<i class="bi bi-pencil-square"></i> View
</a>
{{-- @if (!$payment->status == 1)
<form action="{{ route('payment.delete', $payment) }}" method="POST"
class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm"
onclick="return confirm('Are you sure?')">
<i class="bi bi-trash"></i> Delete
</button>
</form>
@endif --}}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
@section('scripts')
<script>
$(document).ready(function() {
$('#paymentsTable').DataTable({
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'csvHtml5',
'pdfHtml5',
'print'
],
"searching": true,
"ordering": true,
"paging": true,
"lengthMenu": [10, 25, 50, 100]
});
});
</script>
@endsection