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

	<s:Push Id="search" Value="$param1"></s:Push>
	<s:Push Id="outlet" Value="$workflow.outlet"></s:Push>
	<s:Push Id="visit" Value="$workflow.visit"></s:Push>
	<s:Push Id="SKUs" Value="$GetSKUsFromQuesionnaires($search)"></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="$CheckEmtySKUAndForward($outlet,$visit)">
					<c:TextView Id="btnForward" Text="#forward#" />
				</c:DockLayout>
			</s:Else>
			<c:HorizontalLayout>
				<c:TextView Text="#distribution#" />
			</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>

		<c:Image CssClass="4_scroll"></c:Image>
		<c:HorizontalLine />

		<c:ScrollView Id="grScrollView">

			<c:DockLayout CssClass="search">
				<c:Button Id="btnSearch" Text="#search#" OnClickAction="$DoSearch($edtSearch.Text)"></c:Button>
				<c:DockLayout>
					<c:Image />
					<c:EditText Id="edtSearch" Text="$search" Placeholder="#search#"></c:EditText>
				</c:DockLayout>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid" OnClickAction="$Workflow.DoAction(ShowFilters1, Questionnaire)">
				<c:TextView Text="#filter#"></c:TextView>
				<c:Image></c:Image>
			</c:DockLayout>
			<c:HorizontalLine />

			<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>
			</s:If>
			<s:Else>
				<c:HorizontalLayout CssClass="margin_top"></c:HorizontalLayout>
			</s:Else>
			<c:HorizontalLine />

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

				<c:DockLayout CssClass="grid" OnClick="$CreateItemAndShow($sku.SKU, $index)">
					<s:If Test="$ObligateredAreAnswered($sku.Obligatoriness,$sku.ObligateredHistory,$sku.ObligateredCurrent,$sku.ObligateredTotal)">
						<c:HorizontalLayout CssClass="answered_side_wh"></c:HorizontalLayout>
					</s:If>
					<s:Else>
						<s:If Test="$sku.Obligatoriness=='2'">
							<c:HorizontalLayout CssClass="required_side_wh"></c:HorizontalLayout>
						</s:If>
					</s:Else>
					<c:VerticalLayout>
						<s:If Test="@regularAnswers">
							<c:TextView Text="{$sku.Answered} #of# {$sku.Total}" CssClass="description_row" />
						</s:If>
						<s:Else>
							<c:TextView Text="{$GetSum($sku.Answered,$sku.History)} #of# {$sku.Total}" CssClass="description_row" />
						</s:Else>
						<c:TextView Text="$sku.Description" CssClass="main_row"></c:TextView>
					</c:VerticalLayout>
				</c:DockLayout>
				<c:HorizontalLine />
				<s:If Test="$ShowChilds($index)">
					<s:Push Id="childs" Value="$GetChilds($sku.SKU)"></s:Push>
					<s:Iterator Id="child" Value="$childs" Status="statusCountCh">
						<s:Push Id="indexCh" Value="{$statusCountCh.Index}"></s:Push>
						<c:DockLayout CssClass="child_grid">
							<s:If Test="$ObligatedAnswered($child.Answer, $child.Obligatoriness)">
								<c:HorizontalLayout CssClass="answered_side_gr"></c:HorizontalLayout>
							</s:If>
							<s:Else>
								<s:If Test="$child.Obligatoriness">
									<c:HorizontalLayout CssClass="required_side_gr"></c:HorizontalLayout>
								</s:If>
							</s:Else>
							<c:VerticalLayout OnClick="$GoToQuestionAction($child.AnswerType, $child.Id, $sku.SKU, control{$indexCh}, $child.Answer, $sku.SKU)">
								<c:TextView Text="$child.Description" CssClass="description_row"></c:TextView>
								<s:If Test="$child.IsInputField==1">
									<c:EditText Id="control{$indexCh}" Text="$child.Answer" Placeholder="—" OnChange="$CreateVisitSKUValueIfNotExists($sku.SKU, $child.Id, true)" OnLostFocus="$RefreshScreen($search)" Keyboard="$child.KeyboardType" CssClass="answer_main_row"></c:EditText>
								</s:If>
								<s:Else>
									<c:TextView Id="control{$indexCh}" Text="$child.Answer" CssClass="answer_main_row"></c:TextView>
								</s:Else>
							</c:VerticalLayout>
						</c:DockLayout>
						<c:HorizontalLine />
					</s:Iterator>
				</s:If>

			</s:Iterator>

		</c:ScrollView>

	</c:VerticalLayout>

</c:Screen>
