<?php
if($tpl['status'] == 'OK')
{
	if($tpl['event_arr']['status'] == 'T')
	{
		?>
		<div class="panel panel-default pjTbMain">
			<?php
			include_once dirname(__FILE__) . '/elements/header.php';
			
			$STORE = $_SESSION[$controller->defaultStore];
			$ticket_store = isset($STORE['tickets']) && isset($STORE['tickets']['ticket_id']) ? $STORE['tickets']['ticket_id'] : array();
			$seat_store = isset($STORE['seats']) && isset($STORE['seats']['seat_id']) ? $STORE['seats']['seat_id'] : array();
			
			$legends = __('front_lengend', true);
			?>
			<form id="pjEtsSeatsForm_<?php echo $_GET['id'];?>" action="&amp;session_id=<?php echo session_id(); ?>" method="post">
			<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>">
				<div class="panel-body pjTbBody">
					<section class="pjTbSectionSeats">
						<div class="pjTbSessionTipMsg"><?php __('front_select_seats_tip'); ?></div>
						<div class="pjTbSessionTickets">
							<?php
							foreach($tpl['ticket_arr'] as $k => $v)
							{ 
								$qty = isset($ticket_store[$v['id']]) ? $ticket_store[$v['id']] : 0;
								?>
								<p id="pjEtsTicketTitle_<?php echo $v['id'];?>" class="pjTbSectionTitle pjEtsTicketTitle<?php echo $v['id'] == $tpl['focus_ticket_id'] ? ' focus' : NULL;?>" data-id="<?php echo $v['id'];?>" data-qty="<?php echo $qty;?>"><?php echo $qty;?> <?php echo pjSanitize::html($v['title']);?></p><!-- /.pjTbSectionTitle -->
								<?php
							}
							?>
							<div id="pjEtsHiddenSeats_<?php echo $_GET['id'];?>" style="display:none;">
								<?php
								foreach($seat_store as $ticket_id => $seat_id_arr)
								{
									foreach($seat_id_arr as $seat_id)
									{
										?><input type="hidden" id="seat_id_<?php echo $ticket_id;?>_<?php echo $seat_id;?>" name="seat_id[<?php echo $ticket_id;?>][<?php echo $seat_id;?>]" class="pjEtsHiddenSeat_<?php echo $ticket_id;?>" value="<?php echo $seat_id;?>"/><?php
									}
								} 
								?>
							</div>
						</div>
						<div id="pjEtsSeatsSelector_<?php echo $_GET['id'];?>">
							
						</div>
						<ul class="list-inline pjTbListSeatsTypes">
							<li>
								<span class="pjTbSeat pjTbSeatAvailable"></span>
								<span class="pjTbSeatTitle"><?php echo $legends['Available'];?></span>
							</li>
			
							<li>
								<span class="pjTbSeat pjTbSeatDisabled"></span>
								<span class="pjTbSeatTitle"><?php echo $legends['Blocked'];?></span>
							</li>
			
							<li>
								<span class="pjTbSeat pjTbSeatChecked"></span>
								<span class="pjTbSeatTitle"><?php echo $legends['Selected'];?></span>
							</li>
						</ul><!-- /.list-inline pjTbListSeatsTypes -->
					</section><!-- /.pjTbSectionSeats -->
				</div><!-- /.panel-body pjTbBody -->
				
				<div id="pjEtsSeatMsg_<?php echo $_GET['id']; ?>" class="panel-body pjTbBody" style="display: none;"><p class="text-danger"><?php __('front_seats_error_msg');?></p></div>
				
				<footer class="panel-footer clearfix pjTbFooter">
					<a href="#" class="btn btn-default pull-left pjEtsMenuItem" data-load="loadTickets"><?php __('front_btn_back');?></a>
					<button type="submit" class="btn btn-primary pull-right"><?php __('front_btn_submit');?></button>
				</footer><!-- /.panel-footer clearfix pjTbFooter -->
			</form>
		</div><!-- /.panel panel-default pjTbMain -->
		
		<ul id="pjEtsSeatClone_<?php echo $_GET['id'];?>" style="display: none;">
			<li id="pjEtsSeatChosen_{TICKETID}_{SEATID}"><a href="#" class="pjTbSeat pjTbSeatChecked" style="width: 25px; height: 25px; "><span class="pjTbSeatInner">{NAME}</span></a></li>
		</ul><!-- /.list-inline pjTbListChosenSeats -->
		<?php
	}else{
		?>
		<div class="panel panel-default pjTbMain">
			<div class="panel-body pjTbBody">
				<?php __('front_event_not_available');?>
			</div>
		</div>
		<?php
	}
}else{
	?>
	<div class="panel panel-default pjTbMain">
		<div class="panel-body pjTbBody">
			<?php __('front_event_not_exist');?>
		</div>
	</div>
	<?php
}
?>