<?php
/**
 * Template part for displaying Our Project section
 *
 * @package Property Builder
 * @subpackage property_builder
 */
?>
<?php $property_builder_static_image= get_template_directory_uri() . '/assets/images/header_img.png'; ?>
<?php if( get_theme_mod( 'construction_hub_show_hide_project_secton', true) != '') { ?>
  <section id="our_project">
    <div class="container">
      <?php if( get_theme_mod('construction_hub_our_project_title') != '' || get_theme_mod('construction_hub_our_project_para') != ''){ ?>
        <div class="project_bg">
          <?php if( get_theme_mod('construction_hub_our_project_title') != ''){ ?>
            <h2 class="text-uppercase"><?php echo esc_html(get_theme_mod('construction_hub_our_project_title','')); ?></h2>
          <?php }?>
        </div>
      <?php }?>
      <div class="owl-carousel my-5">
          <?php $construction_hub_project_pages = array();

          $property_builder_count = get_theme_mod('property_builder_about_page_count','3');

          for ( $construction_hub_count = 1; $construction_hub_count <= $property_builder_count; $construction_hub_count++ ) {
              $construction_hub_mod = intval( get_theme_mod( 'construction_hub_about_page' . $construction_hub_count ));
            if ( 'page-none-selected' != $construction_hub_mod ) {
              $construction_hub_project_pages[] = $construction_hub_mod;
            }
          }
          if( !empty($construction_hub_project_pages) ) :
            $construction_hub_args = array(
              'post_type' => 'page',
              'post__in' => $construction_hub_project_pages,
              'orderby' => 'post__in'
            );
            $construction_hub_query = new WP_Query( $construction_hub_args );
          if ( $construction_hub_query->have_posts() ) :
            $construction_hub_count = 0;
            while ( $construction_hub_query->have_posts() ) : $construction_hub_query->the_post(); ?>
              <div class="project_box">
                <div class="project-img">
                  <?php if(has_post_thumbnail()){ ?>
                 <img src="<?php the_post_thumbnail_url('full'); ?>"/> <?php }else {echo ('<img src="'.$property_builder_static_image.'">'); } ?>
                </div>
                <div class="project_text">
                  <div class="row">
                    <div class="col-lg-2 col-md-2 col-4 align-self-center">
                      <a href="<?php the_permalink(); ?>"><i class="fas fa-angle-right"></i></a>
                    </div>
                    <div class="col-lg-10 col-md-10 col-8 align-self-center">

                    <?php if( get_theme_mod('construction_hub_our_project_para') != ''){ ?>
                      <p class="my-1 short-title"><?php echo esc_html(get_theme_mod('construction_hub_our_project_para','')); ?></p>
                    <?php }?>
                      <h3><a href="<?php the_permalink(); ?>" class="text-left"><?php the_title(); ?></a></h3>
                    </div>
                  </div>
                </div>
              </div>
            <?php $construction_hub_count++; endwhile;
            wp_reset_postdata();?>
            <?php else : ?>
              <div class="no-postfound"></div>
            <?php endif;
          endif;?>
      </div>
    </div>
  </section>
<?php }?>
