<?php
/**
 * Attendee page template.
 *
 * @link https://www.fooevents.com
 * @package woocommerce-events
 */

?>
<?php $this->output_errors( $errors ); ?>
<div class="woocommerce-page woocommerce" id="fooevents-attendee-page">
<form method="post" class="woocommerce form woocommerce-form">
	<?php foreach ( $event_attendee_items as $event_id => $event_item ) : ?>
		<?php if ( $event_item['capture_attendees'] ) : ?>
			<div id="fooevents-attendee-group-<?php echo esc_attr( $event_id ); ?>" class="fooevents-attendee-group fooevents-attendee-group-event-<?php echo esc_attr( $event_id ); ?>">
				<?php echo '<h2>' . esc_attr( get_the_title( $event_id ) ) . '</h2>'; ?>
				<?php $attendee = 1; ?>
				<?php foreach ( $event_item['items'] as $cart_item_key => $event ) : ?>
					<?php for ( $i = 0; $i < $event['quantity']; $i++ ) : ?>
						<div id="fooevents-attendee-<?php echo esc_attr( $event_id ); ?>" class="fooevents-attendee-item">
							<h3>
								<?php echo esc_attr__( 'Attendee', 'woocommerce-events' ) . ' ' . esc_attr( $attendee ); ?>
								<?php if ( $event['variation_id'] ) : ?>
									<?php $this->fooevents_form->variation( $event ); ?>
								<?php endif; ?>
							</h3>
							<?php if ( $this->fs ) : ?>
								<?php $this->fs->output_form( $event, $attendee, $prev_post ); ?>
							<?php endif; ?>
							<?php if ( $this->fb ) : ?>
								<?php $this->fb->output_form( $event, $attendee, $prev_post ); ?>
							<?php endif; ?>
							<?php if ( 'on' === $event['WooCommerceEventsCaptureAttendeeDetails'] ) : ?>
								<p class="form-row form-row-first">
									<?php $this->fooevents_form->text( 'first_name', __( 'First Name', 'woocommerce-events' ), 'text', 'required', $event, $attendee, $prev_post ); ?>
								</p>
								<p class="form-row form-row-last">
									<?php $this->fooevents_form->text( 'last_name', __( 'Last Name', 'woocommerce-events' ), 'text', 'required', $event, $attendee, $prev_post ); ?>
								</p>
							<?php endif; ?>
							<?php if ( 'on' === $event['WooCommerceEventsCaptureAttendeeEmail'] ) : ?>
								<p class="form-row form-row-wide">
									<?php $this->fooevents_form->text( 'email', __( 'Email', 'woocommerce-events' ), 'text', 'required', $event, $attendee, $prev_post ); ?>
								</p>
							<?php endif; ?>
							<?php if ( 'on' === $event['WooCommerceEventsCaptureAttendeeTelephone'] ) : ?>
								<p class="form-row form-row-wide">
									<?php $this->fooevents_form->text( 'telephone', __( 'Telephone', 'woocommerce-events' ), 'tel', 'required', $event, $attendee, $prev_post ); ?>
								</p>
							<?php endif; ?>
							<?php if ( 'on' === $event['WooCommerceEventsCaptureAttendeeCompany'] ) : ?>
								<p class="form-row form-row-wide">
									<?php $this->fooevents_form->text( 'company', __( 'Company', 'woocommerce-events' ), 'text', 'required', $event, $attendee, $prev_post ); ?>
								</p>
							<?php endif; ?>
							<?php if ( 'on' === $event['WooCommerceEventsCaptureAttendeeDesignation'] ) : ?>
								<p class="form-row form-row-wide">
									<?php $this->fooevents_form->text( 'designation', __( 'Designation', 'woocommerce-events' ), 'text', 'required', $event, $attendee, $prev_post ); ?>
								</p>
							<?php endif; ?>
							<?php if ( $this->fcaf ) : ?>
								<?php $this->fcaf->output_form( $event, $attendee, $prev_post ); ?>
							<?php endif; ?>
							<?php if ( $copy_purchaser ) : ?>
								<?php $this->fooevents_form->copy( $event, $attendee, $copy_purchaser, $event_item ); ?>
							<?php endif; ?>

							<?php ++$attendee; ?>
						</div>
					<?php endfor; ?>
				<?php endforeach; ?>
			</div>
		<?php endif; ?>
	<?php endforeach; ?>
	<?php wp_nonce_field( 'fooevents_attendee_details_page', 'fooevents_attendee_nonce' ); ?>
	<p class="form-row form-row-wide">
		<button type="submit" name="fooevents_submit_attendees" class="button alt wp-element-button"><?php esc_attr_e( 'Proceed to checkout', 'woocommerce-events' ); ?></button>
	</p>
</form>
</div>
