Skip to content

Commit

Permalink
Add time tracking functionality see bug 4428
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4246 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
davidnewcomb committed Dec 12, 2006
1 parent a969a10 commit fe2bc7b
Show file tree
Hide file tree
Showing 27 changed files with 998 additions and 51 deletions.
4 changes: 2 additions & 2 deletions admin/schema.php
Expand Up @@ -5,7 +5,7 @@
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: schema.php,v 1.12 2006-10-31 08:43:57 vboctor Exp $
# $Id: schema.php,v 1.13 2006-12-12 18:26:29 davidnewcomb Exp $
# --------------------------------------------------------

# Each entry below defines the schema. The upgrade array consists of
Expand Down Expand Up @@ -326,4 +326,4 @@
",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = Array('CreateIndexSQL',Array('idx_email_id',config_get('mantis_email_table'),'email_id'));
$upgrade[] = Array('AddColumnSQL',Array(config_get('mantis_bug_table'), "target_version C(64) NOTNULL DEFAULT \" '' \""));
?>
?>
153 changes: 153 additions & 0 deletions billing_inc.php
@@ -0,0 +1,153 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: billing_inc.php,v 1.1 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
# This include file prints out the bug bugnote_stats

# $f_bug_id must already be defined
?>
<?php
$t_core_path = config_get( 'core_path' );

require_once( $t_core_path.'bugnote_api.php' );
?>
<?php
if ( ! config_get('time_tracking_enabled') )
return;
?>

<a name="bugnotestats" id="bugnotestats" /><br />

<?php if ( ON == config_get( 'use_javascript' ) ) { ?>
<div id="bugnotestats_closed" style="display: none;">
<table class="width100" cellspacing="0">
<tr>
<td class="form-title" colspan="4">
<a href="" onClick="ToggleDiv( 'bugnotestats', g_div_bugnotestats ); return false;"
><img border="0" src="images/plus.png" alt="+" /></a>
<?php echo lang_get( 'time_tracking_bugnote_stats' ) ?>
</td>
</tr>
</table>
</div>
<?php } ?>

<div id="bugnotestats_open">
<?php
$f_bugnote_stats_from = gpc_get_string('bugnote_stats_from', '');
$f_bugnote_stats_to = gpc_get_string('bugnote_stats_to', '');
$f_bugnote_cost = gpc_get_string('bugnote_cost', '');
$f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
$f_project_id = helper_get_current_project();

if ( config_get('time_tracking_with_billing') )
$t_cost_col = true;
else
$t_cost_col = false;
?>
<form method="post" action="<?php echo $PHP_SELF ?>">
<table border=0 class="width100" cellspacing="0">
<tr>
<td class="form-title" colspan="4">
<?php if ( ON == config_get( 'use_javascript' ) ) { ?>
<a href="" onClick="ToggleDiv( 'bugnotestats', g_div_bugnotestats ); return false;"
><img border="0" src="images/minus.png" alt="-" /></a>
<?php } ?>
<?php echo lang_get( 'time_tracking_bugnote_stats' ) ?>
</td>
</tr>
<tr class="row-2">
<td class="category" width="25%">
<?php echo lang_get( 'from' ). " (mm/dd/yyyy)"; ?>
</td>
<td width="75%">
<input type="text" name="bugnote_stats_from" value="<?php echo $f_bugnote_stats_from ?>" />
</td>
</tr>
<tr class="row-1">
<td class="category">
<?php echo lang_get( 'to' ). " (mm/dd/yyyy)"; ?>
</td>
<td>
<input type="text" name="bugnote_stats_to" value="<?php echo $f_bugnote_stats_to ?>" />
</td>
</tr>
<?php if ($t_cost_col) { ?>
<tr class="row-2">
<td class="category">
<?php echo lang_get( 'time_tracking_cost_per_hour' ); ?>
</td>
<td>
<input type="text" name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
</td>
</tr>
<?php } ?>
<tr>
<td class="center" colspan="2">
<input type="submit" class="button" name="get_bugnote_stats_button" value="<?php echo lang_get( 'time_tracking_get_bugnote_stats_button' ) ?>" />
</td>
</tr>

