<?php
/**
 * Template Name: Home Template
 */

get_header(); ?>

<main id="skip-content">
  <section id="top-slider">
    <div class="container">
      <?php $corporate_office_slide_pages = array();
        for ( $corporate_office_count = 1; $corporate_office_count <= 3; $corporate_office_count++ ) {
          $corporate_office_mod = intval( get_theme_mod( 'corporate_office_top_slider_page' . $corporate_office_count ));
          if ( 'page-none-selected' != $corporate_office_mod ) {
            $corporate_office_slide_pages[] = $corporate_office_mod;
          }
        }
        if( !empty($corporate_office_slide_pages) ) :
          $corporate_office_args = array(
            'post_type' => 'page',
            'post__in' => $corporate_office_slide_pages,
            'orderby' => 'post__in'
          );
          $corporate_office_query = new WP_Query( $corporate_office_args );
          if ( $corporate_office_query->have_posts() ) :
            $i = 1;
      ?>
      <div class="owl-carousel" role="listbox">
        <?php  while ( $corporate_office_query->have_posts() ) : $corporate_office_query->the_post(); ?>
          <div class="slide-box row">
            <div class="slider-inner-box col-lg-6 col-md-6 align-self-center">
              <h3 class="mt-4"><?php the_title(); ?></h3>
              <p class="content mt-3"><?php echo esc_html( wp_trim_words( get_the_content(), esc_attr(get_theme_mod('corporate_office_slider_excerpt_length', 20)) )); ?></p>
              <div class="slide-btn my-4">
                <a href="<?php the_permalink(); ?>"><?php esc_html_e('Get Started','corporate-office'); ?></a>
              </div>
              <div id="services" class="mt-5 pt-2">
                <div class="row m-0">
                  <?php for ($i=1; $i <= 3; $i++) { ?>
                    <?php if(get_theme_mod('corporate_office_services_box_icon'.$i) != '' || get_theme_mod('corporate_office_services_box_heading'.$i) != '' ){ ?>
                      <div class="col-lg-4 col-md-4 col-sm-4 ser-box">
                        <i class="<?php echo esc_attr(get_theme_mod('corporate_office_services_box_icon'.$i)); ?> mb-2"></i>
                        <h6 class="m-0"><?php echo esc_html(get_theme_mod('corporate_office_services_box_heading'.$i)); ?></h6>
                      </div>
                    <?php } ?>
                  <?php } ?>
                </div>
              </div>
            </div>
            <div class=" col-lg-6 col-md-6">
              <div class="slider-image">
                <?php if(has_post_thumbnail()){
                  the_post_thumbnail();
                } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/image/slider.png" alt="" />
                <?php } ?>
              </div>
            </div>
          </div>
        <?php $i++; endwhile;
        wp_reset_postdata();?>
      </div>
      <?php else : ?>
        <div class="no-postfound"></div>
      <?php endif;
      endif;?>
    </div>
  </section>

  <section class="about py-5">
    <div class="container">
      <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-12 align-self-center about-image text-end">
          <?php if(get_theme_mod('corporate_office_about_us_left_images') != ''){ ?>
            <img src="<?php echo esc_url( get_theme_mod( 'corporate_office_about_us_left_images' )); ?>" alt="Banner Left Image">
            <?php if(get_theme_mod('corporate_office_about_us_left_image_content') != ''){ ?>
              <div class="img-text-box">
                <h5 class="img-text-content"><?php echo esc_html(get_theme_mod('corporate_office_about_us_left_image_content')); ?></h5>
              </div>
            <?php }?>
          <?php }?>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-12 align-self-center ps-4">
          <div class="ser-heading text-start mb-4">
            <?php if(get_theme_mod('corporate_office_about_us_heading') != ''){ ?>
              <h3 class="main-heading "><?php echo esc_html(get_theme_mod('corporate_office_about_us_heading')); ?></h3>
            <?php }?>
            <?php if(get_theme_mod('corporate_office_about_us_content') != ''){ ?>
              <p class="main-heading m-0"><?php echo esc_html(get_theme_mod('corporate_office_about_us_content')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('corporate_office_about_us_content_1') != ''){ ?>
              <p class="main-heading mt-2 mb-3"><?php echo esc_html(get_theme_mod('corporate_office_about_us_content_1')); ?></p>
            <?php }?>
            <div class="row">
              <?php for ($i=0; $i < 2; $i++) { ?>
                <?php if(get_theme_mod('corporate_office_about_us_box_icon'.$i) != '' || get_theme_mod('corporate_office_about_us_box_heading'.$i) != '' ){ ?>
                  <div class="col-lg-6 col-md-6 col-sm-12 about-box align-self-center">
                    <i class="<?php echo esc_attr(get_theme_mod('corporate_office_about_us_box_icon'.$i)); ?> me-3"></i>
                    <h6 class="m-0"><?php echo esc_html(get_theme_mod('corporate_office_about_us_box_heading' .$i)); ?></h6>
                  </div>
                <?php } ?>
              <?php } ?>
            </div>
        </div>
      </div>
    </div>
  </section>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>