~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to label/report/partner_address.xsl

  • Committer: Jordi Esteve
  • Date: 2008-11-24 15:19:02 UTC
  • mto: (3356.3.2 trunk-extra-addons)
  • mto: This revision was merged to the branch mainline in revision 3357.
  • Revision ID: jesteve@alba-20081124151902-wrn3dbba91of8tod
Module partner_spam divide in 2 modules: partner_spam and label. Added security rules and Spanish and Catalan translations (new security and i18n directories) to both

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?>
 
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
3
    <xsl:variable name="page_width"><xsl:value-of select="/addresses/page_width"/></xsl:variable>
 
4
    <xsl:variable name="page_height"><xsl:value-of select="/addresses/page_height"/></xsl:variable>
 
5
    <xsl:variable name="initial_bottom_pos"><xsl:value-of select="/addresses/initial_bottom_pos"/></xsl:variable>
 
6
    <xsl:variable name="initial_left_pos"><xsl:value-of select="/addresses/initial_left_pos"/></xsl:variable>
 
7
    <xsl:variable name="height_increment"><xsl:value-of select="/addresses/height_incr"/></xsl:variable>
 
8
    <xsl:variable name="width_increment"><xsl:value-of select="/addresses/width_incr"/></xsl:variable>
 
9
    <xsl:variable name="frame_height"><xsl:value-of select="/addresses/label_height"/></xsl:variable>
 
10
    <xsl:variable name="frame_width"><xsl:value-of select="/addresses/label_width"/></xsl:variable>
 
11
    <xsl:variable name="number_columns"><xsl:value-of select="/addresses/cols"/></xsl:variable>
 
12
    <xsl:variable name="max_frames"><xsl:value-of select="/addresses/rows * /addresses/cols"/></xsl:variable>
 
13
    <xsl:variable name="printer_top"><xsl:value-of select="/addresses/printer_top"/></xsl:variable>
 
14
    <xsl:variable name="printer_bottom"><xsl:value-of select="/addresses/printer_bottom"/></xsl:variable>
 
15
    <xsl:variable name="printer_left"><xsl:value-of select="/addresses/printer_left"/></xsl:variable>
 
16
    <xsl:variable name="printer_right"><xsl:value-of select="/addresses/printer_right"/></xsl:variable>
 
17
 
 
18
    <xsl:template match="/">
 
19
        <xsl:apply-templates select="addresses"/>
 
20
    </xsl:template>
 
21
 
 
22
    <xsl:template match="addresses">
 
23
        <document>
 
24
            <template leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Address list" author="Generated by Tiny ERP">
 
25
                <xsl:attribute name="pageSize">
 
26
                    <xsl:value-of select="page_width"/><xsl:text>cm,</xsl:text><xsl:value-of select="page_height"/><xsl:text>cm</xsl:text>
 
27
                </xsl:attribute>
 
28
                <pageTemplate id="all">
 
29
                    <pageGraphics/>
 
30
                    <xsl:apply-templates select="address" mode="frames"/>
 
31
                </pageTemplate>
 
32
            </template>
 
33
            <stylesheet>
 
34
                <paraStyle name="nospace" spaceBefore="0" spaceAfter="0">
 
35
                    <xsl:attribute name="fontName">
 
36
                        <xsl:value-of select="font_type"/>
 
37
                    </xsl:attribute>
 
38
                    <xsl:attribute name="fontSize">
 
39
                        <xsl:value-of select="font_size"/>
 
40
                    </xsl:attribute>
 
41
                </paraStyle>
 
42
            </stylesheet>
 
43
            <story>
 
44
                <xsl:apply-templates select="address" mode="story">
 
45
                    <xsl:sort select="contact/country"/>
 
46
                    <xsl:sort select="contact/zip"/>
 
47
                    <xsl:sort select="company-name"/>
 
48
                </xsl:apply-templates>
 
49
            </story>
 
50
        </document>
 
51
    </xsl:template>
 
52
 
 
53
    <xsl:template match="address" mode="frames">
 
54
        <xsl:if test="position() &lt; $max_frames + 1">
 
55
            <xsl:variable name="width"><xsl:value-of select="$frame_width"/></xsl:variable>
 
56
            <xsl:variable name="height"><xsl:value-of select="$frame_height"/></xsl:variable>
 
57
            <xsl:variable name="x1"><xsl:value-of select="$initial_left_pos + ((position()-1) mod $number_columns) * $width_increment"/></xsl:variable>
 
58
            <xsl:variable name="y1"><xsl:value-of select="$initial_bottom_pos - floor((position()-1) div $number_columns) * $height_increment"/></xsl:variable>
 
59
            <frame>
 
60
            <xsl:choose>
 
61
                <!--Left labels over the left printer margin-->
 
62
                <xsl:when test="$x1 &lt; $printer_left">
 
63
                    <xsl:attribute name="x1">
 
64
                        <xsl:value-of select="$printer_left"/>
 
65
                        <xsl:text>cm</xsl:text>
 
66
                    </xsl:attribute>
 
67
                    <xsl:attribute name="width">
 
