<?php
/**
 * Admin view: the Tickets and QR codes panel of the settings screen.
 *
 * Included by admin/views/settings.php inside that tab's own form, so the
 * closures and the $s array 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( 'Tickets and QR codes', 'bitforgenet-guest-tickets' ); ?></h2></div>
		<div class="bfnet-panel__body">
			<div class="bfnet-row">
				<div class="bfnet-field">
					<label for="s-prefix"><?php esc_html_e( 'Serial prefix', 'bitforgenet-guest-tickets' ); ?></label>
					<input type="text" id="s-prefix" name="bfnet_settings[ticket_prefix]" maxlength="12" value="<?php echo esc_attr( $s['ticket_prefix'] ); ?>">
				</div>
				<div class="bfnet-field">
					<label for="s-ecc"><?php esc_html_e( 'QR error correction', 'bitforgenet-guest-tickets' ); ?></label>
					<select id="s-ecc" name="bfnet_settings[qr_ecc]">
						<option value="L" <?php selected( $s['qr_ecc'], 'L' ); ?>><?php esc_html_e( 'L — smallest', 'bitforgenet-guest-tickets' ); ?></option>
						<option value="M" <?php selected( $s['qr_ecc'], 'M' ); ?>><?php esc_html_e( 'M — balanced', 'bitforgenet-guest-tickets' ); ?></option>
						<option value="Q" <?php selected( $s['qr_ecc'], 'Q' ); ?>><?php esc_html_e( 'Q — recommended', 'bitforgenet-guest-tickets' ); ?></option>
						<option value="H" <?php selected( $s['qr_ecc'], 'H' ); ?>><?php esc_html_e( 'H — most robust', 'bitforgenet-guest-tickets' ); ?></option>
					</select>
					<p class="description"><?php esc_html_e( 'Higher levels survive creases and bad lighting.', 'bitforgenet-guest-tickets' ); ?></p>
				</div>
			</div>
			<div class="bfnet-field">
				<label for="s-pdfq"><?php esc_html_e( 'Ticket PDF quality', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="number" id="s-pdfq" name="bfnet_settings[pdf_quality]" min="40" max="100" class="bfnet-narrow" value="<?php echo (int) $s['pdf_quality']; ?>">
				<p class="description"><?php esc_html_e( '80 prints indistinguishably from 95 and roughly halves the file size, which is what keeps a family of five under the mail limit.', 'bitforgenet-guest-tickets' ); ?></p>
			</div>

			<div class="bfnet-field">
				<label for="s-endpoint"><?php esc_html_e( 'Verification URL slug', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="text" id="s-endpoint" name="bfnet_settings[qr_endpoint]" value="<?php echo esc_attr( $s['qr_endpoint'] ); ?>">
				<p class="description">
					<?php
					/* translators: %s: example verification URL. */
					echo esc_html( sprintf( __( 'QR codes point to %s/<token>', 'bitforgenet-guest-tickets' ), home_url( '/' . $s['qr_endpoint'] ) ) );
					?>
				</p>
			</div>
		</div>
	</div>
