@section('metatags')
@php
$image_file_name=$ebook_volume_details[0]->image_file_name;
if(empty($image_file_name)) $image_file_name= 'no_image.jpg';
if(!(file_exists('images/bentham/'.$image_file_name))){
      $image_file_name = 'no_image.jpg';
}
  $image_url= 'http://'.$_SERVER['HTTP_HOST'].'/images/bentham/'.$image_file_name;
  $remchar =array('&lt;p&gt;','&lt;/p&gt;','"');//remove characters
  $txt_abstract=str_replace($remchar,"",strip_tags($chapter_details->abstract));   

  $url='http://'.$_SERVER['HTTP_HOST'].'/chapter/'.$chapter_details->chapter_id;
  $ebook_title = $ebook->title;
  $subtitle = $ebook->subtitle;
  $isbn = $ebook_volume_details[0]->isbn;
  if($CountMultipleVolumeExist > 0){
    $volumeLabel = 'Volume: '.$ebook_volume_details[0]->volume_name;
  }
  else{
    $volumeLabel = '';
  }
  $checkLoginFlag=false;
@endphp

    <meta property="og:type"   content="website" /> 
    <meta property="og:title" content="{{strip_tags($chapter_details->title)}}" />   
    <meta property="og:url" content="{{$url}}" />
    <meta property="og:image" content="{{$image_url}}" />
    <meta property="og:description" content="{{trim(strip_tags(preg_replace('/\n/', '<br>', $txt_abstract)))}}" />
    <meta property="og:site_name" content="http://{{$_SERVER['HTTP_HOST']}}" />


