@extends('admin.master')
@section('title') Notification | SHOP @endsection
@section('push-notification') active @endsection
@section('push-notification.index') active @endsection
@section('styles')
@endsection

@section('main_content_section')
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> Timely Notification List</span></h3>
    </div>
</div>

<div class="table_wrapper py-1 card min-vh-100">
    <div class="row my-2 aggregate-section-div">
        <div class="px-3 ">
            <div class=" d-flex justify-content-between align-items-center aggregate-section border">
                <div class="d-flex align-items-center">
                    <p class="mb-0"><a href="{{route('blog.index')}}"
                            class="text-primary py-2 px-3 active">All({{$data->count()}})</a>
                    </p>
                </div>
                <div class="d-none d-sm-block">
                    @if (Auth::user()->can('direct-push-notification-access')) 
                        <a href="{{route('push-notification.create')}}"
                            class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"><span class="">New Notification</span></a>
                    @endif
                </div>
            </div>

            @if (Auth::user()->can('direct-push-notification-access')) 
                <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none">
                    <a class="text-white" href="{{route('push-notification.create')}}">New Notification</a>
                </div>
            @endif
        </div>
    </div>



    <div class="row px-3">
        <div class="table-container table-responsive">
            <table id="" class="table table-bordered">
                <thead class="text-uppercase">
                    <tr class="me-3">
                        <th class="text-center" scope="col"><span>Notification Titte</span></th>
                        <th class="text-center" scope="col"><span>Notification Message</span></th>
                        <th class="text-center" scope="col"><span>ID</span></th>
                        <th class="text-center" scope="col"><span>Status</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

                    @foreach($data as $key=>$item)
                    @if(isset($item) && $item != null)
                    <tr class="">

                        <td>
                            <div class="row_title custom-text-left">
                                <b>Title: </b> <span>{{ $item->notification_title }}</span><br>
                                <b>Date: </b> <span>{{Carbon\Carbon::parse($item->sending_date)->format('d-m-Y')}}</span><br>
                                <b>Time: </b><span>{{$item->sending_time}}</span>
                            </div>
                            <div class="row-actions custom-text-left">
                                <span><button class="edit_class_modal border-0 bg-transparent" value="{{ $item->id }}"> <a
                                            class="text-primary" href="{{route('push-notification.edit', $item->id)}}">Edit</a> </button> | </span>

                                <span><a href="{{ route('push-notification.delete', ['id'=>$item->id]) }}"
                                        class="row-delete"><span class="trash text-danger">Delete</span> </a></span>
                            </div>
                        </td>

                        <td>
                            {!! Str::limit($item->notification_message, 150) !!}
                        </td>

                        <td>
                            <b>{{$item->id}}</b>
                        </td>

                        <td>
                            @if($item->status == true)
                            <span class="badge bg-success">Done</span>
                            @else
                            <span class="badge bg-danger">Unpaid</span>
                            @endif
                        </td>

                    </tr>
                    @endif
                    @endforeach


                </tbody>
            </table>
        </div>

        <div class="clearfix d-flex">
            <div class="float-left">
                <p class="text-muted">
                    {{ __('Showing') }}
                    <span class="font-weight-bold">{{ $data->firstItem() }}</span>
                    {{ __('to') }}
                    <span class="font-weight-bold">{{ $data->lastItem() }}</span>
                    {{ __('of') }}
                    <span class="font-weight-bold">{{ $data->total() }}</span>
                    {{ __('results') }}
                </p>
            </div>

            <div class="float-right custom-table-pagination">
                {!! $data->links('pagination::bootstrap-4') !!}
            </div>
        </div>
    </div>


</div>
@endsection

@section('scripts')
@endsection