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

	<s:Push Id="order" Value="$workflow.order"></s:Push>
	<s:Push Id="sku" Value="$param1"></s:Push>
	<s:Push Id="price" Value="$param2"></s:Push>
	<s:Push Id="orderitem" Value="$param3"></s:Push>
	<s:Push Id="showimage" Value="$param5"></s:Push>
	<s:Push Id="features" Value="$GetFeatures($sku.Id)"></s:Push>
	<s:Push Id="orderitem" Value="$CreateOrderItemIfNotExist($order.Id,$sku,$orderitem,$price,$features, $param6, $param7)"></s:Push>
	<s:Push Id="featureDescr" Value="$GetFeatureDescr($orderitem.Feature)"></s:Push>

	<s:If Test="$showimage == null">
		<s:Push Id="showimage" Value="NotShow"></s:Push>
	</s:If>

	<c:DockLayout>

		<c:HorizontalLayout CssClass="end_of_block"></c:HorizontalLayout>

		<c:HorizontalLayout Id="btnCancel" CssClass="bottom_btn">
			<c:VerticalLayout OnEvent="Back" OnClickAction="$DeleteAndBack($orderitem)">
				<c:TextView Text="#cancel#" CssClass="left_tv"></c:TextView>
			</c:VerticalLayout>
			<c:VerticalLayout Id="btnAdd" OnEvent="Forward" OnClickAction="$CalculateSKUAndForward($order.Outlet, $orderitem)">
				<c:TextView Text="#add#" CssClass="right_tv"></c:TextView>
			</c:VerticalLayout>
		</c:HorizontalLayout>

		<c:HorizontalLine CssClass="b_line" />

		<c:HorizontalLayout CssClass="caption_grid">
			<c:TextView Id="itemDescription" Text="{$sku.Description}{$featureDescr}"></c:TextView>
		</c:HorizontalLayout>

		<s:If Test="$sku.DefaultPicture != null">
			<s:If Test="$showimage == 'NotShow'">
				<c:HorizontalLayout Id="ShowImage" CssClass="btn_showpicture" OnClickAction="$RefreshEditSKU($orderitem, $sku, $price, $discountEdit.Text, Show)">
					<c:TextView Text="[#showImage#]"></c:TextView>
				</c:HorizontalLayout>
			</s:If>
			<s:If Test="$showimage == 'Show'">
				<c:HorizontalLayout Id="HideImage" CssClass="btn_showpicture" OnClickAction="$RefreshEditSKU($orderitem, $sku, $price, $discountEdit.Text, NotShow)">
					<c:TextView Text="[#hideImage#]"></c:TextView>
				</c:HorizontalLayout>
			</s:If>
		</s:If>

		<c:ScrollView Id="grScrollView" OnScroll="$OnScroll()">

			<s:If Test="$sku.DefaultPicture != null">
				<s:If Test="$showimage == 'Show'">
					<c:HorizontalLine />
					<c:Image CssClass="60" Source="$GetSharedImagePath(Catalog.SKU, $sku.Id, $sku.DefaultPicture, $sku.DefaultPictureExtension)" />
					<c:HorizontalLine />
					<c:HorizontalLayout CssClass="margin_top"></c:HorizontalLayout>
				</s:If>
			</s:If>

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

			<c:DockLayout CssClass="parameter_grid">
				<c:TextView Text="#price#" CssClass="description_row"></c:TextView>
				<c:TextView Id="orderItemTotalId" Text="$orderitem.Total" CssClass="value"></c:TextView>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid">
				<c:TextView Text="#quantity#"></c:TextView>
				<c:EditText Id="orderItemQty" Value="$orderitem.Qty" CssClass="value" Keyboard="numeric" OnGetFocus="$HideSwiped()"></c:EditText>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid" OnClickAction="$ChangeUnit($sku, $orderitem, $price)">
				<c:TextView Text="#packUnit#"></c:TextView>
				<c:TextView Id="itemUnits" Text="$orderitem.Units.Description" CssClass="value"></c:TextView>
			</c:DockLayout>
			<c:HorizontalLine />

			<c:DockLayout CssClass="parameter_grid">
				<s:Push Id="discountDescrText" Value="$GetDiscountDescription($orderitem)"></s:Push>
				<c:HorizontalLayout CssClass="clickable" OnClickAction="$ChandeDiscount($orderitem)">
					<c:TextView Id="discountDescr" Text="$discountDescrText" />
				</c:HorizontalLayout>
				<c:EditText Id="discountEdit" Text="$param4" CssClass="value" Keyboard="numeric" OnChange="$ApplyDiscount($orderitem)" OnGetFocus="$HideSwiped()"></c:EditText>
			</c:DockLayout>
			<c:HorizontalLine />

			<s:Push Id="historyItems" Value="$GetItemHistory($sku, $order)"></s:Push>
			<s:If Test="$historyCount != 0">
				<c:HorizontalLayout CssClass="caption_grid">
					<c:TextView Text="#orderHistory#:"></c:TextView>
				</c:HorizontalLayout>
				<c:HorizontalLine />
				<s:Iterator Id="historyItem" Value="$historyItems">
					<c:SwipeHorizontalLayout CssClass="swipe_history" Index="1" OnSwipe="$WriteSwipedRow()">
						<c:HorizontalLayout CssClass="repeat" OnClickAction="$RepeatOrder($orderitem, $historyItem.Qty, $historyItem.Total, $historyItem.Price, $historyItem.Discount, $sku.BaseUnit, $sku.BaseUnit.Description)">
							<c:TextView Text="#repeat#" />
						</c:HorizontalLayout>
						<c:DockLayout CssClass="parameter_grid">
							<c:TextView Text="$historyItem.Date" CssClass="black_text"></c:TextView>
							<c:TextView Text="{$historyItem.Qty} {$sku.BaseUnit.Description}, x {$historyItem.Total} {#currency#}" CssClass="value"></c:TextView>
						</c:DockLayout>
					</c:SwipeHorizontalLayout>
					<c:HorizontalLine />
				</s:Iterator>
			</s:If>

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

			<s:Iterator Id="feature" Value="$features">
				<c:DockLayout CssClass="parameter_grid" OnClickAction="$ChangeFeatureAndRefresh($orderitem, $feature.Feature, $sku, $price, $discountEdit.Text, $showimage)">
					<s:If Test="$AreEqual($orderitem.Feature, $feature.Feature);">
						<c:Image CssClass="tick" />
					</s:If>
					<s:Else>
						<c:VerticalLayout CssClass="empty_tick"></c:VerticalLayout>
					</s:Else>
					<c:TextView Text="$feature.Feature.Description"></c:TextView>
				</c:DockLayout>
				<c:HorizontalLine />

			</s:Iterator>

		</c:ScrollView>

	</c:DockLayout>

</c:Screen>