68
                        <xsl:value-of select="$width - ($printer_left - $x1)"/>
 
69
                        <xsl:text>cm</xsl:text>
 
70
                    </xsl:attribute>
 
71
                </xsl:when>
 
72
                <!--Right labels over the right printer margin-->
 
73
                <xsl:when test="$page_width - ($x1 + $width) &lt; $printer_right">
 
74
                    <xsl:attribute name="x1">
 
75
                        <xsl:value-of select="$x1"/>
 
76
                        <xsl:text>cm</xsl:text>
 
77
                    </xsl:attribute>
 
78
                    <xsl:attribute name="width">
 
79
                        <xsl:value-of select="$page_width - ($x1 + $printer_right)"/>
 
80
                        <xsl:text>cm</xsl:text>
 
81
                    </xsl:attribute>
 
82
                </xsl:when>
 
83
                <xsl:otherwise>
 
84
                    <xsl:attribute name="x1">
 
85
                        <xsl:value-of select="$x1"/>
 
86
                        <xsl:text>cm</xsl:text>
 
87
                    </xsl:attribute>
 
88
                    <xsl:attribute name="width">
 
89
                        <xsl:value-of select="$width"/>
 
90
                        <xsl:text>cm</xsl:text>
 
91
                    </xsl:attribute>
 
92
                </xsl:otherwise>
 
93
            </xsl:choose>
 
94
            <xsl:choose>
 
95
                <!--Bottom labels over the bottom printer margin-->
 
96
                <xsl:when test="$y1 &lt; $printer_bottom">
 
97
                    <xsl:attribute name="y1">
 
98
                        <xsl:value-of select="$printer_bottom"/>
 
99
                        <xsl:text>cm</xsl:text>
 
100
                    </xsl:attribute>
 
101
                    <xsl:attribute name="height">
 
102
                        <xsl:value-of select="$height - ($printer_bottom - $y1)"/>
 
103
                        <xsl:text>cm</xsl:text>
 
104
                    </xsl:attribute>
 
105
                </xsl:when>
 
106
                <!--Top labels over the top printer margin-->
 
107
                <xsl:when test="$page_height - ($y1 + $height) &lt; $printer_top">
 
108
                    <xsl:attribute name="y1">
 
109
                        <xsl:value-of select="$y1"/>
 
110
                        <xsl:text>cm</xsl:text>
 
111
                    </xsl:attribute>
 
112
                    <xsl:attribute name="height">
 
113
                        <xsl:value-of select="$page_height - ($y1 + $printer_top)"/>
 
114
                        <xsl:text>cm</xsl:text>
 
115
                    </xsl:attribute>
 
116
                </xsl:when>
 
117
                <xsl:otherwise>
 
118
                    <xsl:attribute name="y1">
 
119
                        <xsl:value-of select="$y1"/>
 
120
                        <xsl:text>cm</xsl:text>
 
121
                    </xsl:attribute>
 
122
                    <xsl:attribute name="height">
 
123
                        <xsl:value-of select="$height"/>
 
124
                        <xsl:text>cm</xsl:text>
 
125
                    </xsl:attribute>
 
126
                </xsl:otherwise>
 
127
            </xsl:choose>
 
128
            </frame>
 
129
        </xsl:if>
 
130
    </xsl:template>
 
131
 
 
132
    <xsl:template match="address" mode="story">
 
133
        <para style="nospace">
 
134
        <!--<xsl:value-of select="position()"/> -->
 
135
        <xsl:value-of select="company-name"/><xsl:text> </xsl:text><xsl:value-of select="company-title"/></para>
 
136
        <xsl:choose>
 
137
            <xsl:when test="count(contact[type='default']) >= 1">
 
138
                <!-- apply the first 'contact' node with the type 'default' -->
 
139
                <xsl:apply-templates select="contact[type='default'][1]"/>
 
140
            </xsl:when>
 
141
            <xsl:when test="count(contact[type='']) >= 1">
 
142
                <!-- apply the first 'contact' node with an empty type -->
 
143
                <xsl:apply-templates select="contact[type=''][1]"/>
 
144
            </xsl:when>
 
145
            <xsl:otherwise>
 
146
                <!-- apply the first 'contact' node -->    
 
147
                <xsl:apply-templates select="contact[1]"/>
 
148
            </xsl:otherwise>
 
149
        </xsl:choose>
 
150
        <nextFrame/>
 
151
    </xsl:template>
 
152
    
 
153
    <xsl:template match="contact">
 
154
        <para style="nospace"><xsl:value-of select="title"/><xsl:text> </xsl:text><xsl:value-of select="name"/></para>
 
155
        <para style="nospace"><xsl:value-of select="street"/></para>
 
156
        <para style="nospace"><xsl:value-of select="street2"/></para>
 
157
        <para style="nospace"><xsl:value-of select="zip"/><xsl:text> </xsl:text><xsl:value-of select="city"/></para>
 
158
        <para style="nospace"><xsl:value-of select="state"/></para>
 
159
        <para style="nospace"><xsl:value-of select="country"/></para>
 
160
    </xsl:template>
 
161
</xsl:stylesheet>