<?php
/**
 * Template Part for displaying Services section in homepage
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package NDesign
 */

if ( get_theme_mod( 'testimonial_title' ) || get_theme_mod( 'testimonial_subtitle' ) || get_theme_mod( 'testimonial' ) ) : ?>
<section class="testimonial-section page-section" id="testimonial">
	<div class="container">
		<div class="row">
			<div class="col-12">
				<div class="main-title-blk">
					<!-- Subtitle start -->
					<?php if ( get_theme_mod( 'testimonial_subtitle' ) ) : ?>
						<h4 class="main-subtitle text-center">
								<?php echo esc_html( get_theme_mod( 'testimonial_subtitle' ) ); ?>
							</h4>
						<?php endif ?>
						<!-- Subtitle end -->
						<!-- Title Start -->
						<?php if ( get_theme_mod( 'testimonial_title' ) ) : ?>
						<h2 class="main-title text-center">
							<?php echo esc_html( get_theme_mod( 'testimonial_title' ) ); ?>
						</h2>
						<?php endif ?>
				</div>
			</div>
		</div>
		<?php
		$ndesign_testimonials = get_theme_mod( 'testimonial' );
		if ( ! empty( $ndesign_testimonials ) ) {
			?>
			<div class="row">
				<div class="col-12 testimonial-slider-wrap">
					<div class="testimonial-slider swiper-container">
						<div class="swiper-wrapper">
							<?php foreach ( $ndesign_testimonials as $ndesign_key => $ndesign_val ) { ?>
								<div class="swiper-slide">
									<!-- Testimonial block start -->
									<div class="testimonial-blk text-center">
										<!-- Testimonial Image start -->
										<?php if ( $ndesign_val['image'] ) { ?>
											<div class="testimonial-image">
												<img src="<?php echo esc_url(wp_get_attachment_url( $ndesign_val['image'] )); ?>">
											</div>
										<?php } else { ?>
											<div class="testimonial-image">
												<img src="<?php echo esc_url(get_template_directory_uri() . '/images/ndesign_testimonial_placeholder_grey.png'); ?>">
											</div>
										<?php } ?>
										<!-- Testimonial Image end -->
										<!-- testimonial Detail Start -->
										<div class="testimonial-detail">
											<!-- Testimonial title start -->
											<?php if ( $ndesign_val['name'] ) { ?>
												<h2 class="testimonial-title">
													<?php echo esc_html( $ndesign_val['name'] ); ?>
												</h2>
											<?php } ?>
											<!-- Testimonial title end -->
											<!-- Testimonial description Start -->
											<div class="testimonial-description">
												<?php if ( $ndesign_val['description'] ) { ?>
													<p><?php echo esc_html( $ndesign_val['description'] ); ?></p>
												<?php } ?>
												<!-- Testimonial designation start -->
												<div class="testimonial-designation">
													<?php if ( $ndesign_val['designation'] ) { ?>
														<p><?php echo esc_html( $ndesign_val['designation'] ); ?></p>
													<?php } ?>
													<?php if ( $ndesign_val['organization'] ) { ?>
														<p><?php echo esc_html( $ndesign_val['organization'] ); ?></p>
													<?php } ?>
												</div>
												<!-- Testimonial designation end -->
											</div>
											<!-- Testimonial description end -->
										</div>
										<!-- testimonial Detail End -->
									</div>
									<!-- Testimonial block end -->
								</div>
							<?php } ?>
						</div>
						<!-- Slider Pagination Start -->
						<div class="swiper-pagination"></div>
						<!-- Slider Pagination end -->
					</div>
					<!-- Slider Navigation start -->
					<div class="swiper-button-next"></div>
					<div class="swiper-button-prev"></div>
					<!-- Slider Navigation End -->
				</div>
			</div>
		<?php } ?>
	</div>
</section>
<?php endif ?>
<!-- Testimonial Section end -->
