<?php 
$index = $_GET['index'];
if($_GET['view'] != 'calendar')
{
	?>
	<br />
	<?php
	include_once PJ_VIEWS_PATH . 'pjFrontPublic/elements/header.php';
}
?>
<div id="pjEbcTableCalendar_<?php echo $_GET['index']; ?>" class="pjIcContainer pjEbcBookingWrapper">
	<div class="pjIcCalendar">
		<header class="pjIcCalendarHead clearfix text-center">
			<?php
			if($_GET['view'] != 'calendar')
			{ 
				?>
				<div class="pull-left">
					<a href="#" class="<?php echo $_GET['view'] == 'list' ? 'pjEbcBackToList' : 'pjEbcBackToCalendar'; ?>" data-view="<?php echo $_GET['view'];?>"><span class="glyphicon glyphicon-chevron-left"></span> <?php $_GET['view'] == 'list' ? __('front_back_to_list') : __('front_back_to_calendar');?></a>
				</div><!-- /.pull-left -->
				<?php
			}else{
				?>
				<div class="pull-right">
					<a href="#" class="pull-right btn btn-primary pjEbcBackToCalendar" data-view="<?php echo $_GET['view'];?>"><span class="glyphicon glyphicon-remove"></span></a>
				</div><!-- /.pull-left -->
				<?php
			} 
			?>
		</header><!-- /.pjIcCalendarHead -->
	</div>
</div>

