<?php 
$about_section = get_theme_mod( 'advance_education_pro_events_enabledisable' );
if ( 'Disable' == $about_section ) {
  return;
}
if( get_theme_mod('advance_education_pro_events_bg_color') ) {
  $about_backg = 'background-color:'.esc_attr(get_theme_mod('advance_education_pro_events_bg_color')).';';
}elseif( get_theme_mod('advance_education_pro_events_bgimage') ){
  $about_backg = 'background-image:url(\''.esc_url(get_theme_mod('advance_education_pro_events_bgimage')).'\')';
}else{
  $about_backg = '';
}
$att_style="";
$image_att = get_theme_mod( 'advance_education_pro_events_bgimage_attachment',true );
if ( 'Scroll' == $image_att ) {
  $att_style="section_bg_scroll";
}else{
  $att_style="section_bg_fixed";
}   
?>
<section id="events" style="<?php echo esc_html($about_backg); ?>"class="<?php echo esc_attr($att_style); ?>">
  <div class="container">
    <?php if(get_theme_mod('advance_education_pro_events_sec_title') != '' || get_theme_mod('advance_education_pro_events_sec_subtitle') != ''){?>
      <div class="section-heading">
        <h3> 
          <?php if(get_theme_mod('advance_education_pro_title_icon')){
              ?> <i class="<?php echo esc_html(get_theme_mod('advance_education_pro_title_icon')) ?>"></i><?php
            }?>
            <?php echo esc_html(get_theme_mod('advance_education_pro_events_sec_title')); ?></h3>
        <p><?php echo esc_html(get_theme_mod('advance_education_pro_events_sec_subtitle'))?></p>
      </div>
    <?php } ?>
    <?php if ( defined( 'ADVANCE_EDUCATION_PRO_POSTTYPE_VERSION' ) ) { ?>
    <?php $count =  get_theme_mod('advance_education_pro_events_number'); ?>
            <?php 
              $args = array(
              'post_type' => 'events',
              'post_status' => 'publish',
              'posts_per_page' => $count
            ); 
            $query = new WP_Query($args);
            if ( $query->have_posts() ) :  while ($query->have_posts()) : $query->the_post(); ?>
            <div class="our_events_box">
              <div class="container">
                <div class=row>
                  <div class="col-lg-2 col-md-2 col-sm-12 col-12">
                    <div class="events_date">
                      <?php if(get_post_meta($post->ID,'advance_education_pro_events_date',true) != '') {?>
                        <span class="date"><?php echo esc_html(get_post_meta($post->ID,'advance_education_pro_events_date',true))?></span>
                      <?php } ?>
                      <?php if(get_post_meta($post->ID,'advance_education_pro_events_month',true) != '') {?>
                        <p class="month"><?php echo esc_html(get_post_meta($post->ID,'advance_education_pro_events_month',true))?></p>
                      <?php } ?>
                      <?php if(get_post_meta($post->ID,'advance_education_pro_events_year',true) != '') {?>
                        <span class="year"><?php echo esc_html(get_post_meta($post->ID,'advance_education_pro_events_year',true))?></span>
                      <?php } ?>
                    </div>
                  </div>
                  <div class="col-lg-6 col-md-6 col-sm-12 col-12">
                    <?php if(get_post_meta($post->ID,'advance_education_pro_location',true) != '') {?>
                        <span class="location"><i class="fas fa-map-marker-alt"></i><?php echo esc_html(get_post_meta($post->ID,'advance_education_pro_location',true))?></span>
                    <?php } ?>
                    <?php if(get_post_meta($post->ID,'advance_education_pro_time',true) != '') {?>
                        <span class="time"><i class="far fa-clock"></i><?php echo esc_html(get_post_meta($post->ID,'advance_education_pro_time',true))?></span>
                    <?php } ?>
                    <div class="events_title">
                      <h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    </div>
                    <p class="subtitle"><?php $excerpt = get_the_excerpt(); echo esc_html(advance_education_pro_string_limit_words($excerpt,12)); ?></p>
                  </div>
                  <div class="col-lg-4 col-md-4 col-sm-12 col-12">
                     <div class="image-box media">
                      <?php the_post_thumbnail(); ?>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <?php endwhile; wp_reset_postdata();?>
              <?php else : ?>
                <h5 class="text-center"><?php esc_html_e('Post Not Added','advance-education-pro'); ?></h5>
            <?php endif; ?>
    <?php } else{ ?>
      <h3 class="text-center"><?php echo esc_html_e('Please install Advance Education Pro Posttype plugin and add your Events to enable this section','advance-education-pro')?></h3>
    <?php }?>
    <div class="events-btn">
        <?php if(get_theme_mod('advance_education_pro_events_view_button_text') != '') {?>
                    <a class="events-btn" href="<?php echo esc_html(get_theme_mod('advance_education_pro_events_view_more_button_link')); ?>"><?php echo esc_html(get_theme_mod('advance_education_pro_events_view_button_text'))?></a>
        <?php } ?>
    </div>
    <div class="clearfix"></div>
  </div>
</section>
