
@extends('layouts.admin')

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

@php
       $pageLimit = $searchData['pageLimit'];
       $status_code = $searchData['status_code'];
@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">Iq Call Histories</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.iq.history')}}" 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>From Date</label>
                                                    <input id="fdate"
                                                           type="text"
                                                           class="form-control" name="fdate"
                                                           value="{{$searchData['fdate']}}"
                                                           autocomplete="off">
                                                </div>
                                            </div>
                                            <div class="col-md-2 col-xs-12">
                                                <div class="form-group">
                                                    <label>To Date</label>
                                                    <input id="tdate"
                                                           type="text"
                                                           class="form-control" name="tdate"
                                                           value="{{$searchData['tdate']}}"
                                                           autocomplete="off">
                                                </div>
                                            </div>
                                            <div class="col-md-2 col-xs-12">
                                                <div class="form-group">
                                                    <label>Page Status</label>
                                                    <select name="status_code" class="form-control">
                                                        <option value="" @if($status_code == '') selected @endif>Please Select</option>
                                                        <option value="1" @if($status_code == 1) selected @endif>Ip Blocked</option>
                                                        <option value="2" @if($status_code == 2) selected @endif>Success</option>
                                                    </select>
                                                </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 class="col-md-2 col-xs-12">
                                                <div class="form-group" style="margin-top: 25px;">
                                                    <button class="btn btn-primary btn-outline-primary" name="export" value="1" style="width:100%" type="submit">Excel Export</button>
                                                </div>
                                            </div>

                                        </div>
                                    </form>
                                <div class="table-responsive py-5">
                                    <table id="table-histories" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>IP</th>
                                            <th>Port</th>
                                            <th>Page</th>
                                            <th>Status Code</th>
                                            <th>Status</th>
                                            <th>Created On</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @if(!empty($histories))
                                            @foreach ($histories as $key => $obj)

                                               @php
                                                  $status = "Success";
                                                   if($obj->error_code == 403)
                                                       $status = "Failed";
                                                @endphp
                                                <tr class="tr-height">
                                                    <td>{{ $obj->id }}</td>
                                                    <td>{{$obj->ip}}</td>
                                                    <td>{{$obj->port}}</td>
                                                    <td>{{$obj->page}}</td>
                                                    <td>{{$obj->error_code}}</td>
                                                    <td>{{$status}}</td>
                                                    <td>{{$obj->created_at}}</td>
                                                </tr>
                                            @endforeach
                                        @endif
                                        </tbody>
                                    </table>

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

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

@endsection
@push('script')
    <script>
        $(function() {
            common_helper.datePicker('#fdate',"yyyy-mm-dd",true,null);
            common_helper.datePicker('#tdate',"yyyy-mm-dd",true,null);
        });
    </script>
@endpush