</table>
</form>
<?php
if ( "" != $f_get_bugnote_stats_button ) {
$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $f_bugnote_stats_from, $f_bugnote_stats_to, $f_bugnote_cost );

if ( $f_bugnote_cost == "" )
$t_cost_col = false;
?>
<table border=0 class="width100" cellspacing="0">
<?php $t_prev_id = -1; ?>
<?php foreach ( $t_bugnote_stats as $t_item ) { ?>
<?php
if ( $t_item['bug_id'] != $t_prev_id) {
$t_link = bug_format_summary( $t_item['bug_id'], SUMMARY_CAPTION );
//$t_link = string_get_bug_view_link( $t_item['bug_id'] , null, true);
echo "<tr class='row-category-history'><td colspan=4>".$t_link."</td></tr>";
?>
<tr class="row-category-history">
<td class="small-caption">&nbsp;</td>
<td class="small-caption"><?php echo lang_get( 'username' ) ?></td>
<td class="small-caption"><?php echo lang_get( 'time_tracking' ) ?></td>
<?php if ( $t_cost_col) { ?>
<td class="small-caption"><?php echo lang_get( 'time_tracking_cost' ) ?></td>
<?php } ?>
</tr>
<?php
$t_prev_id = $t_item['bug_id'];
}
?>

<tr <?php echo helper_alternate_class() ?>>
<td class="small-caption">&nbsp;</td>
<td class="small-caption">
<?php echo $t_item['username'] ?>
</td>
<td class="small-caption">
<?php echo $t_item['sum_time_tracking'] ?>
</td>
<?php if ($t_cost_col) { ?>
<td class="small-caption">
<?php echo $t_item['cost'] ?>
</td>
<?php } ?>
</tr>
<?php } # end for?>
</table>
<?php } # end if f_get_bugnote_stats_button?>
</div>

<?php if ( ON == config_get( 'use_javascript' ) ) { ?>
<script type="text/JavaScript">
SetDiv( "bugnotestats", g_div_bugnotestats );
</script>
<?php } ?>
36 changes: 36 additions & 0 deletions billing_page.php
@@ -0,0 +1,36 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: billing_page.php,v 1.1 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
require_once( 'core.php' );

$t_core_path = config_get( 'core_path' );
?>
<?php
/*
compress_enable();
*/
?>
<?php html_page_top1( lang_get( 'time_tracking_billing_link' ) ) ?>
<?php html_page_top2() ?>

<br />

<?php
$t_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
?>
<!-- Jump to Bugnote add form -->
<?php
# Work break-down
include( $t_mantis_dir . 'billing_inc.php' );

html_page_bottom1( __FILE__ );
?>
14 changes: 13 additions & 1 deletion bug_change_status_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_change_status_page.php,v 1.24 2006-09-15 06:00:32 vboctor Exp $
# $Id: bug_change_status_page.php,v 1.25 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -284,6 +284,18 @@
</tr>
<?php } ?>

<?php if ( config_get('time_tracking_enabled') ) { ?>
<?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'time_tracking' ) ?>
</td>
<td>
<input type="text" name="time_tracking" size="5" value="0:00" />
</td>
</tr>
<?php } ?>
<?php } ?>

<!-- Submit Button -->
<tr>
Expand Down
4 changes: 2 additions & 2 deletions bug_reminder.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_reminder.php,v 1.20 2006-03-16 19:20:09 thraxisp Exp $
# $Id: bug_reminder.php,v 1.21 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -64,7 +64,7 @@
$f_to = $t_to;
}
$t_attr = '|' . implode( '|', $f_to ) . '|';
bugnote_add( $f_bug_id, $f_body, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr );
bugnote_add( $f_bug_id, $f_body, 0, config_get( 'default_reminder_view_status' ) == VS_PRIVATE, REMINDER, $t_attr );
}

html_page_top1();
Expand Down
12 changes: 7 additions & 5 deletions bug_update.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_update.php,v 1.90 2006-10-31 08:43:57 vboctor Exp $
# $Id: bug_update.php,v 1.91 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -73,6 +73,7 @@

