<?php
/**
 * Template part for displaying the about section
 *
 * @package Industrial Hub
 * @subpackage industrial_hub
 */

$industrial_hub_static_image = get_template_directory_uri() . '/assets/images/about-img.png';

if ( get_theme_mod( 'industrial_hub_about_enable', true)) : ?>
    <section id="about" class="py-lg-5 py-md-3 py-3 px-md-0 px-3" style="background-image: url('<?php echo get_stylesheet_directory_uri(); ?>/assets/images/about-bg.png');">
        <div class="container">
            <?php
            // Fetch about page ID from customizer
            $industrial_hub_about_page_id = absint( get_theme_mod( 'industrial_hub_about_page' ) );
            // Check if a valid page is set for the about section
            if ( $industrial_hub_about_page_id ) :
                $industrial_hub_args = array(
                    'post_type' => 'page',
                    'p'         => $industrial_hub_about_page_id,
                );
                $industrial_hub_query = new WP_Query( $industrial_hub_args );
                // Check if the query has posts
                if ( $industrial_hub_query->have_posts() ) :
                    while ( $industrial_hub_query->have_posts() ) : $industrial_hub_query->the_post(); ?>
                        <div class="row">
                            <div class="col-lg-7 col-md-6 align-self-center ps-lg-5">
                                <div class="match-heading">
                                    <?php 
                                    $industrial_hub_sub_heading = get_theme_mod( 'industrial_hub_service_sub_heading' );
                                    if ( $industrial_hub_sub_heading ) : ?>
                                        <p class="mb-md-3 mb-2 abt-title text-uppercase"><i class="fas fa-building"></i><span><?php echo esc_html( $industrial_hub_sub_heading ); ?></span></p>
                                    <?php endif; ?>
                                    <h2 class="mb-4 text-capitalize">
                                        <a href="<?php the_permalink(); ?>"><?php the_title();?></a>
                                    </h2>
                                </div>
                                <p class="mb-lg-4 mb-3 abt-content"><?php echo esc_html( wp_trim_words( get_the_content(), 40, '...' ) ); ?></p>
                                <?php if ( get_theme_mod( 'industrial_hub_tab_heading1' ) || get_theme_mod( 'industrial_hub_tab_heading2' ) ) : ?>
                                    <div class="row">
                                        <?php for ( $industrial_hub_i = 1; $industrial_hub_i <= 4; $industrial_hub_i++ ) : ?>
                                            <?php 
                                            $industrial_hub_tab_heading = get_theme_mod( 'industrial_hub_tab_heading' . $industrial_hub_i );
                                            $industrial_hub_tab_icon = esc_attr( get_theme_mod( 'industrial_hub_tab_icon' . $industrial_hub_i, 'fas fa-cog' ) );
                                            ?>
                                            <?php if ( $industrial_hub_tab_heading ) : ?>
                                                <div class="col-lg-6 col-md-12 align-self-center"> <!-- Column -->
                                                    <div class="tab-details my-2 d-flex align-items-center">
                                                        <?php if ( $industrial_hub_tab_icon ) : ?>
                                                            <i class="me-lg-3 me-2 <?php echo $industrial_hub_tab_icon; ?>"></i>
                                                        <?php endif; ?>
                                                        <h3 class="our-servs mb-0"><?php echo esc_html( $industrial_hub_tab_heading ); ?></h3>
                                                    </div>
                                                </div>
                                            <?php endif; ?>
                                        <?php endfor; ?>
                                    </div>
                                <?php endif; ?>
                                <div class="about-contact my-md-4 my-3">
                                    <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( 'Explore More', 'industrial-hub' ); ?></span><i class="fas fa-arrow-right"></i>
                                        </a>
                                    </div>
                                    <div class="call my-lg-0 my-3">
                                        <?php if( get_theme_mod( 'industrial_hub_about_call_text' ) != '' || get_theme_mod( 'industrial_hub_about_call' ) != '') { ?>
                                          <div class="main-abt-contact-box">
                                            <div class="about-call-icon me-3"><i class="fas fa-phone-volume"></i></div>
                                            <div class="about-contact-text">
                                                <p class="call-text mb-0 text-start"><?php echo esc_html( get_theme_mod('industrial_hub_about_call_text','') ); ?></p>
                                                <p class="call-simplep mb-0 text-start"><a href="tel:<?php echo esc_html(get_theme_mod('industrial_hub_about_call')); ?>">
                                                    <?php echo esc_html(get_theme_mod('industrial_hub_about_call')); ?></a>
                                                </p>
                                            </div>
                                          </div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3 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( $industrial_hub_static_image ); ?>" alt="<?php esc_attr_e( 'Placeholder', 'industrial-hub' ); ?>" />
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                                <?php 
                                $industrial_hub_total_yr_experience = get_theme_mod( 'industrial_hub_total_yr_experience', '' );
                                if ( $industrial_hub_total_yr_experience ) : ?>
                                    <div class="satified-box mb-md-0 mb-2">
                                    <div class="start-yr-content">
                                        <div class="start-yr mb-2"><?php echo esc_html( $industrial_hub_total_yr_experience ); ?></div>
                                        <div class="year-text mt-3"><?php esc_html_e( 'Years Of Experience', 'industrial-hub' ); ?></div>
                                    </div>
                                    </div>
                                <?php endif; ?>
                            </div>
                            <div class="col-lg-2 col-md-2 align-self-center abt-bg-img mb-3 ps-lg-3 ps-md-0">
                                <div class="our-progess">
                                    <?php if (get_theme_mod('industrial_hub_total_no_project_completed') != '') { ?>
                                        <div class="customer-counter my-lg-5 my-4">
                                            <div class="customer-no"><?php echo esc_html(get_theme_mod('industrial_hub_total_no_project_completed', '')); ?></div>
                                            <div class="centers-text"><?php esc_html_e('Project Completed', 'industrial-hub'); ?></div>
                                        </div>
                                    <?php } ?>
                                    <?php if (get_theme_mod('industrial_hub_total_no_skilled_contractors') != '') { ?>
                                        <div class="customer-counter my-lg-5 my-4">
                                            <div class="customer-no"><?php echo esc_html(get_theme_mod('industrial_hub_total_no_skilled_contractors', '')); ?></div>
                                            <div class="centers-text"><?php esc_html_e('Skilled Contractors', 'industrial-hub'); ?></div>
                                        </div>
                                    <?php } ?>
                                    <?php if (get_theme_mod('industrial_hub_total_no_industriese_served') != '') { ?>
                                        <div class="customer-counter my-lg-5 my-4">
                                            <div class="customer-no"><?php echo esc_html(get_theme_mod('industrial_hub_total_no_industriese_served', '')); ?></div>
                                            <div class="centers-text"><?php esc_html_e('Industries Served', 'industrial-hub'); ?></div>
                                        </div>
                                    <?php } ?>
                                    <?php if (get_theme_mod('industrial_hub_total_no_satisfied_clients') != '') { ?>
                                        <div class="customer-counter my-lg-5 my-4">
                                            <div class="customer-no"><?php echo esc_html(get_theme_mod('industrial_hub_total_no_satisfied_clients', '')); ?></div>
                                            <div class="centers-text"><?php esc_html_e('satisfied clients', 'industrial-hub'); ?></div>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    <?php endwhile;
                    wp_reset_postdata();
                endif;
            endif; ?>
        </div>
    </section>
<?php endif; ?>
