<?php
/**
 * The template for displaying home page.
 *
 * Template Name: Custom Home Page
 *
 * @package Home Construction Company
 */
get_header(); ?>

<main id="main" role="main">
  
  <?php if( get_theme_mod( 'home_construction_company_slider_hide_show', false ) != '' || get_theme_mod( 'home_construction_company_mobile_media_slider', true ) != '' ) {?>
    <div class="slider-section">
      <section id="slider">
        <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'home_construction_company_slider_speed',3000)); ?>"> 
          <?php $home_construction_company_slider_pages = array();
            for ( $home_construction_company_count = 1; $home_construction_company_count <= 4; $home_construction_company_count++ ) {
              $home_construction_company_mod = intval( get_theme_mod( 'home_construction_company_slider_page' . $home_construction_company_count ));
              if ( 'page-none-selected' != $home_construction_company_mod ) {
                $home_construction_company_slider_pages[] = $home_construction_company_mod;
              }
            }
            if( !empty($home_construction_company_slider_pages) ) :
              $home_construction_company_args = array(
                'post_type' => 'page',
                'post__in' => $home_construction_company_slider_pages,
                'orderby' => 'post__in'
              );
              $home_construction_company_query = new WP_Query( $home_construction_company_args );
            if ( $home_construction_company_query->have_posts() ) :
              $i = 1;
          ?>     
          <div class="carousel-inner" role="listbox">
            <?php  while ( $home_construction_company_query->have_posts() ) : $home_construction_company_query->the_post(); ?>
            <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
              <div class="slider-bgimage">
                <?php if(has_post_thumbnail()){ ?>
                  <?php the_post_thumbnail(); ?>
                <?php } else {?>
                  <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/slider.png" alt="<?php echo esc_attr('Slider Image', 'home-construction-company'); ?>">
                <?php }?>
              </div>
              <div class="carousel-caption wow zoomIn">
                <div class="inner_carousel">
                  <?php if ( get_theme_mod( 'home_construction_company_slider_title', true ) ) : ?>
                    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h1>
                  <?php endif; ?>
                    <?php if ( get_theme_mod( 'home_construction_company_slider_content', true ) ) : ?>  
                    <p class="mb-3"><?php $home_construction_company_excerpt = get_the_excerpt(); echo esc_html( home_construction_company_string_limit_words( $home_construction_company_excerpt,esc_attr(get_theme_mod('home_construction_company_slider_excerpt','20')) ) ); ?></p>
                  <?php endif; ?> 
                  <?php if ( get_theme_mod('home_construction_company_slider_button',true) != ''|| get_theme_mod('home_construction_company_slider_button_responsive',true) != '' || get_theme_mod('home_construction_company_slider_button_text','KNOW MORE') != ''|| get_theme_mod('home_construction_company_slider_button_link') != '') {?> 
                    <div class="read-btn">
                      <a href="<?php echo esc_url(get_theme_mod('home_construction_company_slider_button_link')!= '') ? esc_url(get_theme_mod('home_construction_company_slider_button_link')) : esc_url(get_permalink()); ?>"><?php echo esc_html(get_theme_mod('home_construction_company_slider_button_text',__('KNOW MORE', 'home-construction-company'))); ?><span class="screen-reader-text"><?php echo esc_html('KNOW MORE', 'home-construction-company') ?></span></a>
                    </div>
                  <?php }?>  
                </div>
              </div>
            </div>
            <?php $i++; endwhile; 
            wp_reset_postdata();?>
          </div>
          <?php else : ?>
            <div class="no-postfound"></div>
          <?php endif;
          endif;?>
           <?php if( get_theme_mod('home_construction_company_slider_arrow',true) != ''){ ?>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('home_construction_company_slider_prev_icon','fas fa-angle-left')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Previous','home-construction-company');?></span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('home_construction_company_slider_next_icon','fas fa-angle-right')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Next','home-construction-company');?></span>
          </a>
          <?php }?>
        </div> 
      </section> 
    </div>
  <?php }?>

  <?php do_action( 'home_construction_company_before_services_section' ); ?>

  <?php if( get_theme_mod( 'home_construction_company_choices_hide_show', false ) != '') {?>
  <?php if( get_theme_mod( 'home_construction_company_section_text') != '' || get_theme_mod( 'home_construction_company_section_title') != ''){ ?>
    <section id="services-section" class="pb-5">
      <div class="container">
        <div class="top-text pt-3 px-lg-0 px-md-0 px-2">
          <div class="row top-text1 wow bounceInDown"> 
            <div class="col-lg-10 col-8 align-self-center service-text">
              <?php if( get_theme_mod('home_construction_company_section_text') != ''){ ?>  
                  <p class="mb-0"><?php echo esc_html(get_theme_mod('home_construction_company_section_text')); ?></p>
                <?php }?>
              <?php if (get_theme_mod('home_construction_company_section_title') != '') { ?>
                <h2><?php echo esc_html(get_theme_mod('home_construction_company_section_title')); ?></h2>
              <?php } ?>
            </div>
            <div class="col-lg-2 col-4 align-self-center text-end">
              <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/service.png" alt="">
            </div>
          </div>
        <div class="services-box-section">
          <div class="tab mt-3 mb-5 wow bounceInDown">
            <?php
              $category_post = get_theme_mod('home_construction_company_services_number', '');
              for ( $j = 1; $j <= $category_post; $j++ ){ ?>
              <button class="tablinks" onclick="home_construction_company_project_tab(event, '<?php $main_id = get_theme_mod('home_construction_company_services_text'.$j); $tab_id = str_replace(' ', '-', $main_id); echo $tab_id; ?> ')">
              <?php echo esc_html(get_theme_mod('home_construction_company_services_text'.$j)); ?></button>
            <?php }?>
          </div>

          <?php for ( $j = 1; $j <= $category_post; $j++ ){ ?>
            <div id="<?php $main_id = get_theme_mod('home_construction_company_services_text'.$j); $tab_id = str_replace(' ', '-', $main_id); echo $tab_id; ?>"  class="tabcontent mt-3">
              <div class="row">
                <?php
                $home_construction_company_catData = get_theme_mod('home_construction_company_services_category'.$j);
                if($home_construction_company_catData){
                  $page_query = new WP_Query(array( 'category_name' => esc_html( $home_construction_company_catData ,'home-construction-company')));
                  $bgcolor = 1; ?>
                  <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                    <div class="col-lg-12 col-md-12">
                      <div class="row">
                        <div class="col-lg-8 col-md-6 wow fadeInLeft">
                          <h3 class="p-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h3>
                          <p class="mt-3"><?php $home_construction_company_excerpt = get_the_excerpt(); echo esc_html( home_construction_company_string_limit_words( $home_construction_company_excerpt,40 ) ); ?></p>
                          <div class="text-field text-center">
                            <?php if( get_theme_mod('home_construction_company_section_text1') != ''){ ?>  
                              <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/plan.png" alt=""><p class="plan mb-0"><?php echo esc_html(get_theme_mod('home_construction_company_section_text1')); ?></p>
                            <?php }?>
                            <?php if( get_theme_mod('home_construction_company_section_text2') != ''){ ?>  
                              <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/design.png" alt=""><p class="design mb-0"><?php echo esc_html(get_theme_mod('home_construction_company_section_text2')); ?></p>
                            <?php }?>
                            <?php if( get_theme_mod('home_construction_company_section_text3') != ''){ ?>  
                              <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/delivery.png" alt=""><p class="delivery mb-0"><?php echo esc_html(get_theme_mod('home_construction_company_section_text3')); ?></p>
                            <?php }?>
                          </div>
                          <?php if ( get_theme_mod('home_construction_company_latest_post_button_text','Get In Touch') != '') {?>
                            <div class="button-post mt-3">
                            <a href="<?php echo esc_url( get_permalink() );?>" class="blog-btn" title="<?php esc_attr_e( 'Get In Touch', 'home-construction-company' ); ?>"><?php echo esc_html( get_theme_mod('home_construction_company_latest_post_button_text',__('Get In Touch', 'home-construction-company')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('home_construction_company_latest_post_button_text',__('Get In Touch', 'home-construction-company')) ); ?></span></a>
                          </div>
                        </div>
                        <div class="col-lg-4 col-md-6 text-md-end text-lg-end text-center pt-md-0 pt-lg-0 pt-3">
                          <?php if(has_post_thumbnail()) {?>
                            <div class="box mb-4 wow fadeInRight">
                              <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                            </div>
                          <?php }?>
                        </div>
                        <?php }?>
                      </div>
                    </div>
                  <?php if($bgcolor >= 6){ $bgcolor = 0; } $bgcolor++; endwhile;
                  wp_reset_postdata();
                } ?>
              </div>
            </div>
          <?php }?>
        </div>
      </div>
    </section>
  <?php }?>  

  <?php do_action( 'home_construction_company_after_product_section' ); ?>

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

<?php get_footer(); ?>