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: 425 lines (+391/-2)
4 files modified
htdocs/reports/custom_fields_weekly.php (+110/-0)
lib/eventum/class.report.php (+69/-2)
templates/reports/custom_fields_weekly.tpl.html (+211/-0)
templates/reports/tree.tpl.html (+1/-0)
To merge this branch: bzr merge lp:~raulraat/eventum/customFieldWeeklyReport
Reviewer Review Type Date Requested Status
Eventum Development Team Pending
Review via email: mp+19009@code.launchpad.net

Commit message

- add Custom Fields Weekly Report

To post a comment you must log in.
Revision history for this message
Raul Raat (raulraat) wrote :

add Custom Fields Weekly Report

Revision history for this message
Bryan Alsdorf (balsdorf) wrote :

Raul,

In addition to the custom field weekly report when I go to merge it is also bringing in some localization changes? Is that intended?

added:
  htdocs/reports/custom_fields_weekly.php
  templates/reports/custom_fields_weekly.tpl.html
modified:
  docs/ChangeLog
  lib/eventum/class.issue.php
  lib/eventum/class.report.php
  localization/de.po
  localization/es.po
  localization/eventum.pot
  localization/lv.po
  localization/ru.po
  localization/zh_CN.po
  templates/list.tpl.html
  templates/reports/tree.tpl.html

Revision history for this message
Elan Ruusamäe (glen666) wrote :

On Tuesday 16 February 2010 22:10:55 Bryan Alsdorf wrote:
> Raul,
>
> In addition to the custom field weekly report when I go to merge it is also
> bringing in some localization changes? Is that intended?

i'm 100% sure it is not

after merge do bzr revert *.po *.pot and then bzr commit and bzr push :)

i'd rather regenerate the pot file on main trunk myself.

> added:
> htdocs/reports/custom_fields_weekly.php
> templates/reports/custom_fields_weekly.tpl.html
> modified:
> docs/ChangeLog
> lib/eventum/class.issue.php
> lib/eventum/class.report.php
> localization/de.po
> localization/es.po
> localization/eventum.pot
> localization/lv.po
> localization/ru.po
> localization/zh_CN.po
> templates/list.tpl.html
> templates/reports/tree.tpl.html

--
glen

Revision history for this message
Raul Raat (raulraat) wrote :

> On Tuesday 16 February 2010 22:10:55 Bryan Alsdorf wrote:
> > Raul,
> >
> > In addition to the custom field weekly report when I go to merge it is also
> > bringing in some localization changes? Is that intended?
>
> i'm 100% sure it is not
>
> after merge do bzr revert *.po *.pot and then bzr commit and bzr push :)
>
> i'd rather regenerate the pot file on main trunk myself.
>

Yes it was unintended.

I cloned the trunk from revision 4042 - that's the version of the trunk right now.

But i see that the mentioned files have been edited between revisions 4040 - 4042, maybe your local trunk needs bzr pull first?

4043. By Elan Ruusamäe

- update to use make globs to find new locales
- use flat dir by default

4044. By Elan Ruusamäe

- use flat directory in bzr

4045. By Elan Ruusamäe

- refresh

4046. By Elan Ruusamäe

- package and build clean localization fileset

4047. By Elan Ruusamäe

- comma for readability

4048. By Elan Ruusamäe

- merge localization from launchpad

4049. By Elan Ruusamäe

- keep makefile and .po* in tarball to be able to regenerate them

4050. By Elan Ruusamäe

- handle parallel make for *.mo generation

4051. By Elan Ruusamäe

- add new lang

4052. By Bryan Alsdorf

