<?php
if (isset($tpl['status']) && $tpl['status'] == "OK")
{
	?>
	<div class="panel panel-primary">
		<div class="panel-heading">
			<?php __('front_system_msg'); ?>
		</div><!-- /.panel-heading -->
		
		<?php
		$status = __('front_booking_status', true);
		if (isset($tpl['booking_arr']))
		{
			switch ($tpl['booking_arr']['payment_method'])
			{
				case 'paypal':
					if (in_array($tpl['option_arr']['o_paypal_address'], $tpl['paypal_emails'])) {
						if ($tpl['booking_arr']['booking_status'] == 'pending')
						{
							?>
							<div class="panel-body">
								<?php 
								echo $status[11];
								if (pjObject::getPlugin('pjPaypal') !== NULL)
								{
									$controller->requestAction(array('controller' => 'pjPaypal', 'action' => 'pjActionForm', 'params' => $tpl['params']));
								} 
								?>
							</div>
							<?php
						} else {
							?>
							<div class="panel-body">
								<?php 
								echo $status[3];
								?>
							</div>
							<div class="panel-footer">
								<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
							</div><!-- /.panel-footer -->
							<?php
						}
					} else { 
						?>
						<div class="panel-body">
							<?php 
							echo $status[1];
							?>
						</div>
						<div class="panel-footer">
							<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
						</div><!-- /.panel-footer -->
						<?php
					}
					break;
				case 'authorize':
					if ($tpl['booking_arr']['booking_status'] == 'pending')
					{
						?>
						<div class="panel-body">
							<?php 
							echo $status[11];
							if (pjObject::getPlugin('pjAuthorize') !== NULL)
							{
								$controller->requestAction(array('controller' => 'pjAuthorize', 'action' => 'pjActionForm', 'params' => $tpl['params']));
							}
							?>
						</div>
						<?php
					} else {
						?>
						<div class="panel-body">
							<?php 
							echo $status[3];
							?>
						</div>
						<div class="panel-footer">
							<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
						</div><!-- /.panel-footer -->
						<?php
					}
					break;
                case 'stripe':
                    if ($tpl['booking_arr']['booking_status'] == 'pending')
                    {
                        ?>
						<div class="panel-body">
							<p class="text-success text-center"><?php echo $status[0]; ?></p>
    						<script>
    							var stripe = Stripe('<?php echo $tpl['option_arr']['o_stripe_api_key']; ?>');
    
    							stripe.redirectToCheckout({
    								// Make the id field from the Checkout Session creation API response
    								// available to this file, so you can provide it as parameter here
    								// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
    								sessionId: '<?php echo $tpl['params']['sessionId']; ?>'
    							}).then(function (result) {
    								// If `redirectToCheckout` fails due to a browser or network
    								// error, display the localized error message to your customer
    								// using `result.error.message`.
    								console.log(result.error.message);
    							});
    						</script>
						</div>
						<?php
					} else {
						?>
						<div class="panel-body">
							<?php 
							echo $status[3];
							?>
						</div>
						<div class="panel-footer">
							<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
						</div><!-- /.panel-footer -->
						<?php
					}
					break;
				case 'bank':
					?>
					<div class="panel-body">
						<?php 
						echo $status[1] . '<br/>' . pjSanitize::html(nl2br($tpl['option_arr']['o_bank_account']));
						?>
					</div>
					<div class="panel-footer">
						<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
					</div><!-- /.panel-footer -->
					<?php
					break;
				case 'creditcard':
				case 'none':
				default:
					?>
					<div class="panel-body">
						<?php 
						echo $status[1];
						?>
					</div>
					<div class="panel-footer">
						<a href="#" class="btn btn-primary pull-left pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
					</div><!-- /.panel-footer -->
					<?php
			}
		}else {
			?>
			<div class="panel-body">
				<?php 
				echo $status[4];
				?>
			</div>
			<?php
		}
		?>
	</div>
</div>
	<?php
} elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') {
	?>
	<div class="panel panel-primary">
		<div class="panel-heading">
			<?php __('front_system_msg'); ?>
		</div><!-- /.panel-heading -->
		<div class="panel-body">
			<?php __('front_booking_na'); ?>
		</div>
		<div class="panel-footer">
			<a href="#" class="btn btn-primary pull-left pjTsSelectorPreview"><?php __('front_return_back', false, true); ?></a>
			<a href="#" class="btn btn-primary pull-right pjTsSelectorCalendar"><?php __('front_start_over', false, true); ?></a>
		</div><!-- /.panel-footer -->
	</div>
	<?php
}
?>