<?php
/**
 * Portfolio single page template.
 *
 * @since  1.0.0
 *
 * @package The7\Templates
 */

defined( 'ABSPATH' ) || exit;
?>

<?php 

	if(ICL_LANGUAGE_CODE == 'en'){ 
		$Synopsis = 'Synopsis of the play';
		$Performance = 'Past Performances';
		$author = 'About the author';
		$translator = 'About the translator';
		$start_read = 'Start Reading';
		$read = 'Read';
		$login_read = 'Login to Start Reading';
	}else{
		$Synopsis = 'ملخص المسرحية';
		$Performance = 'العروض السابقة';
		$author = 'عن المؤلف';
		$translator = 'عن المترجم';
		$start_read = 'ابدأ القراءة';
		$read = 'اقرأ';
		$login_read = 'سجل الدخول لتبدأ القراة ';
	}

?>

	<article id="post-<?php the_ID(); ?>" <?php post_class( 'project-post' ); ?>>

		<?php
		do_action( 'presscore_before_post_content' );

		//presscore_get_template_part( 'mod_portfolio', 'portfolio-post-single-content' );

		?>

		<link rel="stylesheet" type="text/css" href="<?php echo site_url();?>/wp-content/plugins/js_composer/assets/css/js_composer.min.css?ver=6.3.0">

		<div class="publication-title-div vc_row wpb_row vc_row-fluid vc_row-has-fill">

			<div class="publication-title wpb_column vc_column_container vc_col-sm-6">
				<div class="vc_column-inner">
					<div class="wpb_wrapper">
						<h2><?=the_title()?></h2>
						<h4 class="author-name"><?php echo get_field( "author_name" ); ?></h4>
					</div>
				</div>
			</div>
			
			<?php if(is_user_logged_in()){ ?>
				<div class="publication-title-read wpb_column vc_column_container vc_col-sm-6">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<div class="read-article-btn"><a  href="javascript:void(0)" onclick="readarticle();"><?=$read?></a></div>
						</div>
					</div>
				</div>
			<?php } ?>

		</div><!-- publication-title-div -->

		<div class="publication-div">

			<div class="feature-img vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="wpb_column vc_column_container vc_col-sm-12">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<div class="wpb_single_image wpb_content_element vc_align_center  vc_custom_1599046502009">
								<figure class="wpb_wrapper vc_figure">
									<?php if(get_field('book_main_image')){?>
										<img src="<?=get_field('book_main_image')?>">
									<?php }?>
									<?php if (has_post_thumbnail( $post->ID ) ): ?>
									  <?php //echo get_the_post_thumbnail( $page->ID, 'full' ); ?>
									<?php endif; ?>
								</figure>
							</div>
						</div>
					</div>
				</div><!-- feature-img -->
			</div>

			<div class="vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="synopsis-of-the-play wpb_column vc_column_container vc_col-sm-12">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<h2><?=$Synopsis?></h2>
							<p><?php echo get_field( "synopsis_of_the_play" ); ?></p>
						</div>
					</div>
				</div><!-- synopsis-of-the-play -->
			</div>

			<?php if( have_rows('past_performances') ): ?>
			<div class="vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="synopsis-of-the-play past-performance wpb_column vc_column_container vc_col-sm-12">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<h2><?=$Performance?></h2>
							<table class="past-perfo-tb">
								<tr>
									<?php if(ICL_LANGUAGE_CODE == 'en'){ ?>
										<th>Date</th>
										<th>Theatre</th>
										<th>Location</th>
									<?php }else{ ?>
										<th>التاريخ</th>
										<th>المسرح</th>
										<th>المكان</th>
									<?php } ?>
								</tr>
								<?php // Loop through rows.
    								while( have_rows('past_performances') ) : the_row(); ?>
								<tr>
									<td><?php echo get_sub_field('performance_date'); ?></td>
									<td><?php echo get_sub_field('performance_theatre'); ?></td>
									<td><?php echo get_sub_field('performance_location'); ?></td>
								</tr>
							<?php endwhile; ?>
							</table>
						</div>
					</div>
				</div><!-- synopsis-of-the-play -->
			</div>
		<?php endif; ?>


			<div class="about-author vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="wpb_column vc_column_container vc_col-sm-12 vc_col-md-7">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<h2><?=$author?></h2>
							<h4 class="author-name"><?php echo get_field( "author_name" ); ?></h4>
							<p><?php echo get_field( "about_the_author" ); ?></p>
						</div>
					</div>
				</div>
				<div class="wpb_column vc_column_container vc_col-sm-12 vc_col-md-5">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<img src="<?=get_field('author_image')?>">
						</div>
					</div>
				</div>
			</div><!-- about-author -->

			<div class="about-translator vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="wpb_column vc_column_container vc_col-sm-12 vc_col-md-7">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<h2><?=$translator?></h2>
							<p><?php echo get_field( "about_the_translator" ); ?></p>
						</div>
					</div>
				</div>

				<div class="wpb_column vc_column_container vc_col-sm-12 vc_col-md-5">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<img src="<?=get_field('translator_image')?>">
						</div>
					</div>
				</div>
			</div><!-- about-translator -->

			<div class="start-reding vc_row wpb_row vc_row-fluid vc_row-has-fill">
				<div class="wpb_column vc_column_container vc_col-sm-12">
					<div class="vc_column-inner">
						<div class="wpb_wrapper">
							<?php if(is_user_logged_in()){ ?>
							<div class="start-reding-btn"><a  href="javascript:void(0)" onclick="readarticle();"><?=$start_read?></a></div>
							<?php }else{ ?>
							<div class="no-start-reding-btn"><a href="javascript:void(0)"><?=$login_read?></a></div>
							<?php } ?>
						</div>
					</div>
				</div>
			</div>



		</div><!-- publication-div -->

		<?php if(is_user_logged_in()){ ?>

			<div class="publication-book" >
				<!-- <a href="javascript:void(0)" onclick="backmain();" class="back-publication">Back</a> -->
				<?php echo do_shortcode(get_field('book_code')); ?>
					
			</div>
		<?php } ?>


		<?php

		do_action( 'presscore_after_post_content' );
		?>

	</article>

<?php presscore_display_related_projects(); ?>

<style type="text/css">
	._df_book{
		display: none;
	}
	.back-publication{
		display: none;
	}
</style>

<script type="text/javascript">
	
	function readarticle(){

		jQuery('.publication-div').fadeOut('slow');

		jQuery('.publication-book').html();
		//jQuery('._df_book').css('display','block');
		jQuery('._df_book').fadeIn('slow');

		jQuery('.back-publication').css('display','block');

		jQuery('.read-article-btn a').attr("onclick","backmain();");
		jQuery('.read-article-btn a').html('Back');

	}

	function backmain(){

		jQuery('.publication-div').fadeIn('slow');
		
		//jQuery('._df_book').css('display','block');
		jQuery('._df_book').fadeOut('slow');	

		jQuery('.back-publication').css('display','none');


		jQuery('.read-article-btn a').attr("onclick","readarticle();");
		jQuery('.read-article-btn a').html('Read');

	}
</script>
