[IMP/ADD]: Header in hr_timesheet xsl reports with saterate template for xsl landscap...
[odoo/odoo.git] / addons / hr_timesheet / report / user_timesheet.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0"
3     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4     xmlns:fo="http://www.w3.org/1999/XSL/Format">
5
6     <xsl:import href="custom_default.xsl"/>
7         <xsl:import href="custom_rml.xsl"/>
8
9         <xsl:template match="/">
10                 <xsl:call-template name="rml"/>
11         </xsl:template>
12
13         <xsl:template name="stylesheet">
14                                 <paraStyle name="normal" fontName="Helvetica" fontSize="6" alignment="left" />
15                                 <paraStyle name="normal-title" fontName="Helvetica" fontSize="6" />
16                                 <paraStyle name="title" fontName="Helvetica" fontSize="18" alignment="center" />
17                                 <paraStyle name="employee" fontName="Helvetica-Oblique" fontSize="10" textColor="blue" />
18                                 <paraStyle name="glande" textColor="red" fontSize="7" fontName="Helvetica"/>
19                                 <paraStyle name="normal_people" textColor="green" fontSize="7" fontName="Helvetica"/>
20                                 <paraStyle name="esclave" textColor="purple" fontSize="7" fontName="Helvetica"/>
21                                 <blockTableStyle id="month">
22                                         <blockAlignment value="CENTER" start="1,0" stop="-1,-1" />
23                                         <blockFont name="Helvetica" size="8" start="0,0" stop="-1,1"/>
24                                         <blockFont name="Helvetica" size="6" start="0,2" stop="-2,-2"/>
25                                         <blockFont name="Helvetica-BoldOblique" size="8" start="0,-1" stop="-1,-1"/>
26                                         <blockBackground colorName="#AAAAAA" start="1,0" stop="-2,1"/>
27                                         <xsl:for-each select="/report/days/day[@weekday=6 or @weekday=7]">
28                                                 <xsl:variable name="col" select="attribute::number" />
29                                                 <blockBackground>
30                                                         <xsl:attribute name="colorName">lightgrey</xsl:attribute>
31                                                         <xsl:attribute name="start">
32                                                                 <xsl:value-of select="$col" />
33                                                                 <xsl:text>,0</xsl:text>
34                                                         </xsl:attribute>
35                                                         <xsl:attribute name="stop">
36                                                                 <xsl:value-of select="$col" />
37                                                                 <xsl:text>,-1</xsl:text>
38                                                         </xsl:attribute>
39                                                 </blockBackground>
40                                         </xsl:for-each>
41                                         <lineStyle kind="LINEABOVE" colorName="black" start="0,0" stop="-1,-1" />
42                                         <lineStyle kind="LINEBEFORE" colorName="black" start="0,0" stop="-1,-1"/>
43                                         <lineStyle kind="LINEAFTER" colorName="black" start="-1,0" stop="-1,-1"/>
44                                         <lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
45                                         <blockValign value="TOP"/>
46                                 </blockTableStyle>
47         </xsl:template>
48
49     <xsl:template name="story">
50                 <spacer length="1cm" />
51                 <para style="title" t="1">Timesheet</para>
52                 <spacer length="1cm" />
53                 <para style="employee"><xsl:value-of select="/report/employee" /></para>
54                 <spacer length="1cm" />
55                 <blockTable>
56                         <xsl:attribute name="style">month</xsl:attribute>
57                         <xsl:attribute name="colWidths"><xsl:value-of select="report/cols" /></xsl:attribute>
58             <tr>
59                                 <td><xsl:value-of select="report/date/attribute::year" /></td>
60                                 <xsl:for-each select="report/days/day">
61                                         <td>
62                                                 <xsl:value-of select="attribute::name" />
63                                         </td>
64                                 </xsl:for-each>
65                                 <td></td>
66             </tr>
67             <tr>
68                                 <td><xsl:value-of select="report/date/attribute::month" /></td>
69                                 <xsl:for-each select="report/days/day">
70                                         <td>
71                                                 <xsl:value-of select="attribute::number" />
72                                         </td>
73                                 </xsl:for-each>
74                                 <td t="1">Total</td>
75             </tr>
76                         <xsl:apply-templates select="report/account"/>
77                         <tr>
78                                 <td t="1">Sum</td>
79                                 <xsl:for-each select="report/days/day">
80                                         <xsl:variable name="today" select="attribute::number" />
81                                         <td>
82                                                 <para style="normal">
83                                                         <xsl:choose>
84                                                                 <xsl:when test="sum(//time-element[@date=$today]) &lt; 7.5">
85                                                                         <xsl:attribute name="style">glande</xsl:attribute>
86                                                                 </xsl:when>
87                                                                 <xsl:when test="sum(//time-element[@date=$today]) &lt; 8.5 and sum(//time-element[@date=$today]) &gt;= 7.5">
88                                                                         <xsl:attribute name="style">normal_people</xsl:attribute>
89                                                                 </xsl:when>
90                                                                 <xsl:otherwise>
91                                                                         <xsl:attribute name="style">esclave</xsl:attribute>
92                                                                 </xsl:otherwise>
93                                                         </xsl:choose>
94                                                         <xsl:value-of select="format-number(sum(//time-element[@date=$today]),'##.##')" />
95                                                 </para>
96                                         </td>
97                                 </xsl:for-each>
98                                 <td>
99                                         <xsl:value-of select="format-number(sum(//time-element),'##.##')" />
100                                 </td>
101                         </tr>
102         </blockTable>
103     </xsl:template>
104
105     <xsl:template match="account">
106                 <xsl:variable name="aid" select="attribute::id" />
107
108                 <tr>
109                         <td>
110                                 <para style="normal-title"><xsl:value-of select="attribute::name" /></para>
111                         </td>
112                         <xsl:for-each select="/report/days/day">
113                                 <xsl:variable name="today" select="attribute::number" />
114                                 <td>
115                                         <para style="normal"><xsl:value-of select="//account[@id=$aid]/time-element[@date=$today]" /></para>
116                                 </td>
117                         </xsl:for-each>
118                         <td>
119                                 <para style="normal"><xsl:value-of select="format-number(sum(//account[@id=$aid]/time-element),'##.##')" /></para>
120                         </td>
121                 </tr>
122     </xsl:template>
123 </xsl:stylesheet>