<?php
/**
 * Template part for displaying the about section
 *
 * @package Packers And Movers
 * @subpackage packers_and_movers
 */

$packers_and_movers_static_image = get_template_directory_uri() . '/assets/images/sliderimage.png';

// Check if the about section is enabled
if ( get_theme_mod( 'packers_and_movers_about_enable', true)) : ?>
    <section id="about" class="my-5 px-md-0 px-3">
        <div class="container">
            <?php
            // Fetch about page ID from customizer
            $packers_and_movers_about_page_id = absint( get_theme_mod( 'packers_and_movers_about_page' ) );
            // Check if a valid page is set for the about section
            if ( $packers_and_movers_about_page_id ) :
                $packers_and_movers_args = array(
                    'post_type' => 'page',
                    'p'         => $packers_and_movers_about_page_id,
                );
                $packers_and_movers_query = new WP_Query( $packers_and_movers_args );
                // Check if the query has posts
                if ( $packers_and_movers_query->have_posts() ) :
                    while ( $packers_and_movers_query->have_posts() ) : $packers_and_movers_query->the_post(); ?>
                        <div class="row">
                            <div class="col-lg-4 col-md-4 align-self-center image-abt mb-3">
                                <div class="about-block position-relative">
                                    <div class="about-image1">
                                        <div class="thumbnail position-relative">
                                            <?php if ( has_post_thumbnail() ) : ?>
                                                <?php the_post_thumbnail( 'full', array( 'alt' => esc_attr( get_the_title() ) ) ); ?>
                                            <?php else : ?>
                                                <img src="<?php echo esc_url( $packers_and_movers_static_image ); ?>" alt="<?php esc_attr_e( 'Placeholder', 'packers-and-movers' ); ?>" />
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-2 col-md-2 align-self-center abt-bg-img mb-3 ps-lg-3 ps-md-0">
                                <?php 
                                $packers_and_movers_satisfied_client = get_theme_mod( 'packers_and_movers_satisfied_client', '' );
                                if ( $packers_and_movers_satisfied_client ) : ?>
                                    <div class="satified-box mb-md-0 mb-2">
                                    <div class="start-yr-content">
                                        <div class="start-yr mb-2"><?php echo esc_html( $packers_and_movers_satisfied_client ); ?></div>
                                        <div class="year-text"><?php esc_html_e( 'Satisfied Client', 'packers-and-movers' ); ?></div>
                                    </div>
                                    </div>
                                <?php endif; ?>
                                <div class="about-banner">
                                    <?php 
                                    $packers_and_movers_image1 = get_theme_mod( 'packers_and_movers_abt_banner_image1', '' );
                                    if ( $packers_and_movers_image1 ) : ?>
                                        <img src="<?php echo esc_url( $packers_and_movers_image1 ); ?>" alt="<?php esc_attr_e( 'About Banner', 'packers-and-movers' ); ?>" />
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="col-lg-6 col-md-6 align-self-center ps-lg-5">
                                <div class="match-heading">
                                    <?php 
                                    $packers_and_movers_sub_heading = get_theme_mod( 'packers_and_movers_service_sub_heading' );
                                    if ( $packers_and_movers_sub_heading ) : ?>
                                        <p class="mb-md-3 mb-2 abt-title text-uppercase"><?php echo esc_html( $packers_and_movers_sub_heading ); ?></p>
                                    <?php endif; ?>
                                    
                                    <h2 class="mb-3 text-capitalize">
                                        <a href="<?php echo esc_url( get_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a>
                                    </h2>
                                </div>
                                <p class="mb-4 abt-content"><?php echo esc_html( wp_trim_words( get_the_content(), 38, '...' ) ); ?></p>
                                <div class="about-contact my-md-3 my-2">
                                    <div class="about-button text-md-start me-md-4 me-md-2 me-0 mb-md-0 mb-3">
                                        <a class="know-more" href="<?php echo esc_url( get_permalink() ); ?>" target="_blank">
                                            <span class="abt-btn text-capitalize"><?php esc_html_e( 'Read More', 'packers-and-movers' ); ?></span>
                                        </a>
                                    </div>
                                    <div class="call col-lg-3 col-md-4 align-self-center mb-md-0">
                                        <?php if( get_theme_mod( 'packers_and_movers_call_text' ) != '' || get_theme_mod( 'packers_and_movers_about_call' ) != '') { ?>
                                          <div class="main-abt-contact-box">
                                            <div class="about-call-icon me-3"><i class="fas fa-phone"></i></div>
                                            <div class="about-contact-text">
                                                <p class="call-text mb-1 text-start"><?php echo esc_html( get_theme_mod('packers_and_movers_call_text','') ); ?></p>
                                                <p class="call-simplep mb-0 text-start"><a href="tel:<?php echo esc_html(get_theme_mod('packers_and_movers_about_call')); ?>">
                                                    <?php echo esc_html(get_theme_mod('packers_and_movers_about_call')); ?></a>
                                                </p>
                                            </div>
                                          </div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endwhile;
                    wp_reset_postdata();
                endif;
            endif; ?>
        </div>
    </section>
<?php endif; ?>
