<?php
$action = $_GET['action'];
$menu_arr = array(
		'pjActionServices' => 1,
		'pjActionDateTime' => 2,
		'pjActionCheckout' => 3,
		'pjActionPreview' => 4
);
$menu_title_arr = array(
		1 => array('text'=> __('front_menu_step_1', true), 'load' => 'loadServices'),
		2 => array('text'=> __('front_menu_step_2', true), 'load' => 'loadDateTime'),
		3 => array('text'=> __('front_menu_step_3', true), 'load' => 'loadCheckout'),
		4 => array('text'=> __('front_menu_step_4', true), 'load' => 'loadPreview')
);
$current_item = $menu_arr[$action];
?>
<header class="panel-heading clearfix pjCcHeader">
	<div class="pull-left">
		<a href="#" data-load="loadServices" class="btn btn-default pjCcHome pjCbsMenuItem">
			<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
		</a>

		<div class="btn-group pjCcNav">
			<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				<?php echo $menu_title_arr[$current_item]['text'];?>
				<span class="caret"></span>
			</button>

			<ul class="dropdown-menu">
				<?php
				foreach($menu_title_arr as $k => $v)
				{
					?><li<?php echo $k <= $current_item ? ($k == $current_item ? ' class="active"' : NULL) : ' class="pjCcDdisabled"'; ?>><a href="#" class="pjCbsMenuItem" data-load="<?php echo $v['load'];?>"><?php echo $v['text'];?></a></li><?php
				} 
				?>
			</ul><!-- /.dropdown-menu -->
		</div><!-- /.btn-group pjCcNav -->
	</div><!-- /.pull-left -->
	<?php if ((!isset($_GET['hide']) || (int) $_GET['hide'] === 0) && isset($tpl['locale_arr']) && is_array($tpl['locale_arr']) && count($tpl['locale_arr']) > 1) : ?>
		<div class="pull-right">
			<div class="btn-group pjCcNav pjCcNavLang">
				<?php
				$selected_title = null;
				$selected_src = NULL;
				foreach ($tpl['locale_arr'] as $locale)
				{
					if ($controller->getLocaleId() == $locale['id'])
					{
						$selected_title = $locale['language_iso'];
						$lang_iso = explode("-", $selected_title);
						if(isset($lang_iso[1]))
						{
							$selected_title = $lang_iso[1];
						}
						if (!empty($locale['flag']) && is_file(PJ_INSTALL_PATH . $locale['flag']))
						{
							$selected_src = PJ_INSTALL_FOLDER . $locale['flag'];
						} elseif (!empty($locale['file']) && is_file(PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $locale['file'])) {
							$selected_src = PJ_INSTALL_FOLDER . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $locale['file'];
						}
						break;
					}
				}
				?>
				<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					<img src="<?php echo $selected_src; ?>" alt="">
					<?php echo $selected_title; ?>
					<span class="caret"></span>
				</button>
	
				<ul class="dropdown-menu">
					<?php
					foreach ($tpl['locale_arr'] as $locale)
					{
						$selected_src = NULL;
						if (!empty($locale['flag']) && is_file(PJ_INSTALL_PATH . $locale['flag']))
						{
							$selected_src = PJ_INSTALL_FOLDER . $locale['flag'];
						} elseif (!empty($locale['file']) && is_file(PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $locale['file'])) {
							$selected_src = PJ_INSTALL_FOLDER . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $locale['file'];
						}
						?>
						<li<?php echo $controller->getLocaleId() == $locale['id'] ? ' active' : NULL; ?>>
							<a href="#" class="pjCbsLocale" data-id="<?php echo $locale['id']; ?>">
								<img src="<?php echo $selected_src; ?>" alt="">
								<?php echo pjSanitize::html($locale['name']); ?>
							</a>
						</li>
						<?php
					}
					?>
				</ul><!-- /.dropdown-menu -->
			</div><!-- /.btn-group pjCcNav pjCcNavLang -->
		</div><!-- /.pull-right -->
	<?php endif;?>
</header><!-- /.panel-heading clearfix pjCcHeader -->