Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user selection on the report page. Added entry date in the repo… #17

Open
wants to merge 1 commit into
base: master-1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion TimeTracking/core/timetracking_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ function plugin_TimeTracking_stats_get_project_array( $p_project_id, $p_from, $p
$t_user_where = '';
}

// BT 2015-07-18
if(isset($_POST['user_id']) && $_POST['user_id'] > 0) {
$t_user_where = " AND user = " . intval($_POST['user_id']) . " ";
}

$t_results = array();
$query = "SELECT u.username, p.name as project_name, bug_id, expenditure_date, hours, timestamp, info
$query = "SELECT u.username, p.id as project_id, p.name as project_name, bug_id, expenditure_date, hours, timestamp, info
FROM $t_timereport_table tr, $t_bug_table b, $t_user_table u, $t_project_table p
WHERE tr.bug_id=b.id and tr.user=u.id AND p.id = b.project_id
$t_project_where $t_from_where $t_to_where $t_user_where
Expand Down
64 changes: 54 additions & 10 deletions TimeTracking/pages/show_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@
?>
</td>
</tr>
<?php if ( access_has_global_level( plugin_config_get( 'view_others_threshold' ) ) ){ ?>

<tr class="row-2">
<td class="category" width="25%">
<?php
$q_usr = db_query("SELECT id, username FROM " . db_get_table( 'mantis_user_table' ));
$all_users = array();
while( $row = db_fetch_array( $q_usr ) ) {
$all_users[$row['id']] = $row['username'];
}
//print_r($all_users);
?>

Select user:
<select name="user_id">
<option value="0">All users</option>
<?php foreach($all_users as $tmp_id => $tmp_user){ ?>
<option value="<?=$tmp_id?>" <?=$_POST['user_id']==$tmp_id ? ' selected ':""?> >
<?=$tmp_user?>
</option>
<?php } ?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td>
<input type="submit" class="button"
Expand Down Expand Up @@ -92,6 +117,9 @@
<td class="small-caption">
<?php echo plugin_lang_get( 'expenditure_date' ) ?>
</td>
<td class="small-caption">
Entry date
</td>
<td class="small-caption">
<?php echo lang_get( 'issue_id' ) ?>
</td>
Expand All @@ -107,17 +135,20 @@
$t_user_summary = array();
$t_project_summary = array();
$t_bug_summary = array();
//echo '<pre>'.print_r($t_plugin_TimeTracking_stats,1).'</pre>';

# Initialize the user summary array
foreach ( $t_plugin_TimeTracking_stats as $t_item ) {
$t_user_summary[$t_item['username']] = 0;
$t_project_summary[$t_item['project_name']] = 0;
$t_bug_summary[$t_item['bug_id']] = 0;
$t_user_summary[$t_item['username']] = 0;
$t_project_summary[$t_item['project_name']] = 0;
$t_bug_summary[$t_item['bug_id']] = 0;
}

foreach ( $t_plugin_TimeTracking_stats as $t_key => $t_item ) {
$t_sum_in_hours += $t_item['hours'];
$t_user_summary[$t_item['username']] += $t_item['hours'];
$t_project_summary[$t_item['project_name']] += $t_item['hours'];
$t_bug_summary[$t_item['bug_id']] += $t_item['hours'];
$t_sum_in_hours += $t_item['hours'];
$t_user_summary[$t_item['username']] += $t_item['hours'];
$t_project_summary[$t_item['project_name']] += $t_item['hours'];
$t_bug_summary[$t_item['bug_id']] += $t_item['hours'];
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="small-caption">
Expand All @@ -126,6 +157,9 @@
<td class="small-caption">
<?php echo date( config_get("short_date_format"), strtotime($t_item['expenditure_date'])) ?>
</td>
<td class="small-caption">
<?php echo date( config_get("short_date_format"), strtotime($t_item['timestamp'])) ?>
</td>
<td class="small-caption">
<?php echo bug_format_summary( $t_item['bug_id'], SUMMARY_FIELD ) ?>
</td>
Expand All @@ -139,12 +173,16 @@
<?php } ?>

<tr <?php echo helper_alternate_class() ?>>
<td class="small-caption">
<td class="small-caption bold">
<?php echo lang_get( 'total_time' ); ?>
</td>
<td></td><td></td><td class="small-caption">
<td></td>
<td></td>
<td></td>
<td class="small-caption bold">
<?php echo number_format($t_sum_in_hours, 2, '.', ','); ?> (<?php echo db_minutes_to_hhmm( $t_sum_in_hours * 60); ?>)
</td><td></td>
</td>
<td></td>
</tr>

</table>
Expand Down Expand Up @@ -208,7 +246,13 @@
<?php foreach ( $t_bug_summary as $t_bug_key => $t_bug_value ) { ?>
<tr <?php echo helper_alternate_class() ?>>
<td class="small-caption">
<?/*
<?php echo lang_get( 'total_time' ); ?>(<?php echo bug_format_id( $t_bug_key ); ?>)
*/ ?>
<?php echo bug_format_summary( $t_bug_key, SUMMARY_FIELD ) ?>
<!--
(<a href="javascript: window.open('view.php?id=<?=$t_bug_key?>','_blank', 'height=500,width=500');">view</a>)
-->
</td>
<td class="small-caption">
<?php echo number_format($t_bug_value, 2, '.', ','); ?> (<?php echo db_minutes_to_hhmm( $t_bug_value * 60); ?>)
Expand Down