Merged changes.
Added Custom Fields Weekly Report (Raul Raat)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'htdocs/reports/custom_fields_weekly.php'
2--- htdocs/reports/custom_fields_weekly.php 1970-01-01 00:00:00 +0000
3+++ htdocs/reports/custom_fields_weekly.php 2010-02-10 14:10:30 +0000
4@@ -0,0 +1,110 @@
5+<?php
6+/* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
7+// +----------------------------------------------------------------------+
8+// | Eventum - Issue Tracking System |
9+// +----------------------------------------------------------------------+
10+// | Copyright (c) 2010 Sun Microsystem Inc. |
11+// | |
12+// | This program is free software; you can redistribute it and/or modify |
13+// | it under the terms of the GNU General Public License as published by |
14+// | the Free Software Foundation; either version 2 of the License, or |
15+// | (at your option) any later version. |
16+// | |
17+// | This program is distributed in the hope that it will be useful, |
18+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
19+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20+// | GNU General Public License for more details. |
21+// | |
22+// | You should have received a copy of the GNU General Public License |
23+// | along with this program; if not, write to: |
24+// | |
25+// | Free Software Foundation, Inc. |
26+// | 59 Temple Place - Suite 330 |
27+// | Boston, MA 02111-1307, USA. |
28+// +----------------------------------------------------------------------+
29+// | Authors: Raul Raat <raul.raat@delfi.ee> |
30+// +----------------------------------------------------------------------+
31+//
32+// @(#) $Id: $
33+
34+require_once dirname(__FILE__) . '/../../init.php';
35+
36+$tpl = new Template_Helper();
37+$tpl->setTemplate("reports/custom_fields_weekly.tpl.html");
38+
39+Auth::checkAuthentication(APP_COOKIE);
40+
41+if (Auth::getCurrentRole() <= User::getRoleID("Customer")) {
42+ echo "Invalid role";
43+ exit;
44+}
45+
46+$prj_id = Auth::getCurrentProject();
47+
48+// get list of fields and convert info useful arrays
49+$fields = Custom_Field::getListByProject($prj_id, '');
50+$custom_fields = array();
51+$options = array();
52+if (is_array($fields) && count($fields) > 0) {
53+ foreach ($fields as $field) {
54+ $custom_fields[$field["fld_id"]] = $field["fld_title"];
55+ $options[$field["fld_id"]] = Custom_Field::getOptions($field["fld_id"]);
56+ }
57+} else {
58+ echo ev_gettext("No custom fields for this project");
59+ exit;
60+}
61+
62+if (count(@$_POST["start"]) > 0 &&
63+ (@$_POST["start"]["Year"] != 0) &&
64+ (@$_POST["start"]["Month"] != 0) &&
65+ (@$_POST["start"]["Day"] != 0)) {
66+ $start_date = join("-", $_POST["start"]);
67+}
68+
69+if (count(@$_POST["end"]) > 0 &&
70+ (@$_POST["end"]["Year"] != 0) &&
71+ (@$_POST["end"]["Month"] != 0) &&
72+ (@$_POST["end"]["Day"] != 0)) {
73+ $end_date = join("-", $_POST["end"]);
74+}
75+
76+$tpl->assign(array(
77+ "custom_fields" => $custom_fields,
78+ "custom_field" => @$_POST["custom_field"],
79+ "options" => $options,
80+ "custom_options" => @$_POST["custom_options"],
81+ "selected_options" => @$_REQUEST['custom_options'],
82+ "start_date" => @$start_date,
83+ "end_date" => @$end_date,
84+ "report_type" => @$_POST["report_type"],
85+ "weeks" => Date_Helper::getWeekOptions(3,0),
86+));
87+
88+if (empty($_POST["week"])) {
89+ $tpl->assign("week", Date_Helper::getCurrentWeek());
90+} else {
91+ $tpl->assign("week", $_POST["week"]);
92+}
93+
94+if (isset($_POST["custom_field"])) {
95+ $tpl->assign(array(
96+ "field_info" => Custom_Field::getDetails($_POST['custom_field'])
97+ ));
98+}
99+
100+// split date up
101+if (@$_POST["report_type"] == "weekly") {
102+ $dates = explode("_", $_POST["week"]);
103+} else {
104+ $dates = array($start_date, $end_date);
105+}
106+
107+if (count(@$_POST['custom_field']) > 0) {
108+ $data = Report::getCustomFieldWeeklyReport($_POST["custom_field"], $_POST["custom_options"], $dates[0], $dates[1]);
109+ $tpl->assign(array(
110+ "data" => $data
111+ ));
112+}
113+
114+$tpl->displayTemplate();
115
116=== modified file 'lib/eventum/class.report.php'
117--- lib/eventum/class.report.php 2010-01-21 15:34:01 +0000
118+++ lib/eventum/class.report.php 2010-02-10 14:10:30 +0000
119@@ -774,8 +774,75 @@
120
121 return $data;
122 }
123-
124-
125+ /**
126+ * Returns data for the custom fields weekly report, based on the field and options passed in.
127+ *
128+ * @access public
129+ * @param integer $fld_id The id of the custom field.
130+ * @param array $cfo_ids An array of option ids.
131+ * @param string $start_date
132+ * @param string $end_date
133+ * @return array An array of data.
134+ */
135+ function getCustomFieldWeeklyReport($fld_id, $cfo_ids, $start_date, $end_date)
136+ {
137+ $prj_id = Auth::getCurrentProject();
138+ $fld_id = Misc::escapeInteger($fld_id);
139+ $cfo_ids = Misc::escapeInteger($cfo_ids);
140+ // get field values
141+ $options = Custom_Field::getOptions($fld_id, $cfo_ids);
142+
143+ $sql = "SELECT
144+ iss_id,
145+ SUM(ttr_time_spent) ttr_time_spent_sum,
146+ iss_summary,
147+ iss_customer_id,
148+ iss_private,
149+ fld_id
150+ FROM
151+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field,
152+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking,";
153+ if (count($options) > 0) {
154+ $sql .= "
155+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option,";
156+ }
157+ $sql .= "
158+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field,
159+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
160+ " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
161+ WHERE
162+ ttr_created_date BETWEEN '" . Misc::escapeString($start_date) . "' AND '" . Misc::escapeString($end_date) . "' AND
163+ fld_id = icf_fld_id AND
164+ ttr_iss_id = iss_id AND
165+ ";
166+ if (count($options) > 0) {
167+ $sql .=
168+ " cfo_id = icf_value AND";
169+ }
170+ $sql .= "
171+ icf_iss_id = iss_id AND
172+ isu_iss_id = iss_id AND
173+ icf_fld_id = $fld_id";
174+ if (count($options) > 0) {
175+ $sql .= " AND
176+ cfo_id IN('" . join("','", Misc::escapeString(array_keys($options))) . "')";
177+ }
178+ $sql .= "
179+ GROUP BY
180+ iss_id";
181+
182+ $res = DB_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
183+ if (PEAR::isError($res)) {
184+ Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
185+ return array();
186+ } else {
187+ for ($i = 0; $i < count($res); $i++) {
188+ $res[$i]['field_value'] = Custom_Field::getDisplayValue($res[$i]['iss_id'], $res[$i]['fld_id']);
189+ $res[$i]['ttr_time_spent_sum_formatted'] = Misc::getFormattedTime($res[$i]['ttr_time_spent_sum'], false);
190+ }
191+ return $res;
192+ }
193+ }
194 /**
195 * Returns workload information for the specified date range and interval.
196 *
197
198=== added file 'templates/reports/custom_fields_weekly.tpl.html'
199--- templates/reports/custom_fields_weekly.tpl.html 1970-01-01 00:00:00 +0000
200+++ templates/reports/custom_fields_weekly.tpl.html 2010-02-10 14:10:30 +0000
201@@ -0,0 +1,211 @@
202+{include file="header.tpl.html"}
203+<br />
204+{literal}
205+<script type="text/javascript">
206+<!--
207+function validateForm(f)
208+{
209+ if (getSelectedOption(f, 'custom_field') == -1) {
210+ selectField(f, 'custom_field');
211+ alert('{/literal}{t escape=js}Please select the custom field that you would like to generate a report against.{/t}{literal}');
212+ return false;
213+ }
214+ return true;
215+}
216+//-->
217+</script>
218+{/literal}
219+
220+<form action="{$smarty.server.PHP_SELF}" name="custom_fields_report" method="post" onSubmit="javascript:return validateForm(this);">
221+<input type="hidden" name="cat" value="generate">
222+<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center" width="400">
223+ <tr>
224+ <td>
225+ <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
226+ <tr>
227+ <td bgcolor="{$cell_color}" colspan="3" class="default_white">
228+ <b>{t}Custom Fields Weekly Report{/t}</b>
229+ </td>
230+ </tr>
231+ <tr>
232+ <td width="120" class="default">
233+ <b>{t}Report Type:{/t}</b>
234+ </td>
235+ <td width="200" class="default" NOWRAP>
236+ <input type="radio" name="report_type" value="weekly" class="default" {if $report_type!='range'}checked{/if} onClick="changeType('weekly');">
237+ <a id="link" class="link" href="javascript:void(null)"
238+ onClick="javascript:checkRadio('weekly_report', 'report_type', 0);changeType('weekly');">{t}Weekly{/t}</a>&nbsp;
239+ <input type="radio" name="report_type" value="range" {if $report_type=='range'}CHECKED{/if} onClick="changeType('range');">
240+ <a id="link" class="link" href="javascript:void(null)"
241+ onClick="javascript:checkRadio('weekly_report', 'report_type', 1);changeType('range');">{t}Date Range{/t}</a>&nbsp;
242+ </td>
243+ </tr>
244+ <tr id="week_row">
245+ <td width="120" class="default">
246+ <b>{t}Week{/t}:</b>
247+ </td>
248+ <td width="200">
249+ <select class="default" name="week">
250+ {html_options options=$weeks selected=$week}
251+ </select>
252+ </td>
253+ </tr>
254+ <tr id="start_row">
255+ <td width="120" class="default">
256+ <b>{t}Start{/t}:</b>
257+ </td>
258+ <td width="200">
259+ {html_select_date time=$start_date prefix="" field_array="start" start_year="-2" end_year="+1" field_order="YMD" month_format="%b" day_value_format="%02d" all_extra="class='default'"}
260+ </td>
261+ </tr>
262+ <tr id="end_row">
263+ <td width="120" class="default">
264+ <b>{t}End:{/t}</b>
265+ </td>
266+ <td width="200">
267+ {html_select_date time=$end_date prefix="" field_array="end" start_year="-2" end_year="+1" field_order="YMD" month_format="%b" day_value_format="%02d" all_extra="class='default'"}
268+ </td>
269+ </tr>
270+ <tr>
271+ <td width="30%" class="default" align="center">
272+ <b>{t}Custom Field{/t}</b>
273+ </td>
274+ <td width="30%" class="default" align="center">
275+ <b>{t}Options{/t}</b>
276+ </td>
277+ </tr>
278+ <tr>
279+ <td align="center" valign="top" height="10">
280+ <select name="custom_field" class="default" onChange="setOptions(this.options[this.selectedIndex].value, true)">
281+ <option value="-1"></option>
282+ {html_options options=$custom_fields selected=$custom_field}
283+ </select>
284+ {include file="error_icon.tpl.html" field="custom_field"}
285+ </td>
286+ <td align="center" valign="top">
287+ <select name="custom_options[]" size="8" multiple class="default">
288+ </select>
289+
290+ </td>
291+ </tr>
292+ <tr>
293+ <td width="120" class="default">
294+ <b>{t}Options:{/t}</b>
295+ </td>
296+ <td width="200" class="default" NOWRAP>
297+ <input type="checkbox" name="time_in_min" value="1" class="default" {if $smarty.post.time_in_min == 1}checked{/if}>
298+ <a id="link" class="link" href="javascript:void(null)"
299+ onClick="javascript:toggleCheckbox('custom_fields_report', 'time_in_min', 0)">{t}Time spent as minutes{/t}</a>&nbsp;
300+ <br />
301+ </td>
302+ </tr>
303+
304+ <tr>
305+ <td colspan="2" align="center">
306+ <input type="submit" name="cat" value="{t}Generate{/t}" class="shortcut">
307+ </td>
308+ </tr>
309+ </table>
310+ </td>
311+ </tr>
312+</table>
313+</form>
314+<script type="text/javascript">
315+var options = new Array();
316+var option_to_fld_id = new Array();
317+{foreach from=$options key=fld_id item=option_list name=option_list}
318+ option_to_fld_id[{$smarty.foreach.option_list.iteration-1}] = {$fld_id};
319+ options[{$smarty.foreach.option_list.iteration-1}] = new Array();
320+ {foreach from=$option_list key=cfo_id item=cfo_value name=option}
321+ options[{$smarty.foreach.option_list.iteration-1}][{$smarty.foreach.option.iteration-1}] = new Option('{$cfo_value}', '{$cfo_id}');
322+ {/foreach}
323+{/foreach}
324+
325+{literal}
326+var options_field = document.forms['custom_fields_report'].elements['custom_options[]'];
327+function setOptions(fld_id, auto_select)
328+{
329+ fld_id_index = '';
330+ for (i = 0; i < option_to_fld_id.length; i++) {
331+ if (option_to_fld_id[i] == fld_id) {
332+ fld_id_index = i;
333+ }
334+ }
335+
336+ options_field.length = 0;
337+ if (options[fld_id_index]) {
338+ options_field.length = options[fld_id_index].length;
339+ for (i = 0; i < options[fld_id_index].length; i++) {
340+ options_field.options[i] = options[fld_id_index][i];
341+ options_field.options[i].selected = auto_select;
342+ }
343+ }
344+}
345+function changeType(type) {
346+ if (type == 'range') {
347+ document.getElementById('week_row').style.display = 'none';
348+ document.getElementById('start_row').style.display = getDisplayStyle();
349+ document.getElementById('end_row').style.display = getDisplayStyle();
350+ } else {
351+ document.getElementById('week_row').style.display = getDisplayStyle();
352+ document.getElementById('start_row').style.display = 'none';
353+ document.getElementById('end_row').style.display = 'none';
354+ }
355+}
356+{/literal}
357+changeType('{$report_type}');
358+
359+setOptions('{$custom_field}', false);
360+{if $custom_options|@count > 0}
361+ {foreach from=$custom_options key=option_index item=option}
362+ {literal}
363+ for (i = 0; i < options_field.options.length; i++) {
364+ if (options_field.options[i].value == '{/literal}{$option}{literal}') {
365+ options_field.options[i].selected = true;
366+ }
367+ }
368+ {/literal}
369+ {/foreach}
370+{/if}
371+</script>
372+
373+{if $data|@count > 0}
374+{assign var="colspan" value=4}
375+<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
376+ <tr>
377+ <td>
378+ <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
379+ <tr>
380+ <td bgcolor="{$cell_color}" colspan="{$colspan}" class="default_white">
381+ <b>{t}Issues/Customers matching criteria{/t}</b>
382+ </td>
383+ </tr>
384+ <tr>
385+ <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
386+ <td bgcolor="{$cell_color}" class="default_white">{t}Summary{/t}</td>
387+ <td bgcolor="{$cell_color}" class="default_white">{t}Time Spent{/t}</td>
388+ <td bgcolor="{$cell_color}" class="default_white">{$field_info.fld_title}</td>
389+ </tr>
390+ {foreach from=$data item=row}
391+ {cycle values=$cycle assign="row_color"}
392+ <tr>
393+ <td class="default" bgcolor="{$row_color}" align="right">
394+ <a href="{$app_base_url}view.php?id={$row.iss_id}" class="link">{$row.iss_id}</a>
395+ </td>
396+ <td class="default" bgcolor="{$row_color}">{$row.iss_summary}</td>
397+ <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>
398+ <td class="default" bgcolor="{$row_color}">{$row.field_value}</td>
399+ </tr>
400+ {foreachelse}
401+ <tr>
402+ <td colspan="8" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No data found{/t}</i></td>
403+ </tr>
404+ {/foreach}
405+ </table>
406+ </td>
407+ </tr>
408+</table>
409+{/if}
410+
411+
412+{include file="footer.tpl.html"}
413\ No newline at end of file
414
415=== modified file 'templates/reports/tree.tpl.html'
416--- templates/reports/tree.tpl.html 2008-05-16 07:09:52 +0000
417+++ templates/reports/tree.tpl.html 2010-02-10 14:10:30 +0000
418@@ -35,6 +35,7 @@
419 tree.add(6, 0, '{t escape=js}Workload by time period{/t}', 'workload_time_period.php', '', 'basefrm');
420 tree.add(7, 0, '{t escape=js}Email by time period{/t}', 'workload_time_period.php?type=email', '', 'basefrm');
421 tree.add(8, 0, '{t escape=js}Custom Fields{/t}', 'custom_fields.php', '', 'basefrm');
422+tree.add(8, 0, '{t escape=js}Custom Fields Weekly Report{/t}', 'custom_fields_weekly.php', '', 'basefrm');
423 tree.add(9, 0, '{t escape=js}Customer Profile Stats{/t}', 'customer_stats.php', '', 'basefrm');
424 tree.add(10, 0, '{t escape=js}Recent Activity{/t}', 'recent_activity.php', '', 'basefrm');
425 tree.add(11, 0, '{t escape=js}Workload By Date Range{/t}', 'workload_date_range.php', '', 'basefrm');

Subscribers

People subscribed via source and target branches