{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ -->
<H1>{$layout.pagetitle}</H1>

<form method="POST" name="tedit" id="tedit" action="?m=customergroupedit&id={$customergroup.id}"></form>

<form name="tmove" id="tmove" method="get" action=""></form>

<input type="submit" class="hiddenbtn" form="tedit">

<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
    <thead>
		<tr>
			<td>
				{icon name="customergroup"}
			</td>
			<td class="nobr">
				<strong>{trans("Name:")}</strong>
			</td>
			<td>
				<div class="lms-ui-cell-flex">
					<input type="text" value="{$customergroup.name}" name="customergroup[name]" size="40" required
						maxlength="255" pattern="{literal}[\.\-_a-zA-Z0-9\p{L}]+{/literal}" form="tedit" {tip trigger="name" bold=1}>
					{hint mode="toggle" content="Group name can contain letters (with national characters), digits, dots, underscores and dashes."}
					<strong>({$customergroup.id|string_format:"%04d"})</strong>
				</div>
			</td>
		</tr>
    </thead>
    <tbody>
		<tr>
			<td>
				{icon name="info"}
			</td>
			<td>
				<strong>{trans("Description:")}</strong>
			</td>
			<td>
				<textarea rows="5" cols="50" name="customergroup[description]" {tip text="Enter additional information (optional)"}
					form="tedit">{$customergroup.description|escape}</textarea>
			</td>
		</tr>
		<tr>
			<td class="lms-ui-box-buttons" colspan="3">
				{button type="submit" icon="save" label="Submit" form="tedit"}
				{button icon="cancel" label="Cancel" href="?m=customergroupinfo&id={$customergroup.id}{if $membersnetid}&membersnetid={$membersnetid}{/if}{if $othersnetid}&othersnetid={$othersnetid}{/if}"}
				{if count($customergroups) > 1 && $customergroup.count}
					{button id="move-members" icon="reload" label="Move members to group:"}
					<select size="1" name="to" {tip text="Select group to which you want to move members"}
							form="tmove">
						{foreach $customergroups as $item}
							{if $item.id != $customergroup.id}
								<option value="{$item.id}">{$item.name}</option>
							{/if}
						{/foreach}
					</select>
					<input type="hidden" name="is_sure" value="1" form="tmove">
					<input type="hidden" name="m" value="customergroupmove" form="tmove">
					<input type="hidden" name="from" value="{$customergroup.id}" form="tmove">
				{/if}
			</td>
		</tr>
    </tbody>
</table>
<script>

	$(function() {
		$('form[name="tedit"] [name="customergroup[name]"]').focus();

		$('#move-members').click(function() {
			confirmDialog($t("Are you sure, you want to move members to selected group?"), this).done(function() {
				document.tmove.submit();
			});
			return false;
		});
	});

</script>
{include file="customer/customergroupassignments.html"}
{/block}
