<?php
/**
 * Ticket themes viewer template
 *
 * @link https://www.fooevents.com
 * @package woocommerce_events
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="wrap">
	<h1 class="wp-heading-inline"><?php esc_attr_e( 'Ticket Themes', 'woocommerce-events' ); ?></h1><button type="button" class="upload-view-toggle page-title-action fooevents-upload-view-toggle"><?php esc_attr_e( 'Upload Ticket Theme', 'woocommerce-events' ); ?></button>
</div>
<?php add_thickbox(); ?> 

<div id="fooevents-theme-viewer-upload-wrapper">
	<p class="install-help"></p>
	<div class="fooevents-theme-viewer-upload-inner">
		<form name="fooevents-theme-viewer-upload-form" action="admin.php?page=fooevents-ticket-themes" method="POST" enctype="multipart/form-data">
			<div>
				<h3><?php esc_attr_e( 'Upload Ticket Theme', 'woocommerce-events' ); ?></h3>
				<p><?php esc_attr_e( 'Upload a ticket theme ZIP file to add or update a ticket theme.', 'woocommerce-events' ); ?></p>
				<div class="fooevents-theme-viewer-uploader">
					<input type="file" name="fooevents-theme-viewer-upload-file" class="fooevents-theme-viewer-upload-file" />
					<input type="submit" value="<?php esc_attr_e( 'Upload', 'woocommerce-events' ); ?>" class="button button-primary" />
					<div class="clear clearfix"></div>
				</div>
				<label>
					<input type="checkbox" name="fooevents-overwrite-confirm" id="fooevents-overwrite-confirm" value="1" /> 
					<?php esc_attr_e( 'Overwrite ticket themes with matching folder names.', 'woocommerce-events' ); ?>
				</label>

				<div id="fooevents-overwrite-notice" style="display: none">
					<strong><?php esc_attr_e( 'Important:', 'woocommerce-events' ); ?></strong> <?php esc_attr_e( 'When uploading ticket theme updates, any ticket theme modifications will be overwritten. If you have modified the ticket theme, download a backup of the ticket theme first.', 'woocommerce-events' ); ?>
				</div>

				<?php wp_nonce_field( 'fooevents_upload_theme' ); ?>
			</div>
		</form>
	</div> 
</div>

<div id="fooevents-theme-viewer-wrapper">
<?php foreach ( $themes as $theme_name => $theme ) : ?>
	<div class="fooevents-theme-viewer-theme">
	<div class="fooevents-theme-viewer-theme-inner">
		<div id="fooevents-theme-viewer-preview-options-<?php echo esc_attr( $theme['file_name'] ); ?>" style="display:none;" class="fooevents-theme-viewer-preview-popup" >
			<div class="fooevents-theme-viewer-preview-controls">
				<form name="fooevents-theme-viewer-preview-form-<?php echo esc_attr( $theme['file_name'] ); ?>" action="admin.php?page=fooevents-ticket-themes" method="POST">
					<br />
					<input type="text" value="<?php echo esc_attr( $user_email ); ?>" name="fooevents-theme-viewer-preview-input" class="regular-text" />
					<input type="submit" value="<?php esc_attr_e( 'Send Ticket Preview', 'woocommerce-events' ); ?>" name="fooevents-theme-viewer-preview-submit" class="button button-primary" />
				
				<input type="hidden" value="<?php echo esc_attr( $theme['path'] ); ?>" name="fooevents-theme-viewer-preview-path" />
				<input type="hidden" value="<?php echo esc_attr( $theme_name ); ?>" name="fooevents-theme-viewer-preview-theme-name" />
				</form>
			</div>
			<img src="<?php echo esc_attr( $theme['preview'] ); ?>" class="fooevents-theme-viewer-image-preview" />
		</div>
		<div class="fooevents-theme-viewer-preview-wrapper">
			<a href="#TB_inline?width=800&height=520&inlineId=fooevents-theme-viewer-preview-options-<?php echo esc_attr( $theme['file_name'] ); ?>" class="thickbox"  title="<?php echo esc_attr_e( 'Ticket Theme Preview', 'woocommerce-events' ); ?>" >
			<img src="<?php echo esc_attr( $theme['preview'] ); ?>" class="fooevents-theme-viewer-image">
			</a>
		</div>
		<?php if ( $theme['update_available'] ) : ?>
			<div class="fooevents-ticket-theme-update-notice">
				<?php esc_attr_e( 'Update available!', 'woocommerce-events' ); ?>
				<a href="<?php echo esc_url( $theme['details_url'] ); ?>" target="_blank" rel="noopener">
					<?php
					printf(
						/* translators: %s: version number */
						esc_html__( 'View version %s details.', 'woocommerce-events' ),
						esc_html( $theme['update_version'] )
					);
					?>
				</a>
			</div>
		<?php endif; ?>
		<div class="fooevents-theme-viewer-name">
			<h3><a href="#TB_inline?width=800&height=550&inlineId=fooevents-theme-viewer-preview-options-<?php echo esc_attr( $theme['file_name'] ); ?>" class="thickbox"><?php echo esc_attr( $theme['name'] ); ?></a></h3>
			<?php esc_attr_e( 'Version:', 'woocommerce-events' ); ?> <?php echo esc_attr( $theme['version'] ); ?>
		</div>
	</div>
	</div>
<?php endforeach; ?>
</div>
