<mvc:View controllerName="slsordage.controller.Items"
          xmlns:mvc="sap.ui.core.mvc"
          displayBlock="true"
          xmlns:core="sap.ui.core"
          xmlns="sap.m"
          xmlns:f="sap.ui.layout.form"
          xmlns:smartTable="sap.ui.comp.smarttable"
          xmlns:l="sap.ui.layout">
 
    <Page id="pageItems"
          title="{i18n>items}"
          showHeader="false"
          enableScrolling="true"
          class="sapUiContentPadding f2mPage"
          showNavButton="false">
 
        <content>
 
            <!-- ============================================================ -->
            <!-- HEADER BRAND BAR                                              -->
            <!-- ============================================================ -->
            <Bar class="f2mBrandBar sapUiTinyMarginBottom" design="Header">
                <contentLeft>
                    <HBox alignItems="Center" class="sapUiTinyMarginBegin">
                        <core:Icon src="sap-icon://list" size="1.25rem" class="f2mBrandIcon sapUiTinyMarginEnd"/>
                        <Title text="{i18n>items}" level="H3" titleStyle="H4" class="f2mBrandTitle"/>
                    </HBox>
                </contentLeft>
                <contentRight>
                    <ObjectStatus text="Order Items" state="Information" icon="sap-icon://hint" class="sapUiTinyMarginEnd"/>
                </contentRight>
            </Bar>
 
            <!-- ============================================================ -->
            <!-- SEZIONE 1 - Ricerca Spare Parts (Division / Family / Codice) -->
            <!-- ============================================================ -->
            <Panel id="panelSpareParts" expandable="false" backgroundDesign="Transparent" class="f2mSectionPanel sapUiNoContentPadding sapUiTinyMarginBottom">
                <headerToolbar>
                    <Toolbar design="Transparent" class="f2mSectionToolbar">
                        <core:Icon src="sap-icon://journey-change" color="#e9730c" class="sapUiTinyMarginBegin sapUiTinyMarginEnd"/>
                        <Title text="{i18n>SP}" level="H4"/>
                        <ToolbarSpacer/>
                    </Toolbar>
                </headerToolbar>
 
                <f:SimpleForm id="sparePartsForm" editable="false" layout="ResponsiveGridLayout"
                              labelSpanXL="3" labelSpanL="3" labelSpanM="3"
                              labelSpanS="12" adjustLabelSpan="false" emptySpanXL="4"
                              emptySpanL="4" emptySpanM="4" emptySpanS="0"
                              columnsXL="1" columnsL="1" columnsM="1"
                              singleContainerFullSize="false">
                    <f:content>
                        <Label class="label" text="{i18n>Division}"/>
                        <Input class="input" id="DivisionId" type="Text"
                               textFormatMode="KeyValue"
                               placeholder="{i18n>EntDivision}"
                               showSuggestion="true"
                               showValueHelp="true"
                               valueHelpRequest=".onDivisionSearch2"
                               suggestionItems="{DivSPJsonSH>/Division}"
                               suggestionItemSelected=".onSuggestionItemSelectedDivision">
                            <suggestionItems>
                                <core:ListItem key="{DivSPJsonSH>Spart}" text="{DivSPJsonSH>Vtext}"/>
                            </suggestionItems>
                        </Input>
 
                        <Button icon="sap-icon://visits"
                                id="sparePartsSearch2"
                                text="Cerca"
                                type="Accept"
                                press="onSPSearch"/>
 
                        <Label class="label" text="{i18n>Family}"/>
                        <Input class="input" id="FamilyId" type="Text"
                               textFormatMode="KeyValue"
                               placeholder="{i18n>EntFamily}"
                               showSuggestion="true"
                               showValueHelp="true"
                               valueHelpRequest=".onFamilySearch2"
                               suggestionItems="{FamSPJsonSH>/Family}"
                               suggestionItemSelected=".onSuggestionItemSelectedFamily">
                            <suggestionItems>
                                <core:ListItem key="{FamSPJsonSH>Prdha}" text="{FamSPJsonSH>Vtext}"/>
                            </suggestionItems>
                        </Input>
 
                        <Label class="label" text="{i18n>CodProd}"/>
                        <Input class="input" id="SparePartId" type="Text"
                               textFormatMode="KeyValue"
                               placeholder="{i18n>EntCodProd}"
                               showSuggestion="true"
                               showValueHelp="true"
                               valueHelpRequest=".onZHYBProductSearch"
                               suggestionItems="{zhybSPJsonSH>/Product}"
                               suggestionItemSelected=".onSuggestionItemSelectedZHYB">
                            <suggestionItems>
                                <core:ListItem key="{zhybSPJsonSH>Matnr}" text="{zhybSPJsonSH>Maktx}"/>
                            </suggestionItems>
                        </Input>
                    </f:content>
                </f:SimpleForm>
            </Panel>
 
            <!-- ============================================================ -->
            <!-- SEZIONE 2 - Ricerca Articolo                                 -->
            <!-- ============================================================ -->
            <Panel id="panelSearchProduct" expandable="false" backgroundDesign="Transparent" class="f2mSectionPanel sapUiNoContentPadding sapUiTinyMarginBottom">
                <headerToolbar>
                    <Toolbar design="Transparent" class="f2mSectionToolbar">
                        <core:Icon src="sap-icon://search" color="#0a6ed1" class="sapUiTinyMarginBegin sapUiTinyMarginEnd"/>
                        <Title text="{i18n>SearchProduct}" level="H4"/>
                        <ToolbarSpacer/>
                    </Toolbar>
                </headerToolbar>
 
                <f:SimpleForm id="SPProductForm" editable="false" layout="ResponsiveGridLayout"
                              labelSpanXL="3" labelSpanL="3"
                              labelSpanM="3" labelSpanS="12" adjustLabelSpan="false"
                              emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0"
                              columnsXL="1" columnsL="1" columnsM="1"
                              singleContainerFullSize="false">
                    <f:content>
                        <Label class="label" text="{i18n>Product}"/>
                        <Input id="SearchProductId" type="Text"
                               textFormatMode="KeyValue"
                               placeholder="{i18n>EntSearchProduct}"
                               showSuggestion="true"
                               showValueHelp="true"
                               valueHelpRequest=".onSearchByProduct"
                               suggestionItems="{SearchProdSPJsonSH>/Article}"
                               suggestionItemSelected=".onSuggestionItemSelectedSearchByProduct">
                            <suggestionItems>
                                <core:ListItem key="{SearchProdSPJsonSH>Matnr}" text="{SearchProdSPJsonSH>Maktx}"/>
                            </suggestionItems>
                        </Input>
 
                        <Button icon="sap-icon://add"
                                id="addArticleId"
                                text="{i18n>Add}"
                                type="Accept"
                                press="onAddSearchByProduct"/>
                    </f:content>
                </f:SimpleForm>
            </Panel>
 
            <!-- ============================================================ -->
            <!-- SEZIONE 3 - Testata ordine (Sales / Requester / Others)      -->
            <!-- ============================================================ -->
            <Panel expandable="false" backgroundDesign="Transparent" class="f2mSectionPanel sapUiNoContentPadding sapUiTinyMarginBottom">
                <headerToolbar>
                    <Toolbar design="Transparent" class="f2mSectionToolbar">
                        <core:Icon src="sap-icon://detail-view" color="#0a6ed1" class="sapUiTinyMarginBegin sapUiTinyMarginEnd"/>
                        <Title text="{i18n>TktDetailTitle}" level="H4"/>
                        <ToolbarSpacer/>
                    </Toolbar>
                </headerToolbar>
 
                <l:VerticalLayout width="100%">
                    <f:SimpleForm id="SimpleFormHeader" editable="false" layout="ResponsiveGridLayout"
                                  labelSpanXL="4" labelSpanL="4" labelSpanM="4" labelSpanS="12"
                                  adjustLabelSpan="false" emptySpanXL="0" emptySpanL="0"
                                  emptySpanM="0" emptySpanS="0" columnsXL="3" columnsL="2"
                                  columnsM="2" singleContainerFullSize="false">
                        <f:content>
 
                            <core:Title id="ordhTitle" text="{i18n>slsData}"/>
                            <l:VerticalLayout class="sapUiContentPadding">
                                <VBox>
                                    <Label id="lblSalesArea" text="{i18n>slsArea}" labelFor="VkorgH"/>
                                    <HBox class="column">
                                        <Input id="VkorgH" value="{order>/header/vkorg}" editable="false"/>
                                        <Input id="VtwegH" value="{order>/header/vtweg}" editable="false"/>
                                        <Input id="SpartH" value="{order>/header/spart}" editable="false"/>
                                    </HBox>
 
                                    <Label id="lblListino" text="{i18n>Listino}" labelFor="PltypH"/>
                                    <HBox class="column">
                                        <Input id="PltypH" value="{order>/header/pltyp}" editable="false"/>
                                        <Input id="PltypTextH" value="{order>/header/pltyp_text}" editable="false"/>
                                    </HBox>
 
                                    <HBox>
                                        <Label id="lblVdatuH" text="{i18n>Vdatu}" labelFor="VdatuH"/>
                                        <Label id="lblBstkd" text="{i18n>Bstkd}" labelFor="stkd"/>
                                    </HBox>
                                    <HBox>
                                        <Input id="VdatuH" value="{order>/header/vdatu}" editable="false"/>
                                        <Input id="stkd" value="{order>/header/bstkd}" editable="false"/>
                                    </HBox>
 
                                    <Label id="lblZterm" text="{i18n>Zterm}" labelFor="Zterm"/>
                                    <HBox>
                                        <Input id="Zterm" value="{order>/header/zterm}" editable="false"/>
                                        <Input id="ZtermName" value="{order>/header/zterm_name}" editable="false"/>
                                    </HBox>
 
                                    <Label id="lblnetwr" text="{i18n>NetValue}" labelFor="Netwr"/>
                                    <HBox>
                                        <Input id="Netwr" value="{order>/header/netwr}" editable="false"/>
                                        <Input id="WaerkH" value="{order>/header/waerk}" editable="false"/>
                                    </HBox>
                                </VBox>
                            </l:VerticalLayout>
 
                            <core:Title id="detailRequester1" text="{i18n>Requester}"/>
                            <l:VerticalLayout class="sapUiContentPadding">
                                <VBox>
                                    <Label id="lblSoldTo" text="{i18n>Sold-To}" labelFor="KunagH"/>
                                    <HBox>
                                        <Input id="KunagH" value="{order>/header/kunag}" editable="false"/>
                                        <Input id="KunagNameH" value="{order>/header/kunag_name}" editable="false"/>
                                        <Input id="KunagStreet" value="{order>/header/kunag_street}" editable="false"/>
                                    </HBox>
 
                                    <Label id="lblShipTo" text="{i18n>Ship-To}" labelFor="KunweH"/>
                                    <HBox>
                                        <Input id="KunweH" value="{order>/header/kunwe}" editable="false"/>
                                        <Input id="KunweNameH" value="{order>/header/kunwe_name}" editable="false"/>
                                    </HBox>
 
                                    <Label id="lblAgent" text="{i18n>Agent}" labelFor="Agent"/>
                                    <HBox>
                                        <Input id="Agent" value="{order>/header/agent}" editable="false"/>
                                        <Input id="AgentName" value="{order>/header/agent_name}" editable="false"/>
                                    </HBox>
                                </VBox>
                            </l:VerticalLayout>
 
                            <core:Title id="othersData" text="{i18n>ZORAData}"/>
                            <l:VerticalLayout class="sapUiContentPadding">
                                <VBox>
                                    <Label id="lblInco" text="{i18n>Inco}" labelFor="Inco"/>
                                    <HBox class="column">
                                        <Input id="Inco" value="{order>/header/inco1}" editable="false"/>
                                    </HBox>
 
                                    <Label text="{i18n>Brgew}"/>
                                    <HBox>
                                        <Input id="Brgew" value="{order>/header/brgew}" editable="false"/>
                                        <Input id="GeweiBr" value="{order>/header/gewei}" editable="false"/>
                                    </HBox>
 
                                    <Label text="{i18n>Ntgew}"/>
                                    <HBox>
                                        <Input id="Ntgew" value="{order>/header/ntgew}" editable="false"/>
                                        <Input id="GeweiNt" value="{order>/header/gewei}" editable="false"/>
                                    </HBox>
 
                                    <Label text="{i18n>Volum}"/>
                                    <HBox>
                                        <Input id="Volum" value="{order>/header/volum}" editable="false"/>
                                        <Input id="Voleh" value="{order>/header/voleh}" editable="false"/>
                                    </HBox>
                                </VBox>
                            </l:VerticalLayout>
 
                        </f:content>
                    </f:SimpleForm>
                </l:VerticalLayout>
            </Panel>
 
            <!-- ============================================================ -->
            <!-- SEZIONE 4 - Tabella Items                                    -->
            <!-- ============================================================ -->
            <Panel expandable="false" backgroundDesign="Transparent" class="f2mSectionPanel sapUiNoContentPadding">
                <headerToolbar>
                    <Toolbar design="Transparent" class="f2mSectionToolbar">
                        <core:Icon src="sap-icon://product" color="#107e3e" class="sapUiTinyMarginBegin sapUiTinyMarginEnd"/>
                        <Title text="{i18n>items}" level="H4"/>
                        <ToolbarSpacer/>
                    </Toolbar>
                </headerToolbar>
 
                <Table id="SalesOrderItems"
                       items="{items>/items}"
                       growing="true"
                       growingThreshold="25"
                       alternateRowColors="true"
                       sticky="ColumnHeaders,HeaderToolbar"
                       class="f2mDataTable"
                       mode="MultiSelect">
 
                    <columns>
                        <Column id="colItem" width="12em">
                            <Text id="textItem" text="{i18n>Posnr}"/>
                        </Column>
                        <Column id="colProduct" minScreenWidth="Tablet" demandPopin="true">
                            <Text id="textProduct" text="{i18n>Matnr}"/>
                        </Column>
                        <Column id="colDescription" minScreenWidth="Tablet" demandPopin="true" hAlign="End">
                            <Text id="textDescription" text="{i18n>Arktx}"/>
                        </Column>
                        <Column id="colQty" hAlign="End">
                            <Text id="textQty" text="{i18n>Kwmeng}"/>
                        </Column>
                        <Column id="colPrice1" hAlign="End">
                            <Text id="textPrice" text="{i18n>Kbetr}"/>
                        </Column>
                        <Column id="ColNotes" minScreenWidth="Tablet" hAlign="Center">
                            <Text id="TextNotes" text="{i18n>Notes}"/>
                        </Column>
                    </columns>
 
                    <items>
                        <ColumnListItem id="itemColList"
                                        type="Active"
                                        vAlign="Middle"
                                        press="onPress1">
                            <cells>
                                <ObjectIdentifier id="itemObjIdentifier" title="Pos." text="{items>item_no}"/>
                                <Text id="Matnr" text="{items>matnr}"/>
                                <Text id="Maktx" text="{items>arktx}"/>
 
                                <ObjectNumber id="Kwmeng"
                                    number="{
                                        parts:[{path:'items>kwmeng'},{path:'items>vrkme'}],
                                        type: 'sap.ui.model.type.Unit',
                                        formatOptions: {showMeasure: false}
                                    }"
                                    unit="{items>vrkme}"
                                    state="Information"
                                    class="sapUiSmallMarginBottom"
                                    inverted="true"/>
 
                                <ObjectNumber id="Kbetr"
                                    number="{
                                        parts:[{path:'items>kbetr'},{path:'items>waerk'}],
                                        type: 'sap.ui.model.type.Currency',
                                        formatOptions: {showMeasure: false}
                                    }"
                                    unit="{items>waerk}"
                                    state="Information"
                                    class="sapUiSmallMarginBottom"
                                    inverted="true"/>
 
                                <core:Icon src="{ path: 'items>notes', formatter: '.getIconNotes' }"
                                           class="size2"
                                           color="#64E4CE"
                                           press="onPressNotes">
                                </core:Icon>
                            </cells>
                        </ColumnListItem>
                    </items>
                </Table>
            </Panel>
 
        </content>
 
        <dependents>
            <core:Fragment id="ItemNotes" fragmentName="slsordage.fragment.Notes" type="XML"/>
        </dependents>
 
        <footer>
            <OverflowToolbar id="otbFooterItems" class="f2mFooterBar">
                <ToolbarSpacer id="toolBarSpace2"/>
 
                <Button id="Print"
                        icon="sap-icon://print"
                        text="{i18n>Print}"
                        type="Transparent"
                        press=".onPrintOrder"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog"/>
 
                <!-- ================== Gruppo E-REPS ================== -->
                <Button id="itemsRefresh"
                        icon="sap-icon://synchronize"
                        text="{i18n>Refresh}"
                        type="Transparent"
                        press=".onItemRefresh"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog"/>
                <Button id="addprod"
                        icon="sap-icon://add-product"
                        text="{i18n>AddProduct}"
                        type="Accept"
                        press=".onAddProductPress"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog">
                    <customData>
                        <core:CustomData key="multi" value="true"/>
                    </customData>
                </Button>
                <Button id="DelItem"
                        icon="sap-icon://delete"
                        text="{i18n>DelItem}"
                        type="Reject"
                        press=".onDeleteItem"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog">
                    <customData>
                        <core:CustomData key="multi" value="true"/>
                    </customData>
                </Button>
 
                <ToolbarSeparator/>
 
                <!-- ================== Gruppo Spare Parts ================== -->
                <Button id="SPitemsRefresh"
                        icon="sap-icon://synchronize"
                        text="{i18n>Refresh}"
                        type="Transparent"
                        press=".onItemRefresh"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog"/>
                <Button id="SPDelItem"
                        icon="sap-icon://delete"
                        text="{i18n>DelItem}"
                        type="Reject"
                        press=".onDeleteItem"
                        class="sapUiSmallMarginBottom f2mFooterBtn"
                        ariaHasPopup="Dialog">
                    <customData>
                        <core:CustomData key="multi" value="true"/>
                    </customData>
                </Button>
 
            </OverflowToolbar>
        </footer>
 
    </Page>
</mvc:View>