<?php
/**
 * Load the iframe personalisation HTML.
 *
 * @package Fast-Events/Helper/Template/Personalise
 *
 * @since 2.1.0
 * @since 2.2.0 - Show coupons if available.
 *              - Eventname and eventdate per ticket (needed for PPT)
 *              - Order_id and create_date on 1 line.
 * @since 2.3.0 - Using bootstrap 5.3.3.
 * @since 2.3.0 - Using bootstrap 5.3.8.
 *              - iFrameResizer 5.5.7
 */

use FeData\FastEvents\Helpers\PersonalisationHelper;
use FeData\FastEvents\Utilities\PluginUtil;

defined( 'ABSPATH' ) || exit;

global $wp_query;
global $fevt_container;

$fevt_personalise = $fevt_container->get( PersonalisationHelper::class );

$is_uid  = true;
$is_cdn  = false;
$is_dark = false;
if ( ! empty( $attr ) ) {
	$is_cdn  = in_array( 'cdn', $attr, true );
	$is_dark = in_array( 'dark', $attr, true );
}

if ( isset( $wp_query->query_vars['redirect_uid'] ) ) {
	$tickets = $fevt_personalise->get_ids_for_uid( sanitize_text_field( $wp_query->query_vars['redirect_uid'] ) );
} elseif ( ! empty( $attr ) && array_key_exists( 'uid', $attr ) ) {
	$wp_query->set( 'redirect_uid', sanitize_text_field( $attr['uid'] ) );
	$tickets = $fevt_personalise->get_ids_for_uid( sanitize_text_field( $attr['uid'] ) );
} else {
	$is_uid  = false;
	$ids     = implode(
		'-',
		array_map(
			'absint',
			explode( '-', sanitize_text_field( $wp_query->query_vars['ticket_ids'] ) )
		)
	);
	$tickets = $fevt_personalise->get_ids_for_list( $ids );
	unset( $tickets['order_input'] );
}
if ( ! empty( $tickets ) ) {
	$num_tickets = count( $tickets['data'] );
}

?>

<!DOCTYPE html>
<html lang="<?php bloginfo( 'language' ); ?>"<?php echo $is_dark ? ' data-bs-theme="dark"' : ''; ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<title><?php esc_html_e( 'Personalise and download tickets', 'fast-events' ); ?></title>
	<?php if ( $is_cdn ) { ?>
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/css/bootstrap.min.css" integrity="sha512-2bBQCjcnw658Lho4nlXJcc6WkV/UxpE/sAokbXPxQNGqmNdQrWqtw26Ns9kFF/yG792pKR1Sx8/Y1Lf1XN4GKA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
	<?php } else { ?>
		<link rel="stylesheet" href="<?php echo PluginUtil::plugin_url() . '/assets/css/bootstrap.min.css'; ?>" />
	<?php } ?>
</head>
<style>
	@media (hover: none) {
		/* Hover is not supported on mobile devices */
		.tooltip {display: none;}
	}
</style>
<body class="p-2">

