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

<main id="skip-content" role="main">

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

	<?php if( get_theme_mod('luzuk_excavator_slider_hide_show') != ''){ ?>
	<section id="slider">	  
		
			<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
			    <?php $luzuk_excavator_slider_pages = array();
			    for ( $count = 1; $count <= 4; $count++ ) {
			        $mod = intval( get_theme_mod( 'luzuk_excavator_slider'. $count ));
			        if ( 'page-none-selected' != $mod ) {
			          $luzuk_excavator_slider_pages[] = $mod;
			        }
			    }
		      	if( !empty($luzuk_excavator_slider_pages) ) :
			        $args = array(
			          	'post_type' => 'page',
			          	'post__in' => $luzuk_excavator_slider_pages,
			          	'orderby' => 'post__in'
			        );
		        	$query = new WP_Query( $args );
		        if ( $query->have_posts() ) :
		          	$i = 1;
		    	?>   
		    	 <div class="carousel-inner" role="listbox">
		    	<!-- <div class="container">    -->
				   
				      	<?php  while ( $query->have_posts() ) : $query->the_post(); ?>
				        <div <?php if($i == 1){echo 'class="carousel-item fade-in-image active"';} else{ echo 'class="carousel-item fade-in-image"';}?>>
							<div class="slideimg">
								<?php
									// Check if the post has a thumbnail
									if (has_post_thumbnail()) {
										// If post has thumbnail, display it
										?>
										<img src="<?php echo esc_url(get_the_post_thumbnail_url(get_the_ID(), 'full')); ?>" alt="<?php the_title_attribute(); ?>" />
										<?php
									} else {
										// If post does not have thumbnail, display default image
										?>
										<img src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/abt1.jpg'); ?>" alt="Default Image" />
										<?php
									}

								?>
								<div class="slider-overlay"></div>
							</div>								
							<div class="content">
								<h2><?php the_title(); ?></h2>
								<div class="sbtn">
									<a href="<?php echo esc_url(get_theme_mod('luzuk_excavator_sliderbtnlink')) ?>">
										<div class="btnbrd"></div>
										<?php esc_html_e( 'Our Services','excavator' );?>
									</a>
								</div>
							</div>
				        </div>
				      	<?php $i++; endwhile; 
				      	wp_reset_postdata();?>
				    <!-- </div> -->
			    <?php else : ?>

			    	</div>
			    	<div class="no-postfound"></div>
	      		<?php endif;
			    endif;?>
			<div class="slidebtn">
			    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
						
					<span class="carousel-control-prev-icon" aria-hidden="true">
					  <i class="fas fa-caret-left"></i>
			      	</span>
			      	<span class="screen-reader-text"><?php esc_html_e( 'Prev','excavator' );?></span>
			    </a>
			    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
					
					<span class="carousel-control-next-icon" aria-hidden="true">
					  <i class="fas fa-caret-right"></i>
			      	</span>
			      	<span class="screen-reader-text"><?php esc_html_e( 'Next','excavator' );?></span>
			    </a>
				<!-- <ol class="carousel-indicators">
                    <//?php for ($j = 0; $j < $i; $j++) : ?>
                        <li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $j; ?>" class="<?php if ($j === 0) echo 'active'; ?>"></li>
                    <//?php endfor; ?>
                </ol> -->
			</div>
		  	<div class="clearfix"></div>
		</div> 
	</section>
	<?php }?>
	
	<?php do_action('luzuk_excavator_below_slider'); ?>

	<section id="aboutus-section">
		<div class="overlay"></div>
		<div class="container"> 
			<div class="row"> 
				<div class="col-lg-6 col-md-12 col-sm-12">
					<div class="aboutus-img">
						<?php 
							$luzuk_excavator_aboutus_image = get_theme_mod('luzuk_excavator_aboutus_image');

							if(!empty($luzuk_excavator_aboutus_image)){
								echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($luzuk_excavator_aboutus_image).'" class="img-responsive secondry-bg-img" />';
							}else{
								echo '<img alt="luzuk_excavator_aboutus_image" src="'.get_template_directory_uri().'/assets/images/aboutusimg.png" class="img-responsive" />';
							}
						?>
						<div class="abt-brd"></div>
					</div>			
				</div>
				<div class="col-lg-6 col-md-12 col-sm-12">
					<h3 class="subheading"><?php echo esc_html(get_theme_mod('luzuk_excavator_aboutussubheading')); ?></h3>				
					<h4 class="heading"><?php echo esc_html(get_theme_mod('luzuk_excavator_aboutusheading')); ?></h4>				
					<p class="description"><?php echo esc_html(get_theme_mod('luzuk_excavator_aboutusdescription')); ?></p>				
					<div class="list">
						<li>
							<i class="fas fa-arrow-right"></i>
							<?php echo esc_html(get_theme_mod('luzuk_excavator_aboutuslist1')); ?>
						</li>
						<li>
							<i class="fas fa-arrow-right"></i>
							<?php echo esc_html(get_theme_mod('luzuk_excavator_aboutuslist2')); ?>
						</li>
						<li>
							<i class="fas fa-arrow-right"></i>
							<?php echo esc_html(get_theme_mod('luzuk_excavator_aboutuslist3')); ?>
						</li>
						<li>
							<i class="fas fa-arrow-right"></i>
							<?php echo esc_html(get_theme_mod('luzuk_excavator_aboutuslist4')); ?>
						</li>
					</div>
					<div class="bttn">
						<a class="get" href="<?php echo esc_url(get_theme_mod('luzuk_excavator_aboutusgetstartedbtnlink')) ?>">
							<span><?php esc_html_e( 'GET STARTED','excavator' );?>
							<i class="fas fa-arrow-right"></i></span>
						</a>
						<a class="video" href="<?php echo esc_url(get_theme_mod('luzuk_excavator_aboutusplayvideobtnlink')) ?>">
							<i class="fas fa-play"></i><span>
							<?php esc_html_e( 'Play A Video','excavator' );?></span>
						</a>
					</div>
				</div>
			</div>
		</div>
	</section>

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

	<section id="services-section">
		<div class="container"> 
			<div class="headbx">		
				<h2 class="heading"><?php echo esc_html(get_theme_mod('luzuk_excavator_servicesheading')); ?></h2>						
			</div>
			<div class="content">
				<div class="row mr-0">
				<?php
				// Check if any page is selected from customizer
				$pages_selected = false;
				for ($i = 1; $i <= 6; $i++) {
					$selected_page_id = get_theme_mod('luzuk_excavator_page_setting_' . $i);
					if ($selected_page_id) {
						$pages_selected = true;
						break;
					}
				}
				?>

				<!-- <div class="owl-carousel owl-theme row"> -->
					<?php
					// Display pages in slider if selected, otherwise show a message
					if ($pages_selected) {
						// Loop through each selected page and display in the slider
						for ($i = 1; $i <= 7; $i++) {
							$selected_page_id = get_theme_mod('luzuk_excavator_page_setting_' . $i);
							if ($selected_page_id) {
								$page = get_post($selected_page_id);
								?>
								<div class="serbx col-lg-4 col-md-6 col-sm-12">
									<div class="serbxinn">
										<a href="<?php echo get_permalink($page->ID); ?>">
											<?php echo get_the_post_thumbnail($page->ID, 'medium'); ?>
											<div class="s_oly"></div>
										</a>
										<div class="sconbx ">
											<a href="<?php echo get_permalink($page->ID); ?>">
												<h4><?php echo $page->post_title; ?></h4>
											</a>
											<div class="btnprice ">
												<div class="landbtn">
													<a href="<?php echo get_permalink($page->ID); ?>">
														<?php _e( 'View More', 'excavator' ); ?>
													</a>										
												</div>
											</div>
										</div>
									</div>
								</div>
							<?php }
						}
					} else {
						// Display message if no pages are selected
						echo '<p>Please select page from customizer</p>';
					}
					?>
				</div>
			</div>
		</div>
	</section>

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

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

<?php get_footer(); ?>