@extends('layout.main')
@section('title') @if( ! empty($title)) {{ $title }} | @endif @parent @endsection

@section('main')
<div class="">
    <div id="wrapper">
        @include('admin.sidebar_menu')

        <div id="page-wrapper">
            @if( ! empty($title))
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"> Agencies </h1>
                </div> <!-- /.col-lg-12 -->
            </div> <!-- /.row -->
            @endif

            @include('admin.flash_msg')

            <div class="row">
                <div class="col-xs-12">

                    <table class="table table-bordered table-striped" id="jDataTable">
                        <thead>
                            <tr>
                                <th>@lang('app.name')</th>
                                <th>@lang('app.via')</th>
                                <th>@lang('app.email')</th>
                                <th>@lang('app.created_at')</th>
                                <th>@lang('app.actions')</th>
                            </tr>
                        </thead>

                        @foreach($agencies as $agency)

                        <tr>
                            <th>{!! '<a href="'.route('agency', $agency->id).'">'.$agency->name.'</a>' !!}</th>
                            <th>{!! $agency->name !!}</th>
                            <th>{!! $agency->email !!}</th>
                            <th>{!! $agency->address !!}</th>
                            <th>{!! '<a href="'.route('agency', $agency->id).'" class="btn btn-info btn-xs"><i
                                        class="fa fa-eye"></i>view</a>' !!}</th>
                        </tr>

                        @endforeach

                    </table>

                </div>
            </div>

        </div> <!-- /#page-wrapper -->

    </div> <!-- /#wrapper -->


</div> <!-- /#container -->
@endsection

@section('page-js')
<script>
    $(document).ready(function() {

            $(document).on('click','.agent-feature-btn', function(){
                var user_id = $(this).data('user-id');
                $that = $(this);
                $.ajax({
                    type : 'POST',
                    url : '{{ route('change_user_feature') }}',
                    data: { user_id : user_id, _token : '{{csrf_token()}}' },
                    success : function(data){
                        $that.html(data);
                    }
                });
            });

        });
</script>
@endsection