<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	
	$token_arr = array();
	foreach($tpl['token_arr'] as $pair)
	{
		$token_arr[] = '<label>' . $pair . '</label>';
	}
	include_once PJ_VIEWS_PATH . 'pjLayouts/elements/docmenu.php';
	pjUtil::printNotice(__('infoUpdateTemplateTitle', true), __('infoUpdateTemplateDesc', true) . '<br/><br/>' . join("", $token_arr), false); 
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminTemplates&amp;action=pjActionUpdate" method="post" id="frmUpdateTemplate" class="form pj-form" autocomplete="off">
		<input type="hidden" name="template_update" value="1" />
		<input type="hidden" name="id" value="<?php echo (int) $tpl['arr']['id']; ?>" />
		
		<p>
			<label class="title"><?php __('lblDocuments'); ?></label>
			<span class="inline_block">
				<?php
				if($tpl['arr']['documents'] > 0)
				{ 
					?>
					<label class="content"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminDocuments&amp;action=pjActionIndex&amp;template_id=<?php echo $tpl['arr']['id'];?>"><?php echo $tpl['arr']['documents'];?></a> <?php $tpl['arr']['documents'] == 1 ? __('lblDocumentUsingTemplate') : __('lblDocumentsUsingTemplate');?></label>
					<?php
				}else{
					?>
					<label class="content"><?php echo $tpl['arr']['documents'];?> <?php __('lblDocumentsUsingTemplate') ;?></label>
					<?php
				} 
				?>
			</span>
		</p>
		<p>
			<label class="title"><?php __('lblTitle'); ?></label>
			<span class="inline_block">
				<input type="text" name="title" id="title" value="<?php echo pjSanitize::html($tpl['arr']['title']); ?>" class="pj-form-field w400 required" data-msg-required="<?php __('lblFieldRequired');?>" data-msg-remote="<?php __('lblTitleUsed');?>"/>
			</span>
		</p>
		<p>
			<label class="title"><?php __('lblText'); ?></label>
			<span class="inline_block">
				<textarea name="content" class="pj-form-field required mceEditor" data-msg-required="<?php __('lblFieldRequired');?>"><?php echo stripslashes($tpl['arr']['content'])?></textarea>
			</span>
		</p>
		<p>
			<label class="title"><?php __('lblStatus'); ?></label>
			<span class="inline_block">
				<select name="status" id="status" class="pj-form-field required" data-msg-required="<?php __('lblFieldRequired');?>" >
					<option value="">-- <?php __('lblChoose'); ?>--</option>
					<?php
					foreach (__('u_statarr', true) as $k => $v)
					{
						?><option value="<?php echo $k; ?>"<?php echo $k == $tpl['arr']['status'] ? ' selected="selected"' : NULL;?>><?php echo $v; ?></option><?php
					}
					?>
				</select>
			</span>
		</p>
		<p>
			<label class="title">&nbsp;</label>
			<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
			<input type="button" value="<?php __('btnCancel'); ?>" class="pj-button" onclick="window.location.href='<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminTemplates&action=pjActionIndex';" />
		</p>
	</form>
	
	<script>
	var myLabel = myLabel || {};
	myLabel.fileuploader_version = '<?php echo $tpl['fileuploader_version']; ?>';
	myLabel.fileuploader_url = '<?php echo $tpl['fileuploader_url']; ?>';
	</script>
	<?php
}
?>