<?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']]);
	}
	
	?>
	
	<div class="form pj-form">
			
		<?php pjUtil::printNotice(__('infoInstallTitle', true), __('infoInstallDesc', true));; ?>
		<p>
			<label class="title"><?php __('lblSelectProduct');?></label>
			<span class="inline_block">
				<?php
				if(count($tpl['product_arr']) > 0)
				{ 
					?>
					<select name="product_id" id="product_id" class="pj-form-field w200 required" data-msg-required="<?php __('lblFieldRequired');?>">
						<option value="">-- <?php __('lblChoose'); ?>--</option>
						<?php
						foreach ($tpl['product_arr'] as $k => $v)
						{
							if(isset($_GET['id']))
							{
								if($_GET['id'] == $v['id']){
									?><option value="<?php echo $v['id']; ?>" selected="selected"><?php echo $v['name']; ?></option><?php
								}else{
									?><option value="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></option><?php
								}
							}else{
								?><option value="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></option><?php
							}
						}
						?>
					</select>
					<?php
				}else{
					$message = __('lblNoProductsMessage', true);
					$message = str_replace("{STAG}", '<a href="'.$_SERVER['PHP_SELF'].'?controller=pjAdminProducts&amp;action=pjActionCreate">', $message);
					$message = str_replace("{ETAG}", '</a>', $message);
					?><label class="block t5"><?php echo $message;?></label><?php
				} 
				?>
			</span>
		</p>
		<p>
			<label class="title"><?php __('lblSelectTheme');?></label>
			<span class="inline_block">
				<select name="theme" id="theme" class="pj-form-field w150">
					<?php
					$default = explode("::", $tpl['theme_arr']['value']);
					$enum = explode("|", $default[0]);
					
					$enumLabels = array();
					if (!empty($tpl['theme_arr']['label']) && strpos($tpl['theme_arr']['label'], "|") !== false)
					{
						$enumLabels = explode("|", $tpl['theme_arr']['label']);
					}
					foreach ($enum as $k => $el)
					{
						if ($default[1] == $el)
						{
							?><option value="<?php echo $el; ?>" selected="selected"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
						} else {
							?><option value="<?php echo $el; ?>"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
						}
					}
					?>
				</select>
			</span>
		</p>
		<?php
		if(count($tpl['product_arr']) > 0)
		{
			?>
			<p>
				<label class="title">&nbsp;</label>
				<span class="inline_block">
					<input type="button" value="<?php __('btnPreview'); ?>" class="pj-button pj-button-preview"/>
					<input type="button" value="<?php __('btnGetInstallCode'); ?>" class="pj-button pj-button-get-code"/>
				</span>
			</p>
			<?php
		
		?>
		
		<div id="step_container" style="display:<?php echo isset($_GET['id']) ? 'block' : 'none';?>;">
		<p style="margin: 20px 0 10px; font-weight: bold"><?php __('lblInstallNotes', false, true); ?></p>
	<textarea class="pj-form-field textarea_install" id="install_code" style="overflow: auto; height:90px; width: 726px;">
&lt;link href="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&action=pjActionLoadCss&theme=<?php echo $tpl['option_arr']['o_theme'];?>" type="text/css" rel="stylesheet" /&gt;
&lt;script type="text/javascript" src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&action=pjActionLoad<?php echo isset($_GET['id']) && (int) $_GET['id'] > 0 ? '&product_id=' . $_GET['id'] : NULL ?>&theme=<?php echo $tpl['option_arr']['o_theme'];?>"&gt;&lt;/script&gt;</textarea>
		<p style="margin: 20px 0 10px; font-weight: bold"><?php __('lblInstallUseLink'); ?></p>
		<textarea class="pj-form-field textarea_install" style="overflow: auto; height:30px; width: 726px;">&lt;a class="pjCBOfferPrice" href="#"&gt;<?php __('lblOfferAPrice');?>&lt;/a&gt;</textarea>
	<div style="display:none" id="hidden_code">&lt;link href="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&action=pjActionLoadCss" type="text/css" rel="stylesheet" /&gt;
&lt;script type="text/javascript" src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&action=pjActionLoadJS"&gt;&lt;/script&gt;</div>
		</div>
		<?php
		} 
	?>
	</div><!-- form -->
	
	<?php
}
?>