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

<main id="skip-content" role="main">
	<?php do_action( 'luzuk_megavoltelectrician_above_slider' ); ?>

	<?php if( get_theme_mod('luzuk_megavoltelectrician_slider_hide_show') != ''){ ?>
	<section id="slider">	  
		<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
			<?php $luzuk_megavoltelectrician_slider_pages = array();
			    for ( $count = 1; $count <= 4; $count++ ) {
			        $mod = intval( get_theme_mod( 'luzuk_megavoltelectrician_slider'. $count ));
			        if ( 'page-none-selected' != $mod ) {
			          $luzuk_megavoltelectrician_slider_pages[] = $mod;
			        }
			    }
		      	if( !empty($luzuk_megavoltelectrician_slider_pages) ) :
			        $args = array(
			          	'post_type' => 'page',
			          	'post__in' => $luzuk_megavoltelectrician_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(null, '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>
							<?php 
								$luzuk_megavoltelectrician_slider_excerpt_length = get_theme_mod('luzuk_megavoltelectrician_slider_excerpt_length','15');
							
								if( $luzuk_megavoltelectrician_slider_excerpt_length != ''){?>
								<p ><?php $luzuk_megavoltelectrician_excerpt = get_the_excerpt(); echo esc_html( luzuk_megavoltelectrician_string_limit_words( $luzuk_megavoltelectrician_excerpt, esc_attr(get_theme_mod('luzuk_megavoltelectrician_slider_excerpt_length','15') ) )); ?></p>
							<?php } ?>
							<div class="sbtn">
								<i class="fa-regular fa-thumbs-up"></i> <a href="<?php echo esc_url(get_theme_mod('luzuk_megavoltelectrician_sliderbtnlink')) ?>">
									<?php esc_html_e( 'What we offers','megavolt-electrician' );?> <i class="fa-solid fa-arrow-right"></i>
								</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','megavolt-electrician' );?></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','megavolt-electrician' );?></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_megavoltelectrician_below_slider'); ?>

	<?php if (get_theme_mod('luzuk_megavoltelectrician_feature_hideshow',true)) {?>
	<section id="feature-section">
		<div class="container"> 
			<div class="row">
				<div class="col-lg-4 col-md-6 col-sm-12">
					<div class="heading">
						<h4><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_heading_subheading')); ?></h4>
						<h2><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_heading_heading')); ?></h2>
						<p><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_heading_description')); ?></p>
						<div class="read_more" >
							<a  href="<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_heading_btnlink')); ?>">
								<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_heading_btntext')); ?>
							</a>
						</div>
					</div>
				</div>
				<div class="col-lg-4 col-md-6 col-sm-12">
					<div class="list">
						<li><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_list1text')); ?></li>
						<li><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_list2text')); ?></li>
						<li><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_list3text')); ?></li>
						<li><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_list4text')); ?></li>
						<li><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_feature_list5text')); ?></li>
					</div>
				</div>
				<div class="col-lg-4 col-md-6 col-sm-12">
					<div class="slider slider-nav">
						<?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_megavoltelectrician_featurepage_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_megavoltelectrician_featurepage_setting_' . $i);
								if ($selected_page_id) {
									$page = get_post($selected_page_id);

									?>
									<!-- <h3>
										</?php echo $page->post_title; ?>
									</h3> -->
								<?php }
							}
						} else {
							// Display message if no pages are selected
							echo '<p>Please select page from customizer</p>';
						}
						?>
					</div>
					<div class="slider slider-for">
						<?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_megavoltelectrician_featurepage_setting_' . $i);
								if ($selected_page_id) {
									$pages_selected = true;
									break;
								}
							}
						?>

						<!-- <div class="owl-carousel owl-theme row"> -->
						<?php
						// Loop through each selected page and display in the slider
						for ($i = 1; $i <= 7; $i++) {
							$selected_page_id = get_theme_mod('luzuk_megavoltelectrician_featurepage_setting_' . $i);
							if ($selected_page_id) {
								$page = get_post($selected_page_id);

							$icon = get_theme_mod('luzuk_megavoltelectrician_featurepage_setting_icon' . $i);
							$count = $i;

						?>
						<div class="fs-box">
							<div class="count">
								0<?php echo esc_attr($count); ?>
							</div>
							<div class="fs-conbox">
								<i class="<?php echo esc_attr($icon); ?>"></i>
								<p><?php echo get_the_excerpt($page->ID); ?></p>
							</div>
							<div class="clearfix"></div>
						</div>
						<?php }
						}
						?>
					<div class="clearfix"></div>
					</div>
				</div>
			</div>
		</div>
	</section>
	<?php }?>

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

	<?php if (get_theme_mod('luzuk_megavoltelectrician_aboutus_hideshow',true)) {?>
	<section id="aboutus-section">
		<!-- <div class="overlay"></div> -->
		<div class="container"> 
			<div class="row mr-0"> 
				<div class="abt_cont">
					<div class="headigbx">
						<h4 class="heading"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusubheading')); ?></h4>	
						<h4 class="subheading"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusubheading')); ?></h4>	

						<h4 class="mainheading"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusheading')); ?></h4>							
						<h4 class="hastag"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutushastag')); ?></h4>							
						<h4 class="title"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutustitle')); ?></h4>
					</div>
					<div class="row mr-0">
						<div class="m-bx">
							<div class="row mr-0">
								<div class="box box1">					
									<?php
										$aboutus_box1icon = esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box1icon'));
									?>
									<?php if (!empty($aboutus_box1icon)): ?>
										<div class="box1ic icon">
											<i class="<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box1icon')); ?>" aria-hidden="true"></i>
										</div>
									<?php endif; ?>
									<div class="cont">
										<h3><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box1title')); ?></h3>
									</div>						
								</div>	
								<div class="box box2">						
									<?php
										$aboutus_box2icon = esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box2icon'));
									?>
									<?php if (!empty($aboutus_box2icon)): ?>
										<div class="box2ic icon">
											<i class="<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box2icon')); ?>" aria-hidden="true"></i>
										</div>
									<?php endif; ?>
									<div class="cont">
										<h3><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box2title')); ?></h3>
									</div>			
								</div>	
							</div>
							<div class="row mr-0">
								<div class="box box3">				
									<?php
										$aboutus_box3icon = esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box3icon'));
									?>
									<?php if (!empty($aboutus_box3icon)): ?>
										<div class="box3ic icon">
											<i class="<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box3icon')); ?>" aria-hidden="true"></i>
										</div>
									<?php endif; ?>
									<div class="cont">
										<h3><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box3title')); ?></h3>
									</div>				
								</div>	
								<div class="box box4">					
									<?php
										$aboutus_box4icon = esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box4icon'));
									?>
									<?php if (!empty($aboutus_box4icon)): ?>
										<div class="box3ic icon">
											<i class="<?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box4icon')); ?>" aria-hidden="true"></i>
										</div>
									<?php endif; ?>
									<div class="cont">
										<h3><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutus_box4title')); ?></h3>
									</div>				
								</div>
							</div>
						</div>
						<div class="yearofexperience">
							<div class="yearbxcir"></div>
							<div class="yearbx">
								<h2><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusyearofexperiencenum')); ?></h2>
								<p><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusyearofexperiencetext')); ?></p>
							</div>
						</div>
					</div>
					<p class="description"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_aboutusdescription')); ?></p>								
					
				</div>
				<div class="abt_imgbx">
					<div class="aboutus-img">
						<div class="row">
							<div class="img1">
								<?php 
									$luzuk_megavoltelectrician_aboutus_image1 = get_theme_mod('luzuk_megavoltelectrician_aboutus_image1');

									if(!empty($luzuk_megavoltelectrician_aboutus_image1)){
										echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($luzuk_megavoltelectrician_aboutus_image1).'" class="img-responsive secondry-bg-img" />';
									}else{
										echo '<img alt="luzuk_megavoltelectrician_aboutus_image1" src="'.get_template_directory_uri().'/assets/images/abthead.png" class="img-responsive" />';
									}
								?>	
							</div>							
							<div class="img2">
								<div class="img2img">
									<?php 
										$luzuk_megavoltelectrician_aboutus_image2 = get_theme_mod('luzuk_megavoltelectrician_aboutus_image2');

										if(!empty($luzuk_megavoltelectrician_aboutus_image2)){
											echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($luzuk_megavoltelectrician_aboutus_image2).'" class="img-responsive secondry-bg-img" />';
										}else{
											echo '<img alt="luzuk_megavoltelectrician_aboutus_image2" src="'.get_template_directory_uri().'/assets/images/abt3.jpg" class="img-responsive" />';
										}
									?>
								</div>
							</div>
							<div class="img3">
								<div class="img3img">
									<?php 
										$luzuk_megavoltelectrician_aboutus_image3 = get_theme_mod('luzuk_megavoltelectrician_aboutus_image3');

										if(!empty($luzuk_megavoltelectrician_aboutus_image3)){
											echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($luzuk_megavoltelectrician_aboutus_image3).'" class="img-responsive secondry-bg-img" />';
										}else{
											echo '<img alt="luzuk_megavoltelectrician_aboutus_image3" src="'.get_template_directory_uri().'/assets/images/abt2.jpg" class="img-responsive" />';
										}
									?>
								</div>
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
	</section>
	<?php }?>

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

	<?php if (get_theme_mod('luzuk_megavoltelectrician_services_hideshow',true)) {?>
	<section id="services-section">
		<div class="container"> 		
			<div class="titlebx">
				<h2 class="heading"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_servicesheading')); ?></h2>
				<h4 class="subheading"><?php echo esc_html(get_theme_mod('luzuk_megavoltelectrician_servicesheading')); ?></h4>
			</div>	
		</div>
		
		<div class="container"> 	
			<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_megavoltelectrician_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_megavoltelectrician_page_setting_' . $i);
						if ($selected_page_id) {
							$page = get_post($selected_page_id);

							$icon = get_theme_mod('luzuk_megavoltelectrician_page_setting_icon' . $i);
							?>
							<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); ?>">
											<i class="<?php echo esc_attr($icon); ?>"></i>
											<h4>								
												<?php echo $page->post_title; ?>
											</h4>
										</a>
										<p><?php echo get_the_excerpt($page->ID); ?></p>
									</div>
								</div>
							</div>
						<?php }
					}
				} else {
					// Display message if no pages are selected
					echo '<p>Please select page from customizer</p>';
				}
				?>
			</div>	
		</div>
	</section>
	<?php }?>

	<?php do_action('luzuk_megavoltelectrician_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(); ?>