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

@section('main')

        <div id="wrapper">

            @include('admin.sidebar_menu')

            <div id="page-wrapper">
                @if( ! empty($title))
                    <div class="row">
                        <div class="col-lg-6">
                            <h1 class="page-header"> {{ $title }}  </h1>
                        </div> <!-- /.col-lg-12 -->
                        <div class="img" class="col-lg-6"><img src="..." alt="..." class="img-thumbnail"></div>
                    </div> <!-- /.row -->
                @endif

                @include('admin.flash_msg')


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

                        <div id="return_msg"></div>

                        <table class="table table-bordered table-striped">
                            <tr>
                                <th>@lang('app.account_status')</th>
                                <td>
                                    <label>
                                        <input type="radio" name="account_status" value="0" data-user-id="{{$agency->id}}" @if($agency->active_status == '0') checked="checked" @endif />
                                        @lang('app.active')
                                    </label>

                                    <label>
                                        <input type="radio" name="account_status" value="1" data-user-id="{{$agency->id}}" @if($agency->active_status == '1' ) checked="checked" @endif />
                                        @lang('app.block')
                                    </label>
                                </td>
                            </tr>

                            <tr>
                                <th><label for="agency_name"><strong>Agency Name </strong></label></th>
                                <td>{{ $agency->name }}</td>
                            </tr>
                            <tr>
                                <th><label for="agency_address"><strong>Agency Address </strong></label></th>
                                <td>{{ $agency->address }}</td>
                            </tr>
                            <tr>
                                <th><label for="agency_email"><strong>Agency Email </strong></label></th>
                                <td>{{ $agency->email }}</td>
                            </tr>
                            <tr>
                                <th>Created At</th>
                                <td>{{ $agency->created_at }}</td>
                            </tr>
                            <tr>
                                <th>@lang('app.status')</th>
                                <td>{{ $agency->status_context() }}</td>
                            </tr>
                        </table>

                    </div>
                </div>
                <div class="img" class="col-lg-12"><img src="..." alt="..." class="img-thumbnail"></div>



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




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

@section('page-js')

    <script>

        $(function(){
            $(document).on('click','[name="account_status"]', function(){
                var user_id = $(this).data('user-id');
                var status = $(this).val();
                $.ajax({
                    type : 'POST',
                    url : '{{ route('change_agency_status') }}',
                    data: { user_id : user_id, status : status, _token : '{{csrf_token()}}' },
                    success : function(data){
                        $('#return_msg').html(data);
                        console.log("done");
                    }
                    // error:function(data){
                    //     console.log(data);
                    // }
                });
            });
        })
    </script>



@endsection