~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/addons/base/res/partner/report/partner_address.xsl

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

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="initial_bottom_pos">20.5</xsl:variable>
 
4
        <xsl:variable name="initial_left_pos">1</xsl:variable>
 
5
        <xsl:variable name="height_increment">6.5</xsl:variable>
 
6
        <xsl:variable name="width_increment">10</xsl:variable>
 
7
        <xsl:variable name="frame_height">5.5cm</xsl:variable>
 
8
        <xsl:variable name="frame_width">10cm</xsl:variable>
 
9
        <xsl:variable name="number_columns">2</xsl:variable>
 
10
        <xsl:variable name="max_frames">8</xsl:variable>
 
11
 
 
12
        <xsl:template match="/">
 
13
                <xsl:apply-templates select="addresses"/>
 
14
        </xsl:template>
 
15
 
 
16
        <xsl:template match="addresses">
 
17
                <document>
 
18
                        <template leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Address list" author="Generated by Tiny ERP">
 
19
                                <pageTemplate id="all">
 
20
                                        <pageGraphics/>
 
21
                                        <xsl:apply-templates select="address" mode="frames"/>
 
22
                                </pageTemplate>
 
23
                        </template>
 
24
                        <stylesheet>
 
25
                                <paraStyle name="nospace" fontName="Courier" fontSize="12" spaceBefore="0" spaceAfter="0"/>
 
26
                        </stylesheet>
 
27
                        <story>
 
28
                                <xsl:apply-templates select="address" mode="story">
 
29
                                        <xsl:sort select="contact/country"/>
 
30
                                        <xsl:sort select="contact/zip"/>
 
31
                                        <xsl:sort select="company-name"/>
 
32
                                </xsl:apply-templates>
 
33
                        </story>
 
34
                </document>
 
35
        </xsl:template>
 
36
 
 
37
        <xsl:template match="address" mode="frames">
 
38
                <xsl:if test="position() &lt; $max_frames + 1">
 
39
                        <frame>
 
40
                                <xsl:attribute name="width">
 
41
                                        <xsl:value-of select="$frame_width"/>
 
42
                                </xsl:attribute>
 
43
                                <xsl:attribute name="height">
 
44
                                        <xsl:value-of select="$frame_height"/>
 
45
                                </xsl:attribute>
 
46
                                <xsl:attribute name="x1">
 
47
                                        <xsl:value-of select="$initial_left_pos + ((position()-1) mod $number_columns) * $width_increment"/>
 
48
                                        <xsl:text>cm</xsl:text>
 
49
                                </xsl:attribute>
 
50
                                <xsl:attribute name="y1">
 
51
                                        <xsl:value-of select="$initial_bottom_pos - floor((position()-1) div $number_columns) * $height_increment"/>
 
52
                                        <xsl:text>cm</xsl:text>
 
53
                                </xsl:attribute>
 
54
                        </frame>
 
55
                </xsl:if>
 
56
        </xsl:template>
 
57
 
 
58
        <xsl:template match="address" mode="story">
 
59
                <para style="nospace"><xsl:value-of select="company-title"/><xsl:text> </xsl:text><xsl:value-of select="company-name"/></para>
 
60
                <xsl:choose>
 
61
                        <xsl:when test="count(contact[type='default']) >= 1">
 
62
                                <!-- apply the first 'contact' node with the type 'default' -->
 
63
                                <xsl:apply-templates select="contact[type='default'][1]"/>
 
64
                        </xsl:when>
 
65
                        <xsl:when test="count(contact[type='']) >= 1">
 
66
                                <!-- apply the first 'contact' node with an empty type -->
 
67
                                <xsl:apply-templates select="contact[type=''][1]"/>
 
68
                        </xsl:when>
 
69
                        <xsl:otherwise>
 
70
                                <!-- apply the first 'contact' node --> 
 
71
                                <xsl:apply-templates select="contact[1]"/>
 
72
                        </xsl:otherwise>
 
73
                </xsl:choose>
 
74
                <nextFrame/>
 
75
        </xsl:template>
 
76
        
 
77
        <xsl:template match="contact">
 
78
                <para style="nospace"><xsl:value-of select="title"/><xsl:text> </xsl:text><xsl:value-of select="name"/></para>
 
79
                <para style="nospace"><xsl:value-of select="street"/></para>
 
80
                <para style="nospace"><xsl:value-of select="street2"/></para>
 
81
                <para style="nospace"><xsl:value-of select="zip"/><xsl:text> </xsl:text><xsl:value-of select="city"/></para>
 
82
                <para style="nospace"><xsl:value-of select="state"/></para>
 
83
                <para style="nospace"><xsl:value-of select="country"/></para>
 
84
        </xsl:template>
 
85
</xsl:stylesheet>