<?xml version="1.0" encoding="utf-8" ?>
<c:Screen xmlns:c="BitMobile.Controls" xmlns:s="BitMobile.ValueStack"
	xmlns:d="DefaultScope" StyleSheet="Outlet.css">


	<s:If Test="$workflow.name=='Visit'">
		<s:Push Id="workflow.outlet" Value="$outlet"></s:Push>
		<s:Push Id="workflow.visit"
			Value="$CreateVisitIfNotExists($outlet,$common.UserRef, $workflow.visit, $planVisit)" />
	</s:If>

	<s:Push Id="outletObj" Value="$GetObject($outlet)" />

	<c:DockLayout Id="vOutlet">

		<s:If Test="$CreateVisitEnable()">
			<c:HorizontalLayout Id="btnDetails" CssClass="bottom_btn">
				<c:VerticalLayout OnClickAction="$DoAction(ShowDetails, $outlet)"
					CssClass="trple">
					<c:TextView Text="#details#" CssClass="trpl_left_tv"></c:TextView>
				</c:VerticalLayout>
				<c:VerticalLayout Id="btnContacts" OnEvent="Forward"
					OnClickAction="$DoAction(ShowContacts, $outlet)" CssClass="trple">
					<c:TextView Text="#contacts#" CssClass="trpl_center_tv"></c:TextView>
				</c:VerticalLayout>
				<c:VerticalLayout Id="btnVisit" OnEvent="Forward"
					OnClickAction="$DoAction(Plans, $outlet)" CssClass="trple">
					<c:TextView Text="#visit#" CssClass="trpl_right_tv"></c:TextView>
				</c:VerticalLayout>
			</c:HorizontalLayout>
		</s:If>
		<s:Else>
			<c:HorizontalLayout Id="btnDetails" CssClass="bottom_btn">
				<c:VerticalLayout OnClickAction="$DoAction(ShowDetails, $outlet)">
					<c:TextView Text="#details#" CssClass="left_tv"></c:TextView>
				</c:VerticalLayout>
				<c:VerticalLayout Id="btnContacts" OnEvent="Forward"
					OnClickAction="$DoAction(ShowContacts, $outlet)">
					<c:TextView Text="#contacts#" CssClass="right_tv"></c:TextView>
				</c:VerticalLayout>
			</c:HorizontalLayout>
		</s:Else>
		<c:HorizontalLine CssClass="b_line" />

		<s:If Test="$workflow.name=='Outlets'">
			<c:DockLayout CssClass="top_navigator">
				<c:HorizontalLayout Id="btnBack" CssClass="btn_back"
					OnEvent="Back" OnClickAction="$SaveAndBack($outlet)">
					<c:Image />
					<c:TextView Text="#list#" />
				</c:HorizontalLayout>
				<c:HorizontalLayout CssClass="btn_forward" />
				<c:HorizontalLayout>
					<c:TextView Text="#client#" />
				</c:HorizontalLayout>
			</c:DockLayout>
			<c:HorizontalLine />
		</s:If>
		<s:Else>
			<c:DockLayout CssClass="top_navigator">
				<c:HorizontalLayout Id="btnBack" CssClass="btn_back"
					OnEvent="Back" OnClickAction="$DoRollback()">
					<c:Image />
					<c:TextView Text="#visits#" />
				</c:HorizontalLayout>
				<c:Button Id="btnForward" Text="#forward#" OnEvent="Forward"
					CssClass="btn_forward" OnClickAction="$CheckNotNullAndForward($outlet, $workflow.visit)" />
				<c:HorizontalLayout>
					<c:TextView Text="#client#" />
				</c:HorizontalLayout>
			</c:DockLayout>

			<c:Image CssClass="1_scroll"></c:Image>
			<c:HorizontalLine />
		</s:Else>

		<c:ScrollView Id="grScrollView">

			<c:HorizontalLayout CssClass="caption_grid">
				<c:TextView Text="#main#:"></c:TextView>
			</c:HorizontalLayout>
			<c:HorizontalLine />

			<c:HorizontalLayout CssClass="grid">
				<c:VerticalLayout>
					<c:TextView Text="#description#" CssClass="description_row"></c:TextView>
					<c:TextView Id="outletDescr" Text="$outlet.Description"
						CssClass="main_row"></c:TextView>
				</c:VerticalLayout>
			</c:HorizontalLayout>
			<c:HorizontalLine />

			<c:HorizontalLayout CssClass="grid">
				<c:VerticalLayout>
					<c:TextView Text="#address#" CssClass="description_row"></c:TextView>
					<c:MemoEdit Id="outletAddress" Value="$outlet.Address"
						OnChange="$SaveValue($outlet)"></c:MemoEdit>
				</c:VerticalLayout>
			</c:HorizontalLayout>
			<c:HorizontalLine />


			<c:HorizontalLayout CssClass="grid">
				<c:VerticalLayout>
					<c:DockLayout>
						<c:TextView Text="#coordinates#"></c:TextView>
						<c:Button Text="#set#" OnClickAction="$SetLocation($outlet)"></c:Button>
					</c:DockLayout>
					<s:If Test="$outlet.Lattitude != null || $outlet.Longitude != null">
						<c:TextView Id="outletCoord"
							Text="{$outlet.Lattitude}; {$outlet.Longitude}" CssClass="main_row"></c:TextView>
					</s:If>
					<s:Else>
						<c:TextView Id="outletCoord" Text="#unknown#" CssClass="main_row"></c:TextView>
					</s:Else>
				</c:VerticalLayout>
			</c:HorizontalLayout>
			<c:HorizontalLine />

			<c:HorizontalLayout CssClass="caption_grid">
				<c:TextView Text="#additionally#:"></c:TextView>
			</c:HorizontalLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid"
				OnClickAction="$SelectIfNotAVisit($outlet,Class,$outletClass)">
				<c:TextView Text="#outlet_class#"></c:TextView>
				<c:TextView Id="outletClass" Text="$outlet.Class.Description"
					CssClass="value"></c:TextView>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid"
				OnClickAction="$SelectIfNotAVisit($outlet,Type,$outletType)">
				<c:TextView Text="#outlet_type#"></c:TextView>
				<c:TextView Id="outletType" Text="$outlet.Type.Description"
					CssClass="value"></c:TextView>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid"
				OnClickAction="$DoSelect($outlet,Distributor,$outletDistr)">
				<c:TextView Text="#distributor#"></c:TextView>
				<c:TextView Id="outletDistr" Text="$outlet.Distributor.Description"
					CssClass="value"></c:TextView>
			</c:DockLayout>
			<c:HorizontalLine />

			<s:Iterator Id="parameter" Value="$GetOutletParameters($outlet)"
				Status="statusCount">

				<s:Push Id="valueStr"
					Value="$GetOutletParameterValue($outlet,$parameter.Id,$parameter.ParameterValue, $parameter.TypeDescription)" />
				<s:Push Id="editText" Value="$UseInput($parameter.TypeDescription)" />
				<s:Push Id="index" Value="$statusCount.Index"></s:Push>
				<c:DockLayout CssClass="parameter_grid"
					OnClickAction="$GoToParameterAction($parameter.TypeDescription, $parameterValue, Value, $outlet, $parameter.Id, control{$index})">
					<c:TextView Text="$parameter.Description"></c:TextView>
					<s:If Test="$editText">
						<c:EditText Id="control{$index}" Text="$valueStr"
							OnChange="$AssignParameterValue($parameter.TypeDescription, $parameterValue, Value, $outlet, $parameter.Id)"
							CssClass="value" Keyboard="$keyboardType"></c:EditText>
					</s:If>
					<s:Else>
						<c:TextView Id="control{$index}" Text="$valueStr"
							CssClass="value"></c:TextView>
					</s:Else>
				</c:DockLayout>

				<c:HorizontalLine />

			</s:Iterator>

		</c:ScrollView>

	</c:DockLayout>

</c:Screen>