<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
        <fo:root>
            <fo:layout-master-set>
                <fo:simple-page-master master-name="A6" page-width="10.5cm" page-height="14.8cm" margin-top="0.05cm" margin-right="0.05cm" margin-bottom="0.05cm" margin-left="0.05cm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="A6">
                <fo:flow flow-name="xsl-region-body">

                    <fo:table table-layout="fixed" width="10.4cm">
                        <fo:table-column column-width="10.4cm"/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell border="0.02cm solid #A52A2A" height="14.275cm" padding="0.2cm" font-family="Helvetica" font-size="9pt" color="#333333" line-height="13pt">
                                    
                                    <fo:table table-layout="fixed" width="9.9cm">
                                        <fo:table-column column-width="4.7cm"/>
                                        <fo:table-column column-width="5.2cm"/>
                                        <fo:table-body>
                                            <fo:table-row border-bottom="0.03cm solid #A52A2A">
                                                <fo:table-cell padding="0.25cm 0.2cm" text-align="right" line-height="normal">
                                                    <fo:block font-size="28pt" font-weight="bold"><xsl:value-of select="data/number"/></fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm" text-align="left" line-height="normal">
                                                    <fo:block>
                                                      <fo:external-graphic content-height="scale-to-fit" height="0.75cm">
                                                        <xsl:attribute name="src">
                                                          <xsl:value-of select="data/courier/logo"/>
                                                        </xsl:attribute>
                                                      </fo:external-graphic>
                                                    </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.04cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block font-weight="bold">Saatja</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block font-weight="bold">Saaja</fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.02cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block><xsl:value-of select="data/sender/name"/></fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block><xsl:value-of select="data/recepient/name"/></fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.02cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block><xsl:value-of select="data/sender/phone"/></fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block><xsl:value-of select="data/recepient/phone"/></fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.02cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block><xsl:value-of select="data/sender/address"/></fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block><xsl:value-of select="data/recepient/address"/></fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.02cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block> </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block> </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row border-bottom="0.04cm solid #DDDDDD">
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm">
                                                    <fo:block> </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.25cm 0.2cm 0.2cm" text-align="right">
                                                    <fo:block> </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                            <fo:table-row>
                                                <fo:table-cell padding="0.5cm 0 0.45cm">
                                                    <fo:block margin-bottom="0.25cm">
                                                        <fo:inline font-weight="bold">LISA:</fo:inline>
                                                        <xsl:value-of select="data/options/add"/>
                                                    </fo:block>
                                                    <fo:block margin-bottom="0.25cm">
                                                        <fo:inline font-weight="bold">Kuupäev:</fo:inline>
                                                        <xsl:value-of select="data/options/date"/>
                                                    </fo:block>
                                                    <fo:block>
                                                        <fo:inline font-weight="bold">Kogus:</fo:inline>
                                                        <xsl:value-of select="data/options/quantity"/>
                                                    </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell padding="0.5cm 0 0.45cm" text-align="right">
                                                  <fo:block>
                                                      <fo:external-graphic content-height="scale-to-fit" height="2cm">
                                                        <xsl:attribute name="src">
                                                          <xsl:value-of select="data/qrcode"/>
                                                        </xsl:attribute>
                                                      </fo:external-graphic>
                                                    </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                        </fo:table-body>
                                    </fo:table>

                                    <fo:table table-layout="fixed" width="9.9cm">
                                        <fo:table-column column-width="9.9cm"/>
                                        <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell text-align="center">
                                                    <fo:block>
                                                        <xsl:variable name="barcode">
                                                            <xsl:value-of select="data/barcode"/>
                                                        </xsl:variable>
                                                        <fo:instream-foreign-object>
                                                            <barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns" message="{$barcode}" orientation="0">
                                                                <barcode:code128>
                                                                    <barcode:module-width>0.04cm</barcode:module-width>
                                                                    <barcode:height>1.5cm</barcode:height>
                                                                    <barcode:human-readable>none</barcode:human-readable>
                                                                </barcode:code128>
                                                            </barcode:barcode>
                                                        </fo:instream-foreign-object>
                                                    </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                        </fo:table-body>
                                    </fo:table>

                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>

                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>
