<?php
$status = __('front_booking_status', true);
if (isset($tpl['status']) && $tpl['status'] == "OK")
{
	if (isset($tpl['booking_arr']))
	{
		switch ($tpl['booking_arr']['payment_method'])
		{
			case 'paypal':
				if (isset($tpl['invoice_arr']) && !empty($tpl['invoice_arr']))
				{
					if ($tpl['invoice_arr']['status'] == 'not_paid')
					{
						?><div class="alert alert-success"><?php
						echo $status[11];
						if (pjObject::getPlugin('pjPaypal') !== NULL)
						{
							$controller->requestAction(array('controller' => 'pjPaypal', 'action' => 'pjActionForm', 'params' => $tpl['params']));
						}
						?></div><?php
					} else {
						?>
						<div class="alert alert-success">
							<?php echo $status[3];?>
							<input type="button" value="<?php __('front_start_over', false, true); ?>" class="btn btn-default pull-left pjErBtn pjErBtnSecondary erSelectorButton erSelectorItems" />
						</div>
						<?php
					}
				} else {
					?>
					<div class="alert alert-success">
						<?php echo $status[5];?>
						<input type="button" value="<?php __('front_start_over', false, true); ?>" class="btn btn-default pull-left pjErBtn pjErBtnSecondary erSelectorButton erSelectorItems" />
					</div>
					<?php
				}
				break;
			case 'authorize':
				if (isset($tpl['invoice_arr']) && !empty($tpl['invoice_arr']))
				{
					if ($tpl['invoice_arr']['status'] == 'not_paid')
					{
						?><div class="alert alert-success"><?php
						echo $status[11];
						if (pjObject::getPlugin('pjAuthorize') !== NULL)
						{
							$controller->requestAction(array('controller' => 'pjAuthorize', 'action' => 'pjActionForm', 'params' => $tpl['params']));
						}
						?></div><?php
					} else {
						?>
						<div class="alert alert-success">
							<?php echo $status[3];?> <a href="#" class="alert-link erSelectorItems"><?php __('front_start_over');?></a>
						</div>
						<?php
					}
				} else {
					
					?>
					<div class="alert alert-success">
						<?php echo $status[5];?> <a href="#" class="alert-link erSelectorItems"><?php __('front_start_over');?></a>
					</div>
					<?php
				}
				break;
			case 'bank':
				?>
				<div class="alert alert-success">
					<?php echo $status[1] . ' <a href="#" class="alert-link erSelectorItems">'.__('front_start_over', true).'</a><br>' . pjSanitize::html(nl2br($tpl['option_arr']['o_bank_account']));?>
				</div>
				<?php
				$thankyou_page = $tpl['option_arr']['o_thankyou_page'];
				if (!empty($thankyou_page) && preg_match('/^http(s)?:\/\//i', $thankyou_page))
				{
					?>
					<script type="text/javascript">
					window.setTimeout(function () {
						window.location.href = '<?php echo $thankyou_page; ?>';
					}, 3000);
					</script>
					<?php
				}
				break;
			case 'creditcard':
			case 'code':
			case 'none':
			default:
				?>
				<div class="alert alert-success">
					<?php echo $status[1];?> <a href="#" class="alert-link erSelectorItems"><?php __('front_start_over');?></a>
				</div>
				<?php
				$thankyou_page = $tpl['option_arr']['o_thankyou_page'];
				if (!empty($thankyou_page) && preg_match('/^http(s)?:\/\//i', $thankyou_page))
				{
					?>
					<script type="text/javascript">
					window.setTimeout(function () {
						window.location.href = '<?php echo $thankyou_page; ?>';
					}, 3000);
					</script>
					<?php
				}
		}
	} else {
		echo $status[4];
	}
} elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') {
	if (isset($tpl['code']))
	{
		?>
		<div class="alert alert-danger">
			<?php
			switch ($tpl['code'])
			{
				case 104:
					__('accept_bookings_notice');
					break;
				case 105:
					echo $status[4];
					break;
			}
			?>
		</div>
		<?php 
	}
	?>
	<div class="alert alert-danger">
		<a href="#" class="alert-link pull-left erSelectorItems"><?php __('front_start_over');?></a>
		
		<a href="#" class="alert-link pull-left erSelectorPreview"><?php __('front_return_back');?></a>
	</div>
	<?php
}
?>