@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"> {{ $title }}  </h1>
                        </div> <!-- /.col-lg-12 -->
                    </div> <!-- /.row -->
                @endif
                @include('admin.flash_msg')

                <div class="row">
                    
                    <div class="col-sm-12">
                        @if(isset($properties_added))
                        <table style="width:100%">
                          <tr>
                            <th>Agent Name</th>
                            <th>Phone Number</th>
                            <th>Property Name</th>
                            <th>Property Status</th>
                            <th>Accept/Reject</th>
                          </tr>
                          @foreach($properties_added as $property_added)
                          @php
                          $ad = App\Ad::find($property_added->property_id);
                          $agent_added = App\User::find($property_added->agent_id);
                          
                          @endphp
                          <tr >
                            <td style="padding:20px 5px">{{$agent_added->name}}</td>
                            <td style="padding:20px 5px">{{$agent_added->phone}}</td>
                            <td style="padding:20px 5px">{{$ad->title}}</td>
                            <td style="padding:20px 5px">
                                @if($ad->status == 0)
                                PENDING
                                @elseif($ad->status == 1)
                                APPROVED
                                @elseif($ad->status == 2)
                                BLOCKED
                                @endif
                            </td>
                            <td style="padding:20px 5px">
                                @if($property_added->accepted == 0)
                                <a href="{{route('ad-accept-invite',['invite_id'=>$property_added->id,'answer'=>1])}}" class="btn btn-success"> ACCEPT </a> 
                                <a href="{{route('ad-accept-invite',['invite_id'=>$property_added->id,'answer'=>2])}}" class="btn btn-danger" style="margin-left:5px;"> REJECT </a>
                                @else
                                    @if($property_added->accepted == 1)
                                    ACCEPTED
                                    @else
                                    REJECTED
                                    @endif
                                @endif
                            </td>
                          </tr>
                          @endforeach
                          
                        </table>
                        @else
                        <h3> You have not been added to a property </h3>
                        @endif
                    </div>
                    
                </div>

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

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


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

@section('page-js')


@endsection

