<?php
/**
 * @copyright Copyright (c) 2016 AmyTheme (http://www.amytheme.com). All rights reserved.
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

defined( 'ABSPATH' ) or die;

get_header();

get_template_part( 'partials/page-header' );

$details 	= get_post_meta( $post->ID, '_cinema_block_options', true );
$gallery 	= $details['cinema_gallery'];
$gallery 	= explode( ',', $gallery );

$slick  = '{';
$slick .= '"slidesToShow":8,"slidesToScroll":8,';
$slick .= '"autoplay":false,';
$slick .= '"centerMode":false,';
$slick .= '"arrows":false,';
$slick .= '"infinite":true,';
$slick .= '"dots":false';
$slick .= '}';

?>

<section class="main-content amy-cinema single-cinema amy-no-padding">
	<div class="row-bg-gray">
		<div class="cinema-heading">
			<div class="container">
				<h1 class="entry-title p-name" itemprop="name headline"><?php echo get_the_title(); ?></h1>
				<div class="entry-content"><?php echo $post->post_content; ?></div>
			</div>
		</div>
		<div class="cinema-details">
			<div class="bg-dl"></div>
			<div class="cinema-gallery">
				<div class="amy-slick" data-slick='<?php echo $slick; ?>'>
					<?php if ( ! empty( $gallery ) ) : ?>
						<?php foreach ( $gallery as $i => $g ) : ?>
							<div class="media-item">
								<?php $src = wp_get_attachment_image_src( $g, 'full' )[0]; ?>
								<a href="<?php echo esc_url( $src ); ?>" class="amy-fancybox" rel="movie-gallery">
									<?php echo wp_get_attachment_image( $g, array( '230', '240' ) ); ?>
								</a>
							</div>
						<?php endforeach; ?>
					<?php endif; ?>
				</div>
			</div>
			<div class="cinema-info">
				<div class="container">
					<?php if ( $details['cinema_address'] != '' ) : ?>
						<div>
							<label><?php echo esc_html__( 'Address:', 'amy-movie' ); ?></label>
							<span><?php echo esc_attr( $details['cinema_address'] ); ?></span>
						</div>
					<?php endif; ?>
					<div>
						<?php if ( $details['cinema_phone'] != '' ) : ?>
							<label><?php echo esc_html__( 'Phone:', 'amy-movie' ); ?></label>
							<span><?php echo esc_attr( $details['cinema_phone'] ); ?></span>
						<?php endif; ?>
						<?php if ( $details['cinema_email'] != '' ) : ?>
							<label><?php echo esc_html__( 'Email:', 'amy-movie' ); ?></label>
							<span><?php echo esc_attr( $details['cinema_email'] ); ?></span>
						<?php endif; ?>
					</div>
					<?php if ( $details['cinema_website'] != '' ) : ?>
						<div>
							<label><?php echo esc_html__( 'Website:', 'amy-movie' ); ?></label>
							<span><?php echo esc_attr( $details['cinema_website'] ); ?></span>
						</div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>

	<div class="cinema-movie">
		<div class="container">
			<div class="amy-tab">
				<div class="amy-tab-nav bs-tab-nav">
					<ul>
						<li class="active"><a href="#cinema-m"><?php echo esc_html__( 'Movie', 'amy-movie' ); ?></a></li>
						<li><a href="#cinema-c"><?php echo esc_html__( 'Comments', 'amy-movie' ); ?></a></li>
						<li><a href="#cinema-map"><?php echo esc_html__( 'Map', 'amy-movie' ); ?></a></li>
					</ul>
				</div>
				<div class="amy-tab-contents">
					<div id="cinema-m" class="amy-tab-content active">
						<?php echo do_shortcode( '[moviegrid layout="layout2" show_sortby="true" movie_number="9" layout2_column="3" show_filter="true" cinema="' . $post->ID . '"]' ); ?>
					</div>
					<div id="cinema-c" class="amy-tab-content">
						<?php comments_template( '', true ); ?>
					</div>
					<div id="cinema-map" class="amy-tab-content">
						<?php echo $details['cinema_map']; ?>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<?php
get_footer();
