<?php
// Template name: Construction updates
get_header(); ?>
<?php 
$display_hero = get_field('display_hero');
if($display_hero) {
    get_template_part('partials/template', 'hero'); 
} elseif(get_post_type() == 'page') {
    echo "<div class='page-title'><div class='container'><h1>" . get_the_title() . "</h1></div></div>";
}
?>

<section class="page-section main-content-section clearfix">
    <div class="container">
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                        <div class="index-content plain_text">
                            <?php the_content(); ?>
                        </div>


                    <?php endwhile; else : ?>
                    <p><?php _e( 'Sorry, nothing was found.' ); ?></p>
                <?php endif; ?>
	</div>
</section>

<?php
get_template_part('partials/template', 'pagesections'); 
?>



<section class="page-section main-content-section clearfix style-med">
    <div class="container">


                        <div class="index-content plain_text" id="updates">
				<h2 class="section-title">Construction Updates</h2>
			<?php
			$all_constructions = Constructions::get_by_date_range(10);
			if($all_constructions) {
				echo '<div class="updates construction-updates "><ol>';
				foreach($all_constructions as $construction)	{ ?>
					<li class="updates-item">
						<a href="<?=get_permalink($construction->ID);?>" class="construction-block-link">					
							<?php	if($construction->status)	{ ?>
									<small class="text-muted date"><span class="construction_update_status" data-status="<?=$construction->status['key'];?>"><?=$construction->status['name'];?></span></small>
								<?php } ?>
							<h4 class="lead"><?=get_the_title($construction->ID);?></h4>
							<div class="p"><?=get_the_excerpt($construction->ID);?></div>
						</a>
					</li>
				<?php }
				wp_reset_postdata();
			}
			echo '</ol></div><!-- .questions -->'; ?>
					</div> 
    </div>
</section>

<!-- TODO: Display all construction updates -->
<?php get_footer(); ?>
