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

	<s:Push Id="outlet" Value="$workflow.outlet"></s:Push>
	<s:Push Id="visit" Value="$workflow.visit"></s:Push>
	<s:Push Id="questions" Value="$GetQuestionsByQuestionnaires($outlet)"></s:Push>

	<c:VerticalLayout>

		<c:DockLayout CssClass="top_navigator">
			<c:DockLayout Id="btnBack" CssClass="btn_back" OnEvent="Back" OnClickAction="$GetActionAndBack()">
				<c:Image />
				<c:TextView Text="#back#" />
			</c:DockLayout>
			<s:If Test="$ForwardIsntAllowed()">
				<c:DockLayout Id="btnForward" CssClass="forward">
					<c:VerticalLayout></c:VerticalLayout>
					<c:TextView Id="obligateredButton" Text="{$ToString(@obligateredLeft)})" />
					<c:Image />
					<c:TextView Text="#forward# (" />
				</c:DockLayout>
			</s:If>
			<s:Else>
				<c:DockLayout CssClass="btn_forward" OnEvent="Forward" OnClickAction="$DoForward()" >
					<c:TextView Id="btnForward" Text="#forward#" />
				</c:DockLayout>
			</s:Else>
			<c:HorizontalLayout>
				<c:TextView Text="#questions#" />
			</c:HorizontalLayout>
		</c:DockLayout>

		<c:HorizontalLayout CssClass="small_grid">
			<s:If Test="@regularAnswers">
				<c:HorizontalLayout CssClass="mode_left_button_on">
					<c:HorizontalLayout Id="regular" CssClass="select_zone" OnClick="$ChangeListAndRefresh(1)">
						<c:TextView Text="#regular# ({@regular_answ} #of# {@regular_total})"></c:TextView>
					</c:HorizontalLayout>
				</c:HorizontalLayout>
				<c:HorizontalLayout CssClass="mode_right_button_off">
					<c:HorizontalLayout Id="nonregular" CssClass="select_zone" OnClick="$ChangeListAndRefresh(0)">
						<c:TextView Text="#nonregular# ({@single_answ} #of# {@single_total})"></c:TextView>
					</c:HorizontalLayout>
				</c:HorizontalLayout>
			</s:If>
			<s:Else>
				<c:HorizontalLayout CssClass="mode_left_button_off">
					<c:HorizontalLayout Id="regular" CssClass="select_zone" OnClick="$ChangeListAndRefresh(1)">
						<c:TextView Text="#regular# ({@regular_answ} #of# {@regular_total})"></c:TextView>
					</c:HorizontalLayout>
				</c:HorizontalLayout>
				<c:HorizontalLayout CssClass="mode_right_button_on">
					<c:HorizontalLayout Id="nonregular" CssClass="select_zone" OnClick="$ChangeListAndRefresh(0)">
						<c:TextView Text="#nonregular# ({@single_answ} #of# {@single_total})"></c:TextView>
					</c:HorizontalLayout>
				</c:HorizontalLayout>
			</s:Else>
		</c:HorizontalLayout>


		<!-- progress picture -->
		<c:Image CssClass="3_scroll"></c:Image>
		<c:HorizontalLine />


		<c:ScrollView Id="grScrollView">

			<s:If Test="$ForwardIsntAllowed()">
				<c:HorizontalLayout CssClass="required_grid">
					<c:TextView Text="#requiredLeft# "></c:TextView>
					<c:Image />
					<c:TextView Id="obligateredInfo" Text="$ToString(@obligateredLeft)"></c:TextView>
				</c:HorizontalLayout>
				<c:HorizontalLine />
			</s:If>
			<s:Else>
				<c:HorizontalLayout CssClass="margin_top"></c:HorizontalLayout>
			</s:Else>
			<c:HorizontalLine />

			<s:Iterator Id="question" Value="$questions" Status="statusCount">

				<s:Push Id="index" Value="{$statusCount.Index}"></s:Push>

				<c:DockLayout CssClass="grid" OnClickAction="$FocusOnEditText(control{$index}, $question.IsInputField)">
					<s:If Test="$question.Obligatoriness=='1'">
						<s:If Test="$IsNullOrEmpty($question.Answer)">
							<c:HorizontalLayout CssClass="required_side_wh"></c:HorizontalLayout>
						</s:If>
						<s:Else>
							<c:HorizontalLayout CssClass="answered_side_wh"></c:HorizontalLayout>
						</s:Else>
					</s:If>
					<s:Else>
						<c:HorizontalLayout CssClass="empty_side_wh"></c:HorizontalLayout>
					</s:Else>
					<s:If Test="$question.IsSnapshot==1">
						<c:HorizontalLayout OnClickAction="$GoToQuestionAction($question.AnswerType, $visit, control{$index}, $question.Question, $question.Answer, $question.Description)">
							<c:TextView Text="$question.Description" CssClass="description_row"></c:TextView>
							<s:If Test="$IsNullOrEmpty($question.Answer)">
								<c:VerticalLayout>
									<c:VerticalLayout CssClass="no_answer">
										<c:Image Id="control{$index}" />
									</c:VerticalLayout>
								</c:VerticalLayout>
							</s:If>
							<s:Else>
								<s:If Test="$SnapshotExists($visit, $outlet, $question.Answer)">
									<c:VerticalLayout>
										<c:Image Id="control{$index}" CssClass="answer_snapshot" Source="$GetImagePath($visit.Id, $outlet.Id, $question.Answer)"></c:Image>
									</c:VerticalLayout>
								</s:If>
								<s:Else>
									<c:VerticalLayout>
										<c:VerticalLayout CssClass="no_image">
											<c:Image Id="control{$index}" />
										</c:VerticalLayout>
									</c:VerticalLayout>
								</s:Else>
							</s:Else>
						</c:HorizontalLayout>
					</s:If>
					<s:Else>
						<c:VerticalLayout OnClickAction="$GoToQuestionAction($question.AnswerType, $visit, control{$index}, $question.Question, $question.Answer, $question.Description)">
							<c:TextView Text="$question.Description" CssClass="description_row"></c:TextView>
							<s:If Test="$question.IsInputField=='1'">
								<c:MemoEdit Id="control{$index}" Text="$question.Answer" Placeholder="—" OnChange="$AssignAnswer($question.Question)" OnLostFocus="$Workflow.DoRefresh()" Keyboard="$question.KeyboardType" CssClass="answer_main_row"></c:MemoEdit>
							</s:If>
							<s:Else>
								<c:TextView Id="control{$index}" Text="$question.AnswerOutput" CssClass="answer_main_row"></c:TextView>
							</s:Else>
						</c:VerticalLayout>
					</s:Else>
				</c:DockLayout>
				<c:HorizontalLine />

			</s:Iterator>

		</c:ScrollView>

	</c:VerticalLayout>

</c:Screen>
