source: clientsplugin/trunk/cron/summary.xslt

Last change on this file was 4204, checked in by Colin Guthrie, 15 years ago

Extract the milestone information for the summary email during the query. This saves an extra query.
Join on the 'estimatedhours' field as used in the TimingAndEstimationPlugin. Add up a total estimate from all tickets in a given milestone.
I need to find a more generic way of doing this

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/xml
File size: 5.6 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
3<xsl:stylesheet
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  version="1.0">
6 
7  <xsl:output method="html" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>
8  <xsl:decimal-format name="GBP" decimal-separator="." grouping-separator=","/>
9 
10  <!-- Match the root of the XML render the three views -->
11  <xsl:template match="/">
12    <xsl:choose>
13      <xsl:when test="$view='html'">
14        <!-- Should return HTML as you see fit -->
15        <xsl:call-template name="html"/>
16      </xsl:when>
17      <xsl:when test="$view='images'">
18        <!--
19        Should return a list of images to embed in the following format:
20       
21        <images>
22          <img id="myimage" src="/local/path/to/image"/>
23        </images>
24       
25        Where "myimage" is references in your HTML image as <img src="cid:myimage" />
26        -->
27        <xsl:call-template name="images"/>
28      </xsl:when>
29      <xsl:otherwise>
30        <!-- The plain text portion of the email -->
31        <xsl:call-template name="plain"/>
32      </xsl:otherwise>
33    </xsl:choose>
34  </xsl:template>
35 
36  <!-- Simple (cop-out) implementation of a plain text message -->
37  <xsl:template name="plain">
38    <xsl:text>
39This message contains HTML content for a rich display.
40
41Please enable the HTML view or use an HTML compatible email client.
42    </xsl:text>
43  </xsl:template>
44 
45  <!-- This HTML version does not contain any images -->
46  <xsl:template name="images"/>
47 
48  <xsl:template name="html">
49    <!-- The root element needs to be created with xsl:element to prevent namespaces sneaking in. -->
50    <xsl:element name="html">
51      <head>
52        <title>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></title>
53        <style type="text/css">
54  body {
55    background: #f3f3f3;
56  }
57  fieldset.milestone {
58    margin-top: 3em;
59  }
60  fieldset.ticket {
61    margin-top: 2em;
62    background: #eee;
63  }
64  .description {
65    margin: 0.5em;
66    padding: 0.5em;
67    border: 1px solid #222;
68    background: #fff;
69  }
70  .status {
71    margin: 4px;
72    padding: 0;
73    font-variant: small-caps;
74  }
75  dl.milestone dt {
76    float: left;
77    margin-right: 0.5em;
78    font-style: italic;
79  }
80  dl.milestone dt:after {
81    content: ':';
82  }
83        </style>
84      </head>
85      <body>
86        <h1>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></h1>
87        <xsl:choose>
88          <xsl:when test="/clientsplugin/summary/ticket">
89            <xsl:for-each select="/clientsplugin/milestones/milestone">
90              <xsl:sort select="duetimestamp" order="asscending"/>
91              <xsl:variable name="ms" select="./name" />
92              <xsl:if test="/clientsplugin/summary/ticket[milestone=$ms]">
93                <fieldset class="milestone">
94                  <legend class="milestone">
95                    <xsl:text>Milestone: </xsl:text>
96                    <xsl:value-of select="$ms" />
97                  </legend>
98                  <xsl:if test="./description!=''">
99                    <div class="milestone description">
100                      <xsl:value-of select="./description" />
101                    </div>
102                  </xsl:if>
103                  <xsl:if test="./due">
104                    <dl class="milestone">
105                      <dt>Estimated delivery date</dt>
106                      <dd><xsl:value-of select="./due" /></dd>
107                      <xsl:if test="./completed">
108                        <dt>Completed on</dt>
109                        <dd><xsl:value-of select="./completed" /></dd>
110                      </xsl:if>
111                      <xsl:if test="./estimatedhours">
112                        <dt>Total estimated development time</dt>
113                        <dd><xsl:value-of select="./estimatedhours" /></dd>
114                      </xsl:if>
115                    </dl>
116                  </xsl:if>
117                  <xsl:for-each select="/clientsplugin/summary/ticket[milestone=$ms]">
118                    <xsl:call-template name="print-ticket" />
119                  </xsl:for-each>
120                </fieldset>
121              </xsl:if>
122            </xsl:for-each>
123            <xsl:variable name="ms" select="''" />
124            <xsl:if test="/clientsplugin/summary/ticket[milestone=$ms]">
125              <fieldset class="milestone">
126                <legend class="milestone">
127                  Tickets not allocated to specific milestones
128                </legend>
129                <div class="milestone description">
130                  <p>The following tickets are not allocated to any specific milestone.</p>
131                </div>
132                <xsl:for-each select="/clientsplugin/summary/ticket[milestone=$ms]">
133                  <xsl:call-template name="print-ticket" />
134                </xsl:for-each>
135              </fieldset>
136            </xsl:if>
137          </xsl:when>
138          <xsl:otherwise>
139            <p>You do not currently have any active tickets</p>
140          </xsl:otherwise>
141        </xsl:choose>
142      </body>
143    </xsl:element>
144  </xsl:template>
145
146  <xsl:template name="print-ticket">
147    <fieldset class="ticket">
148      <legend class="ticket">
149        Ticket #<xsl:value-of select="id"/>: <xsl:value-of select="summary"/>
150      </legend>
151      <xsl:if test="description!=''">
152        <div class="ticket description"><xsl:copy-of select="description"/></div>
153      </xsl:if>
154      <div class="status">Status: <xsl:value-of select="status"/></div>
155      <xsl:if test="estimatedhours">
156        <div class="estimate">Estimated development time: <xsl:value-of select="estimatedhours"/></div>
157      </xsl:if>
158      <!-- <div class="due"><xsl:value-of select="due"/></div> -->
159    </fieldset>
160  </xsl:template>
161</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.