<?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(__('infoUpdateMessageTitle', true, false), __('infoUpdateMessageDesc', true, false));
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminMessages&amp;action=pjActionUpdate" method="post" id="frmUpdateMessage" class="form pj-form">
		<input type="hidden" name="message_update" value="1" />
		<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>" />
		<input type="hidden" name="id" value="<?php echo $tpl['arr']['id']; ?>" />
		
		<p>
			<label class="title"><?php __('lblCategory'); ?></label>
			<span class="inline_block">
				<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)
					{
						if( in_array($v['id'], $tpl['category_id_arr']))
						{
						    ?><option value="<?php echo $v['id']; ?>" selected="selected"><?php echo !empty($v['category_name']) ? pjSanitize::html($v['category_name']) : pjSanitize::html($v['category']); ?></option><?php
						}else{
						    ?><option value="<?php echo $v['id']; ?>"><?php echo !empty($v['category_name']) ? pjSanitize::html($v['category_name']) : pjSanitize::html($v['category']); ?></option><?php
						}
					}
					?>
				</select>	
			</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"><?php echo pjSanitize::html($tpl['arr']['message'])?></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
}
?>