<?php
	$resumeData='';
	if($post->type=='resume' and !Auth::check()){
		$isResumeCreated=$post->user->present()->isResumeCreated($post->user_id);
		if($isResumeCreated and $isResumeCreated->theme==7){
			$resumeData=$isResumeCreated;
		}
	}
?>

@if($resumeData)
	<style type="text/css">
		.container{
			max-width:100% !important;
			padding:0px;
		}
		
		.singlePost#post-page{
			width:100%;
			margin-top: 10px;
		}
		
		#top.navbar-fixed-top {		 
		  display: none !important;
		}
	</style>
    
	<div class="resume-theme-7-main-contianer">  	
       <div class="resume-theme-7-contianer"> 
           <div class="resume-theme-7-left">
                {!! Theme::section('resume.resume.themes.theme7-left',['resume'=>$resumeData]) !!}
           </div>   
           
           <div class="resume-theme-7-center">
           		{!! Theme::section('resume.resume.themes.theme7-header',['resume'=>$resumeData]) !!}
                
                <div class="resume-contents-box">
@endif

<div class="container page-content clearfix">

    <div class="singlePost" id="post-page" style="float:left">
		@if($post->type=="user-timeline" and Auth::check())
			{!! Theme::section('user.home.social-search') !!} 
		@endif	
	
    	<?php 
			$foodCommunity=0;
			$isExternal=0; 
			$community_url="";
			$signup_url="";
			if($post->content_type=="food"){
				$food=$post->present()->getFood();
				
				if($food->selected_for_competition==1){
					$foodCommunity=$food->community_id;
				}
			}elseif($post->type=="page"){
				if($post->page){
					$foodCommunity=$post->page->community_id;
				}
			}
			
			$posted_in_community=$post->posted_in_community;	
	    ?>
    	@if(!empty($post) and ($post->type=="community" || $foodCommunity!=0 || $posted_in_community!=0 || $post->type=="resume"))
        
        	<?php 
				if($foodCommunity!=0){
					$community=app('App\\Repositories\\CommunityRepository')->getById($foodCommunity);
				}elseif($post->community_id!=0){
					$community=app('App\\Repositories\\CommunityRepository')->getById($post->community_id);
				}elseif($post->type=='resume'){
					$community=app('App\\Repositories\\CommunityRepository')->getResumeCommunity();
				}else{
					$community=app('App\\Repositories\\CommunityRepository')->getById($posted_in_community);
				}
				
				if($community){
					$isExternal=$community->external_community;
					$community_url=$community->present()->url('login');
					$signup_url=$community->present()->url('signup');
				}
			?>
			
			@if($community and $redUrl=$community->present()->hasExpiredCommunity())
				<script language="javascript">
					window.location="{{$redUrl}}";
				</script>
			@endif
                
        	@if(Auth::check() and $community)
            	@if($community->present()->isMember(\Auth::user()->id))
                    <div class="box event-page-community-menu external-community-panel">
                        <div class="box-title black-ommunity-tittle">                           
                       		<a href="{{$community->present()->url()}}">
                                <img src="{{$community->present()->getLogoAvatar()}}" class="community-home-avatar-icon"/>
                            
                                @if(strlen($community->title) >28)
                                     {{strtoupper(Str::limit($community->title, 28))}}
                                @else
                                    {{strtoupper($community->title)}}
                                @endif
                            </a>     
                        </div>
                        
                        <ul class="mblCommPost community-homepage-link">
                            <li class="box-title green-tittle">
                                <a data-ajaxify="true" href="{{$community->present()->url()}}">Team Members Collaboration</a>  
                                <a data-ajaxify="true" href="{{$community->present()->url('events')}}"> | Events</a>
                            </li>
                        </ul>    
                    </div> 
                @endif    
            @endif 
            
        @endif  
        		
		@if(Session::has('ticket_message'))
			<div class="ticket-message-success-mobile">	
				<div class="alert alert-dismissible alert-success" style="text-align: center; background-color: #d8d5db;  border-color: #d8d5db;">
					<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>  
					<span style="text-align:center; color:#000; font-size: 16px;">{{Session::get('ticket_message')}}</span>
				</div>				
			</div>	
		@endif	  
		   
        @if(empty($post))
            <div class="box">
                <div class="box-title">{{trans('post.post-error')}}</div>
                <div class="box-content">
                    <div class="alert alert-danger">
                        {{trans('post.post-error-note')}}
                    </div>
                </div>
            </div>
        @else
			<?php
				$racingCommunityUrl="";
									
				if($post->show_on_my_timeline==1 and $post->community_id!=0){
					if(!\Auth::check()){
						if($page_type=="w"){
							//$racingCommunityUrl=url("/")."/post/".$post->id."/w";	
						}else{
							
							$urltype='returnurl';
							$urltypeid="";
							$currentUrl=\URL::to('/').$_SERVER['REQUEST_URI'];
							
							$racingCommunityUrl=$community->present()->authUrl('login', ['urltype' => $urltype, 'urltypeid' => $urltypeid, 'returnUrl' => $currentUrl]);	
						}
						//return \Redirect::to($redirectPostUrl);
					}elseif(\Auth::check() and $page_type!=""){
						$racingCommunityUrl=url("/")."/post/".$post->id;
						//return \Redirect::to($redirectPostUrl);
					}		
				}

				if(($post->type=='resume') || ($post->type=="user-timeline" and $post->posted_in_community==0)){
					$mainUrl=parse_url(\Config::get('app.url'));
					$urlDomain="";
					if(isset($mainUrl['host'])){
						$urlDomain=$mainUrl['host'];
					}
					
					$currentHost=\Request::getHost();
					if($urlDomain!=$currentHost){
						$racingCommunityUrl=\Config::get('app.url')."/post/".$post->id;
					}	
				}	
			?>
				
			@if($racingCommunityUrl!="")
				<script language="javascript">
					window.location="{{$racingCommunityUrl}}";
				</script>
			@else				
				@if($post->present()->canViewPagePost()) 
					<?php \App\Performance\N1QueryOptimizer::primePostMediaForFeed([$post]); ?>
					{!! Theme::section('post.media', ['post' => $post, 'commentsLimit' => 10, 'paginate' => TRUE,'singlePost'=>'singlePost']) !!} 
				@else
					 @if($isExternal==1)
							<?php
								$urltype='returnurl';
								$urltypeid="";
								$currentUrl=URL::to('/').$_SERVER['REQUEST_URI'];
							?>
							
							<script language="javascript">
								window.location="{{$community->present()->authUrl('login', ['urltype' => $urltype, 'urltypeid' => $urltypeid, 'returnUrl' => $currentUrl])}}";
							</script>
					 @endif
				@endif
			@endif	
        
            @if(!Auth::check())
                
                @if($isExternal==1)
                    {!! Theme::section('home.ask-community-login',['community_url'=>$community_url,'signup_url'=>$signup_url]) !!} 
                
                    <script language="javascript">	
                        //document.getElementsByClassName('hideonpostpage')[0].style.visibility = 'hidden';
                       // document.getElementById('showonpostpage').style.display = "block";
                       // document.getElementById("showonpostpage").href='{{$community->present()->url('dashboard')}}';
                    </script>
                    
                   <!-- <a href="{{$community->present()->url('dashboard')}}" class="btn btn-primary">Go to Dashboard</a>-->
                @else
                    {!! Theme::section('home.ask-login-post') !!} 
                @endif    
            @endif
            
    	@endif
    </div>
    
    @if(!$resumeData) 
        <div class="relevantPosts post-page-view">
                <style type="text/css">
                    .feed-posts .post-actions-cnt{
                        width:auto;	
                    }	
                </style>
                @if($post and $post->content_type=="event")
                    {!! Theme::section('post.events.crowd-funding-event',['post'=>$post]) !!} 
                    
                    {!! Theme::section('post.events.calendar-events',['sel_date'=>$sel_date,'calendarEvents'=>$calendarEvents,'eventdasboardurl'=>$eventdasboardurl,'post'=>$post,'communityUrl'=>$communityUrl]) !!} 
                
                    {!! Theme::section('post.events.contributer-list',['post'=>$post,'contributersList'=>$contributersList]) !!} 
                
                    {!! Theme::section('post.events.same-day-events',['sel_date'=>$sel_date,'events'=>$events,'post'=>$post]) !!}
                @else
                    @if(!is_null($relevantPosts))
                        @if($post->type=='resume')                    	                   
                            {!! Theme::section('post.resume-feeds-sidebar', ['posts' => $relevantPosts,'post'=>$post]) !!}
                        @else
                            <button class="btn btn-success relevant-cateory-heading">RELEVANT CATEGORY</button>
                       
                            @foreach($relevantPosts as $rpost)
                                @if($rpost->present()->canShow())
                                    <div class="relevant-post feed-posts">
                                        {!! Theme::section('post.relevant-post', ['post' => $rpost]) !!}  
                                    </div>
                                @endif     
                            @endforeach
                        @endif
                    @else
                        @if(Auth::check())
                            <style type="text/css">
                                .social-media-left-pannel, #suggested-friends-view-list{
                                    background: #fff;
                                }
                            </style>
                            
                            {!! Theme::section('user.side-info',['bookingRideUrl'=>'']) !!}
                            
                            <div id="suggested-friends-view-list" data-id="0">
                                 <div class="box friend-request-invitations suggested-friends-list" style="min-height:1px; margin-bottom:0px;">
                                    <div class="box-title invitations-title">{{trans('connection.suggested')}} ({{trans('connection.friends')}}) <a href="{{URL::route('user-account-privacy')}}"><i class="fa fa-cog" aria-hidden="true"></i></a> 
                        
                                    </div>
                                 </div> 
                            </div> 
                            
                            <div class="userProfile" style="color:#d74d4d; padding:10px; display:none; ">
                <a href="{{URL::route('user-organization')}}" style="text-decoration:none; color:#f2aa84;">Click to complete your profile now to unlock personalized matches and discover verified peers in the idhubs community who share your interests and goals.</a>
                            </div>   
                        @endif    
                    @endif 
                @endif        
        </div>
     @endif   
</div>

@if($resumeData)
				</div>
                
                <a style="background: #ed1b23; color: #fff !important; font-weight: 700;
  text-align: center;position: relative;  padding: 10px;  display: block;box-shadow: 0 0 1px 0 #d3d3d3; border-radius: 4px;" href="{{$resumeData->present()->url()}}">Click here to load more</a>
           </div>   
           
           <div class="resume-theme-7-right">
				{!! Theme::section('resume.resume.themes.theme7-right',[
					'resume' => $resumeData,
					'relevantPosts' => (isset($relevantPosts) ? $relevantPosts : []),
				]) !!}
           </div>   
       </div> 
    </div>
@endif
