<?page title="${labels.UsersFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk>
	<window
		id="editWin"
		border="normal"
		closable="true"
		width="450px"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('vm') @init('info.bukova.isspst.ui.users.UserForm')"
		validationMessages="@id('vmsg')">
		<caption
			zclass="form-caption"
			label="${labels.UsersFormTitle}" />
		
		<tabbox>
			<tabs>
				<tab label="Základní"/>
				<tab label="Adresa"/>
			</tabs>
			<tabpanels>
				<tabpanel>
					<grid
						width="440px"
						form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.userFormValidator)">
						<columns>
							<column hflex="min"></column>
							<column></column>
							<column></column>
						</columns>
						<rows>
							<row>
								<label value="${labels.UsersFormLogin}" />
								<textbox
									value="@bind(vm.dataBean.username)"
									instant="true"
									disabled="@load(vm.editRec)"
									maxlength="@load(vm.lengthText)"
									onChange="@command('checkLogin')" />
								<label
									value="Login je obsazený"
									sclass="error"
									visible="@load(not vm.loginFree)" />
							</row>
							<row>
								<label value="${labels.UsersFormFirstName}" />
								<textbox
									value="@bind(vm.dataBean.firstName)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="${labels.UsersFormSureName}" />
								<textbox
									value="@bind(vm.dataBean.lastName)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="${labels.UsersFormPersonalID}" />
								<textbox
									value="@bind(vm.dataBean.personalNumber)"
									maxlength="@load(vm.lengthText)"
									width="90px" />
							</row>
							<row>
								<label value="${labels.UsersFormEmail}" />
								<textbox
									value="@bind(vm.dataBean.email)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="" />
								<checkbox
									label="${labels.UsersFormSendNotify}"
									checked="@bind(vm.dataBean.notify)" />
							</row>
							<row>
								<label value="${labels.UsersFormPassword}" />
								<textbox
									id="idUserPasswordOriginal"
									value="@save(vm.password, before='save')"
									type="password"
									maxlength="@load(vm.lengthText)"
									instant="true" />
							</row>
							<row>
								<label value="${labels.UsersFormRepeatPassword}" />
								<textbox
									id="idUserPasswordDuplicate"
									value="@save(vm.retPasswd, before='save')"
									type="password"
									maxlength="@load(vm.lengthText)"
									instant="true" />
							</row>
							<row>
								<label value="" />
								<checkbox
									label="${labels.UsersFormActive}"
									checked="@bind(vm.dataBean.enabled)"
									disabled="@load(vm.dataBean.username eq 'admin')" />
							</row>
						</rows>
					</grid>
					<groupbox mold="3d">
						<caption label="Role" />
						<vbox children="@load(vm.userRoles.roleChecks)">
							<template name="children">
								<checkbox
									label="@load(each.role.description)"
									checked="@bind(each.checked)"
									disabled="@load((vm.dataBean.username eq 'admin') or (each.role.authority eq 'ROLE_USER'))" />
							</template>
						</vbox>
					</groupbox>		
				</tabpanel>
				<tabpanel>
					<grid>
						<columns>
							<column/>
							<column/>
						</columns>
						<rows>
							<row>
								<label value="${labels.SuppliersFormStreet}"/>
								<textbox
									value="@bind(vm.dataBean.address.street)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="${labels.SuppliersFormNo}"/>
								<textbox
									value="@bind(vm.dataBean.address.houseNumber)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="${labels.SuppliersFormZIP}"/>
								<textbox
									value="@bind(vm.dataBean.address.zipCode)"
									maxlength="@load(vm.lengthText)" />
							</row>
							<row>
								<label value="${labels.SuppliersFormCity}"/>
								<textbox
									value="@bind(vm.dataBean.address.city)"
									maxlength="@load(vm.lengthText)" />
							</row>
						</rows>
					</grid>
				</tabpanel>
			</tabpanels>
		</tabbox>
		
		<include src="/app/formButtons.zul" />
	</window>
</zk>