<div class="pjEbcBookingWrapper pjEbcBookingForm">
	<div class="pjEbcFormHeader">
		<div class="datetime">
			<?php
			?><span><?php echo stripslashes($tpl['arr']['title']) . ' | ';?></span> <?php
			echo $event_date = pjUtil::getEventDateTime($tpl['arr']['event_start_ts'], $tpl['arr']['event_end_ts'], $tpl['option_arr']['o_date_format'], $tpl['option_arr']['o_time_format'], $tpl['arr']['o_show_start_time'], $tpl['arr']['o_show_end_time']);
			?>
		</div>
	</div>
	<div class="pjEbcFormContainer">
		<form id="pjEbcBookingSummary_<?php echo $index;?>" action="" method="post" class="pjEbcForm" style="width: auto">
			<div class="pjEbcFormBody">
				<?php
				$cc_types = __('cc_types', true);
				$months = __('months', true); ksort($months);
				$payment_methods = __('payment_methods', true);
				$front_messages = __('front_message', true);
				
				if(count($tpl['price_arr']) > 0)
				{
					foreach($tpl['price_arr'] as $k => $v)
					{
						if (isset($_POST['price_' . $v['id']]) && (int) $_POST['price_' . $v['id']] > 0)
						{
							?>
							<dl class="dl-horizontal">
								<dt class="title"><?php echo stripslashes($v['price_name']);?> (<?php echo (int) $_POST['price_' . $v['id']]; ?> x  <?php echo pjUtil::formatCurrencySign($v['price'], $tpl['option_arr']['o_currency']);?>)</dt>
								<dd class="content"><?php echo pjUtil::formatCurrencySign(number_format((int) $_POST['price_' . $v['id']] * $v['price'], 2, '.', ','), $tpl['option_arr']['o_currency']); ?></dd>
							</dl>
							<?php
						}
					}
				}
				?>
				<dl class="dl-horizontal">
					<dt class="title"><?php __('front_label_price'); ?></dt>
					<dd class="content"><?php echo pjUtil::formatCurrencySign(number_format($tpl['amount']['price'], 2, '.', ','), $tpl['option_arr']['o_currency']); ?></dd>
				</dl>
				<dl class="dl-horizontal">
					<dt class="title"><?php __('front_label_tax'); ?></dt>
					<dd class="content"><?php echo pjUtil::formatCurrencySign(number_format($tpl['amount']['tax'], 2, '.', ','), $tpl['option_arr']['o_currency']); ?></dd>
				</dl>
				<dl class="dl-horizontal">
					<dt class="title"><?php __('front_label_total_price'); ?></dt>
					<dd class="content"><?php echo pjUtil::formatCurrencySign(number_format($tpl['amount']['total'], 2, '.', ','), $tpl['option_arr']['o_currency']); ?></dd>
				</dl>
				<dl class="dl-horizontal">
					<dt class="title"><?php __('front_label_deposit'); ?></dt>
					<dd class="content"><?php echo pjUtil::formatCurrencySign(number_format($tpl['amount']['deposit'], 2, '.', ','), $tpl['option_arr']['o_currency']); ?></dd>
				</dl>
				<?php
				if (in_array($tpl['option_arr']['o_bf_include_name'], array(2, 3)) && isset($_POST['customer_name']))
				{
					if(!empty($_POST['customer_name']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_name'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_name']) ? htmlspecialchars($_POST['customer_name']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_email'], array(2, 3)) && isset($_POST['customer_email']))
				{
					if(!empty($_POST['customer_email']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_email'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_email']) ? htmlspecialchars($_POST['customer_email']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_phone'], array(2, 3)) && isset($_POST['customer_phone']))
				{
					if(!empty($_POST['customer_phone']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_phone'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_phone']) ? htmlspecialchars($_POST['customer_phone']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_country'], array(2, 3)) && isset($_POST['customer_country']))
				{
					if(!empty($_POST['customer_country']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_country'); ?></dt>
							<dd class="content">
							<?php
							if (isset($tpl['country_arr']) && is_array($tpl['country_arr']))
							{
								foreach ($tpl['country_arr'] as $v)
								{
									if (isset($_POST['customer_country']) && $_POST['customer_country'] == $v['id'])
									{
										echo htmlspecialchars($v['country_title']);
										break;
									}
								}
							}
							?>
							</dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_city'], array(2, 3)) && isset($_POST['customer_city']))
				{
					if(!empty($_POST['customer_city']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_city'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_city']) ? htmlspecialchars($_POST['customer_city']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_state'], array(2, 3)) && isset($_POST['customer_state']))
				{
					if(!empty($_POST['customer_state']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_state'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_state']) ? htmlspecialchars($_POST['customer_state']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_zip'], array(2, 3)) && isset($_POST['customer_zip']))
				{
					if(!empty($_POST['customer_zip']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_zip'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_zip']) ? htmlspecialchars($_POST['customer_zip']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_address'], array(2, 3)) && isset($_POST['customer_address']))
				{
					if(!empty($_POST['customer_zip']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_address'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_address']) ? htmlspecialchars($_POST['customer_address']) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_notes'], array(2, 3)) && isset($_POST['customer_notes']))
				{
					if(!empty($_POST['customer_zip']))
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_notes'); ?></dt>
							<dd class="content"><?php echo isset($_POST['customer_notes']) ? nl2br(htmlspecialchars($_POST['customer_notes'])) : NULL; ?></dd>
						</dl>
						<?php
					}
				}
				if ($tpl['option_arr']['o_payment_disable'] == 'No')
				{
					if (isset($tpl['amount']['price']) && (float) $tpl['amount']['price'] > 0)
					{
						?>
						<dl class="dl-horizontal">
							<dt class="title"><?php __('front_label_payment_method'); ?></dt>
							<dd class="content"><?php echo isset($_POST['payment_method']) ? $payment_methods[$_POST['payment_method']] : NULL; ?></dd>
						</dl>
						<?php
						if (isset($_POST['payment_method']) && $_POST['payment_method'] == 'creditcard')
						{
							?>
							<dl class="dl-horizontal">
								<dt class="title"><?php __('front_label_cc_type'); ?></dt>
								<dd class="content"><?php echo $cc_types[$_POST['cc_type']]; ?></dd>
							</dl>
							<dl class="dl-horizontal">
								<dt class="title"><?php __('front_label_cc_number'); ?></dt>
								<dd class="content"><?php echo isset($_POST['cc_num']) ? $_POST['cc_num'] : NULL; ?></dd>
							</dl>
							<dl class="dl-horizontal">
								<dt class="title"><?php __('front_label_cc_expiration_date'); ?></dt>
								<dd class="content"><?php echo isset($_POST['cc_exp_year']) ? $_POST['cc_exp_year'] : NULL; ?>-<?php echo isset($_POST['cc_exp_month']) ? $_POST['cc_exp_month'] : NULL;?></dd>
							</dl>
							<dl class="dl-horizontal">
								<dt class="title"><?php __('front_label_cc_code'); ?></dt>
								<dd class="content"><?php echo isset($_POST['cc_code']) ? $_POST['cc_code'] : NULL; ?></dd>
							</dl>
							<?php
						}
						if (isset($_POST['payment_method']) && $_POST['payment_method'] == 'bank')
						{
							?>
							<dl class="dl-horizontal">
								<dt class="title">&nbsp;</dt>
								<dd class="content ebc-overflow"><?php echo nl2br($tpl['option_arr']['o_bank_account']);?></dd>
							</dl>
							<?php
						}
					}
				}
				?>
				<p id="pjEbcErrorMessage_<?php echo $index;?>" class="pjEbcError pjEbcErrorMessage" style="display: none"></dl>
				<p id="pjEbcMessageContainer_<?php echo $index; ?>" style="display:none;"><?php echo $front_messages[5]; ?></dl>
				<div>
					<label class="title pjEbcActions">&nbsp;</label>
					<input type="submit" value="<?php __('front_button_submit'); ?>" class="pjEbcButton btn btn-primary"/>
					<input type="button" value="<?php __('front_button_cancel'); ?>" class="pjEbcButton btn btn-primary pjEbcCancelSummary"/>
				</div>
			</div>
		</form>
	</div>
</div>