<?php
/**
 * Template part for displaying slider section
 *
 * @package Amusement Park
 * @subpackage amusement_park
 */
?>

<?php $amusement_park_static_image = get_stylesheet_directory_uri() . '/assets/images/header_img.png'; ?>

<?php if (get_theme_mod('amusement_park_slider_arrows', true) != '') { ?>
  <section id="slider">
    <div class="owl-carousel owl-theme">
      <?php 
      $amusement_park_slide_pages = array();
      for ($amusement_park_count = 1; $amusement_park_count <= 4; $amusement_park_count++) {
        $mod = intval(get_theme_mod('amusement_park_slider_page' . $amusement_park_count));
        if ('page-none-selected' != $mod) {
          $amusement_park_slide_pages[] = $mod;
        }
      }
      if (!empty($amusement_park_slide_pages)) :
        $amusement_park_args = array(
          'post_type' => 'page',
          'post__in' => $amusement_park_slide_pages,
          'orderby' => 'post__in'
        );
        $amusement_park_query = new WP_Query($amusement_park_args);
        if ($amusement_park_query->have_posts()) :
          while ($amusement_park_query->have_posts()) : $amusement_park_query->the_post(); ?>
            <div class="item">
              <div class="row no-gutters">
                <div class="col-lg-6 col-md-6 col-12 slider-content-col px-md-0">
                    <div class="carousel-caption">
                      <div class="inner_carousel">
                        <?php if (get_theme_mod('amusement_park_show_slider_title', true)) : ?>
                          <h1><a href="<?php the_permalink(); ?>" class="text-uppercase"><?php the_title(); ?></a></h1>
                        <?php endif; ?>
                        <div class="slider-btn">
                          <div class="more-btn mt-3 mb-4 pe-md-5">
                            <a href="<?php the_permalink(); ?>"><?php esc_html_e('Book Ticket','amusement-park'); ?></a>
                          </div>
                        </div>
                      </div> 
                    </div>
                    <?php if (get_theme_mod('amusement_park_banner_form_shortcode') != '') { ?>
                      <div class="slider-contact-form main">
                        <?php echo do_shortcode(get_theme_mod('amusement_park_banner_form_shortcode')); ?>
                      </div>
                    <?php } ?>
                </div>
                <div class="col-lg-6 col-md-6 col-12 slider-img-col px-md-0 position-relative">
                  <?php if (has_post_thumbnail()) { ?>
                    <img src="<?php the_post_thumbnail_url('full'); ?>" />
                  <?php } else { ?>
                    <img src="<?php echo esc_url($amusement_park_static_image); ?>" />
                  <?php } ?>
                  <?php if (get_theme_mod('amusement_park_park_timing') != '') { ?>
                    <div class="open-time-content">
                      <div class="open-time-text"><?php esc_html_e('OPENING TIMING', 'amusement-park'); ?></div>
                      <div class="open-time"><?php echo esc_html(get_theme_mod('amusement_park_park_timing', '')); ?></div>
                      <svg class="svg-border">
                        <rect class="dashed-border" x="0" y="0" width="100%" height="100%" rx="30" ry="30"/>
                      </svg>
                    </div>
                  <?php } ?>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        else : ?>
          <div class="no-postfound"></div>
        <?php endif;
      endif; ?>
    </div>
    <div class="clearfix"></div>
  </section>
  
  <div class="slider-contact-form responsive">
    <?php echo do_shortcode(get_theme_mod('amusement_park_banner_form_shortcode')); ?>
  </div>
<?php } ?>