$f_private = gpc_get_bool( 'private' );
$f_bugnote_text = gpc_get_string( 'bugnote_text', '' );
$f_time_tracking = gpc_get_string( 'time_tracking', '0:00' );
$f_close_now = gpc_get_string( 'close_now', false );

# Handle auto-assigning
Expand Down Expand Up @@ -137,7 +138,8 @@
case $t_resolved:
# bug_resolve updates the status, fixed_in_version, resolution, handler_id and bugnote and sends message
bug_resolve( $f_bug_id, $t_bug_data->resolution, $t_bug_data->fixed_in_version,
$f_bugnote_text, $t_bug_data->duplicate_id, $t_bug_data->handler_id, $f_private );
$f_bugnote_text, $t_bug_data->duplicate_id, $t_bug_data->handler_id,
$f_private, $f_time_tracking );
$t_notify = false;
$t_bug_note_set = true;

Expand All @@ -153,7 +155,7 @@

case CLOSED:
# bug_close updates the status and bugnote and sends message
bug_close( $f_bug_id, $f_bugnote_text, $f_private );
bug_close( $f_bug_id, $f_bugnote_text, $f_private, $f_time_tracking );
$t_notify = false;
$t_bug_note_set = true;
break;
Expand All @@ -162,7 +164,7 @@
if ( $t_old_bug_status >= $t_resolved ) {
bug_set_field( $f_bug_id, 'handler_id', $t_bug_data->handler_id ); # fix: update handler_id before calling bug_reopen
# bug_reopen updates the status and bugnote and sends message
bug_reopen( $f_bug_id, $f_bugnote_text, $f_private );
bug_reopen( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private );
$t_notify = false;
$t_bug_note_set = true;

Expand All @@ -177,7 +179,7 @@

# Add a bugnote if there is one
if ( ( !is_blank( $f_bugnote_text ) ) && ( false == $t_bug_note_set ) ) {
bugnote_add( $f_bug_id, $f_bugnote_text, $f_private );
bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private );
}

# Update the bug entry, notify if we haven't done so already
Expand Down
15 changes: 14 additions & 1 deletion bug_update_advanced_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_update_advanced_page.php,v 1.91 2006-11-11 07:37:59 vboctor Exp $
# $Id: bug_update_advanced_page.php,v 1.92 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------

require_once( 'core.php' );
Expand Down Expand Up @@ -535,6 +535,19 @@
</tr>
<?php } ?>

<!-- Bugnote Time Tracking (if permitted) -->
<?php if ( config_get('time_tracking_enabled') ) { ?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'time_tracking' ) ?>
</td>
<td colspan="5">
<input type="text" name="time_tracking" size="5" value="0:00" />
</td>
</tr>
<?php } ?>
<?php } ?>


<!-- Submit Button -->
<tr>
Expand Down
14 changes: 13 additions & 1 deletion bug_update_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_update_page.php,v 1.92 2006-08-12 08:04:13 vboctor Exp $
# $Id: bug_update_page.php,v 1.93 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------

require_once( 'core.php' );
Expand Down Expand Up @@ -410,6 +410,18 @@
</tr>
<?php } ?>

<!-- Bugnote Time Tracking (if permitted) -->
<?php if ( config_get('time_tracking_enabled') ) { ?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'time_tracking' ) ?>
</td>
<td colspan="5">
<input type="text" name="time_tracking" size="5" value="0:00" />
</td>
</tr>
<?php } ?>


<!-- Submit Button -->
<tr>
Expand Down
8 changes: 6 additions & 2 deletions bug_view_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_view_page.php,v 1.81 2006-09-15 05:19:45 vboctor Exp $
# $Id: bug_view_page.php,v 1.82 2006-12-12 18:26:28 davidnewcomb Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -445,6 +445,10 @@
<br />
<?php } ?>
<?php
# Time Tracking stats
if ( config_get('time_tracking_enabled') ) {
include( $t_mantis_dir . 'bugnote_stats_inc.php' );
}
# History
if ( $f_history ) {
include( $t_mantis_dir . 'history_inc.php' );
Expand All @@ -453,4 +457,4 @@
html_page_bottom1( __FILE__ );

last_visited_issue( $f_bug_id );
?>
?>

0 comments on commit fe2bc7b

Please sign in to comment.