<?php if ( ! empty( $tickets ) ) { ?>


<!-- Define SVG icons -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="d-none">
	<defs>
		<symbol id="svg-bi-unchecked" viewBox="0 0 16 16" fill="currentColor" >
			<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
		</symbol>
		<symbol id="svg-bi-checked" viewBox="0 0 16 16" fill="currentColor" >
			<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
			<path d="M10.97 4.97a.75.75 0 0 1 1.071 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
		</symbol>
		<symbol id="svg-bi-personalise" viewBox="0 0 16 16" fill="currentColor" >
			<path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325"/>
		</symbol>
		<symbol id="svg-bi-download" viewBox="0 0 16 16" fill="currentColor" >
			<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
			<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/>
		</symbol>
		<symbol id="svg-bi-download-all" viewBox="0 0 512 512" fill="currentColor" >
			<path d="M430.337,231.065H81.674c-29.701,0-53.858,24.16-53.858,53.862v49.884v15.976l15.806,2.262
					c9.135,1.31,16.03,9.258,16.03,18.483c0,9.225-6.891,17.173-16.022,18.482l-15.814,2.262v15.978v49.892
					c0,29.693,24.157,53.854,53.858,53.854h348.663c29.701,0,53.862-24.161,53.862-53.854v-49.558V391l-17.571-0.822
					c-9.982-0.463-17.808-8.655-17.808-18.645c0-9.982,7.826-18.174,17.815-18.646l17.564-0.83v-17.58v-49.55
					C484.199,255.225,460.038,231.065,430.337,231.065z M465.765,334.477c-19.686,0.936-35.371,17.14-35.371,37.056
					c0,19.923,15.685,36.135,35.371,37.055v49.558c0,19.565-15.864,35.428-35.428,35.428H81.674c-19.569,0-35.432-15.863-35.432-35.428
					v-49.892c17.991-2.579,31.836-18.011,31.836-36.722c0-18.703-13.846-34.135-31.836-36.721v-49.884
					c0-19.573,15.863-35.436,35.432-35.436h348.663c19.564,0,35.428,15.863,35.428,35.436V334.477z"/>
			<rect x="133.621" y="439.419" class="st0" width="12.19" height="31.8"/>
			<rect x="133.621" y="383.564" class="st0" width="12.19" height="31.792"/>
			<rect x="133.621" y="327.7" class="st0" width="12.19" height="31.8"/>
			<rect x="133.621" y="271.846" class="st0" width="12.19" height="31.799"/>
			<polygon points="111.245,180.758 100.592,186.68 116.053,214.461 126.702,208.539 	"/>
			<path d="M497.524,179.025l-24.095-43.311l-8.558-15.36l-15.749,7.826c-8.948,4.442-19.768,1.09-24.617-7.639
					c-4.865-8.721-2.001-19.687,6.492-24.95l14.952-9.266l-8.558-15.368l-24.088-43.294C398.863,1.714,366.006-7.658,340.047,6.79
					L35.374,176.299c-25.955,14.44-35.318,47.305-20.878,73.256l0.875,1.578c3.27-6.394,7.43-12.243,12.324-17.409
					c-4.803-15.643,1.762-33.044,16.636-41.326l304.681-169.51c17.1-9.518,38.674-3.368,48.192,13.732l24.088,43.302
					c-16.751,10.38-22.575,32.182-12.895,49.582c9.681,17.401,31.271,23.942,48.925,15.172l24.095,43.312
					c7.273,13.056,5.337,28.692-3.571,39.601c4.776,3.961,8.989,8.558,12.65,13.569C505.4,224.524,508.979,199.615,497.524,179.025z"/>
		</symbol>
	</defs>
</svg>

<!-- Tabs menu-->
<ul class="nav nav-tabs" role="tablist">
	<li class="nav-item" role="presentation">
		<a class="nav-link active" id="nav-tab-0" data-bs-toggle="tab" href="#fe-pers-0" role="tab" aria-controls="fe-pers-0" aria-selected="true"><?php isset( $tickets['download'] ) ? esc_html_e( 'Tickets', 'fast-event' ) : esc_html_e( 'Personalise', 'fast-event' ); ?></a>
	</li>

	<?php if ( $is_uid ) { ?>
		<li class="nav-item" role="presentation">
			<a class="nav-link" id="nav-tab-1" data-bs-toggle="tab" href="#fe-pers-1" role="tab" aria-controls="fe-pers-1" aria-selected="false"><?php esc_html_e( 'Order', 'fast-events' ); ?></a>
		</li>
	<?php } ?>

	<?php if ( $is_uid && '1' === $tickets['invoice_needed'] ) { ?>
		<li class="nav-item" role="presentation">
			<a class="nav-link" id="nav-tab-2" data-bs-toggle="tab" href="#fe-pers-2" role="tab" aria-controls="fe-pers-2" aria-selected="false"><?php esc_html_e( 'Invoice', 'fast-events' ); ?></a>
		</li>
	<?php } ?>

	<li class="nav-item ms-auto" role="presentation">
		<button
				type="button"
				id="tickets-download"
				data-bs-toggle="tooltip"
				data-bs-delay="500"
				data-bs-title="<?php esc_html_e( 'Download all tickets', 'fast-events' ); ?>"
				data-bs-placement="left"
				class="btn btn-outline-primary btn-sm me-2 mt-1 position-relative<?php echo esc_html( isset( $tickets['download'] ) ? '' : ' d-none' ); ?>">
			<svg width="20" height="24">
				<use xlink:href="#svg-bi-download-all" />
			</svg>
		</button>
	</li>
</ul>

<div class="tab-content py-3 mr-3">

	<!-- Personalise tickets or download tickets -->
	<div class="tab-pane active" id="fe-pers-0" role="tabpanel" aria-labelledby="fe-pers-0-tab">
		<div class="row row-cols-1 row-cols-md-2 row-cols-lg-2 row-cols-xl-3 g-4">
			<?php foreach ( $tickets['data'] as $key => $ticket ) { ?>
				<div class="col pb-1">
					<div class="card h-100">
						<div
							id="fe-qrcode-<?php echo esc_html( $key ); ?>"
							class="card-img-top d-flex align-items-center justify-content-center mt-2 d-none">
						</div>
						<div class="card-body">
							<h5 class="card-title text-truncate"><?php echo esc_html( $ticket['event_name'] ); ?></h5>
							<div class="card-text">
								<div class="fst-italic text-truncate"><?php echo esc_html( $ticket['ticket_type'] ); ?></div>
								<div class="text-truncate"><?php echo esc_html( $ticket['event_date'] ); ?></div>
								<div id="ticket-pers-data-<?php echo esc_html( $key ); ?>">
								<?php if ( ! empty( $ticket['personalised_input'] ) ) { ?>
									<hr class="border-3 border-secondary m-1" />
									<?php foreach ( $ticket['personalised_input'] as $key2 => $value ) { ?>
										<div class="row">
											<div class="form-floating" style="margin-bottom: -0.75rem !important;">
												<input type="text" readonly class="form-control-plaintext text-truncate" value="<?php echo esc_html( $value ); ?>">
												<label><?php echo esc_html( $key2 ); ?></label>
											</div>
										</div>
									<?php } ?>
								<?php } ?>
								</div>
								<div id="ticket-pers-input-<?php echo esc_html( $key ); ?>" class="d-none">
									<form id="ticket-pers-input-form-<?php echo esc_html( $key ); ?>" class="mt-2">
										<div id="ticket-pers-input-fields-<?php echo esc_html( $key ); ?>"></div>
										<div class="clearfix">
											<button id="ticket-pers-input-close-<?php echo esc_html( $key ); ?>" type="button" class="btn btn-outline-secondary"><?php esc_html_e( 'Close', 'fast-events' ); ?></button>
											<button id="ticket-pers-input-save-<?php echo esc_html( $key ); ?>" type="button" class="btn btn-outline-primary float-end"><?php esc_html_e( 'Save', 'fast-events' ); ?></button>
										</div>
									</form>
								</div>
								<div id="ticket-pers-input-alert-<?php echo esc_html( $key ); ?>" class="alert alert-danger mt-2 text-break d-none" role="alert"></div>
							</div>
						</div>
						<div class="card-footer">
							<div class="float-start">
								<?php if ( $is_uid ) { ?>
								<button
									type="button"
									id="ticket-uncheck-<?php echo esc_html( $key ); ?>"
									data-bs-toggle="tooltip"
									data-bs-delay="500"
									data-bs-title="<?php esc_html_e( 'Select ticket', 'fast-events' ); ?>"
									class="btn btn-outline-primary btn-sm me-2 position-relative">
									<svg width="24" height="24">
										<use xlink:href="#svg-bi-unchecked" />
									</svg>
									<?php if ( $ticket['shared'] ) { ?>
										<span
												id="ticket-badge-<?php echo esc_html( $key ); ?>"
												class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">

										</span>
									<?php } else { ?>
										<span
												id="ticket-badge-<?php echo esc_html( $key ); ?>"
												class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle d-none">
										</span>
									<?php } ?>
								</button>
								<button
									type="button"
									id="ticket-checked-<?php echo esc_html( $key ); ?>"
									data-bs-toggle="tooltip"
									data-bs-delay="500"
									data-bs-title="<?php esc_html_e( 'Unselect ticket', 'fast-events' ); ?>"
									class="btn btn-outline-primary btn-sm me-2 d-none position-relative">
									<svg width="24" height="24">
										<use xlink:href="#svg-bi-checked" />
									</svg>
									<?php if ( $ticket['shared'] ) { ?>
										<span
												id="ticket-badge-checked-<?php echo esc_html( $key ); ?>"
												class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">

										</span>
									<?php } else { ?>
										<span
												id="ticket-badge-checked-<?php echo esc_html( $key ); ?>"
												class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle d-none">
										</span>
									<?php } ?>
								</button>
								<?php } ?>
								<?php if ( ! $ticket['locked'] ) { ?>
									<button
										type="button"
										id="ticket-personalise-<?php echo esc_html( $key ); ?>"
										data-bs-toggle="tooltip"
										data-bs-delay="500"
										data-bs-title="<?php esc_html_e( 'Personalise ticket', 'fast-events' ); ?>"
										class="btn btn-outline-primary btn-sm">
										<svg width="24" height="24">
											<use xlink:href="#svg-bi-personalise" />
										</svg>
									</button>
								<?php } elseif ( isset( $tickets['download'] ) ) { ?>
									<button
										type="button"
										id="ticket-download-<?php echo esc_html( $key ); ?>"
										data-bs-toggle="tooltip"
										data-bs-delay="500"
										data-bs-title="<?php esc_html_e( 'Download ticket', 'fast-events' ); ?>"
										class="btn btn-outline-primary btn-sm">
										<svg width="24" height="24">
											<use xlink:href="#svg-bi-download" />
										</svg>
									</button>
								<?php } ?>
							</div>
							<div class="float-end">
								<?php /* translators: 1: is the ticket number 2: is the total number of tickets */ ?>
								<div class="text-body-secondary"><?php echo esc_html( sprintf( __( '%1$s of %2$s', 'fast-events' ), $key + 1, $num_tickets ) ); ?></div>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>

	<?php if ( $is_uid ) { ?>
	<!-- Show the order information -->
		<div class="tab-pane fade" id="fe-pers-1" role="tabpanel" aria-labelledby="fe-pers-1-tab">
			<form class="form-horizontal">
				<div class="mb-3 row">
					<div class="col-4">
						<div class="form-floating">
							<input type="text" id="orderId" class="form-control" disabled readonly value='<?php echo esc_html( $tickets['order_id'] ); ?>'>
							<label for="orderId" ><?php esc_html_e( 'Order id', 'fast-events' ); ?></label>
						</div>
					</div>
					<div class="col-8">
						<div class="form-floating">
							<input type="text" id="createdAt" class="form-control" disabled value='<?php echo esc_html( $tickets['created_at'] ); ?>'>
							<label for="createdAt" ><?php esc_html_e( 'Created at', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row">
					<div class="col-12">
						<div class="form-floating">
							<input type="text" id="userName" class="form-control" disabled value='<?php echo esc_html( $tickets['name'] ); ?>'>
							<label for="userName" class="col-sm-3 col-form-label"><?php esc_html_e( 'Name', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row">
					<div class="col-12">
						<div class="form-floating">
							<input type="text" id="userEmail" class="form-control" disabled value='<?php echo esc_html( $tickets['email'] ); ?>'>
							<label for="userEmail"><?php esc_html_e( 'Email', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<?php foreach ( $tickets['order_input']->fields as $item ) { ?>
					<div class="mb-3 row">
						<div class="col-12">
							<div class="form-floating">
								<input type="text" id="orderInput<?php echo esc_html( $item->name ); ?>" class="form-control" disabled value='<?php echo esc_html( $item->value ); ?>'>
								<label for="orderInput<?php echo esc_html( $item->name ); ?>"><?php echo esc_html( $item->name ); ?></label>
							</div>
						</div>
					</div>
				<?php } ?>
			</form>
			<table class="table table-striped">
				<thead>
				<tr>
					<th scope="col"><?php esc_html_e( 'Ticket types', 'fast-events' ); ?></th>
					<th class="text-end" scope="col"><?php esc_html_e( 'Quantity', 'fast-events' ); ?></th>
					<th class="text-end" scope="col"><?php esc_html_e( 'Amount', 'fast-events' ); ?></th>
				</tr>
				</thead>
				<?php foreach ( $tickets['order_input']->tickets as $item ) { ?>
					<tr>
						<td><?php echo esc_html( $item->name ); ?></td>
						<td class="text-end" ><?php echo esc_html( $item->count ); ?></td>
						<td class="text-end" ><?php echo esc_html( number_format_i18n( $item->count * (float) $item->price, 2 ) ); ?></td>
					</tr>
					<?php
				}
				if ( ! empty( $tickets['order_input']->discounts ) ) {
					foreach ( $tickets['order_input']->discounts as $item ) {
						?>
					<tr>
						<?php /* translators: 1: is the coupon code */ ?>
						<td class="fst-italic" colspan="2"><?php echo esc_html( sprintf( esc_html__( 'Coupon (%1$s)', 'fast-events' ), $item->code ) ); ?></td>
						<td class="fst-italic text-end" >-<?php echo esc_html( number_format_i18n( (float) $item->amount, 2 ) ); ?></td>
					</tr>
						<?php
					}
				}
				?>
			</table>
		</div>
	<?php } ?>

	<?php if ( $is_uid && '1' === $tickets['invoice_needed'] ) { ?>
	<!-- Personalise invoice and download invoice -->
		<div class="tab-pane fade" id="fe-pers-2" role="tabpanel" aria-labelledby="fe-pers-2-tab">
			<form class="form-horizontal" id="fe-pers-invoice">
				<div class="mb-3 row">
					<div class="col-8">
						<div class="form-floating">
							<input type="text" class="form-control" id="company" name="company" autocomplete="organization" maxlength="50" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'Company', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->company ?? '' ); ?>">
							<label for="company"><?php esc_html_e( 'Company', 'fast-events' ); ?></label>
						</div>
					</div>
					<div class="col-4">
						<div class="form-floating">
							<input type="text" class="form-control" id="vat" name="vat" autocomplete="on" maxlength="50" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'VAT id', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->vat ?? '' ); ?>">
							<label for="vat"><?php esc_html_e( 'VAT id', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row">
					<div class="col-12">
						<div class="form-floating">
							<input type="text" class="form-control" id="name" name="name" autocomplete="name" maxlength="50" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'Name', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->name ?? $tickets['name'] ); ?>">
							<label for="name"><?php esc_html_e( 'Name', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row">
					<div class="col-12">
						<div class="form-floating">
							<input type="text" class="form-control" id="street" name="street" autocomplete="street-address" maxlength="50" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'Street', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->street ?? '' ); ?>">
							<label for="street"><?php esc_html_e( 'Street', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row">
					<div class="col-4">
						<div class="form-floating">
							<input type="text" class="form-control" id="postcode" name="postcode" autocomplete="postal-code" maxlength="20" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'Postcode', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->postcode ?? '' ); ?>">
							<label for="postcode"><?php esc_html_e( 'Postcode', 'fast-events' ); ?></label>
						</div>
					</div>
					<div class="col-8">
						<div class="form-floating">
							<input type="text" class="form-control" id="city" name="city" autocomplete="address-level2" maxlength="50" <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'disabled' : '' ); ?> placeholder="<?php esc_html_e( 'City', 'fast-events' ); ?>" value="<?php echo esc_html( $tickets['order_input']->invoice->city ?? '' ); ?>">
							<label for="city"><?php esc_html_e( 'City', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div class="mb-3 row <?php echo esc_html( isset( $tickets['order_input']->invoice->locked ) ? 'd-none' : '' ); ?>" id="invoice-locked">
					<div class="col-12">
						<div class="form-check">
							<input type="checkbox" class="form-check-input" id="locked" name="locked" >
							<label for="locked" class="form-check-label"><?php esc_html_e( 'I have entered everything truthfully and understand that once the data is stored, it cannot be changed.', 'fast-events' ); ?></label>
						</div>
					</div>
				</div>
				<div id="fe-pers-invoice-alert" class="alert alert-danger text-break d-none" role="alert"></div>
			</form>
			<button type="button" class="btn btn-outline-primary" id="fe-pers-invoice-button"><?php echo esc_html( ! isset( $tickets['order_input']->invoice->locked ) ? esc_html__( 'Save', 'fast-events' ) : esc_html__( 'Download invoice', 'fast-events' ) ); ?></button>
		</div>
	<?php } ?>

</div>
<?php } else { ?>
	<div class="alert alert-danger" role="alert">
	<?php echo esc_html__( 'No tickets found to personalise', 'fast-events' ); ?>
	</div>
<?php } ?>

<div data-iframe-size></div>

<?php if ( $is_cdn ) { ?>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/js/bootstrap.bundle.min.js" integrity="sha512-HvOjJrdwNpDbkGJIG2ZNqDlVqMo77qbs4Me4cah0HoDrfhrbA+8SBlZn1KrvAQw7cILLPFJvdwIgphzQmMm+Pw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" integrity="sha512-CNgIRecGo7nphbeZ04Sc13ka07paqdeTu0WR1IM4kNcpmBAUSHSQX0FslNhTDadL4O5SAGapGt4FodqL8My0mA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<?php require_once PluginUtil::plugin_path() . '/templates/personalise-iframe-js.php'; ?>
	<script src="https://cdn.jsdelivr.net/npm/@iframe-resizer/child@5.5.7"></script>
<?php } else { ?>
	<script src="<?php echo PluginUtil::plugin_url() . '/assets/js/bootstrap.bundle.min.js'; ?>"></script>
	<script src="<?php echo PluginUtil::plugin_url() . '/assets/js/qrcode.min.js'; ?>"></script>
	<?php require_once PluginUtil::plugin_path() . '/templates/personalise-iframe-js.php'; ?>
	<script src="<?php echo PluginUtil::plugin_url() . '/assets/js/iframeResizer.contentWindow.min.js'; ?>"></script>
<?php } ?>
</body>
</html>
<?php
