<?php 
/**
 * Template part for displaying Upcoming Events Section
 *
 *@package Rock Singer
 */
    $upcoming_events_section_subtitle        = rock_singer_get_option( 'upcoming_events_section_subtitle' );
    $upcoming_events_section_title           = rock_singer_get_option( 'upcoming_events_section_title' );
    $number_of_upcoming_events_items         = rock_singer_get_option( 'number_of_upcoming_events_items' ); ?>

    <?php if( !empty($upcoming_events_section_title) || !empty($upcoming_events_section_subtitle) ): ?>
        <div class="section-header">
            <?php if( !empty($upcoming_events_section_subtitle) ): ?>
                <h3 class="section-subtitle"><?php echo esc_html($upcoming_events_section_subtitle);?></h3>
            <?php endif; ?>
            
            <?php if( !empty($upcoming_events_section_title) ): ?>
                <h2 class="section-title"><?php echo esc_html($upcoming_events_section_title);?></h2>
            <?php endif; ?>
        </div><!-- .section-header -->
    <?php endif; ?>

    <div class="section-content col-3 clear">
        <?php for( $i=1; $i<=$number_of_upcoming_events_items; $i++ ) : 
            $upcoming_events_image[$i]              = rock_singer_get_option( 'upcoming_events_image_'.$i );
            $upcoming_events_title[$i]              = rock_singer_get_option( 'upcoming_events_title_'.$i );
            $upcoming_events_location[$i]           = rock_singer_get_option( 'upcoming_events_location_'.$i );
            $upcoming_events_date[$i]               = rock_singer_get_option( 'upcoming_events_date_'.$i );
            $upcoming_events_time[$i]               = rock_singer_get_option( 'upcoming_events_time_'.$i );
            $upcoming_events_button_label[$i]       = rock_singer_get_option( 'upcoming_events_button_label_'.$i );
            $upcoming_events_button_url[$i]         = rock_singer_get_option( 'upcoming_events_button_url_'.$i );
        ?>          
            
        <article>
            <div class="event-item">
                <div class="featured-image" style="background-image: url('<?php echo esc_url($upcoming_events_image[$i]); ?>');">
                </div><!-- .featured-image -->

                <div class="entry-container">
                    <?php if( !empty($upcoming_events_title[$i]) || !empty($upcoming_events_location[$i]) ):?>
                        <header class="entry-header">
                            <?php if( !empty($upcoming_events_title[$i]) ):?>
                                <h2 class="entry-title"><?php echo esc_html( $upcoming_events_title[$i] ); ?></h2>
                            <?php endif; ?>

                            <?php if( !empty($upcoming_events_location[$i]) ): ?>
                                <p><?php echo esc_html( $upcoming_events_location[$i] ); ?></p>
                            <?php endif; ?>
                        </header>
                    <?php endif; ?>

                        <?php if( !empty($upcoming_events_date[$i]) || !empty($upcoming_events_time[$i]) ): ?>
                            <div class="event-date">
                                <span><?php echo esc_html( $upcoming_events_date[$i] ); ?></span>
                                <span><?php echo esc_html( $upcoming_events_time[$i] ); ?></span>
                            </div><!-- .event-date -->
                        <?php endif; ?>

                    <?php if( !empty($upcoming_events_button_label[$i]) ):?>
                        <div class="event-tickets">
                            <a href="<?php echo esc_html( $upcoming_events_button_url[$i] ); ?>" class="btn"><?php echo esc_html( $upcoming_events_button_label[$i] ); ?><i class="fa-solid fa-arrow-up-right-from-square"></i></a>
                        </div><!-- .event-tickets -->
                    <?php endif; ?>
                </div><!-- .entry-container -->
            </div><!-- .event-item -->
        </article>
        <?php endfor; ?>
    </div><!-- .section-content -->