@extends('backend.layouts.master')

@section('main-content')

<div class="card">

    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary float-left">
            Subscription List
        </h6>

        <a href="{{ route('subscription.create') }}"
           class="btn btn-primary btn-sm float-right"
           data-toggle="tooltip"
           data-placement="bottom"
           title="Add Subscription">

            <i class="fas fa-plus"></i> Add Subscription
        </a>
    </div>

    <div class="card-body">

        <div class="table-responsive">

            @if(count($subscriptions) > 0)

            <table class="table table-bordered" id="subscription-dataTable" width="100%" cellspacing="0">

                <thead>
                    <tr>
                        <th>S.N.</th>
                        <th>Package Name</th>
                        <th>Price</th>
                        <th>Duration (Days)</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>

                <tfoot>
                    <tr>
                        <th>S.N.</th>
                        <th>Package Name</th>
                        <th>Price</th>
                        <th>Duration (Days)</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </tfoot>

                <tbody>

                    @foreach($subscriptions as $subscription)

                    <tr>
                        <td>{{ $loop->iteration }}</td>

                        <td>{{ $subscription->package_name }}</td>

                        <td>₹ {{ $subscription->price }}</td>

                        <td>{{ $subscription->duration_days }} Days</td>

                        <td>
                            @if($subscription->is_active)
                                <span class="badge badge-success">Active</span>
                            @else
                                <span class="badge badge-danger">Inactive</span>
                            @endif
                        </td>

                        <td>

                            <!-- View -->
                            <a href="{{ route('subscription.show', $subscription->id) }}"
                               class="btn btn-info btn-sm"
                               data-toggle="tooltip"
                               title="View">
                                <i class="fas fa-eye"></i>
                            </a>

                            <!-- Edit -->
                            <a href="{{ route('subscription.edit', $subscription->id) }}"
                               class="btn btn-primary btn-sm"
                               data-toggle="tooltip"
                               title="Edit">
                                <i class="fas fa-edit"></i>
                            </a>

                            <!-- Delete -->
                            <form method="POST"
                                  action="{{ route('subscription.destroy', $subscription->id) }}"
                                  style="display:inline-block;">

                                @csrf
                                @method('DELETE')

                                <button class="btn btn-danger btn-sm"
                                        data-toggle="tooltip"
                                        title="Delete"
                                        onclick="return confirm('Are you sure?')">
                                    <i class="fas fa-trash"></i>
                                </button>

                            </form>

                        </td>

                    </tr>

                    @endforeach

                </tbody>

            </table>

            @else

            <h6 class="text-center">No Subscriptions Found!!!</h6>

            @endif

        </div>
    </div>
</div>

@endsection