@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">
                <h5 class="mb-0" data-anchor="data-anchor">List of all members Sponsored by government are {{ $membersWithPremiums}}</h5>
            </div>
        </div>
    </div>
    <div class="card-body pt-0">
        <div class="dt-responsive table-sm table-responsive">
            <small>
                <table id="basic-btn" class="table table-sm text-sm table-striped table-bordered nowrap">
                    <thead class="bg-200 text-900">
                        <tr>
                            <th>Payment</th>
                            <th>Name</th>
                            <th>Surname</th>
                            <th>National ID</th>
                            <th>Cell Number</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($members as $member)
                        <tr>
                            <td>

                                <a href='{{ url("/memberpayments", $member->id)}}' class="btn btn-primary btn-sm"><i class="fas fa-money-check"></i> Payment</a> &nbsp;
                                <a href='{{ url("/member_profile", $member->id)}}' class="btn btn-primary btn-sm"><i class="far fa-user-circle"></i> Profile</a>&nbsp;

                            </td>
                            <td>{{$member->name}}</td>
                            <td>{{$member->surname}}</td>
                            <td>{{$member->national_id}}</td>
                            <td>{{$member->cell_number}}</td>
                            <td>{{$member->status1}}</td>
                            <td>
                                @if ((Auth::user()->role == 3) & ($member->status1 == "Restart"))
                                <a href='{{ url("/restart", $member->id)}}' class="btn btn-secondary btn-sm"><i class="far fa-clock"></i> Restart</a>&nbsp;
                                @endif
                                <a href='{{ url("/member", $member->id)}}' class="btn btn-primary btn-sm"><i class="far fa-edit"></i> Edit</a>&nbsp;
                                <a href='{{ url("/predelete_member", $member->id)}}' class="btn btn-danger btn-sm delete" data-confirm="Are you sure to delete this item?"><i class="far fa-trash-alt"></i> Delete</a>
                            </td>

                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </small>
        </div>


    </div>

</div>

<script>
    var deleteLinks = document.querySelectorAll('.delete');

    for (var i = 0; i < deleteLinks.length; i++) {
        deleteLinks[i].addEventListener('click', function(event) {
            event.preventDefault();

            var choice = confirm(this.getAttribute('data-confirm'));

            if (choice) {
                window.location.href = this.getAttribute('href');
            }
        });
    }
</script>

@endsection