<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	$titles = __('error_titles', true);
	$bodies = __('error_bodies', true);
	include PJ_VIEWS_PATH . 'pjLayouts/elements/contentmenu.php';
	?>
	<div class="ui-tabs ui-widget ui-widget-content ui-corner-all b10">
		<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
			<li class="ui-state-default ui-corner-top"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminDestinations&amp;action=pjActionIndex"><?php __('menuDestinations'); ?></a></li>
			<li class="ui-state-default ui-corner-top"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminDestinations&amp;action=pjActionCreate"><?php __('dest_create'); ?></a></li>
			<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminDestinations&amp;action=pjActionUpdate"><?php __('dest_update'); ?></a></li>
		</ul>
	</div>

	<?php
	if (isset($_GET['err']))
	{
		pjUtil::printNotice(@$titles[$_GET['err']], @$bodies[$_GET['err']]);
	}
	pjUtil::printNotice(@$titles['AD12'], @$bodies['AD12']);
	?>
	
	<div class="multilang"></div>
	<div class="pj-form form">
		<div class="p">
			<label class="title"><?php __('dest_image'); ?>:</label>
			<div id="upload" class="float_left" data-id="<?php echo $tpl['arr']['id']; ?>"></div>
		</div>
		<p>
			<label class="title">&nbsp;</label>
			<span class="inline_block" id="box-dest">
			<?php include dirname(__FILE__) . '/pjActionImage.php'; ?>
			</span>
		</p>
	</div>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminDestinations&amp;action=pjActionUpdate" method="post" id="frmUpdateDestination" class="form pj-form">
		<input type="hidden" name="destination_update" value="1" />
		<input type="hidden" name="id" value="<?php echo $tpl['arr']['id']; ?>" />
		<p>
			<label class="title"><?php __('dest_country'); ?>:</label>
			<span class="inline_block">
			<select name="country_id" id="country_id" class="pj-form-field required">
				<option value="">-- <?php __('lblChoose'); ?> --</option>
				<?php
				foreach ($tpl['country_arr'] as $country)
				{
					?><option value="<?php echo $country['id']; ?>"<?php echo $tpl['arr']['country_id'] != $country['id'] ? NULL : ' selected="selected"'; ?>><?php echo pjSanitize::html($country['country_title']); ?></option><?php
				}
				?>
			</select>
			</span>
		</p>
		<?php
		foreach ($tpl['lp_arr'] as $v)
		{
			?>
			<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
				<label class="title"><?php __('dest_name'); ?>:</label>
				<span class="inline_block">
					<input type="text" name="i18n[<?php echo $v['id']; ?>][name]" class="pj-form-field w300<?php echo (int) $v['is_default'] === 0 ? NULL : ' required'; ?>" value="<?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']]['name']); ?>" />
					<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
				</span>
			</p>
			<?php
		}
		?>
		<p>
			<label class="title"><?php __('dest_url'); ?>:</label>
			<span class="inline_block">
				<input type="text" name="seo_url" id="seo_url" class="pj-form-field w400 required" maxlength="100" value="<?php echo pjSanitize::html($tpl['arr']['seo_url']); ?>" />
				<a href="#" class="pj-form-langbar-tip center-langbar-tip" title="<?php __('tip_seo_url', false, true); ?>"></a>
			</span>
		</p>
		<?php
		foreach ($tpl['lp_arr'] as $v)
		{
			?>
			<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
				<label class="title"><?php __('dest_title'); ?>:</label>
				<span class="inline_block">
					<input type="text" name="i18n[<?php echo $v['id']; ?>][title]" class="pj-form-field w500<?php echo (int) $v['is_default'] === 0 ? NULL : ' required'; ?>" value="<?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']]['title']); ?>" />
					<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
				</span>
			</p>
			<?php
		}
		foreach ($tpl['lp_arr'] as $v)
		{
			?>
			<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
				<label class="title"><?php __('dest_full_desc'); ?>:</label>
				<span class="inline_block">
					<textarea name="i18n[<?php echo $v['id']; ?>][full_desc]" class="pj-form-field selector-tinymce w500 h400<?php echo (int) $v['is_default'] === 0 ? NULL : ' required'; ?>"><?php echo stripslashes(@$tpl['arr']['i18n'][$v['id']]['full_desc']); ?></textarea>
					<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
				</span>
			</p>
			<?php
		}
		foreach ($tpl['lp_arr'] as $v)
		{
			?>
			<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
				<label class="title"><?php __('page_meta_title'); ?>:</label>
				<span class="inline_block">
					<input type="text" name="i18n[<?php echo $v['id']; ?>][meta_title]" class="pj-form-field w500" value="<?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']]['meta_title']); ?>" />
					<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
					<a href="#" class="pj-form-langbar-tip center-langbar-tip" title="<?php __('tip_meta_title', false, true); ?>"></a>
				</span>
			</p>
			<?php
		}
		foreach ($tpl['lp_arr'] as $v)
		{
			?>
			<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
				<label class="title"><?php __('page_meta_desc'); ?>:</label>
				<span class="inline_block">
					<input type="text" name="i18n[<?php echo $v['id']; ?>][meta_desc]" class="pj-form-field w500" value="<?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']]['meta_desc']); ?>" />
					<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
					<a href="#" class="pj-form-langbar-tip center-langbar-tip" title="<?php __('tip_meta_desc', false, true); ?>"></a>
				</span>
			</p>
			<?php
		}
		?>
		<p>
			<label class="title"><?php __('dest_on_home_title'); ?></label>
			<span class="inline_block">
				<select name="on_home" id="on_home" class="pj-form-field required">
					<option value="">-- <?php __('lblChoose'); ?> --</option>
				<?php
				foreach (__('_bool', true) as $k => $v)
				{
					?><option value="<?php echo $k; ?>"<?php echo $k != $tpl['arr']['on_home'] ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
				}
				?>
				</select>
			</span>
		</p>
		<p>
			<label class="title">&nbsp;</label>
			<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
		</p>
	</form>
	
	<div id="dialogDestinationDelete" title="<?php __('slide_del_img_title', false, true); ?>" style="display: none"><?php __('slide_del_img_desc'); ?></div>
	<div id="dialogDestinationCrop" title="<?php __('slide_crop_img_title', false, true); ?>" style="display: none"></div>
	
	<script type="text/javascript">
	var myLabel = myLabel || {};
	myLabel.localeId = "<?php echo $controller->getLocaleId(); ?>";
	(function ($) {
		$(function() {
			$(".multilang").multilang({
				langs: <?php echo $tpl['locale_str']; ?>,
				flagPath: "<?php echo PJ_FRAMEWORK_LIBS_PATH; ?>pj/img/flags/",
				select: function (event, ui) {
					// Callback, e.g. ajax requests or whatever
				}
			});
		});
	})(jQuery_1_8_2);
	</script>
	<?php
}
?>