<?php
/**
 * Admin view: the Event tab of the event editor.
 *
 * Included by admin/views/event-edit.php inside that tab's own form, so the
 * $event row and the $bfnet_dt helper defined there are in scope here.
 *
 * @package BitForgeNet_Guest_Tickets
 */

defined( 'ABSPATH' ) || exit;

// This file is a template: it is included from a method -- never at file
// scope -- so everything declared here belongs to that method's variable
// scope and not to the global one. PHPCS reads each file on its own and has
// no way to see where the include happens, so it reads these as globals.
// Stated once, for the whole file, per this plugin's suppression rule.
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div class="bfnet-panel">
	<div class="bfnet-panel__head"><h2><?php esc_html_e( 'Event header', 'bitforgenet-guest-tickets' ); ?></h2></div>
	<div class="bfnet-panel__body">
		<div class="bfnet-field">
			<label for="bfnet-title"><?php esc_html_e( 'Title', 'bitforgenet-guest-tickets' ); ?> *</label>
			<input type="text" id="bfnet-title" name="title" required maxlength="180" value="<?php echo esc_attr( $event ? $event->title : '' ); ?>" placeholder="<?php esc_attr_e( 'Opening Night', 'bitforgenet-guest-tickets' ); ?>">
		</div>

		<div class="bfnet-row">
			<div class="bfnet-field">
				<label for="bfnet-series"><?php esc_html_e( 'Series', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="text" id="bfnet-series" name="series" maxlength="180" value="<?php echo esc_attr( $event ? $event->series : '' ); ?>" placeholder="<?php esc_attr_e( 'Friday Sessions', 'bitforgenet-guest-tickets' ); ?>">
				<p class="description"><?php esc_html_e( 'Groups recurring parties together.', 'bitforgenet-guest-tickets' ); ?></p>
			</div>
			<div class="bfnet-field">
				<label for="bfnet-edition"><?php esc_html_e( 'Edition', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="text" id="bfnet-edition" name="edition" maxlength="60" value="<?php echo esc_attr( $event ? $event->edition : '' ); ?>" placeholder="<?php esc_attr_e( 'No. 7', 'bitforgenet-guest-tickets' ); ?>">
			</div>
		</div>

		<div class="bfnet-field">
			<label for="bfnet-subtitle"><?php esc_html_e( 'Subtitle', 'bitforgenet-guest-tickets' ); ?></label>
			<input type="text" id="bfnet-subtitle" name="subtitle" maxlength="240" value="<?php echo esc_attr( $event ? $event->subtitle : '' ); ?>" placeholder="<?php esc_attr_e( 'An evening of music and dancing', 'bitforgenet-guest-tickets' ); ?>">
		</div>

		<div class="bfnet-field">
			<label for="bfnet-short"><?php esc_html_e( 'Short description', 'bitforgenet-guest-tickets' ); ?></label>
			<textarea id="bfnet-short" name="short_description" rows="2" maxlength="400"><?php echo esc_textarea( $event ? $event->short_description : '' ); ?></textarea>
			<p class="description"><?php esc_html_e( 'Shown on the event cards.', 'bitforgenet-guest-tickets' ); ?></p>
		</div>

		<div class="bfnet-field">
			<label for="bfnet-description"><?php esc_html_e( 'Full description', 'bitforgenet-guest-tickets' ); ?></label>
			<?php
			wp_editor(
				$event ? $event->description : '',
				'bfnet-description',
				array(
					'textarea_name' => 'description',
					'textarea_rows' => 8,
					'media_buttons' => false,
					'teeny'         => true,
				)
			);
			?>
		</div>

		<div class="bfnet-field">
			<label class="bfnet-label"><?php esc_html_e( 'Cover image', 'bitforgenet-guest-tickets' ); ?></label>
			<div class="bfnet-media">
				<div class="bfnet-media__preview">
					<?php if ( $cover_url ) : ?>
						<img src="<?php echo esc_url( $cover_url ); ?>" alt="">
					<?php else : ?>
						<span><?php esc_html_e( 'No image', 'bitforgenet-guest-tickets' ); ?></span>
					<?php endif; ?>
				</div>
				<div>
					<input type="hidden" name="cover_id" value="<?php echo (int) $cover_id; ?>">
					<button type="button" class="button" data-bfnet-media><?php esc_html_e( 'Choose image', 'bitforgenet-guest-tickets' ); ?></button>
					<button type="button" class="button-link" data-bfnet-media-clear style="margin-left:8px"><?php esc_html_e( 'Remove', 'bitforgenet-guest-tickets' ); ?></button>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="bfnet-panel">
	<div class="bfnet-panel__head"><h2><?php esc_html_e( 'Address', 'bitforgenet-guest-tickets' ); ?></h2></div>
	<div class="bfnet-panel__body">
		<div class="bfnet-field">
			<label for="bfnet-slug"><?php esc_html_e( 'URL slug', 'bitforgenet-guest-tickets' ); ?></label>
			<input type="text" id="bfnet-slug" name="slug" value="<?php echo esc_attr( $event ? $event->slug : '' ); ?>">
			<p class="description"><?php esc_html_e( 'The end of the booking link. Leave it alone once the event has been shared.', 'bitforgenet-guest-tickets' ); ?></p>
		</div>
	</div>
</div>
