<?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:attribute-set name="link">
        <xsl:attribute name="color">#006FAE</xsl:attribute>
    </xsl:attribute-set>

    <xsl:template match="/">
        <fo:root>
            <fo:layout-master-set>
                <fo:simple-page-master master-name="A4" page-width="210mm" page-height="297mm">
                    <fo:region-body region-name="xsl-region-body" margin="0.85cm 0.85cm 2cm 0.85cm"/>
                    <fo:region-before region-name="xsl-region-before" extent="15mm"/>
                    <fo:region-after region-name="xsl-region-after" extent="12mm"/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="A4" id="page">
                <fo:static-content flow-name="xsl-region-after">
                    <fo:block-container background-color="#e9e9e9" absolute-position="absolute" bottom="0" left="0" right="0" width="100%">
                        <fo:block font-family="Helvetica" font-size="12pt">
                            <fo:table table-layout="fixed" width="210mm">
                                <fo:table-column column-width="25%"/>
                                <fo:table-column column-width="50%"/>
                                <fo:table-column column-width="25%"/>
                                <fo:table-body>
                                    <fo:table-row>
                                        <fo:table-cell padding="0.25cm 0.5cm 0cm" display-align="center">
                                            <fo:block text-align="left">
                                                <fo:basic-link xsl:use-attribute-sets="link">
                                                    <xsl:attribute name="external-destination">
                                                        <xsl:value-of select="data/alvadi/link"/>
                                                    </xsl:attribute>
                                                    <fo:external-graphic content-height="scale-to-fit" width="2.75cm">
                                                        <xsl:attribute name="src">
                                                            <xsl:value-of select="data/alvadi/logo"/>
                                                        </xsl:attribute>
                                                    </fo:external-graphic>
                                                </fo:basic-link>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell padding="0.25cm 0.5cm 0cm" display-align="center">
                                            <fo:block text-align="center">
                                                <xsl:value-of select="data/alvadi/phone"/> | <xsl:value-of select="data/alvadi/www"/> | <xsl:value-of select="data/alvadi/email"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell padding="0.25cm 0.5cm 0cm" display-align="center">
                                            <fo:block text-align="right">
                                                page <fo:page-number/>/<fo:page-number-citation-last ref-id="page"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </fo:table-body>
                            </fo:table>
                        </fo:block>
                    </fo:block-container>
                </fo:static-content>    
                <fo:flow flow-name="xsl-region-body">
          
                    <fo:block font-family="Helvetica" font-size="13pt" break-after="page">

                        <fo:block margin-bottom="0.75cm">
                            <fo:basic-link xsl:use-attribute-sets="link">
                                <xsl:attribute name="external-destination">
                                    <xsl:value-of select="data/alvadi/link"/>
                                </xsl:attribute>
                                <fo:external-graphic content-height="scale-to-fit" width="7cm">
                                    <xsl:attribute name="src">
                                        <xsl:value-of select="data/alvadi/logo"/>
                                    </xsl:attribute>
                                </fo:external-graphic>
                            </fo:basic-link>
                        </fo:block>
                        
                        <fo:block margin-bottom="0.15cm" font-size="18pt" font-weight="bold"><xsl:value-of select="data/alvadi/action"/></fo:block>
                        <fo:block margin-bottom="0.75cm">
                            <xsl:value-of select="data/alvadi/description"/>
                            <fo:basic-link xsl:use-attribute-sets="link">
                                <xsl:attribute name="external-destination">
                                    <xsl:value-of select="data/alvadi/link"/>
                                </xsl:attribute>
                                alvadi.ee
                            </fo:basic-link>
                        </fo:block>

                        <fo:block margin-bottom="0.85cm">
                            <fo:block margin-bottom="0.25cm" font-size="16pt" font-weight="bold">
                                <xsl:value-of select="data/personal/title"/>
                            </fo:block>
                            <fo:block font-size="12pt">
                                <fo:table table-layout="fixed" width="180mm">
                                    <fo:table-column column-width="30%"/>
                                    <fo:table-column column-width="70%"/>
                                    <fo:table-body>
                                        
                                        <xsl:for-each select="data/personal/table/tr">
                                        <fo:table-row>
                                            <fo:table-cell padding="0.15cm 0" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block>
                                                    <xsl:value-of select="key"/>
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell padding="0.15cm 0" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block>
                                                    <xsl:value-of select="value"/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        </xsl:for-each>

                                    </fo:table-body>
                                </fo:table>
                            </fo:block>
                        </fo:block>

                        <fo:block margin-bottom="0.85cm">
                            <fo:block margin-bottom="0.25cm" font-size="16pt" font-weight="bold">
                                <xsl:value-of select="data/contacts/title"/>
                            </fo:block>
                            <fo:block font-size="12pt">
                                <fo:table table-layout="fixed" width="180mm">
                                    <fo:table-column column-width="30%"/>
                                    <fo:table-column column-width="70%"/>
                                    <fo:table-body>
                                        
                                        <xsl:for-each select="data/contacts/table/tr">
                                        <fo:table-row>
                                            <fo:table-cell padding="0.15cm 0" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block>
                                                    <xsl:value-of select="key"/>
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell padding="0.15cm 0" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block>
                                                    <xsl:value-of select="value"/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        </xsl:for-each>

                                    </fo:table-body>
                                </fo:table>
                            </fo:block>
                        </fo:block>

                    </fo:block>

                    <fo:block font-family="Helvetica" font-size="13pt" break-after="page">
                        
                        <fo:block margin-bottom="0.5cm" font-size="16pt" font-weight="bold">
                            <xsl:value-of select="data/bank/title"/>
                        </fo:block>
                        <fo:block font-size="12pt">
                            <!-- <fo:table table-layout="fixed" width="180mm"> -->
                            <fo:table table-layout="fixed" width="100%">
                                <!-- <xsl:for-each select="data/bank/thead/col">
                                <fo:table-column/>
                                </xsl:for-each> -->
                                <fo:table-column column-width="35%"/>
                                <fo:table-column column-width="35%"/>
                                <fo:table-column column-width="30%"/>
                                <fo:table-body>
                                    <fo:table-row>
                                        <xsl:for-each select="data/bank/thead/col">
                                            <fo:table-cell background-color="#e9e9e9" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block margin="0.15cm 0.15cm 0.10cm 0.15cm">
                                                    <xsl:value-of select="."/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </xsl:for-each>
                                    </fo:table-row>
                                    <xsl:for-each select="data/bank/tbody/tr">
                                    <fo:table-row>
                                        <xsl:for-each select="td">
                                            <fo:table-cell border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block margin="0.15cm 0.15cm 0.10cm 0.15cm">
                                                    <xsl:value-of select="."/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </xsl:for-each>
                                    </fo:table-row>
                                    </xsl:for-each>

                                </fo:table-body>
                            </fo:table>
                        </fo:block>

                    </fo:block>

                    <fo:block font-family="Helvetica" font-size="13pt" break-after="page">
                        
                        <fo:block margin-bottom="0.5cm" font-size="16pt" font-weight="bold">
                            <xsl:value-of select="data/history/title"/>
                        </fo:block>

                        <fo:block margin-bottom="0.5cm" font-size="11pt">
                            <!-- <fo:table table-layout="fixed" width="180mm"> -->
                            <fo:table table-layout="fixed" width="100%">
                                <!-- <xsl:for-each select="data/history/thead/col">
                                <fo:table-column/>
                                </xsl:for-each> -->
                                <fo:table-column column-width="30%"/>
                                <fo:table-column column-width="25%"/>
                                <fo:table-column column-width="25%"/>
                                <fo:table-column column-width="20%"/>
                                <fo:table-body>
                                    <fo:table-row>
                                        <xsl:for-each select="data/history/thead/col">
                                            <fo:table-cell background-color="#e9e9e9" border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block margin="0.15cm 0.15cm 0.10cm 0.15cm">
                                                    <xsl:value-of select="."/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </xsl:for-each>
                                    </fo:table-row>
                                    <xsl:for-each select="data/history/tbody/tr">
                                    <fo:table-row>
                                        <xsl:for-each select="td">
                                            <fo:table-cell border-bottom-width="0.5mm" border-bottom-color="#e9e9e9" border-bottom-style="solid">
                                                <fo:block margin="0.15cm 0.15cm 0.10cm 0.15cm">
                                                    <xsl:value-of select="."/>
                                                </fo:block>
                                            </fo:table-cell>
                                        </xsl:for-each>
                                    </fo:table-row>
                                    </xsl:for-each>

                                </fo:table-body>
                            </fo:table>
                        </fo:block>

                        <fo:block-container absolute-position="absolute" top="268mm" left="0" right="0" width="100%" text-align="center">
                            <fo:block font-size="12pt">
                                <xsl:value-of select="data/alvadi/thx"/>
                            </fo:block>
                        </fo:block-container>

                    </fo:block>

                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>