in report user_timesheet and users_timesheet, the background of sunday column is...
[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:template match="/">
7         <xsl:call-template name="rml" />
8     </xsl:template>
9
10
11     <xsl:template name="rml">
12                 <document filename="example.pdf">
13                         <template pageSize="29.7cm,21cm" leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Timesheets" author="Generated by Tiny ERP, Fabien Pinckaers" allowSplitting="20">
14                                 <pageTemplate id="first">
15                                         <frame id="col1" x1="2.0cm" y1="2.5cm" width="24.7cm" height="17cm"/>
16                                 </pageTemplate>
17                         </template>
18                         
19                         <stylesheet>
20                                 <paraStyle name="normal" fontName="Helvetica" fontSize="6" alignment="center" />
21                                 <paraStyle name="normal-title" fontName="Helvetica" fontSize="6" />
22                                 <paraStyle name="title" fontName="Helvetica" fontSize="18" alignment="center" />
23                                 <paraStyle name="employee" fontName="Helvetica-Oblique" fontSize="10" textColor="blue" />
24                                 <paraStyle name="glande" textColor="red" />
25                                 <paraStyle name="normal_people" textColor="green" />
26                                 <paraStyle name="esclave" textColor="purple" />
27                                 <blockTableStyle id="month">
28                                         <blockAlignment value="CENTER" start="1,0" stop="-1,-1" />
29                                         <blockFont name="Helvetica" size="8" start="0,0" stop="-1,1"/>
30                                         <blockFont name="Helvetica" size="6" start="0,2" stop="-2,-2"/>
31                                         <blockFont name="Helvetica-BoldOblique" size="8" start="0,-1" stop="-1,-1"/>
32                                         <blockBackground colorName="#AAAAAA" start="1,0" stop="-2,1"/>
33                                         <xsl:for-each select="/report/days/day[@name='Sat' or @name='Sun']">
34                                                 <xsl:variable name="col" select="attribute::number" />
35                                                 <blockBackground>
36                                                         <xsl:attribute name="colorName">lightgrey</xsl:attribute>
37                                                         <xsl:attribute name="start">
38                                                                 <xsl:value-of select="$col" />
39                                                                 <xsl:text>,0</xsl:text>
40                                                         </xsl:attribute>
41                                                         <xsl:attribute name="stop">
42                                                                 <xsl:value-of select="$col" />
43                                                                 <xsl:text>,-1</xsl:text>
44                                                         </xsl:attribute>
45                                                 </blockBackground>
46                                         </xsl:for-each>
47                                         <lineStyle kind="LINEABOVE" colorName="black" start="0,0" stop="-1,-1" />
48                                         <lineStyle kind="LINEBEFORE" colorName="black" start="0,0" stop="-1,-1"/>
49                                         <lineStyle kind="LINEAFTER" colorName="black" start="-1,0" stop="-1,-1"/>
50                                         <lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
51                                         <blockValign value="TOP"/>
52                                 </blockTableStyle>
53                         </stylesheet>
54
55                         <story>
56                                 <xsl:call-template name="story"/>
57                         </story>
58                 </document>
59     </xsl:template>
60
61     <xsl:template name="story">
62                 <para style="title" t="1">Timesheet</para>
63                 <spacer length="1cm" />
64                 <para style="employee"><xsl:value-of select="/report/employee" /></para>
65                 <spacer length="1cm" />
66                 <blockTable>
67                         <xsl:attribute name="style">month</xsl:attribute>
68                         <xsl:attribute name="colWidths"><xsl:value-of select="report/cols" /></xsl:attribute>
69             <tr>
70                                 <td><xsl:value-of select="report/date/attribute::year" /></td>
71                                 <xsl:for-each select="report/days/day">
72                                         <td>
73                                                 <xsl:value-of select="attribute::name" />
74                                         </td>
75                                 </xsl:for-each>
76                                 <td></td>
77             </tr>
78             <tr>
79                                 <td><xsl:value-of select="report/date/attribute::month" /></td>
80                                 <xsl:for-each select="report/days/day">
81                                         <td>
82                                                 <xsl:value-of select="attribute::number" />
83                                         </td>
84                                 </xsl:for-each>
85                                 <td t="1">Total</td>
86             </tr>
87                         <xsl:apply-templates select="report/account"/>
88                         <tr>
89                                 <td t="1">Sum</td>
90                                 <xsl:for-each select="report/days/day">
91                                         <xsl:variable name="today" select="attribute::number" />
92                                         <td>
93                                                 <para>
94                                                         <xsl:choose>
95                                                                 <xsl:when test="sum(//time-element[@date=$today]) &lt; 7.5">
96                                                                         <xsl:attribute name="style">glande</xsl:attribute>
97                                                                 </xsl:when>
98                                                                 <xsl:when test="sum(//time-element[@date=$today]) &lt; 8.5 and sum(//time-element[@date=$today]) &gt;= 7.5">
99                                                                         <xsl:attribute name="style">normal_people</xsl:attribute>
100                                                                 </xsl:when>
101                                                                 <xsl:otherwise>
102                                                                         <xsl:attribute name="style">esclave</xsl:attribute>
103                                                                 </xsl:otherwise>
104                                                         </xsl:choose>
105                                                         <xsl:value-of select="sum(//time-element[@date=$today])" />
106                                                 </para>
107                                         </td>
108                                 </xsl:for-each>
109                                 <td>
110                                         <xsl:value-of select="sum(//time-element)" />
111                                 </td>
112                         </tr>
113         </blockTable>
114     </xsl:template>
115
116     <xsl:template match="account">
117                 <xsl:variable name="aid" select="attribute::id" />
118                 <tr>
119                         <td>
120                                 <para style="normal-title"><xsl:value-of select="attribute::name" /></para>
121                         </td>
122                         <xsl:for-each select="/report/days/day">
123                                 <xsl:variable name="today" select="attribute::number" />
124                                 <td>
125                                         <para style="normal"><xsl:value-of select="//account[@id=$aid]/time-element[@date=$today]" /></para>
126                                 </td>
127                         </xsl:for-each>
128                         <td>
129                                 <para style="normal"><xsl:value-of select="sum(//account[@id=$aid]/time-element)" /></para>
130                         </td>
131                 </tr>
132     </xsl:template>
133 </xsl:stylesheet>