<header class="row pjErHeader">
<?php
include PJ_VIEWS_PATH . 'pjFrontEnd/elements/header.php';
$filter = 'items';
include PJ_VIEWS_PATH . 'pjFrontEnd/elements/search.php'; 
?>
</header><!-- /.row pjErHeader -->

<?php
if ($acceptBookings)
{ 
	if (isset($tpl['summary']) && isset($tpl['summary']['items']) && !empty($tpl['summary']['items']))
	{
		$CART = $tpl['summary']['cart'];
		$FORM = $_SESSION[$controller->defaultForm];
		?>
		<div class="panel panel-default pjErBody pjErBasket">
			<div class="panel-body">
				<form action="" method="post" class="erSelectorCartForm">
					<input type="hidden" name="er_cart" value="1" />
					<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table pjErBasketProducts">
						<tr class="pjErBasketProduct">
							<th><?php __('front_product');?>:</th>
					
							<th class="hidden-xs"></th>
					
							<th class="hidden-xs"><?php __('number_items'); ?>:</th>
							<?php
							if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
							{ 
								?>
								<th><?php __('front_price');?>:</th>
								<?php
							} else {
								?><th>&nbsp;</th><?php
							}
							?>
					
							<th></th>
						</tr><!-- /.pjErBasketProduct -->
						<?php
						$back_url = '';
						$iterated = 0;
						foreach ($tpl['summary']['items'] as $item)
						{ 
							$key = $item['type']."_".$item['id'];
							$_action = $item['type'] == "item" ? 'Item' : 'Package';
							$_class = $item['type'] == "item" ? 'erSelectorItem' : 'erSelectorPackage';
							
							$slug = NULL;
							$href = NULL;
							if($item['type'] == "item")
							{
								if ((int) $tpl['option_arr']['o_seo_url'] === 1)
								{
									$slug = sprintf("%s-%u.html", pjAppController::friendlyURL($item['title']), $item['id']);
									$href = pjUtil::getReferer() . '#!/Item/' . $slug;
								}else{
									$href = pjUtil::getReferer() . '#!/Item/' . $item['id'];
								}
							}else{
								if ((int) $tpl['option_arr']['o_seo_url'] === 1)
								{
									$slug = sprintf("%s-%u.html", pjAppController::friendlyURL($item['title']), $item['id']);
									$href = pjUtil::getReferer() . '#!/Package/' . $slug;
								}else{
									$href = pjUtil::getReferer() . '#!/Package/' . $package['id'];
								}
							}
							
							$src = PJ_INSTALL_URL . PJ_IMG_PATH . 'frontend/er-noimg.png';
							if (!empty($item['small_pic']) && is_file($item['small_pic']))
							{
								$src = PJ_INSTALL_URL . $item['small_pic'];
							}
							if($iterated == 0)
							{
								$back_url = pjUtil::getReferer() . '#!/' . $_action . '/' . $item['id'];
							}
							$iterated++;
							?>
							<tr class="pjErBasketProduct">
								<td class="col-md-1 col-sm-2 hidden-xs">
									<div class="pjErBasketProductImage">
										<a href="<?php echo pjUtil::getReferer(); ?>#!/<?php echo $_action; ?>/<?php echo $item['id']; ?>" data-id="<?php echo $item['id']; ?>" data-slug="<?php echo $slug;?>" class="<?php echo $_class; ?>"><img src="<?php echo $src; ?>" alt="<?php echo pjSanitize::html($item['title']); ?>" /></a>
									</div><!-- /.pjErBasketProductImage -->
								</td><!-- /.col-md-1 col-sm-2 hidden-xs -->
								
								<td class="col-sm-5 col-xs-8">
									<p class="pjErBasketProductTitle">
										<a href="<?php echo pjUtil::getReferer(); ?>#!/<?php echo $_action; ?>/<?php echo $item['id']; ?>" data-id="<?php echo $item['id']; ?>" data-slug="<?php echo $slug;?>" class="<?php echo $_class; ?>"><?php echo pjSanitize::html($item['title']); ?></a>
									</p><!-- /.pjErBasketProductTitle -->
								</td><!-- /.col-sm-5 col-xs-8 -->
								
								<td class="col-md-4 col-sm-3 hidden-xs">
									<select name="qty[<?php echo $key; ?>]" class="form-control pjErCartItems">
										<?php
										for($i = 1; $i <= ($item['cnt'] - $item['booked_qty']) ; $i++ )
										{
											?><option value="<?php echo $i;?>"<?php echo (int) $CART[$key]==$i ? ' selected="selected"' : NULL;?>><?php echo $i;?></option><?php
										}
										?>
									</select>
								</td><!-- /.col-md-4 col-sm-3 hidden-xs -->
								
								<td class="col-sm-1 col-xs-2">
									<?php
									if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
									{ 
										?>
										<p><strong><?php echo pjUtil::formatCurrencySign(number_format(@$item['price'] * (int) $CART[$key], 2), $tpl['option_arr']['o_currency']); ?></strong></p>
										<?php
									}else{
										?>
										<p><strong>&nbsp;</strong></p>
										<?php
									} 
									?>
								</td><!-- /.col-sm-1 col-xs-2 -->
								
								<td class="col-xs-1">
									<a href="<?php echo pjUtil::getReferer(); ?>#!/Cart" data-id="<?php echo $item['id']; ?>" data-type="<?php echo $item['type']; ?>" class="pjErBtn pjErBtnClose erSelectorRemoveFromCart">
										<span class="glyphicon glyphicon-remove"></span>
									</a>
								</td><!-- /.col-xs-1 -->
							</tr><!-- /.pjErBasketProduct -->
							<?php
						} 
						?>
					</table><!-- /.table pjErBasketProducts -->
					<?php
					$pickup = !isset($FORM['forth']) || $FORM['forth'] == 'pickup';
					$delivery = isset($FORM['forth']) && $FORM['forth'] == 'delivery';
					$return = !isset($FORM['back']) || $FORM['back'] == 'return';
					$collection = isset($FORM['back']) && $FORM['back'] == 'collection';
					$forths = __('booking_forths', true);
					$backs = __('booking_backs', true);
					?>
					<div class="pjErBasketInner">
						<div class="row">
							<div class="col-sm-5 col-xs-12">
								<dl>
									<dt><?php __('booking_forth'); ?></dt>
									<?php
									if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
									{ 
										?>
										<dd>
											<ul class="list-inline pjErRadios">
												<li class="pjErRadio">
													<label><input type="radio" name="forth" value="pickup" data-price="0"<?php echo $pickup ? ' checked="checked"' : NULL; ?> /> <?php echo pjSanitize::html($forths['pickup']); ?> (<?php echo pjUtil::formatCurrencySign(number_format(0, 2), $tpl['option_arr']['o_currency']); ?>)</label>
												</li><!-- /.pjErRadio -->
												
												<li class="pjErRadio">
													<label><input type="radio" name="forth" value="delivery" data-price="<?php echo (float) $tpl['option_arr']['o_delivery']; ?>"<?php echo $delivery ? ' checked="checked"' : NULL; ?> /> <?php echo pjSanitize::html($forths['delivery']); ?> (<?php echo pjUtil::formatCurrencySign(number_format($tpl['option_arr']['o_delivery'], 2), $tpl['option_arr']['o_currency']); ?>)</label>
												</li><!-- /.pjErRadio -->
											</ul><!-- /.list-inline pjErRadios -->
										</dd>
										<?php
									} else {
										?>
										<dd>
											<ul class="list-inline pjErRadios">
												<li class="pjErRadio">
													<label><input type="radio" name="forth" value="pickup" data-price="0"<?php echo $pickup ? ' checked="checked"' : NULL; ?> /> <?php echo pjSanitize::html($forths['pickup']); ?></label>
												</li><!-- /.pjErRadio -->
												
												<li class="pjErRadio">
													<label><input type="radio" name="forth" value="delivery" data-price="<?php echo (float) $tpl['option_arr']['o_delivery']; ?>"<?php echo $delivery ? ' checked="checked"' : NULL; ?> /> <?php echo pjSanitize::html($forths['delivery']); ?></label>
												</li><!-- /.pjErRadio -->
											</ul><!-- /.list-inline pjErRadios -->
										</dd>
										<?php
									}
									?>
								</dl>
							</div><!-- /col-sm-5 col-xs-12 -->
							
							<div class="col-sm-5 col-xs-12">
								<dl>
									<dt><?php __('booking_back'); ?></dt>
									<?php
									if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
									{ 
										?>
										<dd>
											<ul class="list-inline pjErRadios">
												<li class="pjErRadio">
													<label><input type="radio" name="back" value="return" data-price="0"<?php echo $return ? ' checked="checked"' : NULL; ?>/>  <?php echo pjSanitize::html($backs['return']); ?> (<?php echo pjUtil::formatCurrencySign(number_format(0, 2), $tpl['option_arr']['o_currency']); ?>)</label>
												</li><!-- /.pjErRadio -->
												
												<li class="pjErRadio">
													<label><input type="radio" name="back" value="collection" data-price="<?php echo (float) $tpl['option_arr']['o_collection']; ?>"<?php echo $collection ? ' checked="checked"' : NULL; ?>/>  <?php echo pjSanitize::html($backs['collection']); ?> (<?php echo pjUtil::formatCurrencySign(number_format($tpl['option_arr']['o_collection'], 2), $tpl['option_arr']['o_currency']); ?>)</label>
												</li><!-- /.pjErRadio -->
											</ul><!-- /.list-inline pjErRadios -->
										</dd>
										<?php
									} else {
										?>
										<dd>
											<ul class="list-inline pjErRadios">
												<li class="pjErRadio">
													<label><input type="radio" name="back" value="return" data-price="0"<?php echo $return ? ' checked="checked"' : NULL; ?>/>  <?php echo pjSanitize::html($backs['return']); ?></label>
												</li><!-- /.pjErRadio -->
												
												<li class="pjErRadio">
													<label><input type="radio" name="back" value="collection" data-price="<?php echo (float) $tpl['option_arr']['o_collection']; ?>"<?php echo $collection ? ' checked="checked"' : NULL; ?>/>  <?php echo pjSanitize::html($backs['collection']); ?></label>
												</li><!-- /.pjErRadio -->
											</ul><!-- /.list-inline pjErRadios -->
										</dd>
										<?php
									}
									?>
								</dl>
							</div><!-- /.col-sm-5 col-xs-12 -->
							
							<div class="col-sm-2 col-xs-12">
								<?php
								if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
								{ 
									?>
									<dl>
										<dt><?php __('delivery_price'); ?>:</dt>
								
										<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['delivery'] + $tpl['summary']['collection'], 2), $tpl['option_arr']['o_currency']); ?></dd>
									</dl>
									<?php
								} 
								?>
							</div><!-- /.col-lg-2 col-md-2 col-sm-2 col-xs-12 -->
							
							<div class="col-md-10 col-sm-12 col-xs-12">
								<p><?php __('delivery_notes'); ?></p>
							</div><!-- /.col-md-10 col-sm-12 col-xs-12 -->
						</div><!-- /.row -->
					</div><!-- /.pjErBasketInner -->
		
					<div class="row pjErBasketResults">
						<div class="col-md-6 col-md-offset-6 col-sm-12 col-xs-12">
							<?php
							if($tpl['option_arr']['o_disable_payments'] == 0 || $tpl['option_arr']['o_hide_prices'] == 0)
							{ 
								?>
								<dl class="dl-horizontal">
									<dt><?php __('front_items_price'); ?>:</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['price'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
			
								<dl class="dl-horizontal">
									<dt><?php __('front_dc'); ?>:</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['delivery'] + $tpl['summary']['collection'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
			
								<dl class="dl-horizontal">
									<dt><?php __('front_tax'); ?> (+ <?php echo $tpl['option_arr']['o_tax']?>%):</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['tax'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
			
								<dl class="dl-horizontal">
									<dt><?php __('front_security'); ?>:</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['security'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
			
								<dl class="dl-horizontal">
									<dt><?php __('front_total'); ?>:</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['total'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
			
								<dl class="dl-horizontal">
									<dt><?php __('front_deposit'); ?><?php echo $tpl['option_arr']['o_deposit_type'] == 'percent' ? ' ('.$tpl['option_arr']['o_deposit'].'%)' : NULL;?>:</dt>
									<dd><?php echo pjUtil::formatCurrencySign(number_format($tpl['summary']['deposit'], 2), $tpl['option_arr']['o_currency']); ?></dd>
								</dl><!-- /.dl-horizontal -->
								<?php
							} 
							?>
						</div><!-- /.col-md-6 col-md-offset-6 col-sm-12 col-xs-12 -->
					</div><!-- /.row pjErBasketResults -->
		
					<div class="clearfix pjErBasketActions">
						<?php
						if($back_url != '')
						{ 
							?>
							<a href="<?php echo $back_url; ?>" class="btn btn-default pull-left pjErBtn pjErBtnSecondary"><?php __('button_back'); ?></a>
							<?php
						}else{
							?>
							<a href="<?php echo pjUtil::getReferer(); ?>#!/Items" class="btn btn-default pull-left pjErBtn pjErBtnSecondary erSelectorItems"><?php __('button_back'); ?></a>
							<?php
						} 
						?>
						<button type="submit" class="btn btn-default pull-right pjErBtn pjErBtnPrimary"><?php __('button_checkout'); ?></button>
					</div><!-- /.clearfix pjErBasketActions -->
				</form>
			</div><!-- /.panel-body -->
		</div><!-- /.panel panel-default pjErBody pjErBasket -->
		<?php
	}else{
		?>
		<div class="panel panel-default pjErBody pjErProductDetails">
			<div class="panel-body pjErProductDetailsInner">
				<div class="row">
					<div class="col-md-7 col-sm-6 col-xs-12">
						<div class="pjErProductBody">
							<p><?php __('cart_empty_notice');?></p>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php
	}
} else{
	?>
	<div class="panel panel-default pjErBody pjErProductDetails">
		<div class="panel-body pjErProductDetailsInner">
			<div class="row">
				<div class="col-md-7 col-sm-6 col-xs-12">
					<div class="pjErProductBody">
						<p><?php __('accept_bookings_notice');?></p>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php
}
?>