<?php
	$makingPaymentFrom='inside';
	if(isset($payment_from) and $payment_from=='outside'){
		$makingPaymentFrom='outside';
	}	
	$cardLoaded= app('App\\Repositories\\CommunityPricingPlanPaymentCardsRepository')->getCommunityCardDetailsById($community->id);
?>

{!! Theme::section('community.pannel.plan.plan-menu',['page'=>'details']) !!}

<div class="box" style="border-bottom:none;box-shadow: none;">

    @if($planDetails)	
   
   	   <?php
			$plan=$community->present()->getPricingPlan($planDetails->plan_id);
	   ?>
         
	   {{-- @if($plan->is_plan_free==0) --}}
		   {{--@if($planDetails->paid_for_plan==1)--}}	
			   <div class="box-title" style="font-size:18px;">
					@if($planDetails->paid_for_plan==0)
                        {{ trans('internal-collaborations.current-plan-details') }}:
					@else
                        {{ trans('internal-collaborations.current-plan-details') }}:
					@endif   
                    
                    <span class="change-plan-open-btn">Change Plan</span> 
			   </div>
           {{--@endif--}}
		   
           <div class="box-content" style="font-size:16px">
                <?php
                    $trialDays=$plan->trial_days;
                    $registrationDate=$planDetails->registration_date;
                    $trialExpiryDate=date('Y-m-d', strtotime($registrationDate. ' + '.$trialDays.'days'));
                    $todaysDate=date("Y-m-d");
                    $todayStr=strtotime($todaysDate);
                    $registrationStr=strtotime($trialExpiryDate);
					
					$showingType=$planDetails->plan_type;
					$planEndDate=$trialExpiryDate;
					
					if($planDetails->paid_for_plan==1){
						$planEndDate=$planDetails->plan_end_date;
					}
					
					if($community->skip_card_dtls==1 and $community->skip_card_till_date){
						$planEndDate=$community->skip_card_till_date;
						$showingType='Trial';
					}
					
					$cutsomTrialDays=$community->trial_days;
					$CustomTrailStartDate=$community->trial_start_date;
					$planStartDate='';
					if($cutsomTrialDays and $CustomTrailStartDate){
						$planStartDate=$community->trial_start_date;
						$planEndDate=date('Y-m-d', strtotime($CustomTrailStartDate. ' + '.$cutsomTrialDays.'days'));
						$showingType='Trial';
					}
                ?>
                
                {{-- @if($planDetails->paid_for_plan==1 || $todayStr<=$registrationStr) --}}
                    <p><strong>{{ trans('internal-collaborations.current-plan-name') }}</strong> : {{getPricingPlanName($planDetails->plan_id)}} ({{$community->present()->getPlanUsersLimit()}} {{ trans('internal-collaborations.corporate-users') }})
                    
                        <a href="javascript:void(0)" class="toggle-view-plan-details" data-id="{{$plan->plan_id}}" style="font-weight:bold;">Details +</a>
                    
                        <div class="plan-details-info-box plan-details-info-{{$plan->plan_id}}" style="display:none;">
                            <div style="font-weight:bold; margin-top:5px;">Included:</div>
                            <ul style="margin-top:6px; padding-left:18px;">
                                @if(isset($planFeaturesByPlanId[$plan->plan_id]))
                                    @foreach(($planFeaturesByPlanId[$plan->plan_id] ?? []) as $feature)
                                        <li>{{ $feature->title }}</li>
                                    @endforeach
    
                                    @if(empty($planFeaturesByPlanId[$plan->plan_id] ?? []))
                                        <li>No features selected.</li>
                                    @endif
                                @endif    
                            </ul>
                        </div>
                    </p>
                    
                    <p><strong>{{ trans('internal-collaborations.subscription-type') }}</strong> : {{ucfirst($showingType)}}</p>
                {{-- @endif	--}}	
                    
                {{-- @if($planDetails->paid_for_plan==1) --}}
                	
                    @if($planStartDate)
                    	<p><strong>Plan Start Date</strong> : {{date("F d, Y",strtotime($planStartDate))}}</p>
                    @endif
                    
                   <p><strong>{{ trans('internal-collaborations.plan-expiry-date') }}</strong> : {{date("F d, Y",strtotime($planEndDate))}}</p>
                    
                    @if($planDetails->upcoming_plan_id==0)
                        <!--<p><strong>{{ trans('internal-collaborations.plan-renewal-date') }}</strong> : {{date("F d, Y",strtotime($planEndDate))}}</p>-->
                    @else
                        <p><strong>{{ trans('internal-collaborations.plan-renewal-date') }}</strong> : {{date("F d, Y",strtotime($planDetails->plan_end_date))}}</p>
                    @endif 
					
					@if($community->increased_member_limit)
                        <p><strong>{{ trans('internal-collaborations.increased-corporate-users') }}</strong> : {{$community->present()->getIncreasedCorporateUsers()}} {{ trans('internal-collaborations.corporate-users') }}</p>
					@endif	

                    <!--<p><strong>{{ trans('internal-collaborations.amount') }}</strong>: ${{number_format($community->present()->getPricingPlanAmount(), 2, '.', ',')}} + {{ trans('internal-collaborations.additional-subscriptions-if-any') }}</p>-->	
                {{-- @endif --}}

                @if($planDetails->paid_for_plan==0 and $plan->is_plan_free==0)
                    {!! Theme::section('community.pannel.plan.pay-current-plan', ['community' => $community, 'planDetails' => $planDetails, 'plan' => $plan,'cardLoaded'=>$cardLoaded]) !!}
                @endif
               
                @if($planDetails->paid_for_plan==0 && $todayStr >=$registrationStr)
				{{--  {!! Theme::section('community.pannel.plan.subscribe-new-plan',['paytype'=>0]) !!} --}}
                @endif
                
           </div>
      {{-- @else    
           <div class="box-title" style="font-size:18px;">
                 {{ trans('internal-collaborations.current-plan-details') }}:
           </div>
           
           <div class="box-content" style="font-size:16px">
                <p><strong>{{ trans('internal-collaborations.current-plan-name') }}</strong> : {{getPricingPlanName($planDetails->plan_id)}} ({{$community->present()->getAllowedMembersInPlan()}} {{ trans('internal-collaborations.corporate-users') }})</p>
           </div>
       @endif --}}
	   
	   <div class="box-content" style="font-size:16px">
		   <div class="row">
				<div class="col-sm-12" style="font-weight:normal; margin-bottom:15px;">
					
                    <!--<p>{{ trans('internal-collaborations.current-corporate-users') }}: {{$community->countMembers()+1}}/{{$community->present()->getAllowedMembersInPlan()}} {{ strtolower(trans('internal-collaborations.corporate-users')) }}</p>-->
					
					@if($community->present()->canAddExtraMembers())											
                        <p class="add-more-corporate-users-link"><a href="{{$community->present()->url('communityplanuserlimit')}}" style="color:#f00;">{{ trans('global.click-here') }}</a> {{ trans('internal-collaborations.add-more-corporate-users-suffix', ['price' => $community->present()->extraMembersAddPrice()]) }}</p>
					@endif					
				</div>
			</div>
        </div>
        
        <div class="box-content" style="font-size:16px">
            {!! Theme::section('community.pannel.plan.subscribe-new-plan',['planDetails'=>$planDetails,'paytype'=>1,'card_details'=>$default_card,'makingPaymentFrom'=>$makingPaymentFrom,'allPlans'=>$allPlans,'planFeaturesByPlanId'=>$planFeaturesByPlanId ?? []]) !!}
        </div> 
   @else
        <div class="box-content" style="font-size:16px">
			{!! Theme::section('community.pannel.plan.subscribe-new-plan',['planDetails'=>$planDetails,'paytype'=>1,'card_details'=>$default_card,'makingPaymentFrom'=>$makingPaymentFrom,'allPlans'=>$allPlans,'planFeaturesByPlanId'=>$planFeaturesByPlanId ?? []]) !!}
        </div>   
   @endif
   
   <!--<div class="box-content" style="font-size:16px; margin-top:15px;">
       <div class="row">
            <div class="col-sm-12">
                <p>
					{{ trans('internal-collaborations.access-features-note') }} {{ trans('internal-collaborations.click-to-explore') }}
                </p>
                
                <?php
					$user=\Auth::user();
					
					$websiteUrl= config('app.url').'/ip/create';
					$storefrontUrl= config('app.url').'/pages';
					
                    $url=config('app.url').'/cmownpage?reset_vc=1&lgkey='.$user->login_key.'&lgurl=';
				?>
                
                <p>
					1. <a href="{{$url}}{{$websiteUrl}}">{{ trans('internal-collaborations.personal-website') }}</a>
                </p>
                
                <p>
					2. <a href="{{$url}}{{$storefrontUrl}}">{{ trans('internal-collaborations.storefront') }}</a>
                </p> 
                
                <p>   
					3. <a href="{{$url}}{{config('app.url')}}">idhubs social media</a> 
                </p>    
            </div>
        </div>
   </div>-->         
</div>