@extends('layouts.admin') @section('content')

<div class="card mb-3">
  <div class="card-header">
    <div class="row flex-between-end">
      <div class="col-auto align-self-center">
        
        <form class="form-material" method="POST" action="{{ url ('/search_payment')}}">
          @csrf
          <input type="text" class="form-control" name="search" id="search">
          <br><button type="submit" class="btn btn-primary btn-sm" aria-placeholder="Search"><i class="fas fa-search"></i> Search</button>
           <br><br>
           <h5 class="mb-0" data-anchor="data-anchor">List of payments</h5>        
        </form>
      </div>
    </div>
  </div>
  <div class="card-body pt-0">

    <div id="tableExample2">
      <div class="table-responsive scrollbar">
        <small>
          <table id="basic-btn" class="table table-sm table-striped table-bordered nowrap">
            <thead class="bg-200 text-900">
              <tr>
                <th>ID</th>
                <th>Member ID</th>
                <th>Date</th>
                <th>Member Name</th>
                <th>Amount</th>
                <th>Payment Method</th>
                <th>Action</th>
              </tr>
            </thead>
            <tbody class="list">
              @foreach ($payments as $payment)
              <tr>
                <td>{{$payment->id}}</td>
                <td>{{$payment->member_id}}</td>
                <td>{{$payment->payment_date}}</td>
                <td>{{$payment->member->name}}</td>
                <td>{{$payment->amount_paid}}</td>
                <td>{{$payment->mode->name}}</td>
                <td>
                  <a href='{{ url("/receipt", $payment->id)}}' class="btn btn-primary btn-sm"> Print</a>&nbsp;
                  <a href='{{ url("/payment_edit", $payment->id)}}' onclick="return confirm('Are you sure you want to delete this payment?')" class="btn btn-sm btn-danger btn-outline-primary">Delete Request</a>
                  @if (Auth::user()->role == 3) &nbsp;
                  <a href='{{ url("/delete_payment")}}/{{$payment->id }}/{{ $payment->member_id}}' class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this payment?')"> Delete </a>
                  @endif
                </td>
              </tr>
              @endforeach
            </tbody>
          </table>
        </small>
      </div>
     
    </div>
  </div>

</div>
@endsection