<?php
/**
 * Basic Forms - Entry Detail (for modal)
 *
 * @package BasicForms
 * @since 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="wpps-bf-entry-detail">
	<div class="wpps-bf-entry-meta">
		<div class="wpps-bf-entry-meta-item">
			<span class="wpps-bf-entry-meta-label"><?php esc_html_e( 'Entry ID', 'wp-powersuite' ); ?></span>
			<span class="wpps-bf-entry-meta-value">#<?php echo (int) $entry->id; ?></span>
		</div>
		<div class="wpps-bf-entry-meta-item">
			<span class="wpps-bf-entry-meta-label"><?php esc_html_e( 'Form', 'wp-powersuite' ); ?></span>
			<span class="wpps-bf-entry-meta-value"><?php echo esc_html( $form->post_title ?? '' ); ?></span>
		</div>
		<div class="wpps-bf-entry-meta-item">
			<span class="wpps-bf-entry-meta-label"><?php esc_html_e( 'Date', 'wp-powersuite' ); ?></span>
			<span class="wpps-bf-entry-meta-value"><?php echo esc_html( gmdate( 'F j, Y \a\t g:i A', strtotime( $entry->date_created ) ) ); ?></span>
		</div>
		<?php if ( ! empty( $entry->user_ip ) ) : ?>
		<div class="wpps-bf-entry-meta-item">
			<span class="wpps-bf-entry-meta-label"><?php esc_html_e( 'IP Address', 'wp-powersuite' ); ?></span>
			<span class="wpps-bf-entry-meta-value"><?php echo esc_html( $entry->user_ip ); ?></span>
		</div>
		<?php endif; ?>
	</div>
	<div class="wpps-bf-entry-data">
		<h3><?php esc_html_e( 'Form Data', 'wp-powersuite' ); ?></h3>
		<table class="widefat striped">
			<thead>
				<tr>
					<th style="width:30%"><?php esc_html_e( 'Field', 'wp-powersuite' ); ?></th>
					<th><?php esc_html_e( 'Value', 'wp-powersuite' ); ?></th>
				</tr>
			</thead>
			<tbody>
			<?php foreach ( $data as $label => $value ) : ?>
				<tr>
					<td class="wpps-bf-entry-label"><?php echo esc_html( $label ); ?></td>
					<td class="wpps-bf-entry-value"><?php echo \BasicForms\FormFileStorage::normalizeReferences( $value ) !== [] ? \BasicForms\FormFileStorage::formatValueForAdmin( $value, (int) $entry->id ) : nl2br( esc_html( is_array( $value ) ? implode( ', ', $value ) : (string) $value ) ); ?></td>
				</tr>
			<?php endforeach; ?>
			</tbody>
		</table>
	</div>
</div>
