{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
{$hide_disabled_users = ConfigHelper::checkConfig('rt.hide_disabled_users', ConfigHelper::checkConfig('phpui.helpdesk_hide_disabled_users'))}
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>
<form method="POST" name="category" action="?m=rtcategoryedit&id={$category.id}">
<input type="submit" class="hiddenbtn">
<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
	<thead>
		<tr>
			<td>
				{icon name="queue"}
			</td>
			<td>
				<strong>{trans("Name:")}</strong>
			</td>
			<td>
				<input type="text" name="category[name]" value="{$category.name}"
					{tip text="Enter category name" trigger="name" bold=1}>
				<strong>({$category.id|string_format:"%04d"})</strong>
			</td>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				{icon name="description"}
			</td>
			<td>
				<strong>{trans("Description:")}</strong>
			</td>
			<td>
				<textarea name="category[description]" cols="50" rows="2"
					{tip text="Enter additional information (optional)"}>{$category.description}</textarea>
			</td>
		</tr>
		<tr>
			<td>
				{icon name="color"}
			</td>
			<td>
				<label for="background-style">
					<strong>{trans("<!rt-category>Background:")}</strong>
				</label>
			</td>
			<td>
				<input id="background-style" type="color" name="category[background-style]"
					value="{if empty($category['background-style'])}#ffffff{else}{$category['background-style']}{/if}">
			</td>
		</tr>
		<tr>
			<td>
				{icon name="color"}
			</td>
			<td>
				<label for="text-style">
					<strong>{trans("<!rt-category>Text:")}</strong>
				</label>
			</td>
			<td>
				<input id="text-style" type="color" name="category[text-style]"
					value="{if empty($category['text-style'])}#000000{else}{$category['text-style']}{/if}">
			</td>
		</tr>
		<tr>
			<td>
				{icon name="user"}
			</td>
			<td>
				<strong>{trans("Users")}</strong>
			</td>
			<td>
				<table class="lmsbox lms-ui-background-cycle">
					<colgroup>
						<col style="width:99%;">
						<col style="width:1%;">
					</colgroup>
					<thead>
						<tr>
							<td>
								<strong>{trans("User")}</strong>
							</td>
							<td class="nobr align-center">
								<strong>{trans("Owner")}</strong>
							</td>
						</tr>
					</thead>
					<tbody class="lms-ui-multi-check">
						{foreach $category.owners as $user}
							<tr class="highlight{if empty($users[$user.id].access)} blend{/if}"
								{if empty($users[$user.id].access) && $hide_disabled_users} style="display: none;"{/if}>
								<td>
									<a href="?m=userinfo&id={$user.id}">
										{$user.rname|escape} ({$user.login})
									</a>
								</td>
								<td class="text-center">
									<input type="checkbox" name="category[users][{$user.id}]" class="lms-ui-multi-check"
										value="1"{if $user.owner > 0} checked{/if}>
								</td>
							</tr>
							{if empty($users[$user.id].access) && $hide_disabled_users}
								<tr style="display: none;">
									<td colspan="2"></td>
								</tr>
							{/if}
						{/foreach}
						<tr>
							<td class="text-right">
								<label for="allbox">
									{trans("Check All")}
								</label>
							</td>
							<TD class="text-center">
								<input type="checkbox" name="allbox" id="allbox" class="lms-ui-multi-check-all">
							</TD>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3" class="lms-ui-box-buttons">
				{button type="submit" icon="save" label="Submit"}
				{button id="delete-rtcategory" icon="delete" label="Delete" data_name="{$category.name}"
					href="?m=rtcategorydel&id={$category.id}" data-name="{$category.name}"}
				{button icon="cancel" label="Cancel" href="?m=rtcategorylist"}
			</td>
		</tr>
    </tbody>
</table>
</form>
<script>

	$(function() {
		$('[name="category[name]"]').focus();

		$('#delete-rtcategory').click(function() {
			var name = $(this).attr('data-name');
			confirmDialog($t("Are you sure, you want to remove category '$a'?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
		});
	});

</script>
{/block}
