<?php
/**
 * Admin view: the Updates and maintenance 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( 'Updates and maintenance', 'bitforgenet-guest-tickets' ); ?></h2></div>
		<div class="bfnet-panel__body">
			<div class="bfnet-field">
				<label for="s-resetmail"><?php esc_html_e( 'Address that authorises data resets', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="email" id="s-resetmail" name="bfnet_settings[reset_authorised_email]" value="<?php echo esc_attr( $s['reset_authorised_email'] ); ?>">
				<p class="description"><?php esc_html_e( 'Archiving the bookings requires a one-time code sent to this mailbox. Tools & data is where you run it.', 'bitforgenet-guest-tickets' ); ?></p>
			</div>

			<div class="bfnet-field">
				<label for="s-retention"><?php esc_html_e( 'Keep activity logs for (days)', 'bitforgenet-guest-tickets' ); ?></label>
				<input type="number" id="s-retention" name="bfnet_settings[log_retention_days]" min="0" max="3650" value="<?php echo (int) $s['log_retention_days']; ?>">
			</div>
			<?php
			$bfnet_check( 'debug_mode', __( 'Verbose logging', 'bitforgenet-guest-tickets' ), '', $s );
			$bfnet_check( 'delete_data_on_uninstall', __( 'Delete all BitForgeNet Guest Tickets data when the plugin is uninstalled', 'bitforgenet-guest-tickets' ), __( 'Off by default. Turning this on means uninstalling destroys every event, booking and ticket.', 'bitforgenet-guest-tickets' ), $s );
			?>

			<div class="bfnet-note-box" style="margin-top:14px">
				<strong><?php esc_html_e( 'Environment', 'bitforgenet-guest-tickets' ); ?></strong><br>
				<?php
				echo esc_html(
					sprintf(
						/* translators: 1: plugin version, 2: PHP version, 3: GD status. */
						__( 'BitForgeNet Guest Tickets %1$s · PHP %2$s · GD %3$s', 'bitforgenet-guest-tickets' ),
						BFNET_VERSION,
						PHP_VERSION,
						extension_loaded( 'gd' ) ? __( 'available', 'bitforgenet-guest-tickets' ) : __( 'MISSING', 'bitforgenet-guest-tickets' )
					)
				);
				?>
			</div>
		</div>
	</div>