@endsection


    <section id="ebook-banner" class="chapter">

      <div class="container" >
        <div class="row">
          
          <div id="side-a" class="col-md-5">
            <div class="row">
              <div class="col">
                <div class="media">
                	<img 
					  src="{{'/images/bentham/'.$ebook_volume_details[0]->image_file_name}}" 	  
					  class="mr-3 img-thumbnail" alt="">	

						

					<div class="media-body">
						<h2 class="pr-lg-3 h5">
							{!! $ebook->title !!}
						</h2>
						<h3 class="h6">{{$volumeLabel}}</h3>

		                </div>
                </div>
				
				<div class="col-md-12 mt-3 p-0">
						@if($ebook_volume_details[0]->flyer_link != "")
						<!--a class="btn btn-outline-light btn-sm"  href="/DownloadFlyer/{{Crypt::encrypt(config('constants.admin.root_path').'E-books/BEN/'.$ebook_volume_details[0]->eisbn.'/'.$ebook_volume_details[0]->volume_name.'/EBOOK/'.$ebook_volume_details[0]->flyer_link)}}" name="language_btn">Download PDF Flyer</a-->												<a class="btn btn-outline-light btn-sm" href="/images/ebook-flyer/{{$ebook_volume_details[0]->flyer_link}}" name="language_btn">Download PDF Flyer</a>
						@endif

						<a class="btn btn-outline-light btn-sm" href="javascript:GoBack()">Back</a>

						<!-- HTML to write -->
						  <a tabindex="0" class="btn btn-sm btn-info" role="button" data-toggle="popover" data-html="true" data-trigger="focus" title="Book Details" data-content="
		                      <h5>{!! $ebook_volume_details[0]->ebook_subtitle !!}</h5>
		                      
		                      <!-- chapter authors -->
								@if (isset($chapter_details->chapter_id))
								<p>
									@if($ebook_volume_details[0]->doi != '')
									DOI: <a href='https://doi.org/{{ $ebook_volume_details[0]->doi }}' target=
                    '_blank'>{{ $ebook_volume_details[0]->doi }}</a>
									@endif	

									@if($ebook_volume_details[0]->eisbn != '')
									<br />eISBN: {{ $ebook_volume_details[0]->eisbn }}, 
									@endif	

									{{ $ebook_volume_details[0]->year }}

									@if($ebook_volume_details[0]->isbn != '')
									<br />ISBN: {{ $ebook_volume_details[0]->isbn }}
									@endif	

									@if($ebook_volume_details[0]->issn != '')
									<br />ISSN: {{ $ebook_volume_details[0]->issn }} <strong>(Print)</strong>
									@endif	

									@if($ebook_volume_details[0]->eissn != '')
									<br />ISSN: {{ $ebook_volume_details[0]->eissn }} <strong>(Online)</strong>
									@endif	
								</p>
								@endif
							">Book Details <i class="fas fa-angle-double-right"></i></a>
		                   
					</div>

              </div>
            </div>
          </div>

          <div id="side-b" class="col-md-7">

          	<h1 class="h3">{!!$chapter_details->title!!}</h1>

          	<p>
          @php
          $count=count($authors);
          $i = 0;
          $b=1;
          @endphp
  <strong>Author(s):</strong> 
            <?php  $author=""; $affiliation="";
   foreach ($authors as $value) 
   {  $affiliation="";      
      $affiliation.="<ul>";
            
            if($value->affiliation != "") 
            { 
             // $affiliation.="<li>".$value->affiliation.' '.$value->country."</li>";
            } 

              $auth_aff="";
              $auth_aff=explode('|', getAffiliationPattern($value->web_view));

              if(count($auth_aff) > 0)
              { 
                for($a=0;$a<sizeof($auth_aff);$a++)
                {
                  if(trim($auth_aff[$a]) != "")
                  {
                    $affiliation.="<li>".$auth_aff[$a]."</li>";
                  }
                }
              }
      
      $affiliation.="</ul>";

         if($count == ($i+1)) 
       {
           if($value->is_principle==1)
           { $author.=$value->authors." *";
             if($affiliation != "<ul></ul>") 
             {
              echo "<a href='javascript:void(0)' class='text-secondary' title='Affiliation'  data-html='true' data-toggle='popover' data-placement='bottom' data-trigger='hover'  data-content='".$affiliation."'>".$value->authors." *</a> .";
              if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
              }
              else
              {
                echo $value->authors." * .";
              }
            } 
           else
           {  $author.=$value->authors;
             if($affiliation != "<ul></ul>") 
             {
              echo "<a href='javascript:void(0)' class='text-secondary' title='Affiliation'  data-html='true' data-toggle='popover' data-placement='bottom' data-trigger='hover'  data-content='".$affiliation."'>".$value->authors."</a>";
              if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
              }
              else
              {
                echo $value->authors;
              }
            }  
       }
      else 
      {
             if($value->is_principle==1)
            {  
               $author.=$value->authors." *, ";

                 if($affiliation != "<ul></ul>") 
                 {
                     if($count > 1 && ($count-1 == $b))
                      {
                        echo '<a href="javascript:void(0)" class="text-secondary" title="Affiliation"  data-html="true" data-toggle="popover" data-placement="bottom" data-trigger="hover"  data-content="'.$affiliation.'">'.$value->authors.'*</a> and ';
                        if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
                      }
                      else
                      {
                        echo '<a href="javascript:void(0)" class="text-secondary" title="Affiliation"  data-html="true" data-toggle="popover" data-placement="bottom" data-trigger="hover"  data-content="'.$affiliation.'">'.$value->authors.'*</a>, ';
                        if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
                      }
                }
                else
                {
                   if($count > 1 && ($count-1 == $b))
                    {
                      echo $value->authors."* and";
                    }
                    else
                    {
                      echo $value->authors."*, ";
                    }
                }
            }
            else
            {  $author.=$value->authors.", "; 
               if($affiliation != "<ul></ul>") 
               {
                if($count > 1 && ($count-1 == $b))
                {
                   echo '<a href="javascript:void(0)" class="text-secondary" title="Affiliation"  data-html="true" data-toggle="popover" data-placement="bottom" data-trigger="hover"  data-content="'.$affiliation.'">'.$value->authors.'</a>';
                    if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
                   echo ' and ';
                }
                else
                {
                   echo '<a href="javascript:void(0)" class="text-secondary" title="Affiliation"  data-html="true" data-toggle="popover" data-placement="bottom" data-trigger="hover"  data-content="'.$affiliation.'">'.$value->authors.'</a>';
                    if($value->orcid!="") {echo '<a title="OrcID Profile" class="green-orcid" target="_blank" href="https://orcid.org/'.$value->orcid.'"><img src="/images/orcid.png"></a>';}
                   echo ', ';
                }


                }
                else
                {
                  if($count > 1 && ($count-1 == $b))
                  {
                    echo $value->authors." and ";
                  }
                  else
                  {
                    echo $value->authors.",";
                  }
                }
            } 
      }
      ?>

    <?php
      $b++;
    $i++;
   }
   ?>
   </p>

   <p><strong>Pp:</strong> {{$chapter_details->first_page}}-{{$chapter_details->last_page}} ({{$chapter_details->page_count}}) </p>

     <p><strong>Doi:</strong> <a href='https://doi.org/{{ $chapter_details->doi }}' target=
                    '_blank'>{{ $chapter_details->doi }}</a> </p>


		
		
		@if (isset($page) && $page == 'chapter')
			
			@if((isset($DownloadAccess) && $DownloadAccess > 0))
              @if($terms_popup)
                  @php
                    $checklicense = 'javascript:return CheckLicense(this.id)';
                  @endphp
                @else
                  @php
                  $checklicense ='';
                  $session_data = session()->get('access_user_data');
                  if($access_base_text==='Token Based Access' && $type!=666)
				  {
                    $checklicense ="javascript:return LoginToDownload('download_hide_".$chapter_details->chapter_id."')";
                    $checkLoginFlag=true;
                  }                  
                  
                  @endphp
              @endif
       @endif   
      @if((isset($DownloadAccess) && $DownloadAccess > 0) && $view_option==0)
						<div class="header-download">	
						   <div class="dropdown btn-group btn-group-sm">
							  <button class="btn btn-dark bg-siteblue text-white dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
							    Download Options 
                  @if($access_base_text !="")
                    <span class="badge badge-danger ml-2">{{$access_base_text}}</span>
                  @endif
							  </button>
							  <div class="dropdown-menu">
                    @if(!$checkLoginFlag)
				              {{ Form::open(array('method' => 'POST','route' => 'ebook_download_chapter','id' => 'download-form-pdf')) }}
                      <input type="hidden" name="agree-flag" id="agree-flag" value="1">
                      <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'pdf'.'||'.$content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">
                    @else
                      <form action="#">
                    @endif
				              
							   <button type="submit" id="pdf" class="dropdown-item popsubmit" onclick="{{$checklicense}}">Download Chapter <i class="fas fa-download"></i></button>
							   {{ Form::close() }}
								    @if($chapter_details->supplementary_filename)
								    	{{ Form::open(array('method' => 'POST','route' => 'ebook_download_chapter','id' => 'download-form-supp')) }}
									      <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'supplementary'.'||'.$content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">

													<button type="submit" class="dropdown-item">Supplementary</button>
												
									      {{ Form::close() }}
									@endif

								    @if($chapter_details->prc_filename)
								    	{{ Form::open(array('method' => 'POST','route' => 'ebook_download_chapter','id' => 'download-form-prc')) }}
									      <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'prc'.'||'.$content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">

													<button type="submit" class="dropdown-item">PRC</button>
												
									      {{ Form::close() }}
									@endif

								    @if($chapter_details->epub_filename)
								    	{{ Form::open(array('method' => 'POST','route' => 'ebook_download_chapter','id' => 'download-form-epub')) }}
									      <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'epub'.'||'.$content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">

													<button type="submit" class="dropdown-item">ePub</button>
												
									      {{ Form::close() }}
									@endif

                  @php 
                    $cparam=encrypt(array('readchapterpdf',$chapter_details->chapter_id,config('constants.admin.token'),$content_download_type));
                    @endphp
                    
                  @if(!$checkLoginFlag)
                    @if($content_download_type != 'F' && $content_download_type != 'FO')
						  			<a class="dropdown-item" id="readpdf_{{$chapter_details->chapter_id}}"  target="_blank" href="{{route('chapter', ['id' => $chapter_details->chapter_id,'param' => $cparam])}}" onclick="{{$checklicense}}">Read Chapter</a>
                    @endif
                  @endif			                
							  </div>
							</div>
						</div>
      @elseif((isset($DownloadAccess) && $DownloadAccess > 0) && ($content_download_type != 'F' && $content_download_type != 'FO') && $view_option==1)
                  @php 
                    $cparam=encrypt(array('readchapterpdf',$chapter_details->chapter_id,config('constants.admin.token'),$content_download_type));
                    @endphp
                    
            <div class="header-download"> 
               <div class="dropdown btn-group btn-group-sm">
                <a class="btn btn-dark bg-siteblue text-white dropdown-toggle" id="readpdf_{{$chapter_details->chapter_id}}" href="{{route('chapter', ['id' => $chapter_details->chapter_id,'param' => $cparam])}}" role="button" aria-expanded="false" onclick="{{$checklicense}}">
                  Read Chapter 
                @if($access_base_text !="")
                <span class="badge badge-danger ml-2">{{$access_base_text}}</span>
                @endif
                </a>
							</div>
						</div>
			@else
        @if(empty($bundle_content) || $bundle_content->chapter==0)
					<div class="header-download">			
					{{ Form::open(array('id'=>"addtocartForm",'method' => 'POST','route' => 'cart.store')) }}					
						<input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->nid)}}">        
						<button type="submit" class="btn bg-siteblue text-white">
						Buy Chapters <span class="badge badge-light ml-md-2"> {{ $ebook_volume_details[0]->chapter_price }}</span> 
						</button>	
					{{ Form::close() }}				  
				
					  <p class="mt-2">* (Excluding Mailing and Handling)</p>
					</div>
        @else
          <div class="header-download">     
            {{ Form::open(array('method' => 'POST','route' => 'chapter_download_bundle_file','id' => 'download-form-pdf')) }}
            <input type="hidden" name="agree-flag" id="agree-flag" value="1">
            <input type="hidden" name="bundle_offer_order_id" id="bundle_offer_order_id" value="{{$bundle_content->bundle_offer_order_id}}"> 
            <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'pdf'.'||'.$bundle_content->content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">

           <button type="submit" id="pdf" class="btn bg-siteblue text-white">Download Chapter <i class="fas fa-download"></i></button>
           {{ Form::close() }}
            </div>
        @endif				
			@endif
		
		
		@endif

		 </div>
		</div>
      </div>
    </section>
      