<mvc:View
	controllerName="com.example.fiori.bp.controller.Wizard"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns="sap.m"
	xmlns:f="sap.f"
	xmlns:core="sap.ui.core"
	xmlns:form="sap.ui.layout.form"
	xmlns:l="sap.ui.layout"
	height="100%">
	<Page
		id="wizardPage"
		showHeader="true"
		title="{i18n>appTitle}"
		class="bpWizardPage"
		showNavButton="true"
		navButtonPress=".onNavHome">
		<customHeader>
			<Bar class="bpTopBar">
				<contentLeft>
					<Button icon="sap-icon://nav-back" type="Transparent" press=".onNavHome" tooltip="{i18n>navBack}" />
					<Title text="{i18n>appTitle}" level="H4" />
				</contentLeft>
				<contentRight>
					<ObjectStatus text="Mock OData" state="Information" inverted="true" />
				</contentRight>
			</Bar>
		</customHeader>
		<content>
			<VBox class="bpShell" renderType="Bare">
				<!-- Hero -->
				<VBox class="bpHero" renderType="Bare">
					<Text text="{i18n>heroEyebrow}" class="bpHeroEyebrow" />
					<Title text="{i18n>heroTitle}" level="H1" class="bpHeroTitle" />
					<Text text="{i18n>heroSubtitle}" class="bpHeroSubtitle" />
					<HBox class="bpHeroMeta" wrap="Wrap" renderType="Bare">
						<HBox class="bpMetaChip" alignItems="Center" renderType="Bare">
							<core:Icon src="sap-icon://official-service" class="bpMetaIcon" />
							<Text text="ZCCIAA_LOOKUP_SRV" />
						</HBox>
						<HBox class="bpMetaChip" alignItems="Center" renderType="Bare">
							<core:Icon src="sap-icon://customer" class="bpMetaIcon" />
							<Text text="API_BUSINESS_PARTNER" />
						</HBox>
					</HBox>
				</VBox>

				<!-- Wizard card -->
				<VBox class="bpWizardCard" renderType="Bare">
					<Wizard
						id="bpWizard"
						class="bpWizard"
						enableBranching="false"
						complete=".onWizardComplete"
						navigationChange=".onNavigationChange"
						finishButtonText="{i18n>finishReview}">

						<!-- STEP 1: CCIAA -->
						<WizardStep
							id="stepCciaa"
							title="{i18n>step1Title}"
							icon="sap-icon://inspect"
							validated="{= !!${draft>/cciaa/selectedKey} || (!!${draft>/general/vatNumber} &amp;&amp; !!${draft>/general/name1}) }">
							<VBox class="bpStepIntro" renderType="Bare">
								<Title text="{i18n>cciaaSectionTitle}" level="H3" />
								<Text text="{i18n>cciaaSectionText}" class="bpStepText" />
							</VBox>

							<form:SimpleForm
								editable="true"
								layout="ColumnLayout"
								columnsM="2"
								columnsL="3"
								columnsXL="3"
								class="bpSearchForm">
								<form:content>
									<Label text="{i18n>vatLabel}" />
									<Input
										id="searchVat"
										value="{draft>/search/vatNumber}"
										placeholder="11 cifre"
										maxLength="16"
										submit=".onSearchCciaa" />
									<Label text="{i18n>fiscalCodeLabel}" />
									<Input
										value="{draft>/search/fiscalCode}"
										maxLength="16"
										submit=".onSearchCciaa" />
									<Label text="{i18n>companyNameLabel}" />
									<Input
										value="{draft>/search/companyName}"
										placeholder="es. Nord Meccanica"
										submit=".onSearchCciaa" />
								</form:content>
							</form:SimpleForm>

							<HBox justifyContent="SpaceBetween" alignItems="Center" class="bpSearchActions" wrap="Wrap">
								<Text text="{i18n>searchHint}" class="bpHint" />
								<Button
									text="{i18n>searchCciaa}"
									type="Emphasized"
									icon="sap-icon://travel-expense-report"
									press=".onSearchCciaa"
									busy="{draft>/cciaa/busy}" />
							</HBox>

							<MessageStrip
								text="{i18n>cciaaSelectHint}"
								type="Information"
								showIcon="true"
								class="sapUiSmallMarginTop sapUiSmallMarginBottom"
								visible="{= ${draft>/cciaa/searched} &amp;&amp; ${draft>/cciaa/results}.length > 0 }" />

							<List
								id="cciaaList"
								mode="SingleSelectMaster"
								selectionChange=".onSelectCompany"
								items="{draft>/cciaa/results}"
								growing="true"
								growingThreshold="20"
								noDataText="{i18n>cciaaEmpty}"
								visible="{draft>/cciaa/searched}"
								busy="{draft>/cciaa/busy}"
								busyIndicatorDelay="0"
								class="bpResultList">
								<headerToolbar>
									<OverflowToolbar>
										<Title text="{i18n>cciaaResultsTitle}" level="H4" />
										<ToolbarSpacer />
										<ObjectStatus
											text="{= ${draft>/cciaa/results}.length + ' risultati' }"
											state="Indication03" />
									</OverflowToolbar>
								</headerToolbar>
								<CustomListItem
									type="Active"
									class="bpResultItem">
									<HBox alignItems="Center" justifyContent="SpaceBetween" class="bpResultRow" wrap="Wrap">
										<VBox class="bpResultMain" renderType="Bare">
											<Title text="{draft>CompanyName}" level="H5" />
											<HBox wrap="Wrap" class="bpResultTags" renderType="Bare">
												<ObjectAttribute title="P.IVA" text="{draft>VatNumber}" class="sapUiTinyMarginEnd" />
												<ObjectAttribute title="REA" text="{draft>ReaNumber}" class="sapUiTinyMarginEnd" />
												<ObjectAttribute title="CCIAA" text="{draft>CciaaCode}" />
											</HBox>
											<Text
												text="{draft>Street} {draft>HouseNumber}, {draft>PostalCode} {draft>City} ({draft>Region})"
												class="bpResultAddress" />
											<Text text="{draft>AtecoCode} · {draft>AtecoText}" class="bpResultAteco" />
										</VBox>
										<ObjectStatus
											class="bpResultStatus"
											text="{draft>Status}"
											state="{= ${draft>Status} === 'Attiva' ? 'Success' : 'Warning' }"
											inverted="true" />
									</HBox>
								</CustomListItem>
							</List>

							<MessageStrip
								text="{i18n>cciaaSelected}: {draft>/general/name1}"
								type="Success"
								showIcon="true"
								class="sapUiSmallMarginTop"
								visible="{= !!${draft>/cciaa/selectedKey} }" />
						</WizardStep>

						<!-- STEP 2: General -->
						<WizardStep
							id="stepGeneral"
							title="{i18n>step2Title}"
							icon="sap-icon://customer"
							validated="{= !!${draft>/general/name1} &amp;&amp; !!${draft>/general/vatNumber} }">
							<VBox class="bpStepIntro" renderType="Bare">
								<Title text="{i18n>generalSectionTitle}" level="H3" />
								<Text text="{i18n>generalSectionText}" class="bpStepText" />
							</VBox>

							<form:SimpleForm
								editable="true"
								layout="ColumnLayout"
								columnsM="2"
								columnsL="2"
								columnsXL="2">
								<form:content>
									<core:Title text="{i18n>generalSectionTitle}" />
									<Label text="{i18n>bpCategory}" />
									<SegmentedButton selectedKey="{draft>/general/bpCategory}">
										<items>
											<SegmentedButtonItem key="2" text="{i18n>catOrg}" />
											<SegmentedButtonItem key="1" text="{i18n>catPerson}" />
										</items>
									</SegmentedButton>
									<Label text="{i18n>name1}" required="true" />
									<Input value="{draft>/general/name1}" />
									<Label text="{i18n>name2}" />
									<Input value="{draft>/general/name2}" />
									<Label text="{i18n>legalForm}" />
									<Select selectedKey="{draft>/general/legalForm}">
										<items>
											<core:Item key="SRL" text="{i18n>legalSRL}" />
											<core:Item key="SPA" text="{i18n>legalSPA}" />
											<core:Item key="SAPA" text="{i18n>legalSAPA}" />
											<core:Item key="DI" text="{i18n>legalDI}" />
										</items>
									</Select>
									<Label text="{i18n>vatLabel}" required="true" />
									<Input value="{draft>/general/vatNumber}" />
									<Label text="{i18n>fiscalCodeLabel}" />
									<Input value="{draft>/general/fiscalCode}" />
									<Label text="{i18n>reaNumber}" />
									<Input value="{draft>/general/reaNumber}" />
									<Label text="{i18n>cciaaCode}" />
									<Input value="{draft>/general/cciaaCode}" />
									<Label text="{i18n>industry}" />
									<Select selectedKey="{draft>/general/industry}">
										<items>
											<core:Item key="MANU" text="{i18n>indMANU}" />
											<core:Item key="TRAD" text="{i18n>indTRAD}" />
											<core:Item key="SERV" text="{i18n>indSERV}" />
											<core:Item key="TECH" text="{i18n>indTECH}" />
											<core:Item key="LOGI" text="{i18n>indLOGI}" />
										</items>
									</Select>
								</form:content>
							</form:SimpleForm>

							<VBox class="bpRolesBox" renderType="Bare">
								<Title text="{i18n>rolesTitle}" level="H5" />
								<HBox wrap="Wrap">
									<CheckBox text="{i18n>roleCustomer}" selected="{draft>/general/customerRole}" class="sapUiSmallMarginEnd" />
									<CheckBox text="{i18n>roleSupplier}" selected="{draft>/general/supplierRole}" />
								</HBox>
							</VBox>
						</WizardStep>

						<!-- STEP 3: Address -->
						<WizardStep
							id="stepAddress"
							title="{i18n>step3Title}"
							icon="sap-icon://map"
							validated="{= !!${draft>/address/city} &amp;&amp; !!${draft>/address/postalCode} }">
							<VBox class="bpStepIntro" renderType="Bare">
								<Title text="{i18n>addressSectionTitle}" level="H3" />
								<Text text="{i18n>addressSectionText}" class="bpStepText" />
							</VBox>

							<form:SimpleForm
								editable="true"
								layout="ColumnLayout"
								columnsM="2"
								columnsL="2"
								columnsXL="2">
								<form:content>
									<core:Title text="{i18n>addressSectionTitle}" />
									<Label text="{i18n>street}" />
									<Input value="{draft>/address/street}" />
									<Label text="{i18n>houseNumber}" />
									<Input value="{draft>/address/houseNumber}" width="8rem" />
									<Label text="{i18n>postalCode}" required="true" />
									<Input value="{draft>/address/postalCode}" width="8rem" />
									<Label text="{i18n>city}" required="true" />
									<Input value="{draft>/address/city}" />
									<Label text="{i18n>region}" />
									<Input value="{draft>/address/region}" width="6rem" maxLength="3" />
									<Label text="{i18n>country}" />
									<Select selectedKey="{draft>/address/country}">
										<items>
											<core:Item key="IT" text="Italia" />
											<core:Item key="DE" text="Germania" />
											<core:Item key="FR" text="Francia" />
											<core:Item key="CH" text="Svizzera" />
										</items>
									</Select>
									<Label text="{i18n>email}" />
									<Input value="{draft>/address/email}" type="Email" />
									<Label text="{i18n>phone}" />
									<Input value="{draft>/address/phone}" type="Tel" />
									<Label text="{i18n>pec}" />
									<Input value="{draft>/address/pec}" type="Email" />
									<Label text="{i18n>website}" />
									<Input value="{draft>/address/website}" />
								</form:content>
							</form:SimpleForm>
						</WizardStep>

						<!-- STEP 4: Review -->
						<WizardStep
							id="stepReview"
							title="{i18n>step4Title}"
							icon="sap-icon://accept"
							validated="true">
							<VBox class="bpStepIntro" renderType="Bare">
								<Title text="{i18n>reviewTitle}" level="H3" />
								<Text text="{i18n>reviewText}" class="bpStepText" />
								<MessageStrip
									text="{i18n>reviewConfirmed}"
									type="Success"
									showIcon="true"
									visible="{draft>/create/reviewDone}"
									class="sapUiSmallMarginTop" />
							</VBox>

							<l:Grid defaultSpan="L6 M12 S12" class="bpReviewGrid">
								<VBox class="bpReviewPanel" renderType="Bare">
									<Title text="{i18n>reviewGeneral}" level="H5" class="bpReviewHeading" />
									<ObjectAttribute title="{i18n>name1}" text="{draft>/general/name1}" />
									<ObjectAttribute title="{i18n>vatLabel}" text="{draft>/general/vatNumber}" />
									<ObjectAttribute title="{i18n>fiscalCodeLabel}" text="{draft>/general/fiscalCode}" />
									<ObjectAttribute title="{i18n>legalForm}" text="{draft>/general/legalForm}" />
									<ObjectAttribute title="{i18n>industry}" text="{draft>/general/industry}" />
									<ObjectAttribute title="{i18n>reaNumber}" text="{draft>/general/reaNumber}" />
								</VBox>
								<VBox class="bpReviewPanel" renderType="Bare">
									<Title text="{i18n>reviewAddress}" level="H5" class="bpReviewHeading" />
									<ObjectAttribute
										title="{i18n>street}"
										text="{draft>/address/street} {draft>/address/houseNumber}" />
									<ObjectAttribute
										title="{i18n>city}"
										text="{draft>/address/postalCode} {draft>/address/city} ({draft>/address/region})" />
									<ObjectAttribute title="{i18n>country}" text="{draft>/address/country}" />
									<ObjectAttribute title="{i18n>email}" text="{draft>/address/email}" />
									<ObjectAttribute title="{i18n>phone}" text="{draft>/address/phone}" />
									<ObjectAttribute title="{i18n>pec}" text="{draft>/address/pec}" />
								</VBox>
							</l:Grid>

							<HBox class="bpReviewRoles" wrap="Wrap" renderType="Bare">
								<ObjectStatus
									class="sapUiTinyMarginEnd"
									text="{i18n>roleCustomer}"
									state="Success"
									inverted="true"
									visible="{draft>/general/customerRole}" />
								<ObjectStatus
									text="{i18n>roleSupplier}"
									state="Indication05"
									inverted="true"
									visible="{draft>/general/supplierRole}" />
							</HBox>

							<Button
								id="btnCreate"
								text="{i18n>createBp}"
								type="Emphasized"
								icon="sap-icon://save"
								class="sapUiMediumMarginTop bpCreateBtn"
								press=".onCreateBp"
								busy="{draft>/create/busy}"
								enabled="{= ${draft>/create/reviewDone} &amp;&amp; !${draft>/create/busy} }" />
							<Text
								text="{i18n>createNeedsReview}"
								visible="{= !${draft>/create/reviewDone} }"
								class="sapUiSmallMarginTop" />
						</WizardStep>
					</Wizard>
				</VBox>
			</VBox>
		</content>
	</Page>
</mvc:View>
