<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	if (isset($_GET['err']))
	{
		$titles = __('error_titles', true);
		$bodies = __('error_bodies', true);
		pjUtil::printNotice(@$titles[$_GET['err']], @$bodies[$_GET['err']]);
	}
	$week_start = isset($tpl['option_arr']['o_week_start']) && in_array((int) $tpl['option_arr']['o_week_start'], range(0,6)) ? (int) $tpl['option_arr']['o_week_start'] : 0;
	$jqDateFormat = pjUtil::jqDateFormat($tpl['option_arr']['o_date_format']);
	$str_disabled = $controller->isViewer() ? 'disabled="disabled"' : '';
	?>
	<div class="bold b10 fs14"><?php __('lblRoute'); ?>: <?php echo pjSanitize::html($tpl['route_arr']['title']);?></div>
	<?php
	include_once PJ_VIEWS_PATH . 'pjLayouts/elements/submenu.php';
	pjUtil::printNotice(__('infoBlockSeatsTitle', true, false), __('infoBlockSeatsDesc', true, false)); 
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBuses&amp;action=pjActionBlockSeats" method="post" id="frmBlockSeats" class="pj-form form">
		<input type="hidden" name="bus_update" value="1" />
		<input type="hidden" id="id" name="id" value="<?php echo $tpl['arr']['id']?>" />
		<?php if (count($tpl['block_seat_arr']) <= 0) {?>
			<div class="pjBrsBlockSeats b5" style="display: none;"><?php __('lblNoBlockSeatsAdded');?></div>
		<?php } ?>
		<div id="bs_block_seats_container">
			<?php
			foreach($tpl['block_seat_arr'] as $v)
			{
				$index = 'bs_' . rand(1, 999999);
				?>
				<p>
					<label class="title"><?php __('lblBlockSeatDate'); ?>:</label>
					<span class="float_left overflow r10">
						<span class="pj-form-field-custom pj-form-field-custom-after float_left r5 b5">
							<input type="text" <?php echo $str_disabled;?> name="date[<?php echo $index;?>]" id="date_<?php echo $index;?>" class="pj-form-field pointer w80 datepick required" readonly="readonly" rel="<?php echo $week_start; ?>" rev="<?php echo $jqDateFormat; ?>" value="<?php echo pjUtil::formatDate($v['date'], "Y-m-d", $tpl['option_arr']['o_date_format']); ?>"/>
							<span class="pj-form-field-after"><abbr class="pj-form-field-icon-date"></abbr></span>
						</span>
					</span>
					<label class="title"><?php __('lblBlockSeatBlock'); ?>:</label>
					<span class="float_left overflow">
						<span class="block">
							<input type="text" <?php echo $str_disabled;?> name="seats[<?php echo $index;?>]" value="<?php echo (int)$v['seats'];?>" class="pj-form-field digits w80 required" />
							<?php __('lblBlockSeatSeats');?>
							<?php if (!$controller->isViewer()) { ?>
							<input type="button" value="<?php __('btnRemove'); ?>" class="pj-button pj-button-remove-block-seat l10" />
							<?php } ?>
						</span>
					</span>
				</p>
				<?php
			}
			if(isset($_GET['date']))
			{
				$index = 'bs_' . rand(1, 999999);
				?>
				<p>
					<label class="title"><?php __('lblBlockSeatDate'); ?>:</label>
					<span class="float_left overflow r10">
						<span class="pj-form-field-custom pj-form-field-custom-after float_left r5 b5">
							<input type="text" <?php echo $str_disabled;?> name="date[<?php echo $index;?>]" id="date_<?php echo $index;?>" class="pj-form-field pointer w80 datepick required" readonly="readonly" rel="<?php echo $week_start; ?>" rev="<?php echo $jqDateFormat; ?>" value="<?php echo $_GET['date']; ?>"/>
							<span class="pj-form-field-after"><abbr class="pj-form-field-icon-date"></abbr></span>
						</span>
					</span>
					<label class="title"><?php __('lblBlockSeatBlock'); ?>:</label>
					<span class="float_left overflow">
						<span class="block">
							<input type="text" <?php echo $str_disabled;?> name="seats[<?php echo $index;?>]" class="pj-form-field digits w80 required" />
							<?php __('lblBlockSeatSeats');?>
							<?php if (!$controller->isViewer()) { ?>
							<input type="button" value="<?php __('btnRemove'); ?>" class="pj-button pj-button-remove-block-seat l10" />
							<?php } ?>
						</span>
					</span>
				</p>
				<?php
			} 
			?>			
		</div>
		<?php if (!$controller->isViewer()) { ?>
		<p>
			<label class="title">&nbsp;</label>
			<input type="button" value="<?php __('btnAdd'); ?>" class="pj-button pj-button-add-block-seat" />
			<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
		</p>
		<?php } ?>
	</form>
	
	<div id="bs_block_seats_clone" style="display:none;">
		<p>
			<label class="title"><?php __('lblBlockSeatDate'); ?>:</label>
			<span class="float_left overflow r10">
				<span class="pj-form-field-custom pj-form-field-custom-after float_left r5 b5">
					<input type="text" name="date[{INDEX}]" id="date_{INDEX}" class="pj-form-field pointer w80 datepick required" readonly="readonly" rel="<?php echo $week_start; ?>" rev="<?php echo $jqDateFormat; ?>" />
					<span class="pj-form-field-after"><abbr class="pj-form-field-icon-date"></abbr></span>
				</span>
			</span>			
			<label class="title"><?php __('lblBlockSeatBlock'); ?>:</label>
			<span class="float_left overflow">
				<span class="block">
					<input type="text" name="seats[{INDEX}]" class="pj-form-field digits w80 required" />
					<?php __('lblBlockSeatSeats');?>
					<input type="button" value="<?php __('btnRemove'); ?>" class="pj-button pj-button-remove-block-seat l10" />
				</span>
			</span>
		</p>
	</div>
	
	<script type="text/javascript">
	var locale_array = new Array(); 
	var myLabel = myLabel || {};
	myLabel.field_required = "<?php __('bs_field_required'); ?>";
	myLabel.timeFormat = "<?php echo $tpl['option_arr']['o_time_format']?>";
	</script>
	<?php
}
?>