<?php 
/**
 * Template part for displaying Services Section
 *
 *@package Party Planner Bell
 */

    $services_top_title       =party_planner_bell_get_option( 'services_top_title' );
    $services_top_content       =party_planner_bell_get_option( 'services_top_content' );
    $services_title       =party_planner_bell_get_option( 'services_title' );
    $services_subtitle       =party_planner_bell_get_option( 'services_subtitle' );
    $services_background_image       =party_planner_bell_get_option( 'services_background_image' );
    $disable_services_background     =party_planner_bell_get_option( 'disable_services_background' );
    $services_content_type     =party_planner_bell_get_option( 'services_content_type' );
    $number_of_services_column =party_planner_bell_get_option( 'number_of_services_column' );
    $number_of_services_items  =party_planner_bell_get_option( 'number_of_services_items' );
    $services_category =party_planner_bell_get_option( 'services_category' );
    $disable_services_icon =party_planner_bell_get_option( 'disable_services_icon' );
    $btn_url =party_planner_bell_get_option( 'services_btn_url');
    $btn_text =party_planner_bell_get_option( 'services_btn_text');
    $services_content   =party_planner_bell_get_option( 'services_content_enable' );
    $services_header_font_size =party_planner_bell_get_option( 'services_font_size');
    $services_content_font_size =party_planner_bell_get_option( 'services_content_font_size');
    $services_subtitle_font_size =party_planner_bell_get_option( 'services_subtitle_font_size');
    $services_section_header_font_size =party_planner_bell_get_option( 'services_section_header_font_size');
    $excerpt_length =party_planner_bell_get_option( 'services_excerpt_length');
    $services_content_align       =party_planner_bell_get_option( 'services_content_align' );
    $home_layout = party_planner_bell_get_option( 'homepage_design_layout_options');
    for( $i=1; $i<=$number_of_services_items; $i++ ) :
        $services_page_posts[] = absint(party_planner_bell_get_option( 'services_page_'.$i ) );
        $services_post_posts[] = absint(party_planner_bell_get_option( 'services_post_'.$i ) );
        $readmore_text   =party_planner_bell_get_option( 'services_custom_text_' . $i );
        $services_icon   =party_planner_bell_get_option( 'services_icon_'.$i );
    endfor;
    $icon_class='';
    if ( ( false == $disable_services_icon )){
        $icon_class='disable-services-icon';
    }
    ?> 
    <style>
        <?php if ($services_subtitle_font_size != 0): ?>
            #services .section-subtitle{
                font-size:<?php echo esc_html($services_subtitle_font_size); ?>px;
            }
        <?php endif ?>
        <?php if ($services_section_header_font_size != 0): ?>
            #services .section-title{
                font-size:<?php echo esc_html($services_section_header_font_size); ?>px;
            }
        <?php endif ?>

        <?php if ($services_header_font_size != 0): ?>
            #services .entry-title{
                font-size:<?php echo esc_html($services_header_font_size); ?>px;
            }
        <?php endif ?>
        <?php if ($services_content_font_size != 0): ?>
            #services .entry-content p{
                font-size:<?php echo esc_html($services_content_font_size); ?>px;
            }
        <?php endif ?>
    </style>
<div class="services-top">
    <div class="services-top-left">
        <?php party_planner_bell_leaf_shape(); ?>
        <?php if( !empty($services_top_title)):?>
            <h2 class="section-title"><?php echo esc_html($services_top_title);?></h2>
        <?php endif;?>
        <?php if (!empty($services_top_content)): ?>
            <p class="section-subtitle"><?php echo esc_html($services_top_content);?></p>
        <?php endif; ?>
        <?php if ( !empty( $btn_text ) && !empty($btn_url) ) : ?>
            <div class="read-more">
                <a href="<?php echo esc_url( $btn_url ); ?>" class="btn btn-primary" ><?php echo esc_html( $btn_text );  ?></a>
            </div>
        <?php endif; ?>
    </div>
    <div class="services-top-right">
        <?php for ($i=1; $i <=4 ; $i++) { ?>
            <?php $services_top_image =party_planner_bell_get_option( 'services_top_image_'.$i ); ?>
            <?php if (!empty($services_top_image)) { ?>
                <article class="services-image-<?php echo $i; ?>">
                    <img src="<?php echo esc_url($services_top_image); ?>">
                </article>
            <?php } ?>
        <?php } ?>
    </div>
</div>
<div class="services-post">    
    <div class="section-content col-<?php echo esc_attr( $number_of_services_column ); ?>">
            <?php 
                $args = array (
                    'post_type'     => 'post',
                    'post_per_page' => count( $services_post_posts ),
                    'post__in'      => $services_post_posts,
                    'orderby'       =>'post__in', 
                    'ignore_sticky_posts' => true, 
                ); 
            
            $loop = new WP_Query($args);                        
            if ( $loop->have_posts() ) :
                $i=0;  
                while ($loop->have_posts()) : $loop->the_post(); $i++;?>
                        <?php $services_post_bg_color = party_planner_bell_get_option( 'services_post_background_color_'.$i ); ?>

                        <article class="<?php echo esc_attr($services_content_align); ?> <?php echo esc_attr($icon_class); ?>">

                            <div class="services-item-wrapper">
                            <?php 
                             $cloud_enable =party_planner_bell_get_option('disable_homepage_cloud_section');
                             $icon_cloud =party_planner_bell_get_option('disable_icon_cloud');
                            $services_icon =party_planner_bell_get_option( 'services_icon_'.$i );
                            if ( ( true == $disable_services_icon ) && !empty($services_icon) ) { ?>
                                <div class="icon-container">
                                    <a href="<?php the_permalink();?>">
                                        <i class="fa <?php echo esc_attr( $services_icon)?>"></i> 
                                    </a>
                                </div>
                            <?php  } ?>
                            <?php if ( ( has_post_thumbnail() ) && ( false == $disable_services_icon )  ) : ?>
                                <div class="featured-image">
                                    <img src="<?php the_post_thumbnail_url('large'); ?>"/>
                                </div><!-- .featured-image -->
                            <?php endif; ?>
                            <div class="services-content <?php echo esc_attr($services_content_align); ?>">
                                <header class="entry-header">
                                    <h2 class="entry-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                                </header>
                                <?php if ($services_content == true): ?>
                                    <div class="entry-content">
                                        <?php
                                            $excerpt = party_planner_bell_the_excerpt( $excerpt_length );
                                            echo wp_kses_post( wpautop( $excerpt ) );
                                        ?>
                                    </div><!-- .entry-content -->
                                <?php endif ?>
                            </div>
                          </div>
                        </article>
                <?php endwhile;?>
            <?php endif; ?>
        <?php wp_reset_postdata(); ?>
    </div> 
</div>
