<?php
/**
 * The template for the CONTENT of the "View Visitor" modal.
 */
if ( ! defined( 'ABSPATH' ) ) exit;

// Note: The $attendee and $booking variables are passed here from the view_visitor() Ajax method.
?>
<div class="view activities-view">
    <div class="sidebar">
        <div class="module-wrapper">
            <div class="module">
                <ul class="list-unstyled filter-list">
                    <li class="active"><a><?php _e('Name', 'event-monster'); ?></a></li>
                    <li><a><?php echo esc_html($attendee->first_name . " " . $attendee->last_name); ?></a></li>

                    <li class="active"><a><?php _e('Email', 'event-monster'); ?></a></li>
                    <li><a><?php echo esc_html($attendee->email); ?></a></li>

                    <?php if( !empty($attendee->phone) ) : ?>
                        <li class="active"><a><?php _e('Phone', 'event-monster'); ?></a></li>
                        <li><a><?php echo esc_html($attendee->phone); ?></a></li>
                    <?php endif; ?>

                    <li class="active"><a><?php _e('Event', 'event-monster'); ?></a></li>
                    <li><a><?php echo get_the_title($attendee->event_id); ?></a></li>

                    <li class="active"><a><?php _e('Tickets & Quantity', 'event-monster'); ?></a></li>
                    <?php
                    $ticket_ids = maybe_unserialize($booking->ticket_id);
                    if (is_array($ticket_ids) && !empty($ticket_ids)) {
                        global $wpdb;
                        foreach($ticket_ids as $id => $quantity) { 
                            if( !empty($quantity) ) {
                                $ticket_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM `{$wpdb->prefix}em_tickets` WHERE id = %d", $id));
                                if ($ticket_name) {
                                    echo '<li><a>' . esc_html($ticket_name) . ' (' . esc_html($quantity) . ')</a></li>';
                                }
                            }
                        }
                    }
                    ?>
                </ul>
            </div>
        </div>
    </div>
</div>