@extends('adminlte::page')

@section('content')
        <div class="container-fluid">
            <div class="">
                <div class="col-sm-6">
                    <h2>Manage Country / State / City</h2>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Home</a></li>
                    <li class="breadcrumb-item active">Manage Country / State / City</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    

    <section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title"></h3>
                            <div class="alert alert-success alert-dismissible groputitle" style="display:none">
                        </div>
                        @if(Session::has('add_message'))
                        <div class="alert alert-success alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        {!! session('add_message') !!} 
                        </div>
                        @endif
                        <form id="cities-mng" method="get" action="{{route('admin.cities')}}">
                            {{ csrf_field() }}
                            <div class="row clearfix">
                                <div class="col-sm-2">
                                    <div class="form-group">
                                        <div class="form-line">
                                            <input class="form-control" name="keyword" value="{{old('keyword',$request->keyword)}}" placeholder="Keyword" type="text">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <button type="submit" class="btn btn-primary btn-info">Search<div></div></button>
                                    <a href="{{route('admin.cities')}}" class="btn btn-primary btn-success">Reset</a>
                                </div>
                                <div class="col-sm-2 pull-right">
                                    <a href="{{route('admin.cities.add')}}" class="btn btn-block btn-warning">Add </a>
                                </div>
                            </div>
                        </form>

                        @if(Session::has('message'))
                        <div class="alert alert-success alert-dismissible">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            {!! session('message') !!} 
                        </div>
                        @endif
                    </div>

                    

                    <!-- /.box-header -->
                    <form id="cities-add" method="get" action="">

                    <div class="card">
                        <!-- /.card-header -->
                        <div class="card-body">
                            <table class="table table-bordered">
                            <tr>
                                <th style="width: 10px">#</th>
                                <th>@sortablelink('name')</th>
                                <th>@sortablelink('created_at')</th>
                                <th style="width: 40px">Action</th>
                            </tr>
                            @if(count($records)>0)
                            <?php $k = ($pageNo == 1) ? $pageNo : (($pageNo - 1) * $record_per_page) + 1; ?>
                            @foreach($records as $row)
                            <tr>
                                <td>{{$row->id}}</td>
                                <td>{{$row->name}}</td>
                                <td>{{date("F j, Y", strtotime($row->created_at))}}</td>
                                <td style="width:10%">
                                    <a href="{{route('admin.cities.edit',['id'=>$row->id])}}" class="btn btn-info btn-xs action-btn" title ="Edit"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
                                    <a href="{{route('admin.cities.delete',['id'=>$row->id])}}" class="btn btn-danger btn-xs action-btn" onclick="return confirm('Are you sure you want to delete ?');" title ="Delete"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                                </td>
                            </tr>
                            <?php $k++; ?>     
                            @endforeach
                            @else
                            <tr class="bg-info">
                                <td colspan="4">Record(s) not found.</td>
                            </tr>
                            @endif
                            </table>
                        </div>
                        <!-- /.card-body -->
                        <div class="card-footer clearfix">
                            <ul class="pagination pagination-sm m-0 float-right">
                                {!! $records->links() !!}
                            </ul>
                        </div>
                        <!-- /.card -->
                    </div>    
                    </form>
                    <!-- /.box-body -->
                    
                </div>
                <!-- /.box -->
            </div>
        </div>
</div>

@endsection
