
@extends( isClient() ? 'layouts.app' : 'layouts.admin')

@push('css')
    <link href="{{ asset('css/support/support.css') }}" rel="stylesheet">
@endpush

@php
       $pageLimit = $searchData['pageLimit'];
       $status = $searchData['status'];
       $search_value = $searchData['search_value'];
@endphp

@section('content')
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row" style="padding-left: 20px;padding-right: 15px">
                        <h3 class="pull-left">Client Support</h3>
                    </div>
                </div>

                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="x_panel">
                                <div class="x_content">
                                    <form action="{{route('list.client.support')}}" method="get" role="search">
                                        <div class="row">
                                            <div class="col-md-2 col-xs-12">
                                                <div class="form-group">
                                                    <label>Show</label>
                                                    <select name="pageLimit" id="pagination" class="form-control"
                                                            onchange="this.form.submit()">
                                                        <option value="10" @if($pageLimit == 10) selected @endif>10</option>
                                                        <option value="20" @if($pageLimit == 20) selected @endif>20</option>
                                                        <option value="50" @if($pageLimit == 50) selected @endif>50</option>
                                                        <option value="100" @if($pageLimit == 100) selected @endif>100</option>
                                                        <option value="500" @if($pageLimit == 500) selected @endif>500</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-md-2 col-xs-12">
                                                <div class="form-group">
                                                    <label>Status</label>
                                                    <select name="status" id="status" class="form-control">
                                                        <option value="All" >All</option>
                                                        <option value="0" @if($status == 0) selected @endif>Open</option>
                                                        <option value="2" @if($status == 2) selected @endif>Close</option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="col-md-4 col-xs-12">
                                                <div class="form-group">
                                                    <label>Title/Email</label>
                                                    <input id="search_value"
                                                           type="text"
                                                           value="{{$searchData['search_value']}}"
                                                           placeholder="Search By Title/Email"
                                                           class="form-control" name="search_value" autocomplete="off">
                                                </div>
                                            </div>
                                            <div class="col-md-2 col-xs-12">
                                                <div class="form-group" style="margin-top: 25px;">
                                                    <button class="btn btn-primary btn-outline-primary"  style="width:100%" type="submit">Search</button>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                <div class="table-responsive py-5">
                                    <table id="table-clients" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Title</th>
{{--                                            <th>Priority</th>--}}
                                            <th>Created</th>
                                            <th>Status</th>
                                            <th>Actions</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @if(!empty($supports))
                                            @foreach ($supports as $key => $obj)
                                                @php
                                                    $message = '';
                                                @endphp

                                                  @if(!($obj->supportreplays->isEmpty()))
                                                     @php
                                                        $message = $obj->supportreplays->first()->message ;
                                                     @endphp
                                                  @endif
                                                <tr class="tr-height">
                                                    <td>{{ $obj->id }}</td>
                                                    <td>
                                                        <a style="color:black;" data-toggle="tooltip" title="" href="#" data-original-title="{{$message}}">{{ $obj->title }}</a>
                                                    </td>
{{--                                                    <td>{{ config('constant.SUPPORT_PRIORITY.'.$obj->priority)  }}</td>--}}
                                                    <td>{{ getStringToDateTime($obj->created_at,'m/d/Y h:i:s a') }}</td>
                                                    <td>{{ config('constant.SUPPORT_STATUS.'.$obj->status) }}</td>
                                                    <td>
                                                        @if(isShowContent('view.client.support'))
                                                            <a href="{{route('view.client.support',$obj->id)}}"
                                                               class="btn" title="View Ticket" style="padding: 5px;"> <span
                                                                    class="glyphicon glyphicon-eye-open text-success" ></span></a>
                                                            @if($obj->status == config('constant.SUPPORT_STATUS.Open'))
                                                                <button onclick="return closeTicket({{$obj}},'{{route('process.ajax')}}')" class="btn" title="Close Ticket" style="padding: 5px;">
                                                                    <span class="glyphicon glyphicon-remove text-danger"></span>
                                                                </button>
                                                            @endif

                                                        @endif

                                                    </td>
                                                </tr>
                                            @endforeach
                                        @endif
                                        </tbody>
                                    </table>

                                </div>
                                <div id="pagination_panel">
                                    {{ $supports->links('basic.pagination') }}
                                    <input type="hidden" name="redirect_url" value="{{route('list.client.support')}}">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

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

@endsection
@push('script')
    <script src="{{asset('/')}}js/support/support.js"></script>
@endpush
