<div class="media general-listing business-search-result-list-view">

    <div class="media-object pull-left">
        <a data-ajaxify="true" @if(!Auth::check()) target="_blank" @endif class="cover" href="{{URL::route('store', ['slug' => $page->slug])}}"><img src="{{$page->present()->getAvatar(600)}}"/> </a>
    
    	<a href="{{URL::route('store', ['slug' => $page->slug])}}">
            <div class="product-listing-rating-view">
                <?php 
                    $productRatingsCount=$page->present()->businessRatingsCount($page->id);
                    $reviewsCount=$page->present()->businessReviewsCount($page->id);
                ?>
                
                <div class="product-listing-rating-overall">
                    <span class="fa fa-star product-overall-rating @if($productRatingsCount>0) checked @endif"></span>
                    <span class="fa fa-star product-overall-rating @if($productRatingsCount>1) checked @endif"></span>
                    <span class="fa fa-star product-overall-rating @if($productRatingsCount>2) checked @endif"></span>
                    <span class="fa fa-star product-overall-rating @if($productRatingsCount>3) checked @endif"></span>
                    <span class="fa fa-star product-overall-rating @if($productRatingsCount>4) checked @endif"></span>
                
                    <span>({{$reviewsCount}})</span>
                </div> 
               
            </div>
    	</a>
    </div>

    <div class="media-body business-info">
        	<h3 class="media-heading">
            	<a data-ajaxify="true" class="cover" href="{{URL::route('store', ['slug' => $page->slug])}}" @if(!Auth::check()) target="_blank" @endif>{{$page->title}} </a>
            </h3>

        	<?php 
				$location=$page->street." ".$page->city." ".$page->zip." ".$page->state." ".$page->country;
			?>
            
           <p>{{$location}}</p>
            
           <p>
                <img src="{{Theme::asset()->img('theme/images/tel-icon.png')}}" class="business-contact-icons"/> &nbsp;<a href="tel:{{$page->business_contact}}">{{$page->business_contact}}</a> 
           </p>
           
           <p>      
           		<img src="{{Theme::asset()->img('theme/images/email-icon.png')}}" class="business-contact-icons"/> &nbsp;<a href="mailto:{{$page->business_email}}">{{$page->business_email}}</a>
           </p>
            
           <i class="icon ion-thumbsup"></i> <span class="post-like-count-{{$page->id}}">{{$page->countLikes()}}</span> {{trans('like.likes')}}

        {!! Theme::extend('page-display', ['page' => $page]) !!}

        <?php
            $authUserId = \Auth::check() ? (int) \Auth::id() : 0;
            $hasLikeMapKey = $authUserId > 0 ? ('feed_page_has_liked_map:u' . $authUserId) : null;
            $pageHasLikedMap = $hasLikeMapKey ? request()->attributes->get($hasLikeMapKey) : null;
            $hasLike = $authUserId > 0 && is_array($pageHasLikedMap)
                ? !empty(($pageHasLikedMap[(int) $page->id] ?? false))
                : $page->hasLiked();
        ?>

		@if(Auth::check())
        	<a data-is-login="{{Auth::check()}}" data-status="{{($hasLike) ? '1' : 0}}" class="btn btn-default btn-xs like-button" data-like="{{trans('like.like')}}" data-unlike="{{trans('like.unlike')}}" data-id="{{$page->id}}" data-type="page" href=""><i class="icon ion-ios7-heart"></i> <span>{{($hasLike) ? trans('like.unlike') : trans('like.like')}}</span></a>
		
        	@if(isset($showActBtn) and $showActBtn=='showActBtn')
        		<span class="btn btn-xs change-business-status @if($page->status==0) btn-success @else btn-danger @endif" data-id="{{$page->id}}" data-value="{{$page->status}}">@if($page->status==0) Activate @else Deactivate @endif </span>	
        	
            
            	<span class="btn btn-xs business-communication @if($page->business_communication==0) btn-success @else btn-danger @endif" data-id="{{$page->id}}" data-value="{{$page->business_communication}}">@if($page->business_communication==0) Activate B2B @else Stop B2B @endif</span>
            @endif
            
            <?php
				$myOwnedCommunity="";
				if(Auth::check()){
					$myOwnedCommunity=app('App\\Repositories\\CommunityRepository')->getExternalByUserId(\Auth::user()->id);
				}
			?>
            
            @if($myOwnedCommunity and $myOwnedCommunity->public_business_community==1)
                <span class="btn btn-xs change-business-featuring @if($page->is_featured_global==0) btn-success @else btn-danger @endif" data-id="{{$page->id}}" data-value="{{$page->is_featured_global}}">@if($page->is_featured_global==0) Start Featuring @else Stop Featuring @endif </span>
                
            @elseif(isset($showActBtn) and $showActBtn=='showActBtn')
                   <span class="btn btn-xs change-business-featuring @if($page->is_featured==0) btn-success @else btn-danger @endif" data-id="{{$page->id}}" data-value="{{$page->is_featured}}">@if($page->is_featured==0) Start Featuring @else Stop Featuring @endif </span>	
            @endif
            
        @endif
        
		@if($page->isOwner() or $page->present()->isAdmin() or $page->present()->isEditor())
        	<a data-ajaxify="true" href="{{$page->present()->url('edit')}}" class="btn btn-default btn-xs">
                Edit
            </a>
            
            <a data-url="{{URL::route('pages-delete', ['id' => $page->id])}}" class="btn btn-danger btn-xs business-profile-delete">
            	Delete
            </a>
        @endif

		@if(isset($domainshow) and $domainshow=='domainshow')
        	<br />
            @if($page->community_id!=0)
                <?php
                    $community=app('App\\Repositories\\CommunityRepository')->getById($page->community_id);
                    $urlDomain="";
                    $urlScheme="http://";
                    $mainUrl=parse_url(Config::get('app.url'));
                    if(isset($mainUrl['host'])){
                        $urlDomain=$mainUrl['host'];
                    }
                    
                    /*if(isset($mainUrl['scheme'])){
                        $urlScheme=$mainUrl['scheme']."://";
                    }*/
                ?>
                @if($community)
                    <p class="busniess_created_at">@if($community->domain==1 and $community->domain_name!="") {{$community->domain_name}} @else {{$community->slug}}.{{$urlDomain}} @endif</p>
                @endif
            @endif
        @endif
    </div>
</div>
