Merge lp:~raulraat/eventum/customFieldWeeklyReport into lp:eventum

Proposed by Raul Raat
Status: Merged
Merged at revision: not available
Proposed branch: lp:~raulraat/eventum/customFieldWeeklyReport
Merge into: lp:eventum
Diff against target: 155 lines (+42/-8)
3 files modified
htdocs/reports/custom_fields_weekly.php (+3/-1)
lib/eventum/class.report.php (+26/-4)
templates/reports/custom_fields_weekly.tpl.html (+13/-3)
To merge this branch: bzr merge lp:~raulraat/eventum/customFieldWeeklyReport
Reviewer Review Type Date Requested Status
Eventum Development Team Pending
Review via email: mp+23390@code.launchpad.net

Description of the change

I did a small change to Custom Fields Weekly Report - added the option to show time spent per user.
If enabled it will add a new colum "User" to the report. If multiple users have spent time on the issue then the issue will be listed as many times in the report as many users spent time on it.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'htdocs/reports/custom_fields_weekly.php'
2--- htdocs/reports/custom_fields_weekly.php 2010-02-10 13:50:11 +0000
3+++ htdocs/reports/custom_fields_weekly.php 2010-04-14 13:34:19 +0000
4@@ -68,6 +68,7 @@
5 (@$_POST["end"]["Day"] != 0)) {
6 $end_date = join("-", $_POST["end"]);
7 }
8+$per_user = empty($_POST['time_per_user']) ? false : true;
9
10 $tpl->assign(array(
11 "custom_fields" => $custom_fields,
12@@ -78,6 +79,7 @@
13 "start_date" => @$start_date,
14 "end_date" => @$end_date,
15 "report_type" => @$_POST["report_type"],
16+ "per_user" => $per_user,
17 "weeks" => Date_Helper::getWeekOptions(3,0),
18 ));
19
20@@ -101,7 +103,7 @@
21 }
22
23 if (count(@$_POST['custom_field']) > 0) {
24- $data = Report::getCustomFieldWeeklyReport($_POST["custom_field"], $_POST["custom_options"], $dates[0], $dates[1]);
25+ $data = Report::getCustomFieldWeeklyReport($_POST["custom_field"], $_POST["custom_options"], $dates[0], $dates[1], $per_user);
26 $tpl->assign(array(
27 "data" => $data
28 ));
29
30=== modified file 'lib/eventum/class.report.php'
31--- lib/eventum/class.report.php 2010-02-10 13:50:11 +0000
32+++ lib/eventum/class.report.php 2010-04-14 13:34:19 +0000
33@@ -782,9 +782,10 @@
34 * @param array $cfo_ids An array of option ids.
35 * @param string $start_date
36 * @param string $end_date
37+ * @param boolean $per_user Show time spent per user
38 * @return array An array of data.
39 */
40- function getCustomFieldWeeklyReport($fld_id, $cfo_ids, $start_date, $end_date)
41+ function getCustomFieldWeeklyReport($fld_id, $cfo_ids, $start_date, $end_date, $per_user = false)
42 {
43 $prj_id = Auth::getCurrentProject();
44 $fld_id = Misc::escapeInteger($fld_id);
45@@ -799,9 +800,21 @@
46 iss_customer_id,
47 iss_private,
48 fld_id
49+ ";
50+
51+
52+ if ($per_user) {
53+ $sql .= ', usr_full_name ';
54+ }
55+ $sql .= "
56 FROM
57 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field,
58 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking,";
59+
60+ if ($per_user) {
61+ $sql .= APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user, ";
62+ }
63+
64 if (count($options) > 0) {
65 $sql .= "
66 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option,";
67@@ -819,6 +832,9 @@
68 $sql .=
69 " cfo_id = icf_value AND";
70 }
71+ if ($per_user) {
72+ $sql .= " usr_id = ttr_usr_id AND ";
73+ }
74 $sql .= "
75 icf_iss_id = iss_id AND
76 isu_iss_id = iss_id AND
77@@ -827,9 +843,15 @@
78 $sql .= " AND
79 cfo_id IN('" . join("','", Misc::escapeString(array_keys($options))) . "')";
80 }
81- $sql .= "
82- GROUP BY
83- iss_id";
84+ if ($per_user) {
85+ $sql .= "
86+ GROUP BY
87+ iss_id, ttr_usr_id";
88+ } else {
89+ $sql .= "
90+ GROUP BY
91+ iss_id";
92+ }
93
94 $res = DB_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
95 if (PEAR::isError($res)) {
96
97=== modified file 'templates/reports/custom_fields_weekly.tpl.html'
98--- templates/reports/custom_fields_weekly.tpl.html 2010-02-10 13:50:11 +0000
99+++ templates/reports/custom_fields_weekly.tpl.html 2010-04-14 13:34:19 +0000
100@@ -89,7 +89,7 @@
101 </td>
102 </tr>
103 <tr>
104- <td width="120" class="default">
105+ <td width="120" class="default" valign="top">
106 <b>{t}Options:{/t}</b>
107 </td>
108 <td width="200" class="default" NOWRAP>
109@@ -97,6 +97,10 @@
110 <a id="link" class="link" href="javascript:void(null)"
111 onClick="javascript:toggleCheckbox('custom_fields_report', 'time_in_min', 0)">{t}Time spent as minutes{/t}</a>&nbsp;
112 <br />
113+ <input type="checkbox" name="time_per_user" value="1" class="default" {if $smarty.post.time_per_user == 1}checked{/if}>
114+ <a id="link" class="link" href="javascript:void(null)"
115+ onClick="javascript:toggleCheckbox('custom_fields_report', 'time_per_user', 0)">{t}Time spent per user{/t}</a>&nbsp;
116+ <br />
117 </td>
118 </tr>
119
120@@ -170,7 +174,7 @@
121 </script>
122
123 {if $data|@count > 0}
124-{assign var="colspan" value=4}
125+{assign var="colspan" value=5}
126 <table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
127 <tr>
128 <td>
129@@ -185,6 +189,9 @@
130 <td bgcolor="{$cell_color}" class="default_white">{t}Summary{/t}</td>
131 <td bgcolor="{$cell_color}" class="default_white">{t}Time Spent{/t}</td>
132 <td bgcolor="{$cell_color}" class="default_white">{$field_info.fld_title}</td>
133+ {if $per_user}
134+ <td bgcolor="{$cell_color}" class="default_white">{t}User{/t}</td>
135+ {/if}
136 </tr>
137 {foreach from=$data item=row}
138 {cycle values=$cycle assign="row_color"}
139@@ -195,6 +202,9 @@
140 <td class="default" bgcolor="{$row_color}">{$row.iss_summary}</td>
141 <td class="default" bgcolor="{$row_color}">{if $smarty.post.time_in_min == 1}{$row.ttr_time_spent_sum}{else}{$row.ttr_time_spent_sum_formatted}{/if}</td>
142 <td class="default" bgcolor="{$row_color}">{$row.field_value}</td>
143+ {if $per_user}
144+ <td class="default" bgcolor="{$row_color}">{$row.usr_full_name}</td>
145+ {/if}
146 </tr>
147 {foreachelse}
148 <tr>
149@@ -208,4 +218,4 @@
150 {/if}
151
152
153-{include file="footer.tpl.html"}
154\ No newline at end of file
155+{include file="footer.tpl.html"}

Subscribers

People subscribed via source and target branches