<?php
/**
 * Template Name: Custom Home Page
 */
get_header();

?>
<!-- banner section -->
<main id="maincontent" role="main">

  <?php do_action('vw_tourism_before_slider'); ?>
    <?php if( get_theme_mod( 'vw_tourism_banner_hide_show', true) == 1 || get_theme_mod( 'vw_tourism_resp_slider_hide_show', true)) { ?>
      <section id="banner" class="position-relative pb-5">
        <div class="banner-img"></div>
          <div class="container">
            <div class="banner-content">
              <?php if(get_theme_mod('vw_tourism_banner_top_text') != '') {?>
                <p class="banner-top-text text-start mb-0"><?php echo esc_html(get_theme_mod('vw_tourism_banner_top_text')) ?></p>
              <?php }?>
              <?php if(get_theme_mod('vw_tourism_slider_main_title') != '') {?>
                <h1 class="banner-title text-center mb-0 py-2"><?php echo esc_html(get_theme_mod('vw_tourism_slider_main_title')) ?></h1>
              <?php }?>
              <?php if(get_theme_mod('vw_tourism_banner_bottom_text') != '') {?>
                <p class="banner-bottom-text text-end mb-0"><?php echo esc_html(get_theme_mod('vw_tourism_banner_bottom_text')) ?></p>
              <?php }?>
            </div>
            <div class="banner-short-img">
              <div class="row">
                <div class="col-lg-4 col-md-4 col-12 start-img">
                  <?php for ($vw_tourism_i = 1; $vw_tourism_i <= 3; $vw_tourism_i++) { ?>    
                    <div class="country-img">
                      <?php if(get_theme_mod('vw_tourism_service_banner_short_image'.$vw_tourism_i) != '') {?>
                        <div class="short-img">
                          <img src="<?php echo esc_url(get_theme_mod('vw_tourism_service_banner_short_image'.$vw_tourism_i)); ?>" alt="" />
                        </div>
                      <?php }?>
                      <?php if(get_theme_mod('vw_tourism_add_country_name'.$vw_tourism_i) != '') {?>
                        <p class="country-name mb-0"><?php echo esc_html(get_theme_mod('vw_tourism_add_country_name'.$vw_tourism_i)) ?></p>
                      <?php }?>
                    </div>
                  <?php }?>
                </div>
                <div class="col-lg-4 col-md-4 col-12 mid-img">
                  <div class="country-img">
                    <?php if(get_theme_mod('vw_tourism_service_banner_short_mid_image') != '') {?>
                      <div class="short-img">
                        <img src="<?php echo esc_url(get_theme_mod('vw_tourism_service_banner_short_mid_image')); ?>" alt="" />
                      </div>
                    <?php }?>
                    <?php if(get_theme_mod('vw_tourism_add_mid_country_name') != '') {?>
                      <p class="country-name mb-0"><?php echo esc_html(get_theme_mod('vw_tourism_add_mid_country_name')) ?></p>
                    <?php }?>
                  </div>
                </div>
                <div class="col-lg-4 col-md-4 col-12 last-img">
                  <?php for ($vw_tourism_j = 1; $vw_tourism_j <= 3; $vw_tourism_j++) { ?>    
                    <div class="country-img">
                      <?php if(get_theme_mod('vw_tourism_service_banner_short_last_image'.$vw_tourism_j) != '') {?>
                        <div class="short-img">
                          <img src="<?php echo esc_url(get_theme_mod('vw_tourism_service_banner_short_last_image'.$vw_tourism_j)); ?>" alt="" />
                        </div>
                      <?php }?>
                      <?php if(get_theme_mod('vw_tourism_add_last_country_name'.$vw_tourism_j) != '') {?>
                        <p class="country-name mb-0"><?php echo esc_html(get_theme_mod('vw_tourism_add_last_country_name'.$vw_tourism_j)) ?></p>
                      <?php }?>
                    </div>
                  <?php }?>
                </div>
              </div>
            </div>    
          </div>  
        </div>  
        <div class="clearfix"></div>
      </section>
    <?php }?>
  <?php do_action('vw_tourism_after_slider'); ?>

  <!-- Our Places Section -->
  <?php if( get_theme_mod('vw_tourism_section_title') != '' || get_theme_mod('vw_tourism_feature_palces_section_text') != '' ){ ?>
    <section id="our-places" class="py-5">
      <div class="container">
        <div class="row">
          <div class="col-lg-6 col-md-6 mb-4">
            <div class="places-text align-self-center">
              <?php if(get_theme_mod('vw_tourism_feature_palces_section_text') != ''){ ?>
                <p class="mb-1 text-capitalize"><?php echo esc_html(get_theme_mod('vw_tourism_feature_palces_section_text')) ?></p>
              <?php }?>
              <?php if(get_theme_mod('vw_tourism_section_title') != '') {?>
                <h2><?php echo esc_html(get_theme_mod('vw_tourism_section_title')) ?></h2>
              <?php }?>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 text-md-end text-sm-end text-center align-self-center">
            <div class="tab-section position-relative">
              <div class="tab align-self-center d-flex gap-4 justify-content-end">
                <?php
                $vw_tourism_featured_post = get_theme_mod('vw_tourism_services_number', '');
                for ($vw_tourism_j = 1; $vw_tourism_j <= $vw_tourism_featured_post; $vw_tourism_j++) { ?>
                  <div class="icon-tab">
                    <button class="tablinks" onclick="vw_tourism_services_tab(event, '<?php $vw_tourism_main_id = get_theme_mod('vw_tourism_services_text' .$vw_tourism_j);
                        $vw_tourism_tab_id = str_replace(' ', '-', $vw_tourism_main_id);
                          echo $vw_tourism_tab_id; ?> ')">
                        <span><?php echo esc_html(get_theme_mod('vw_tourism_services_text'.$vw_tourism_j)); ?></span>
                    </button>
                  </div>
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
        <?php for ($vw_tourism_j = 1; $vw_tourism_j <= $vw_tourism_featured_post; $vw_tourism_j++) { ?>
          <div id="<?php $vw_tourism_main_id = get_theme_mod('vw_tourism_services_text'.$vw_tourism_j);
            $vw_tourism_tab_id = str_replace(' ', '-', $vw_tourism_main_id);
            echo $vw_tourism_tab_id; ?>" class="tabcontent">
            <div class="owl-carousel">
              <?php
              $vw_tourism_services_post_count = get_theme_mod('vw_tourism_services_post_count'.$vw_tourism_j, '');
              for ($vw_tourism_i=1; $vw_tourism_i <= $vw_tourism_services_post_count; $vw_tourism_i++) { 
                $vw_tourism_postData=  get_theme_mod('vw_tourism_services_category'.$vw_tourism_i.$vw_tourism_j);
                if($vw_tourism_postData){ ?>
                  <div class="feature-box1 pb-3">
                    <?php 
                      $args = array( 
                        'p' => esc_html($vw_tourism_postData ,'vw-tourism'),
                        'post_type' => 'post'
                      );
                      $query = new WP_Query( $args );
                      if ( $query->have_posts() ) :
                        while ( $query->have_posts() ) : $query->the_post(); ?>
                          <div class="box">
                            <div class="post-overlay"></div>
                            <?php if(has_post_thumbnail()){ ?>
                              <?php the_post_thumbnail(); ?>
                            <?php } else {?>
                              <img src="<?php echo esc_url(get_template_directory_uri()) ?>/assets/images/post-image.png" alt="<?php echo esc_attr('Post Image', 'vw-tourism'); ?>">
                            <?php }?>
                          </div>
                          <div class="post-inner-content mx-3">
                            <div class="post-tag p-2 mt-3 mb-3">
                              <?php
                                $tags = get_the_tags();
                                if ($tags) {
                                  $tag_links = array();
                                  foreach ($tags as $tag) {
                                    $tag_links[] = '<a href="' . esc_url(get_tag_link($tag->term_id)) . '">' . esc_html($tag->name) . '</a>';
                                  }
                                  echo implode(', ', $tag_links);
                              }?>
                            </div>
                            <div class="tour-content">
                              <?php if(get_theme_mod('vw_tourism_tour_title'.$vw_tourism_i.$vw_tourism_j) != ''){ ?>
                                <h4 class="tour-title mb-1 pb-2 text-uppercase text-left"><?php echo esc_html(get_theme_mod('vw_tourism_tour_title'.$vw_tourism_i.$vw_tourism_j)) ?></h4>
                              <?php }?>
                              <div class="row">
                                <div class="col-lg-7 col-md-7 col-7 align-self-center">
                                  <?php if(get_theme_mod('vw_tourism_add_duration'.$vw_tourism_i.$vw_tourism_j) != ''){ ?>
                                    <p class="tour-duration mb-0 text-uppercase text-left"><?php echo esc_html(get_theme_mod('vw_tourism_add_duration'.$vw_tourism_i.$vw_tourism_j)) ?></p>
                                  <?php }?>
                                  <p class="person-text"><?php esc_html_e('PER PERSON','vw-tourism'); ?></p>
                                </div>
                                <div class="col-lg-5 col-md-5 col-5 align-self-center">
                                  <?php if(get_theme_mod('vw_tourism_tour_price'.$vw_tourism_i.$vw_tourism_j) != ''){ ?>
                                    <p class="tour-price mb-1 text-uppercase text-left"><?php echo esc_html(get_theme_mod('vw_tourism_tour_price'.$vw_tourism_i.$vw_tourism_j)) ?></p>
                                  <?php }?>
                                </div>
                              </div>
                            </div>
                            <h5 class="post-text text-center mt-2 "><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h5>
                            <?php if(get_theme_mod('vw_tourism_travel_name'.$vw_tourism_i.$vw_tourism_j) != ''){ ?>
                              <p class="travel-name mb-1 text-capitalize text-center"><?php echo esc_html(get_theme_mod('vw_tourism_travel_name'.$vw_tourism_i.$vw_tourism_j)) ?></p>
                            <?php }?>
                            <div class="post-btn mt-3">
                              <a href="<?php the_permalink();?>"><?php esc_html_e('Book Now','vw-tourism'); ?><span class="screen-reader-text"><?php esc_html_e('Book Now','vw-tourism'); ?></span><i class="fa-solid fa-caret-right"></i></a>
                            </div>
                          </div>
                        <?php endwhile;
                          wp_reset_postdata();
                      endif; ?> 
                  </div>
                <?php }
              } ?>   
            </div>
          </div>
        <?php }?>
      </div>
    </section>
  <?php }?>
  <?php do_action( 'vw_tourism_after_service' ); ?>

  <!-- Unique Offering Section -->
  <?php if( get_theme_mod('vw_tourism_special_text') != '' || get_theme_mod('vw_tourism_special_heading') != '' ){ ?>
    <section id="unique-offering" class="pt-5">
      <div class="container">
        <div class="offering-text text-center">
          <?php if(get_theme_mod('vw_tourism_special_text') != ''){ ?>
            <p class="mb-1 text-uppercase"><?php echo esc_html(get_theme_mod('vw_tourism_special_text')); ?></p>
          <?php } ?>
          <?php if(get_theme_mod('vw_tourism_special_heading') != ''){ ?>
            <h3><?php echo esc_html(get_theme_mod('vw_tourism_special_heading')); ?></h3>
          <?php } ?>
        </div>
          <?php
            $vw_tourism_offering_number = get_theme_mod('vw_tourism_offering_number');
            if ($vw_tourism_offering_number != '') { ?>
                <div id="offer-section" class="pt-4 wow bounceInLeft delay-1000">
                    <div class="row">
                        <?php for ($vw_tourism_i = 1; $vw_tourism_i <= $vw_tourism_offering_number; $vw_tourism_i++) { ?>
                            <div class="col-xl-4 col-lg-4 col-md-6 col-sm-6 col-12 mb-4">
                                <div class="inner-box">
                                    <div class="row">
                                        <div class="col-xl-2 col-lg-2 col-md-12 col-sm-12 col-12 align-self-center offer-icon">
                                            <i class="<?php echo esc_attr(get_theme_mod('vw_tourism_services_icon'.$vw_tourism_i,'fa-solid fa-mountain-sun')); ?>"></i>
                                        </div>
                                        <div class="col-xl-10 col-lg-10 col-md-12 col-sm-12 col-12 align-self-center offer-details">
                                            <div class="counter">
                                                <span class="count-num"><?php echo sprintf('%02d', $vw_tourism_i); ?></span>
                                            </div>
                                            <?php if (get_theme_mod('vw_tourism_client_tagline_title'.$vw_tourism_i) != '') { ?>
                                                <h4 class="mb-2 mt-3"><?php echo esc_html(get_theme_mod('vw_tourism_client_tagline_title'.$vw_tourism_i)); ?></h4>
                                            <?php } ?>
                                            <?php if (get_theme_mod('vw_tourism_client_text'.$vw_tourism_i) != '') { ?>
                                                <p><?php echo esc_html(get_theme_mod('vw_tourism_client_text'.$vw_tourism_i)); ?></p>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                </div>
          <?php } ?>
      </div>
    </section>
  <?php }?>

  <div id="content-vw" class="entry-content pt-5">
    <div class="container">
      <?php while (have_posts()) : the_post(); ?>
        <?php the_content(); ?>
      <?php endwhile; // end of the loop. 
      ?>
    </div>
  </div>
  
</main>

<?php get_footer(); ?> 