<?php
$class = isset($args['class']) ? $args['class'] : '';
$category = isset($args['category']) ? $args['category'] : '';
$query_args = array(
    'post_type'           => 'industry',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page'      => -1,
    'orderby'             => 'menu_order',
    'order'               => 'ASC',
    'tax_query'           => array(array(
        'taxonomy' => 'industry_categories',
        'field'    => 'slug',
        'terms'    => $category ? $category : 'all',
        'operator' => 'IN'
    ))
);

$industries = new WP_Query($query_args);

?>


<?php if ($industries->have_posts()) : ?>

<section class="section benefiting-bigcommerce-wms <?php echo $class?>">
    <div class="container-fluid">
       <div class="row">
           <div class="col-xl-5 col-lg-12">
               <div class="text-cont">
                    <h2 class="section-title">
                        <?php echo get_field('industry_benefits_section_title'); ?>
                    </h2>
                    <?php if(get_field('industry_benefits_section_text')) : ?>
                    <div class="image">
                        <img src="<?php echo get_field('industry_benefits_section_image'); ?>" alt="<?php echo strip_tags(get_the_title()); ?>" class="img-fluid">
                    </div>
                    <?php endif;?>
                    <p class="section-content"><?php echo get_field('industry_benefits_section_text'); ?></p>
                    <?php $cta = get_field('industry_benefits_section_button'); 
                    if($cta):
                    ?>
                    <a href="<?php echo esc_url($cta['url']); ?>" class="primary animated-btn mt-4" <?php echo is_modal_link($cta['url']); ?>><?php echo $cta['title']; ?></a>
                    <?php endif; ?>
                    <!-- <div class="slide-owl-nav d-none d-xl-flex">
                        <button class="slide-prev-button">
                            <img src='<?php // echo get_template_directory_uri(); ?>/assets/img/left-arrow.webp'>
                        </button>
                        <button class="slide-next-button">
                            <img src='<?php // echo get_template_directory_uri(); ?>/assets/img/right-arrow.webp'>
                        </button>
                    </div> -->
               </div>
           </div>
           <div class="col-xl-7 col-lg-12 pe-md-0">
               <div class="owl-carousel owl-theme bigcommerce-industries-slider">
                        <?php $i = 1; while ($industries->have_posts()) : $industries->the_post(); ?>
                            <div class="item">
                                <div class="card h-100">
                                    <div class="img-content">
                                        <img src="<?php echo get_field('industry_image'); ?>" alt="<?php echo strip_tags(get_the_title()); ?>" class="img-fluid">
                                        <h4><?php echo get_the_title(); ?></h4>
                                    </div>
                                    <div class="text-content">
                                        <div class="left">
                                            <span><?php echo $i < 10 ? '0' . $i : $i;?></span>
                                        </div>
                                        <div class="right">
                                            <h3><?php echo get_the_title(); ?></h3>
                                            <?php echo wpautop( get_the_content() ); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php $i++; endwhile; ?>
                            <?php wp_reset_postdata(); ?>
               </div>
               <!-- <div class="slide-owl-nav d-xl-none d-flex">
                   <button class="slide-prev-button">
                       <img src='<?php // echo get_template_directory_uri(); ?>/assets/img/left-arrow.webp'>
                   </button>
                   <button class="slide-next-button">
                       <img src='<?php // echo get_template_directory_uri(); ?>/assets/img/right-arrow.webp'>
                   </button>
               </div> -->
           </div>
       </div>
    </div>
</section>

<?php endif; ?>