<?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:DockLayout Id="btnBack" CssClass="btn_back" OnEvent="Back" OnClickAction="$DoRollback()">
					<c:Image />
					<c:TextView Text="#visits#" />
				</c:DockLayout>
				<c:DockLayout OnEvent="Forward" CssClass="btn_forward" OnClickAction="$CheckNotNullAndForward($outlet, $workflow.visit)">
					<c:TextView Id="btnForward" Text="#forward#" />
				</c:DockLayout>
				<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 />

			<s:Push Id="snapshots" Value="$GetSnapshots($outlet)" />

			<s:If Test="@snapshotsExists">
				<c:DockLayout CssClass="snapshot_grid">
					<s:If Test="$IsOutletPrimaryParameterEditable($sessionConst.editOutletParameters, snapshots)">
						<c:Button Text="#add#" OnClick="$AddSnapshot($outlet)" />
					</s:If>
					<c:TextView Text="#outletSnapshots#" />
				</c:DockLayout>
				<s:If Test="@singlePicture">
					<c:VerticalLayout CssClass="single_picture" OnClick="$ImageActions($snapshots.Id)">
						<s:If Test="$snapshots.Unavailable">
							<c:TextView Text="#notAvailable#"/>
						</s:If>
						<s:Else>
							<c:Image Source="$GetImagePath(catalog.outlet, $outlet, $snapshots.FileName, .jpg)" />
						</s:Else>
					</c:VerticalLayout>
				</s:If>
				<s:Else>
					<c:SwipeHorizontalLayout Id="snapshotLayout" CssClass="carousel" Alignment="Center">
						<s:Iterator Id="snapshot" Value="$snapshots">
							<c:VerticalLayout OnClick="$ImageActions($snapshot.Id)">
								<s:If Test="$snapshot.Unavailable">
									<c:TextView Text="#notAvailable#"/>
								</s:If>
								<s:Else>
									<c:Image Source="$GetImagePath(catalog.outlet, $outlet, $snapshot.FileName, .jpg)" />
								</s:Else>
							</c:VerticalLayout>
						</s:Iterator>
					</c:SwipeHorizontalLayout>
				</s:Else>
				<c:HorizontalLine />
			</s:If>
			<s:Else>
				<s:If Test="$sessionConst.editOutletParameters">
					<c:DockLayout CssClass="grid">
						<c:VerticalLayout>
							<c:TextView Text="#outletSnapshots#" CssClass="description_row" />
							<s:If Test="$IsOutletPrimaryParameterEditable($sessionConst.editOutletParameters, snapshots)">
								<c:Button OnClick="$AddSnapshot($outlet)" Text="#add#" CssClass="add_button" />
							</s:If>
						</c:VerticalLayout>
					</c:DockLayout>
					<c:HorizontalLine />
				</s:If>
			</s:Else>

			<c:HorizontalLayout CssClass="grid" OnClickAction="$FocusIfHasEditText(outletDescr, $sessionConst.editOutletParameters, description)">
				<c:VerticalLayout>
					<c:TextView Text="#description#" CssClass="description_row"></c:TextView>
					<s:If Test="$IsOutletPrimaryParameterEditable($sessionConst.editOutletParameters, description)">
						<c:EditText Id="outletDescr" Value="$outlet.Description" CssClass="main_row"></c:EditText>
					</s:If>
					<s:Else>
						<c:TextView Id="outletDescr" Text="$outlet.Description" CssClass="main_row"></c:TextView>
					</s:Else>
				</c:VerticalLayout>
			</c:HorizontalLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="grid" OnClickAction="$FocusIfHasEditText(outletAddress, $sessionConst.editOutletParameters, address)">
				<c:Button Id="clearButton" CssClass="clear" Visible="false" OnClick="$ClearField($outletAddress, $outlet, Address)"/>
				<c:VerticalLayout>
					<c:TextView Text="#address#" CssClass="description_row"></c:TextView>
					<s:If Test="$IsOutletPrimaryParameterEditable($sessionConst.editOutletParameters, address)">
						<c:MemoEdit Id="outletAddress" Value="$outlet.Address" OnGetFocus="$ShowClearButton($clearButton)" OnLostFocus="$HideClearButton($clearButton)" OnChange="$SaveValue($outlet)"></c:MemoEdit>
					</s:If>
					<s:Else>
						<c:TextView Id="outletAddress" Text="$outlet.Address" CssClass="main_row"></c:TextView>
					</s:Else>
				</c:VerticalLayout>
			</c:DockLayout>
			<c:HorizontalLine />


			<c:DockLayout CssClass="grid">
				<s:If Test="$HasCoordinates($outlet)">
					<c:Button OnClickAction="$DoAction(ShowMap, $outlet)" />
				</s:If>
				<s:Else>
					<c:Image />
				</s:Else>
				<c:VerticalLayout>
					<c:TextView Text="#coordinates#" CssClass="description_row"></c:TextView>
					<s:If Test="$HasCoordinates($outlet)">
						<c:HorizontalLayout OnClick="$ShowCoordOptions($outlet, $sessionConst.editOutletParameters, coordinates)">
							<c:TextView Id="outletCoord" Text="{$outlet.Lattitude}; {$outlet.Longitude}" CssClass="main_row"></c:TextView>
						</c:HorizontalLayout>
					</s:If>
					<s:Else>
						<s:If Test="$IsOutletPrimaryParameterEditable($sessionConst.editOutletParameters, coordinates)">
							<c:Button OnClick="$SetLocation($outlet)" Text="#set#" CssClass="coordButton" />
						</s:If>
					</s:Else>
				</c:VerticalLayout>
			</c:DockLayout>
			<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,#outlet_class#, $sessionConst.editOutletParameters, class)">
				<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,#outlet_type#, $sessionConst.editOutletParameters, type)">
				<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,#distributor#, $sessionConst.editOutletParameters, distributor)">
				<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="index" Value="$statusCount.Index"></s:Push>
				<s:Push Id="visible" Value="$parameter.Visible"></s:Push>
				<s:Push Id="editable" Value="$parameter.Editable"></s:Push>
				<s:If Test="$visible">
					<c:DockLayout CssClass="parameter_grid" OnClickAction="$GoToParameterAction($parameter.TypeDescription, $parameter.Value, Value, $outlet, $parameter.Id, control{$index}, $parameter.Description, $editable)">
						<s:If Test="$IsEditText($sessionConst.editOutletParameters, $parameter.IsInputField, $editable)">
							<c:EditText Id="control{$index}" Text="$parameter.Value" Placeholder="—" OnChange="$AssignParameterValue($parameter.TypeDescription, $parameterValue, Value, $outlet, $parameter.Id)" CssClass="value" Keyboard="$parameter.KeyboardType"></c:EditText>
						</s:If>
						<s:Else>
							<s:If Test="$parameter.TypeDescription == 'Snapshot'">
								<s:If Test="$IsEmptyString($parameter.Value)">
									<c:TextView Text="#noSnapshot#" CssClass="value"></c:TextView>
								</s:If>
								<s:Else>
									<s:If Test="$IsUnavailable($parameter.Unavailable)">
										<c:TextView Text="#notAvailableShort#" CssClass="not_available" />
									</s:If>
									<s:Else>
										<c:Image Source="$GetImagePath(catalog.outlet, $outlet, $parameter.Value, .jpg)" CssClass="parameter_image" />
									</s:Else>
								</s:Else>
							</s:If>
							<s:Else>
								<c:TextView Id="control{$index}" Text="$parameter.AnswerOutput" CssClass="value"></c:TextView>
							</s:Else>
						</s:Else>
						<c:TextView Text="$parameter.Description"></c:TextView>
					</c:DockLayout>
					<c:HorizontalLine />
				</s:If>
			</s:Iterator>

		</c:ScrollView>

	</c:DockLayout>

</c:Screen>
