<?php /*template name: Body Jewellery*/ get_header(); ?>
<div class="uk-cover-container uk-text-center banner white" uk-scrollspy="cls: uk-animation-fade; delay: 300">
    <canvas class="uk-visible@m" width="" height="300"></canvas>
    <canvas class="uk-hidden@m" width="" height="300"></canvas>

    <?php
    $image = get_field('banner_image');
    if( !empty( $image ) ): ?>
        <img uk-img data-src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" / data-width data-height uk-cover>
    <?php endif; ?>


	<div class="uk-position-cover uk-text-center uk-container uk-flex uk-flex-center uk-flex-middle" uk-scrollspy="cls: uk-animation-fade; delay: 500">
        <div>
            <h1 class="white"><?php the_title(); ?></h1>
      </div>
    </div>
</div>


<?php
// Check if the correct password cookie is set
if ( isset( $_COOKIE['custom_password'] ) && $_COOKIE['custom_password'] === get_field('password_field', 7) ) {
    // If the password matches, show the protected content
    ?>
    <div class="protected-content">



<div class="uk-container uk-container-large uk-margin-large-bottom">
	<main role="main">
			<section >


				<?php if (have_posts()): while (have_posts()) : the_post(); ?>

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

            <h2 uk-scrollspy="cls: uk-animation-fade; delay: 300" class="uk-text-center uk-margin-xlarge-top uk-margin-medium-bottom"><?php echo esc_html( get_field('header') ); ?></h2>


            <?php
            $sub_title = get_field('sub_title');
            if ( !empty( $sub_title ) ) : ?>
                <h3 uk-scrollspy="cls: uk-animation-fade; delay: 300" class="uk-text-center uk-margin-medium-bottom"><?php echo esc_html( $sub_title ); ?></h3>
            <?php endif; ?>

            <div class="uk-text-center" >



              <?php if( have_rows('section') ): ?>
                <?php while( have_rows('section') ): the_row(); ?>
                    <div class="section">
                        <h2 class="uk-margin-medium-bottom uk-margin-large-top"><?php the_sub_field('section_title'); ?></h2>

                        <?php if( have_rows('item') ): ?>
                            <div class="uk-grid uk-child-width-1-4@m uk-grid-large" uk-grid uk-scrollspy="target: > div; cls: uk-animation-fade; delay: 300">
                                <?php while( have_rows('item') ): the_row(); ?>
                                    <div class="item">
                                        <?php
                                        $item_image = get_sub_field('item_image');
                                        if( !empty($item_image) ): ?>
                                            <img src="<?php echo esc_url($item_image['url']); ?>" alt="<?php echo esc_attr($item_image['alt']); ?>" />
                                        <?php endif; ?>

                                        <h3><?php the_sub_field('item_title'); ?></h3>
                                        <h4 class="blue"><?php the_sub_field('stock_number'); ?></h4>

                                        <?php
                                          $file = get_sub_field('order_form');
                                          if( $file ): ?>
                                              <a class="yellow-btn yellow-blue" target="_BLANK" href="<?php echo $file['url']; ?>">Download Order Form <i class="fa-light fa-file-pdf"></i></a>
                                          <?php endif; ?>
                                    </div>
                                <?php endwhile; ?>
                            </div>
                        <?php endif; ?>
                    </div>
                <?php endwhile; ?>
            <?php endif; ?>


						<?php the_content(); ?>

						<div class="uk-clearfix"></div>

						<p class="uk-text-right"><?php edit_post_link( __('Edit this page'), '', '', 0, 'post-edit-link uk-text-large uk-padding-small uk-button-large uk-button uk-button-primary' ); ?></p>

					</article>

			<?php endwhile; ?><?php endif; ?>

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

</div>


</div>
<?php
} else { ?>

  <div class="uk-container">

    <h3 class="blue uk-margin-large-top uk-margin-medium-bottom">This page is only available to our Registered Dealers</h3>

    <a href="#" uk-toggle="target: #login" class=" yellow-btn yellow-blue uk-margin-xlarge-bottom">Login or Sign Up<i class="fa-kit fa-diamond-icon"></i></a>

  </div>
<?php }
?>


<?php get_footer(); ?>
