<?page title="${labels.RequirementsFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk
	xmlns="http://www.zkoss.org/2005/zul"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
	<window
		id="editWin"
		closable="true"
		width="95%"
		height="95%"
		border="normal"
		position="center"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.TripRequirementForm')">
		<caption
			src="/img/reqact.png"
			zclass="form-caption"
			label="${labels.TripRequirement}" />
		<!-- Dialog -->
		<vlayout
			form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.validator)"
			sclass="addScrollbar"
			vflex="1">
			<!-- Formulář + soubory -->
			<hbox
				hflex="1"
				vflex="min">
				<grid
					hflex="min"
					vflex="1">
					<columns>
						<column
							align="right"
							hflex="min" />
						<column />
					</columns>
					<rows>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormNumberSerie} :</cell>
							<cell>
								<textbox
									id="numser"
									width="200px"
									value="@bind(fx.numser)"
									maxlength="@load(vm.lengthText)"
									readonly="true" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormReqDate} :</cell>
							<cell>
								<datebox
									id="reqDate"
									width="200px"
									value="@bind(fx.reqDate)"
									format="${labels.DateFormat}" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormCenter} :</cell>
							<cell>
								<combobox
									model="@load(vm.centres)"
									readonly="true"
									selectedItem="@bind(fx.centre)">
									<template name="model">
										<comboitem label="@load(each.fullName)" />
									</template>
								</combobox>
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormFrom} :</cell>
							<cell>
								<textbox
									id="from"
									width="300px"
									maxlength="@load(vm.lengthText)"
									value="@bind(fx.from)" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormStartDateTime} :</cell>
							<cell>
								<hbox>
									<datebox
										id="tripDate"
										width="200px"
										format="${labels.DateFormat}"
										value="@bind(fx.tripDate)" />
									<timebox
										id="tripTime"
										width="90px"
										format="short"
										value="@bind(fx.tripDate)" />
								</hbox>
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormTo} :</cell>
							<cell>
								<textbox
									id="to"
									width="300px"
									maxlength="@load(vm.lengthText)"
									value="@bind(fx.to)" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormPurpose} :</cell>
							<cell>
								<textbox
									id="description"
									width="300px"
									maxlength="@load(vm.lengthText)"
									value="@bind(fx.description)" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormEndTravel} :</cell>
							<cell>
								<textbox
									id="end"
									width="200px"
									maxlength="@load(vm.lengthText)"
									value="@bind(fx.end)" />
							</cell>
						</row>
						<row>
							<cell sclass="row-title">${labels.RequirementsFormEndDate} :</cell>
							<cell>
								<datebox
									id="endDate"
									width="300px"
									format="${labels.DateFormat}"
									value="@bind(fx.endDate)" />
							</cell>
						</row>
					</rows>
				</grid>
				<include
					src="/app/uploadComponents.zul"
					vflex="1" />
			</hbox>
			<!-- Spolucestující -->
			<groupbox
				closable="false"
				hflex="1"
				vflex="min"
				mold="3d">
				<caption label="${labels.RequirementsFormPassengers}" />
				<hlayout
					hflex="1"
					vflex="min">
					<vlayout
						hflex="1"
						vflex="1">
						<grid>
							<columns>
								<column hflex="min" />
								<column />
							</columns>
							<rows>
								<row>
									<cell sclass="row-title">${labels.ChooseThePasseger} :</cell>
									<cell>
										<combobox
											model="@load(vm.users)"
											autocomplete="true"
											selectedItem="@bind(vm.selUser)">
											<template name="model">
												<comboitem label="@load(each)" />
											</template>
										</combobox>
										<button
											label="${labels.Confirm}"
											onClick="@command('addPassanger')"
											sclass="nicebutton"
											disabled="@load(vm.selUser eq null)" />
									</cell>
								</row>
								<row>
									<cell sclass="row-title">${labels.ForeignPersons} :</cell>
									<cell>
										<textbox
											id="foreignPersons"
											hflex="1"
											maxlength="@load(vm.lengthText)"
											value="@bind(fx.foreignPersons)" />
									</cell>
								</row>
							</rows>
						</grid>
						<checkbox
							label="${labels.GenerateBillingForPassengers}"
							checked="@bind(vm.dataBean.billForPassengers)"
							disabled="@load(empty vm.passengers)" />
					</vlayout>
					<vlayout
						hflex="1"
						vflex="1">
						<grid
							model="@load(vm.passengers)"
							sizedByContent="true"
							hflex="1"
							height="200px">
							<columns>
								<column hflex="10" />
								<column hflex="min" />
								<column hflex="1" />
							</columns>
							<rows>
								<template name="model">
									<row>
										<label value="@load(each)" />
										<button
											label="${labels.RemoveItem}"
											onClick="@command('removePassanger', user=each)"
											sclass="nicebutton" />
									</row>
								</template>
							</rows>
						</grid>
					</vlayout>
				</hlayout>
			</groupbox>
			<!-- Způsob dopravy -->
			<vbox
				hflex="1"
				vflex="min">
				<groupbox
					closable="false"
					vflex="min"
					hflex="1"
					mold="3d">
					<caption label="${labels.TransportMode}" />
					<hbox>
						<grid hflex="min">
							<columns>
								<column hflex="min" />
								<column hflex="min" />
							</columns>
							<rows>
								<row>
									<label value="${labels.RequirementsFormVehicle}" />
									<combobox
										model="@load(vm.settings.vehicles)"
										selectedItem="@bind(fx.vehicle)"
										readonly="true">
										<template name="model">
											<comboitem label="@load(each)" />
										</template>
									</combobox>
								</row>
								<row>
									<checkbox
										label="Požaduji zálohu"
										checked="@bind(vm.dataBean.requireDownPayment)" />
									<textbox
										value="@bind(vm.dataBean.downPayment)"
										maxlength="@load(vm.lengthText)"
										disabled="@bind(not vm.dataBean.requireDownPayment)" />
								</row>
							</rows>
						</grid>
					</hbox>
				</groupbox>
			</vbox>
			<!-- Prázdný vbox = ostatní mají min. plochu a tento se roztahuje podle toho co zbyde. Když nic nezbyde, zobrazí se na min. plochou scrollbar a tohle není vidět -->
			<vbox
				hflex="1"
				vflex="1">
			</vbox>
		</vlayout>
		<include
			src="/app/formButtons.zul"
			vflex="min" />
	</window>
</zk>