<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	?>
	<?php
	include_once PJ_VIEWS_PATH . 'pjLayouts/elements/optmenu.php';
	include_once PJ_VIEWS_PATH . 'pjLayouts/elements/messagemenu.php';
	pjUtil::printNotice(__('infoAddMessageTitle', true, false), __('infoAddMessageDesc', true, false));
	?>
	<div class="multilang"></div>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminMessages&amp;action=pjActionCreate" method="post" id="frmCreateMessage" class="pj-form form">
		<input type="hidden" name="message_create" value="1" />
		<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>" />
		
		<p>
			<label class="title"><?php __('lblCategory'); ?></label>
			<span class="inline_block">
				<?php
				if(count($tpl['category_arr']) > 0)
				{ 
					?>
					<select data-placeholder="--<?php __('lblChoose'); ?>--" name="category_id[]" id="category_id" multiple="multiple" class="pj-form-field w300 required">
						<?php
						foreach ($tpl['category_arr'] as $v)
						{
							?><option value="<?php echo $v['id']; ?>"><?php echo !empty($v['category_name']) ? stripslashes($v['category_name']) : stripslashes($v['category']); ?></option><?php
						}
						?>
					</select>
					<?php
				}else{
					$message = __('lblNoCategoryMessage', true);
					$message = str_replace("{STAG}", '<a href="'.$_SERVER['PHP_SELF'].'?controller=pjAdminCategories&amp;action=pjActionCreate">', $message);
					$message = str_replace("{ETAG}", '</a>', $message);
					?>
					<label class="block t5"><?php echo $message;?></label>
					<input type="hidden" name="category_id" class="required"/>
					<?php
				} 
				?>
			</span>
		</p>
		<p>
			<label class="title"><?php __('lblMessage'); ?></label>
			<span class="inline_block">
				<textarea name="message" id="message" class="pj-form-field h150 w500 required"></textarea>
			</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=pjAdminMessages&action=pjActionIndex';" />
		</p>
	</form>
	<script type="text/javascript">
	var myLabel = myLabel || {};
	myLabel.field_required = "<?php __('ts_field_required'); ?>";
	</script>
	<?php
}
?>