source: timingandestimationplugin/branches/trac0.11-Permissions/timingandestimationplugin/reports.py

Last change on this file was 4382, checked in by Russ Tyndall, 15 years ago

fixes #3833 changed all the null as tickets to 0 as ticket (this still seems like a bug in trac, but one easily enough fixed

File size: 25.0 KB
RevLine 
[1119]1# IF YOU ADD A NEW SECTION OF REPORTS, You will need to make
2# sure that section is also added to the all_reports hashtable
3# near the bottom
4
5#Please try to keep this clean"
6
7billing_reports = [
8        {
[2390]9    "uuid":"b24f08c0-d41f-4c63-93a5-25e18a8513c2",
[1119]10    "title":"Ticket Work Summary",
[4382]11    "version":21,
[1119]12    "sql":"""
[2590]13SELECT __ticket__ as __group__, __style__, ticket,
[2785]14newvalue as Work_added, author, time as datetime, _ord
[1119]15FROM(
[2590]16  SELECT '' as __style__, author,
17  t.summary as __ticket__,
18  t.id as ticket,
19  CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
20    ELSE CAST( newvalue AS DECIMAL ) END AS newvalue,
21  ticket_change.time as time, 0 as _ord
[1606]22  FROM ticket_change
23  JOIN ticket t on t.id = ticket_change.ticket
[3784]24  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]25    and billable.name = 'billable'
26  WHERE field = 'hours' and
[3784]27    t.status IN (#STATUSES#)
[1606]28      AND billable.value in ($BILLABLE, $UNBILLABLE)
29      AND ticket_change.time >= $STARTDATE
30      AND ticket_change.time < $ENDDATE
[3784]31
32  UNION
33
[1606]34  SELECT 'background-color:#DFE;' as __style__,
35    'Total work done on the ticket in the selected time period ' as author,
[2590]36    t.summary as __ticket__,
37    t.id as ticket,
38  SUM( CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
39         ELSE CAST( newvalue AS DECIMAL ) END ) as newvalue,
[1606]40    NULL as time, 1 as _ord
41  FROM ticket_change
42  JOIN ticket t on t.id = ticket_change.ticket
[3784]43  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]44    and billable.name = 'billable'
45  WHERE field = 'hours' and
[3784]46    t.status IN (#STATUSES#)
[1606]47      AND billable.value in ($BILLABLE, $UNBILLABLE)
48      AND ticket_change.time >= $STARTDATE
49      AND ticket_change.time < $ENDDATE
[3398]50  GROUP By t.id, t.summary
[1496]51)  as tbl
[1606]52ORDER BY __ticket__, _ord ASC, time ASC
[1119]53
54    """
55    },#END Ticket work summary
56        {
[2390]57    "uuid":"af13564f-0e36-4a17-96c0-632dc68d8d14",
[1119]58    "title":"Milestone Work Summary",
[4382]59    "version":18,
[1119]60    "sql":"""
[1396]61
[3784]62SELECT
[1606]63  milestone as __group__, __style__,  ticket, summary, newvalue as Work_added,
[2785]64  time  as datetime, _ord
[1119]65FROM(
[1606]66  SELECT '' as __style__, t.id as ticket,
[2590]67    SUM( CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
68         ELSE CAST( newvalue AS DECIMAL ) END) as newvalue, t.summary as summary,
[1606]69    MAX(ticket_change.time) as time, t.milestone as milestone, 0 as _ord
70  FROM ticket_change
71  JOIN ticket t on t.id = ticket_change.ticket
[3784]72  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]73    and billable.name = 'billable'
74  WHERE field = 'hours' and
[3784]75    t.status IN (#STATUSES#)
[1606]76      AND billable.value in ($BILLABLE, $UNBILLABLE)
77      AND ticket_change.time >= $STARTDATE
78      AND ticket_change.time < $ENDDATE
79  GROUP BY t.milestone, t.id, t.summary
[3784]80
81  UNION
82
[4382]83  SELECT 'background-color:#DFE;' as __style__, 0 as ticket,
[2590]84    sum( CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
85         ELSE CAST( newvalue AS DECIMAL ) END) as newvalue, 'Total work done' as summary,
[1606]86    NULL as time, t.milestone as milestone, 1 as _ord
87  FROM ticket_change
88  JOIN ticket t on t.id = ticket_change.ticket
[3784]89  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]90    and billable.name = 'billable'
91  WHERE field = 'hours' and
[3784]92    t.status IN (#STATUSES#)
[1606]93      AND billable.value in ($BILLABLE, $UNBILLABLE)
94      AND ticket_change.time >= $STARTDATE
95      AND ticket_change.time < $ENDDATE
96  GROUP By t.milestone
[1496]97)  as tbl
[1571]98ORDER BY milestone,  _ord ASC, ticket, time
[1119]99
100
[1177]101
[1119]102    """
103    },#END Milestone work summary
[3784]104
[1119]105    {
[2390]106    "uuid":"7bd4b0ce-da6d-4b11-8be3-07e65b540d99",
[1119]107    "title":"Developer Work Summary",
[4382]108    "version":18,
[1119]109    "sql":"""
[2590]110SELECT author as __group__,__style__, ticket, summary,
[2785]111  newvalue as Work_added, time as datetime, _ord
[1119]112FROM(
[2590]113  SELECT '' as __style__, author, t.id  as ticket,
114    t.summary as summary,
115    CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
116         ELSE CAST( newvalue AS DECIMAL ) END as newvalue,
117    ticket_change.time as time, 0 as _ord
[1606]118  FROM ticket_change
119  JOIN ticket t on t.id = ticket_change.ticket
[3784]120  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]121    and billable.name = 'billable'
122  WHERE field = 'hours' and
[3784]123    t.status IN (#STATUSES#)
[1606]124      AND billable.value in ($BILLABLE, $UNBILLABLE)
125      AND ticket_change.time >= $STARTDATE
126      AND ticket_change.time < $ENDDATE
[3784]127
128  UNION
129
[4382]130  SELECT 'background-color:#DFE;' as __style__, author, 0 as ticket,
[2590]131    Null as summary,
132    SUM( CASE WHEN newvalue = '' OR newvalue IS NULL THEN 0
133         ELSE CAST( newvalue AS DECIMAL ) END) as newvalue,
134    NULL as time, 1 as _ord
[1606]135  FROM ticket_change
136  JOIN ticket t on t.id = ticket_change.ticket
[3784]137  LEFT JOIN ticket_custom as billable on billable.ticket = t.id
[1606]138    and billable.name = 'billable'
139  WHERE field = 'hours' and
[3784]140    t.status IN (#STATUSES#)
[1606]141      AND billable.value in ($BILLABLE, $UNBILLABLE)
142      AND ticket_change.time >= $STARTDATE
143      AND ticket_change.time < $ENDDATE
144  GROUP By author
[1496]145)  as tbl
[1571]146ORDER BY author,  _ord ASC, time
[3784]147
[1119]148    """
149    },#END Hours Per Developer
150]
[4382]151th_version =16
[1119]152ticket_hours_reports = [
153{
[2390]154    "uuid":"8d785cdb-dcf5-43c9-b2a6-216997b0011a",
[1119]155    "title": "Ticket Hours",
[2590]156    "version":th_version,
[1119]157    "sql": """
[1606]158SELECT __color__, __style__, ticket, summary, component ,version, severity,
159  milestone, status, owner, Estimated_work, Total_work, billable,_ord
[1119]160FROM (
[1606]161  SELECT p.value AS __color__,
162    '' as __style__,
163    t.id AS ticket, summary AS summary,             -- ## Break line here
164    component,version, severity, milestone, status, owner,
[2590]165    CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
166      ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
167    CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
[3784]168      ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
169    CASE WHEN billable.value = '1' THEN 'Y' else 'N' END as billable,
[1606]170    time AS created, changetime AS modified,         -- ## Dates are formatted
171    description AS _description_,                    -- ## Uses a full row
172    changetime AS _changetime,
173    reporter AS _reporter
[3784]174    ,0 as _ord
175
[1606]176    FROM ticket as t
177    JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]178
[1606]179  LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
180        AND EstimatedHours.Ticket = t.Id
181  LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
182        AND totalhours.Ticket = t.Id
183  LEFT JOIN ticket_custom as billable ON billable.name='billable'
184        AND billable.Ticket = t.Id
[3784]185
186    WHERE t.status IN (#STATUSES#)
[1606]187      AND billable.value in ($BILLABLE, $UNBILLABLE)
[3784]188
189
190  UNION
191
[1606]192  SELECT '1' AS __color__,
193         'background-color:#DFE;' as __style__,
[4382]194         0 as ticket, 'Total' AS summary,
[2590]195         NULL as component,NULL as version, NULL as severity, NULL as  milestone,
196         'Time Remaining: ' as status,
197         CAST(
198       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]199         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]200       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
201         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]202         AS CHAR(512))  as owner,
[2590]203         SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
204      ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
205         SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
206      ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1606]207         NULL as billable,
208         NULL as created, NULL as modified,         -- ## Dates are formatted
[3784]209
[1606]210         NULL AS _description_,
211         NULL AS _changetime,
212         NULL AS _reporter
213         ,1 as _ord
214    FROM ticket as t
215    JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]216
[1606]217  LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
218        AND EstimatedHours.Ticket = t.Id
[3784]219
[1606]220  LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
221        AND totalhours.Ticket = t.Id
[3784]222
[1606]223  LEFT JOIN ticket_custom as billable ON billable.name='billable'
224        AND billable.Ticket = t.Id
[3784]225
226    WHERE t.status IN (#STATUSES#)
[1606]227      AND billable.value in ($BILLABLE, $UNBILLABLE)
[1496]228)  as tbl
[1571]229ORDER BY  _ord ASC, ticket
[1119]230    """
231    },
[2590]232#END Ticket Hours
[1119]233{
[2390]234    "uuid":"71e7c36d-e512-4d0b-b499-087d4d20ff0b",
[1119]235    "title": "Ticket Hours with Description",
[2590]236    "version":th_version,
[1119]237    "sql": """
[1606]238SELECT __color__,  __style__,  ticket, summary, component ,version, severity,
239 milestone, status, owner, Estimated_work, Total_work, billable
[3521]240-- ## ,created,  modified,         -- ## Dates are formatted
[1119]241,_description_
[3521]242-- ## _changetime,
243-- ## _reporter
[1119]244,_ord
245
246FROM (
247SELECT p.value AS __color__,
248       '' as __style__,
[1606]249       t.id AS ticket, summary AS summary,             -- ## Break line here
[1119]250       component,version, severity, milestone, status, owner,
[2590]251       CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
252      ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
253       CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
254      ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
[3784]255       CASE WHEN billable.value = '1' THEN 'Y'
[1119]256            else 'N'
257       END as billable,
258       time AS created, changetime AS modified,         -- ## Dates are formatted
259       description AS _description_,                    -- ## Uses a full row
260       changetime AS _changetime,
261       reporter AS _reporter
[3784]262       ,0 as _ord
263
[1119]264  FROM ticket as t
265  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]266
[1119]267LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
268      AND EstimatedHours.Ticket = t.Id
269LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
270      AND totalhours.Ticket = t.Id
271LEFT JOIN ticket_custom as billable ON billable.name='billable'
272      AND billable.Ticket = t.Id
273
[3784]274  WHERE t.status IN (#STATUSES#)
[1119]275    AND billable.value in ($BILLABLE, $UNBILLABLE)
276
277
[3784]278UNION
279
[1606]280SELECT '1' AS __color__,
[1119]281       'background-color:#DFE;' as __style__,
[4382]282       0 as ticket, 'Total' AS summary,
[2590]283       NULL as component,NULL as version, NULL as severity, NULL as  milestone,
284       'Time Remaining: ' as status,
285       CAST(
286       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]287         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]288       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
289         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]290         AS CHAR(512))  as owner,
[2590]291       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
292         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
293       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
294         ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1496]295       NULL as billable,
296       NULL as created, NULL as modified,         -- ## Dates are formatted
[1119]297
[1496]298       NULL AS _description_,
299       NULL AS _changetime,
300       NULL AS _reporter
[1119]301       ,1 as _ord
302  FROM ticket as t
303  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]304
[1119]305LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
306      AND EstimatedHours.Ticket = t.Id
307
308LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
309      AND totalhours.Ticket = t.Id
310
311LEFT JOIN ticket_custom as billable ON billable.name='billable'
312      AND billable.Ticket = t.Id
[3784]313
314  WHERE t.status IN (#STATUSES#)
[1119]315    AND billable.value in ($BILLABLE, $UNBILLABLE)
[1496]316)  as tbl
[1571]317ORDER BY _ord ASC, ticket
[1119]318    """
319    },
[3784]320#END Ticket Hours
[1119]321
322    {
[2390]323    "uuid":"5f33b102-e6a6-47e8-976c-ac7a6794a909",
[1119]324    "title":"Ticket Hours Grouped By Component",
[2590]325    "version":th_version,
[1119]326    "sql": """
[1606]327SELECT __color__, __group__, __style__, ticket, summary, __component__ ,version,
328  severity, milestone, status, owner, Estimated_work, total_work, billable,
329  _ord
[1119]330
331FROM (
332SELECT p.value AS __color__,
333       t.component AS __group__,
334       '' as __style__,
[1606]335       t.id AS ticket, summary AS summary,             -- ## Break line here
336       component as __component__,version, severity, milestone, status, owner,
[2590]337       CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
338         ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
339       CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
340         ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
[3784]341       CASE WHEN billable.value = '1' THEN 'Y'
[1119]342            else 'N'
343       END as billable,
344       time AS created, changetime AS modified,         -- ## Dates are formatted
345       description AS _description_,                    -- ## Uses a full row
346       changetime AS _changetime,
347       reporter AS _reporter
[3784]348       ,0 as _ord
349
[1119]350  FROM ticket as t
351  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]352
[1119]353LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
354      AND EstimatedHours.Ticket = t.Id
355LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
356      AND totalhours.Ticket = t.Id
357LEFT JOIN ticket_custom as billable ON billable.name='billable'
358      AND billable.Ticket = t.Id
359
[3784]360  WHERE t.status IN (#STATUSES#)
[1119]361    AND billable.value in ($BILLABLE, $UNBILLABLE)
362
363
[3784]364UNION
365
[1606]366SELECT '1' AS __color__,
[1119]367       t.component AS __group__,
368       'background-color:#DFE;' as __style__,
[4382]369       0 as ticket, 'Total work' AS summary,
[1606]370       t.component as __component__, NULL as version, NULL as severity,
[2590]371       NULL as  milestone, 'Time Remaining: ' as status,
372       CAST(
373       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]374         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]375       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
376         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]377         AS CHAR(512))  as owner,
[2590]378       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
379         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
380       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
381         ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1496]382       NULL as billable,
383       NULL as created,
384       NULL as modified,         -- ## Dates are formatted
[1119]385
[1496]386       NULL AS _description_,
387       NULL AS _changetime,
388       NULL AS _reporter
[1119]389       ,1 as _ord
390  FROM ticket as t
391  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]392
[1119]393LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
394      AND EstimatedHours.Ticket = t.Id
395
396LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
397      AND totalhours.Ticket = t.Id
398
399LEFT JOIN ticket_custom as billable ON billable.name='billable'
400      AND billable.Ticket = t.Id
[3784]401
402  WHERE t.status IN (#STATUSES#)
[1119]403    AND billable.value in ($BILLABLE, $UNBILLABLE)
404  GROUP BY t.component
[1496]405)  as tbl
[1606]406ORDER BY __component__, _ord ASC,ticket
[1119]407    """
408    },
409# END Ticket Hours  GROUPED BY COMPONENT
[3784]410
[1119]411    {
[2390]412    "uuid":"7816f034-a174-4a94-aed6-358fb648b2fc",
[1119]413    "title":"Ticket Hours Grouped By Component with Description",
[2590]414    "version":th_version,
[1119]415    "sql": """
[1606]416SELECT __color__, __group__, __style__,  ticket, summary, __component__ ,
417  version, severity, milestone, status, owner, Estimated_work, Total_work,
418  billable, _description_, _ord
[1119]419
420FROM (
421SELECT p.value AS __color__,
422       t.component AS __group__,
423       '' as __style__,
[1606]424       t.id AS ticket, summary AS summary,             -- ## Break line here
425       component as __component__, version, severity, milestone, status, owner,
[2590]426       CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
427         ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
428       CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
429         ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
[3784]430       CASE WHEN billable.value = '1' THEN 'Y' else 'N' END as billable,
[1119]431       time AS created, changetime AS modified,         -- ## Dates are formatted
432       description AS _description_,                    -- ## Uses a full row
433       changetime AS _changetime,
434       reporter AS _reporter
[3784]435       ,0 as _ord
436
[1119]437  FROM ticket as t
438  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]439
[1119]440LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
441      AND EstimatedHours.Ticket = t.Id
442LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
443      AND totalhours.Ticket = t.Id
444LEFT JOIN ticket_custom as billable ON billable.name='billable'
445      AND billable.Ticket = t.Id
446
[3784]447  WHERE t.status IN (#STATUSES#)
[1119]448    AND billable.value in ($BILLABLE, $UNBILLABLE)
449
450
[3784]451UNION
452
[1606]453SELECT '1' AS __color__,
[1119]454       t.component AS __group__,
455       'background-color:#DFE;' as __style__,
[4382]456       0 as ticket, 'Total work' AS summary,
[1606]457       t.component as __component__, NULL as version, NULL as severity,
[2590]458       NULL as  milestone, 'Time Remaining: ' as status,
459       CAST(
460       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]461         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]462       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
463         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]464         AS CHAR(512))  as owner,
[2590]465       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
466         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
467       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
468         ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1496]469       NULL as billable,
470       NULL as created, NULL as modified,         -- ## Dates are formatted
[1119]471
[1496]472       NULL AS _description_,
473       NULL AS _changetime,
474       NULL AS _reporter
[1119]475       ,1 as _ord
476  FROM ticket as t
477  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]478
[1119]479LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
480      AND EstimatedHours.Ticket = t.Id
481
482LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
483      AND totalhours.Ticket = t.Id
484
485LEFT JOIN ticket_custom as billable ON billable.name='billable'
486      AND billable.Ticket = t.Id
[3784]487
488  WHERE t.status IN (#STATUSES#)
[1119]489    AND billable.value in ($BILLABLE, $UNBILLABLE)
490  GROUP BY t.component
[1496]491)  as tbl
[1606]492ORDER BY __component__, _ord ASC, ticket
[1119]493    """
494    },
495# END Ticket Hours Grouped BY Component with Description
496    {
[2390]497    "uuid":"03815803-7688-4f3a-8e65-8d254cc1d1fb",
[1119]498    "title":"Ticket Hours Grouped By Milestone",
[2590]499    "version":th_version,
[1119]500    "sql": """
[1606]501SELECT __color__, __group__, __style__,  ticket, summary, component ,version,
502  severity, __milestone__, status, owner, Estimated_work, Total_work, billable,
503  _ord
[1119]504
505FROM (
506SELECT p.value AS __color__,
507       t.milestone AS __group__,
508       '' as __style__,
[1606]509       t.id AS ticket, summary AS summary,             -- ## Break line here
510       component,version, severity, milestone as __milestone__, status, owner,
[2590]511       CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
512         ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
513       CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
514         ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
[3784]515       CASE WHEN billable.value = '1' THEN 'Y'
[1119]516            else 'N'
517       END as billable,
518       time AS created, changetime AS modified,         -- ## Dates are formatted
519       description AS _description_,                    -- ## Uses a full row
520       changetime AS _changetime,
[3784]521       reporter AS _reporter, 0 as _ord
522
[1119]523  FROM ticket as t
524  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]525
[1119]526LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
527      AND EstimatedHours.Ticket = t.Id
528LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
529      AND totalhours.Ticket = t.Id
530LEFT JOIN ticket_custom as billable ON billable.name='billable'
531      AND billable.Ticket = t.Id
532
[3784]533  WHERE t.status IN (#STATUSES#)
[1119]534    AND billable.value in ($BILLABLE, $UNBILLABLE)
535
536
[3784]537UNION
538
[1606]539SELECT '1' AS __color__,
[1119]540       t.milestone AS __group__,
541       'background-color:#DFE;' as __style__,
[4382]542       0 as ticket, 'Total work' AS summary,
[1606]543       NULL as component,NULL as version, NULL as severity,
[2590]544       t.milestone as  __milestone__, 'Time Remaining: ' as status,
545       CAST(
546       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]547         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]548       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
549         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]550         AS CHAR(512)) as owner,
[2590]551       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
552         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
553       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
554         ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1496]555       NULL as billable,
556       NULL as created, NULL as modified,         -- ## Dates are formatted
[1119]557
[1496]558       NULL AS _description_,
559       NULL AS _changetime,
560       NULL AS _reporter
[1119]561       ,1 as _ord
562  FROM ticket as t
563  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]564
[1119]565LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
566      AND EstimatedHours.Ticket = t.Id
567
568LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
569      AND totalhours.Ticket = t.Id
570
571LEFT JOIN ticket_custom as billable ON billable.name='billable'
572      AND billable.Ticket = t.Id
[3784]573
574  WHERE t.status IN (#STATUSES#)
[1119]575    AND billable.value in ($BILLABLE, $UNBILLABLE)
576  GROUP BY t.milestone
[1496]577)  as tbl
[1606]578ORDER BY __milestone__, _ord ASC, ticket
[1119]579    """
580    },
581#END Ticket Hours Grouped By MileStone
582        {
[2390]583    "uuid":"040c9025-7641-4d18-96ad-2b26b4095566",
[1119]584    "title":"Ticket Hours Grouped By MileStone with Description",
[2590]585    "version":th_version,
[1119]586    "sql": """
[1606]587SELECT __color__, __group__, __style__,  ticket, summary, component ,version, severity,
588 __milestone__, status, owner, Estimated_work, Total_work, billable,
589 _description_, _ord
[1119]590
591FROM (
592SELECT p.value AS __color__,
593       t.milestone AS __group__,
594       '' as __style__,
[1606]595       t.id AS ticket, summary AS summary,             -- ## Break line here
596       component,version, severity, milestone as __milestone__, status, owner,
[2590]597       CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
598         ELSE CAST( EstimatedHours.value AS DECIMAL ) END as Estimated_work,
599       CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
600         ELSE CAST( totalhours.value AS DECIMAL ) END as Total_work,
[3784]601       CASE WHEN billable.value = '1' THEN 'Y'
[1119]602            else 'N'
603       END as billable,
604       time AS created, changetime AS modified,         -- ## Dates are formatted
605       description AS _description_,                    -- ## Uses a full row
606       changetime AS _changetime,
607       reporter AS _reporter
[3784]608       ,0 as _ord
609
[1119]610  FROM ticket as t
611  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]612
[1119]613LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
614      AND EstimatedHours.Ticket = t.Id
615LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
616      AND totalhours.Ticket = t.Id
617LEFT JOIN ticket_custom as billable ON billable.name='billable'
618      AND billable.Ticket = t.Id
619
[3784]620  WHERE t.status IN (#STATUSES#)
[1119]621    AND billable.value in ($BILLABLE, $UNBILLABLE)
622
623
[3784]624UNION
625
[1606]626SELECT '1' AS __color__,
[1119]627       t.milestone AS __group__,
628       'background-color:#DFE;' as __style__,
[4382]629       0 as ticket, 'Total work' AS summary,
[1606]630       NULL as component,NULL as version, NULL as severity,
631       t.milestone as __milestone__,
[2590]632       'Time Remaining: ' as status,
633       CAST(
634       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
[3784]635         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) -
[2590]636       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
637         ELSE CAST( totalhours.value AS DECIMAL ) END)
[3521]638         AS CHAR(512)) as owner,
[2590]639       SUM(CASE WHEN EstimatedHours.value = '' OR EstimatedHours.value IS NULL THEN 0
640         ELSE CAST( EstimatedHours.value AS DECIMAL ) END) as Estimated_work,
641       SUM(CASE WHEN totalhours.value = '' OR totalhours.value IS NULL THEN 0
642         ELSE CAST( totalhours.value AS DECIMAL ) END) as Total_work,
[1496]643       NULL as billable,
644       NULL as created, NULL as modified,         -- ## Dates are formatted
645       NULL AS _description_,
646       NULL AS _changetime,
[1606]647       NULL AS _reporter, 1 as _ord
[1119]648  FROM ticket as t
649  JOIN enum as p ON p.name=t.priority AND p.type='priority'
[3784]650
[1119]651LEFT JOIN ticket_custom as EstimatedHours ON EstimatedHours.name='estimatedhours'
652      AND EstimatedHours.Ticket = t.Id
653
654LEFT JOIN ticket_custom as totalhours ON totalhours.name='totalhours'
655      AND totalhours.Ticket = t.Id
656
657LEFT JOIN ticket_custom as billable ON billable.name='billable'
658      AND billable.Ticket = t.Id
[3784]659
660  WHERE t.status IN (#STATUSES#)
[1119]661    AND billable.value in ($BILLABLE, $UNBILLABLE)
662  GROUP BY t.milestone
[1496]663)  as tbl
[1606]664ORDER BY __milestone__, _ord ASC, ticket
[1119]665    """
666    }
667    #END Ticket Hours Grouped By MileStone with Description
668]
[3784]669
[1119]670all_reports = [
671    {"title":"Billing Reports",
672     "reports":billing_reports},
673    {"title":"Ticket/Hour Reports",
674     "reports": ticket_hours_reports}
675    ]
Note: See TracBrowser for help on using the repository browser.