<mvc:View
	controllerName="com.example.fiori.eliq.controller.Search"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns="sap.m"
	xmlns:f="sap.f"
	xmlns:form="sap.ui.layout.form"
	xmlns:core="sap.ui.core"
	height="100%">
	<f:DynamicPage id="searchPage" toggleHeaderOnTitleClick="false">
		<f:title>
			<f:DynamicPageTitle>
				<f:heading>
					<Title text="{i18n>searchTitle}" />
				</f:heading>
				<f:actions>
					<Button text="{i18n>navActivities}" type="Emphasized" icon="sap-icon://activity-items" press=".onNavBack" />
					<Button icon="sap-icon://home" tooltip="{i18n>navHome}" press=".onNavHome" type="Transparent" />
				</f:actions>
			</f:DynamicPageTitle>
		</f:title>
		<f:header>
			<f:DynamicPageHeader>
				<IconTabBar selectedKey="{search>/mode}" select=".onModeSelect">
					<items>
						<IconTabFilter key="INVOICE" text="{i18n>processInvoice}" />
						<IconTabFilter key="ADL" text="{i18n>processAdl}" />
					</items>
				</IconTabBar>
				<form:SimpleForm
					editable="true"
					layout="ColumnLayout"
					columnsM="2"
					columnsL="3"
					visible="{= ${search>/mode} === 'INVOICE' }">
					<form:content>
						<Label text="{i18n>colInvoice}" />
						<Input value="{search>/invoiceNumber}" />
						<Label text="{i18n>colSupplier}" />
						<Input value="{search>/supplier}" />
						<Label text="{i18n>colProtocol}" />
						<Input value="{search>/protocol}" />
						<Label text="{i18n>colStage}" />
						<Input value="{search>/stage}" placeholder="NEW, ASSIGNED, …" />
					</form:content>
				</form:SimpleForm>
				<form:SimpleForm
					editable="true"
					layout="ColumnLayout"
					columnsM="2"
					columnsL="3"
					visible="{= ${search>/mode} === 'ADL' }">
					<form:content>
						<Label text="{i18n>colAdl}" />
						<Input value="{search>/adlId}" />
						<Label text="{i18n>colType}" />
						<Input value="{search>/adlType}" placeholder="AL, RD, RQ" />
						<Label text="{i18n>colOffice}" />
						<Input value="{search>/office}" />
						<Label text="{i18n>colStage}" />
						<Input value="{search>/stage}" placeholder="NEW, CHECKLIST, …" />
					</form:content>
				</form:SimpleForm>
				<HBox class="sapUiSmallMarginTop">
					<Button text="{i18n>search}" type="Emphasized" icon="sap-icon://search" press=".onSearch" class="sapUiTinyMarginEnd" />
					<Button text="{i18n>clear}" press=".onClear" class="sapUiTinyMarginEnd" />
					<Button
						text="{i18n>generateReport}"
						icon="sap-icon://excel-attachment"
						press=".onReportMock"
						enabled="{search>/searched}" />
				</HBox>
			</f:DynamicPageHeader>
		</f:header>
		<f:content>
			<Table
				items="{search>/results}"
				visible="{search>/searched}"
				growing="true"
				noDataText="{i18n>msgNoSearchResults}">
				<headerToolbar>
					<OverflowToolbar>
						<Title text="{i18n>searchResults}" level="H3" />
					</OverflowToolbar>
				</headerToolbar>
				<columns>
					<Column><Text text="{i18n>colId}" /></Column>
					<Column><Text text="{i18n>colDescription}" /></Column>
					<Column><Text text="{i18n>colStage}" /></Column>
					<Column hAlign="End"><Text text="{i18n>colAmount}" /></Column>
				</columns>
				<items>
					<ColumnListItem type="Navigation" press=".onOpenResult">
						<cells>
							<ObjectIdentifier
								title="{= ${search>/mode} === 'ADL' ? ${search>AdlId} : ${search>InvoiceId} }"
								text="{= ${search>/mode} === 'ADL' ? ${search>AdlType} : ${search>InvoiceNumber} }" />
							<Text text="{= ${search>/mode} === 'ADL' ? ${search>Office} : ${search>Supplier} }" />
							<ObjectStatus text="{search>StageText}" state="{path: 'search>Stage', formatter: '.formatter.stageState'}" />
							<Text text="{search>Amount}" />
						</cells>
					</ColumnListItem>
				</items>
			</Table>
		</f:content>
	</f:DynamicPage>
</mvc:View>
