diff --git a/admin/schema.php b/admin/schema.php index 76af40eafb..d70fe45390 100644 --- a/admin/schema.php +++ b/admin/schema.php @@ -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 @@ -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 \" '' \"")); -?> \ No newline at end of file +?> diff --git a/billing_inc.php b/billing_inc.php new file mode 100644 index 0000000000..8efc876348 --- /dev/null +++ b/billing_inc.php @@ -0,0 +1,153 @@ + + + + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + - + + +
+ + + +
+ + + +
+ + + +
+ +
+
+ + + + +"; +?> + + + + + + + + + + +> + + + + + + + + +
".$t_link."
 
  + + + + + +
+ +
+ + + + diff --git a/billing_page.php b/billing_page.php new file mode 100644 index 0000000000..5de6d77620 --- /dev/null +++ b/billing_page.php @@ -0,0 +1,36 @@ + + + + + + +
+ + + + diff --git a/bug_change_status_page.php b/bug_change_status_page.php index b116d81ba7..82405a64fc 100644 --- a/bug_change_status_page.php +++ b/bug_change_status_page.php @@ -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 $ # -------------------------------------------------------- ?> + + +> + + + + + + + + + diff --git a/bug_reminder.php b/bug_reminder.php index 1a35e5cf37..d7cca78a6d 100644 --- a/bug_reminder.php +++ b/bug_reminder.php @@ -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 $ # -------------------------------------------------------- ?> 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; @@ -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; @@ -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; @@ -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 diff --git a/bug_update_advanced_page.php b/bug_update_advanced_page.php index dc4d440ce8..15d3f954ac 100644 --- a/bug_update_advanced_page.php +++ b/bug_update_advanced_page.php @@ -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' ); @@ -535,6 +535,19 @@ + + +> + + + + + + + + + + diff --git a/bug_update_page.php b/bug_update_page.php index 68d61b1e34..b848296fac 100644 --- a/bug_update_page.php +++ b/bug_update_page.php @@ -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' ); @@ -410,6 +410,18 @@ + + +> + + + + + + + + + diff --git a/bug_view_page.php b/bug_view_page.php index e0f13910ef..03f5577bcd 100644 --- a/bug_view_page.php +++ b/bug_view_page.php @@ -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 $ # -------------------------------------------------------- ?> \ No newline at end of file +?> diff --git a/bugnote_add.php b/bugnote_add.php index fd76047c4e..4bfe39959a 100644 --- a/bugnote_add.php +++ b/bugnote_add.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: bugnote_add.php,v 1.46 2005-07-25 16:34:10 thraxisp Exp $ + # $Id: bugnote_add.php,v 1.47 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- ?>
-
+ @@ -69,6 +69,25 @@ + + +> + + + + + + + + + +'. function custom_function_default_print_bug_view_page_custom_buttons( $p_bug_id ) { } -?> \ No newline at end of file +?> diff --git a/core/database_api.php b/core/database_api.php index 1657addfb0..1117821bd8 100644 --- a/core/database_api.php +++ b/core/database_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: database_api.php,v 1.49 2006-04-25 12:01:06 vboctor Exp $ + # $Id: database_api.php,v 1.50 2006-12-12 18:26:29 davidnewcomb Exp $ # -------------------------------------------------------- ### Database ### @@ -319,6 +319,18 @@ function db_prepare_string( $p_string ) { } } + # -------------------- + # prepare a string before DB insertion + # @@@ should default be return addslashes( $p_string ); or generate an error + function db_convert_time( $p_hhmmss ) { + // MySQL + if ( "" == $p_hhmmss || "00:00:00" == $p_hhmmss ) { + return ""; + } + $t_a = explode(":", $p_hhmmss); + return $t_a[0] . ":". $t_a[1]; + } + # -------------------- # prepare an integer before DB insertion function db_prepare_int( $p_int ) { diff --git a/core/html_api.php b/core/html_api.php index 6a74a808e1..a5ee81b996 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: html_api.php,v 1.201 2006-12-08 06:28:42 vboctor Exp $ + # $Id: html_api.php,v 1.202 2006-12-12 18:26:29 davidnewcomb Exp $ # -------------------------------------------------------- ########################################################################### @@ -569,6 +569,8 @@ function print_menu() { # Add custom options $t_custom_options = prepare_custom_menu_options( 'main_menu_custom_options' ); $t_menu_options = array_merge( $t_menu_options, $t_custom_options ); + if ( config_get('time_tracking_enabled') && config_get('time_tracking_with_billing') ) + $t_menu_options[] = '' . lang_get( 'time_tracking_billing_link' ) . ''; # Logout (no if anonymously logged in) if ( !current_user_is_anonymous() ) { diff --git a/javascript/common.js b/javascript/common.js index 6db31c148c..681a1a11a8 100644 --- a/javascript/common.js +++ b/javascript/common.js @@ -6,7 +6,7 @@ * See the README and LICENSE files for details * * -------------------------------------------------------- - * $Id: common.js,v 1.7 2005-05-10 17:56:40 thraxisp Exp $ + * $Id: common.js,v 1.8 2006-12-12 18:26:29 davidnewcomb Exp $ * -------------------------------------------------------- */ @@ -85,6 +85,7 @@ function SetCookie( p_cookie, p_value ) { var g_div_history = 0x0001; var g_div_bugnotes = 0x0002; var g_div_bugnote_add = 0x0004; +var g_div_bugnotestats = 0x0008; var g_div_upload_form = 0x0010; var g_div_monitoring = 0x0020; var g_div_sponsorship = 0x0040; diff --git a/javascript/time_tracking_stopwatch.js b/javascript/time_tracking_stopwatch.js new file mode 100644 index 0000000000..e909b2813b --- /dev/null +++ b/javascript/time_tracking_stopwatch.js @@ -0,0 +1,46 @@ + + +var time_tracking_ms = 0; +var time_tracking_running = 0; + +function time_tracking_swstartstop() { + if (time_tracking_running == 0) { + time_tracking_running = 1; + time_tracking_then = new Date(); + time_tracking_then.setTime(time_tracking_then.getTime() - time_tracking_ms); + document.bugnoteadd.time_tracking_ssbutton.value = "Stop"; + } else { + time_tracking_running = 0; + time_tracking_now = new Date(); + time_tracking_ms = time_tracking_now.getTime() - time_tracking_then.getTime(); + document.bugnoteadd.time_tracking_ssbutton.value = "Start"; + } +} +function time_tracking_swreset() { + time_tracking_running = 0; + time_tracking_ms = 0; + document.bugnoteadd.time_tracking.value = "0:00:00"; + document.bugnoteadd.time_tracking_ssbutton.value = "Start"; +} + +function time_tracking_display() { + setTimeout("time_tracking_display();", 1000); + if (time_tracking_running == 1) { + time_tracking_now = new Date(); + time_tracking_ms = time_tracking_now.getTime() - time_tracking_then.getTime(); + time_tracking_seconds = Math.round(time_tracking_ms / 1000) ; + time_tracking_hours = Math.floor(time_tracking_seconds / 3600); + time_tracking_left = time_tracking_seconds - (time_tracking_hours * 3600); + time_tracking_mins = Math.floor(time_tracking_left / 60); + time_tracking_secs = time_tracking_left - (time_tracking_mins * 60); + if (time_tracking_secs < 10) + time_tracking_secs = "0" + time_tracking_secs; + if (time_tracking_mins < 10) + time_tracking_mins = "0" + time_tracking_mins; + + document.bugnoteadd.time_tracking.value = time_tracking_hours + ":" + time_tracking_mins + ":" + time_tracking_secs; + } +} + +setTimeout("time_tracking_display();", 1000); + diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 08b024ea2b..9952a3fc8c 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -11,11 +11,11 @@ ########################################################################### # English strings for Mantis (source language for translations) # ------------------------------------------------- - # $Revision: 1.284 $ - # $Author: vboctor $ - # $Date: 2006-11-18 06:33:22 $ + # $Revision: 1.285 $ + # $Author: davidnewcomb $ + # $Date: 2006-12-12 18:26:29 $ # - # $Id: strings_english.txt,v 1.284 2006-11-18 06:33:22 vboctor Exp $ + # $Id: strings_english.txt,v 1.285 2006-12-12 18:26:29 davidnewcomb Exp $ ########################################################################### ?> @@ -1318,4 +1318,13 @@ $s_on_or_after = 'On Or After' ; # wiki related strings $s_wiki = 'Wiki'; + +# Time Tracking +$s_time_tracking_billing_link = 'Billing'; +$s_time_tracking = 'Time tracking'; +$s_time_tracking_bugnote_stats = 'Bugnote Statistics'; +$s_time_tracking_get_bugnote_stats_button = 'Get bugnote statistics'; +$s_time_tracking_cost_per_hour = 'Cost / Hour (£)'; +$s_time_tracking_cost = 'Cost'; + ?> diff --git a/print_all_bug_options_inc.php b/print_all_bug_options_inc.php index b6393e6e6a..c64330bb32 100644 --- a/print_all_bug_options_inc.php +++ b/print_all_bug_options_inc.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: print_all_bug_options_inc.php,v 1.24 2004-08-10 10:46:12 jlatour Exp $ + # $Id: print_all_bug_options_inc.php,v 1.25 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- ?>
+ + + + + + + + + + +
diff --git a/bugnote_edit_page.php b/bugnote_edit_page.php index da7afa2bf1..b41a887cf6 100644 --- a/bugnote_edit_page.php +++ b/bugnote_edit_page.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: bugnote_edit_page.php,v 1.49 2005-07-25 16:34:10 thraxisp Exp $ + # $Id: bugnote_edit_page.php,v 1.50 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- # CALLERS @@ -57,6 +57,8 @@ } $t_bugnote_text = string_textarea( bugnote_get_text( $f_bugnote_id ) ); + $t_time_tracking = bugnote_get_field( $f_bugnote_id, "time_tracking" ); + $t_time_tracking = db_convert_time( $t_time_tracking ); # Determine which view page to redirect back to. $t_redirect_url = string_get_bug_view_url( $t_bug_id ); @@ -82,6 +84,14 @@
+ (HH:MM)
+ +
diff --git a/bugnote_stats_inc.php b/bugnote_stats_inc.php new file mode 100644 index 0000000000..9587c08fd8 --- /dev/null +++ b/bugnote_stats_inc.php @@ -0,0 +1,124 @@ + + + + + + +
+ + + + + +
+date_submitted ); + $f_bugnote_stats_from = gpc_get_string('bugnote_stats_from', $t_bugnote_stats_from_def); + $f_bugnote_stats_to = gpc_get_string('bugnote_stats_to', date("d/m/Y")); + $f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', ''); +?> + + + + + + + + + + + + + + + + + + +
+ + - + + +
+ + + +
+ + + +
+ +
+ + + + + + + + + + +> + + + + +
+ + + +
+ + + +
+ +
+ + + + diff --git a/bugnote_update.php b/bugnote_update.php index 86ea16da2f..475c638bfa 100644 --- a/bugnote_update.php +++ b/bugnote_update.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: bugnote_update.php,v 1.43 2005-02-12 20:01:05 jlatour Exp $ + # $Id: bugnote_update.php,v 1.44 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- ?> diff --git a/bugnote_view_inc.php b/bugnote_view_inc.php index de5735e1ac..509dea2e63 100644 --- a/bugnote_view_inc.php +++ b/bugnote_view_inc.php @@ -6,7 +6,7 @@ # See the files README and LICENSE for details # -------------------------------------------------------- - # $Id: bugnote_view_inc.php,v 1.32 2006-09-26 01:50:10 thraxisp Exp $ + # $Id: bugnote_view_inc.php,v 1.33 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- ?>
'.$v3_time_tracking.'
'; if ( true == $t_bugnote_modified ) { echo ''.lang_get( 'edited_on').' '.$v3_last_modified.'
'; } diff --git a/config_defaults_inc.php b/config_defaults_inc.php index c5130341ff..6563747a0b 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: config_defaults_inc.php,v 1.321 2006-12-08 06:37:40 vboctor Exp $ + # $Id: config_defaults_inc.php,v 1.322 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- @@ -1769,4 +1769,22 @@ # The maximum number of issues to keep in the recently visited list. $g_recently_visited_count = 5; -?> \ No newline at end of file + + ##################### + # Time tracking + ##################### + + # Turn on Time Tracking accounting + $g_time_tracking_enabled = OFF; + + # When a single value is entered into the time tracking field + # is it treated as hours or minutes + $g_time_tracking_hours = ON; + + # A billing sums + $g_time_tracking_with_billing = OFF; + + # Stop watch to build time tracking field + $g_time_tracking_stopwatch = OFF; + +?> diff --git a/config_inc.php.sample b/config_inc.php.sample index d816addd14..128de843c8 100644 --- a/config_inc.php.sample +++ b/config_inc.php.sample @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: config_inc.php.sample,v 1.17 2006-09-12 04:08:32 vboctor Exp $ + # $Id: config_inc.php.sample,v 1.18 2006-12-12 18:26:28 davidnewcomb Exp $ # -------------------------------------------------------- # This sample file contains the essential files that you MUST @@ -50,4 +50,4 @@ # The default value is ON but you must make sure file uploading is enabled # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. $g_allow_file_upload = ON; -?> \ No newline at end of file +?> diff --git a/core/bug_api.php b/core/bug_api.php index 9d3d3b7e6d..aad548dd2a 100644 --- a/core/bug_api.php +++ b/core/bug_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: bug_api.php,v 1.102 2006-11-18 06:33:22 vboctor Exp $ + # $Id: bug_api.php,v 1.103 2006-12-12 18:26:29 davidnewcomb Exp $ # -------------------------------------------------------- $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; @@ -1153,7 +1153,7 @@ function bug_assign( $p_bug_id, $p_user_id, $p_bugnote_text='', $p_bugnote_priva # Add bugnote if supplied if ( !is_blank( $p_bugnote_text ) ) { - bugnote_add( $p_bug_id, $p_bugnote_text, $p_bugnote_private ); + bugnote_add( $p_bug_id, $p_bugnote_text, 0, $p_bugnote_private ); } # updated the last_updated date @@ -1170,14 +1170,14 @@ function bug_assign( $p_bug_id, $p_user_id, $p_bugnote_text='', $p_bugnote_priva # -------------------- # close the given bug - function bug_close( $p_bug_id, $p_bugnote_text = '', $p_bugnote_private = false ) { + function bug_close( $p_bug_id, $p_bugnote_text = '', $p_bugnote_private = false, $p_time_tracking = '0:00' ) { $p_bugnote_text = trim( $p_bugnote_text ); bug_set_field( $p_bug_id, 'status', CLOSED ); # Add bugnote if supplied if ( !is_blank( $p_bugnote_text ) ) { - bugnote_add( $p_bug_id, $p_bugnote_text, $p_bugnote_private ); + bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private ); } email_close( $p_bug_id ); @@ -1193,7 +1193,7 @@ function bug_close( $p_bug_id, $p_bugnote_text = '', $p_bugnote_private = false # -------------------- # resolve the given bug - function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bugnote_text = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_private = false ) { + function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bugnote_text = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_private = false, $p_time_tracking = '0:00' ) { $p_bugnote_text = trim( $p_bugnote_text ); if( !is_blank( $p_duplicate_id ) && ( $p_duplicate_id != 0 ) ) { @@ -1253,7 +1253,7 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug # Add bugnote if supplied if ( !is_blank( $p_bugnote_text ) ) { - bugnote_add( $p_bug_id, $p_bugnote_text, $p_bugnote_private ); + bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private ); } email_resolved( $p_bug_id ); @@ -1269,7 +1269,7 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug # -------------------- # reopen the given bug - function bug_reopen( $p_bug_id, $p_bugnote_text='', $p_bugnote_private = false ) { + function bug_reopen( $p_bug_id, $p_bugnote_text='', $p_time_tracking = '0:00', $p_bugnote_private = false ) { $p_bugnote_text = trim( $p_bugnote_text ); bug_set_field( $p_bug_id, 'status', config_get( 'bug_reopen_status' ) ); @@ -1277,7 +1277,7 @@ function bug_reopen( $p_bug_id, $p_bugnote_text='', $p_bugnote_private = false ) # Add bugnote if supplied if ( !is_blank( $p_bugnote_text ) ) { - bugnote_add( $p_bug_id, $p_bugnote_text, $p_bugnote_private ); + bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private ); } email_reopen( $p_bug_id ); diff --git a/core/bugnote_api.php b/core/bugnote_api.php index fa7cf4e7ed..dc31e217c8 100644 --- a/core/bugnote_api.php +++ b/core/bugnote_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: bugnote_api.php,v 1.37 2005-06-26 02:05:47 vboctor Exp $ + # $Id: bugnote_api.php,v 1.38 2006-12-12 18:26:29 davidnewcomb Exp $ # -------------------------------------------------------- $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; @@ -31,6 +31,7 @@ class BugnoteData { var $last_modified; var $note_type; var $note_attr; + var $time_tracking; } #=================================== @@ -86,9 +87,10 @@ function bugnote_is_user_reporter( $p_bugnote_id, $p_user_id ) { # Add a bugnote to a bug # # return the ID of the new bugnote - function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null ) { + function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null ) { $c_bug_id = db_prepare_int( $p_bug_id ); $c_bugnote_text = db_prepare_string( $p_bugnote_text ); + $c_time_tracking = db_prepare_string( $p_time_tracking ); $c_private = db_prepare_bool( $p_private ); $c_type = db_prepare_int( $p_type ); $c_attr = db_prepare_string( $p_attr ); @@ -96,6 +98,20 @@ function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_private = false, $p_type = $t_bugnote_text_table = config_get( 'mantis_bugnote_text_table' ); $t_bugnote_table = config_get( 'mantis_bugnote_table' ); + # Have they just entered a number + $t_1 = explode(":", $c_time_tracking); + if (count($t_1) == 1) { + if (config_get_global( 'time_tracking_hours')) { + # Hours + $t_time_tracking = $c_time_tracking . ":00:00"; + } else { + # Minutes + $t_time_tracking = "00:" . $c_time_tracking . ":00"; + } + } else { + $t_time_tracking = $c_time_tracking; + } + # insert bugnote text $query = "INSERT INTO $t_bugnote_text_table ( note ) @@ -123,9 +139,9 @@ function bugnote_add ( $p_bug_id, $p_bugnote_text, $p_private = false, $p_type = # insert bugnote info $query = "INSERT INTO $t_bugnote_table - (bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr ) + (bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking ) VALUES - ('$c_bug_id', '$c_user_id','$t_bugnote_text_id', '$t_view_state', " . db_now() . "," . db_now() . ", '$c_type', '$c_attr')"; + ('$c_bug_id', '$c_user_id','$t_bugnote_text_id', '$t_view_state', " . db_now() . "," . db_now() . ", '$c_type', '$c_attr', '$t_time_tracking' )"; db_query( $query ); # get bugnote id @@ -332,6 +348,7 @@ function bugnote_get_all_bugnotes( $p_bug_id, $p_user_bugnote_order, $p_user_bug $t_bugnote->last_modified = db_unixtimestamp( $row['last_modified'] ); $t_bugnote->note_type = $row['note_type']; $t_bugnote->note_attr = $row['note_attr']; + $t_bugnote->time_tracking = $row['time_tracking']; $t_bugnotes[] = $t_bugnote; } @@ -345,6 +362,22 @@ function bugnote_get_all_bugnotes( $p_bug_id, $p_user_bugnote_order, $p_user_bug # Data Modification #=================================== + # -------------------- + # Update the time_tracking field of the bugnote + function bugnote_set_time_tracking( $p_bugnote_id, $p_time_tracking ) { + $c_bugnote_id = db_prepare_int( $p_bugnote_id ); + $c_bugnote_time_tracking = db_prepare_string( $p_time_tracking ); + $t_bugnote_table = config_get( 'mantis_bugnote_table' ); + + $query = "UPDATE $t_bugnote_table + SET time_tracking = '$c_bugnote_time_tracking' + WHERE id='$c_bugnote_id'"; + db_query( $query ); + + # db_query() errors if there was a problem so: + return true; + } + # -------------------- # Update the last_modified field of the bugnote function bugnote_date_update( $p_bugnote_id ) { @@ -419,4 +452,84 @@ function bugnote_format_id( $p_bugnote_id ) { return str_pad( $p_bugnote_id, $t_padding, '0', STR_PAD_LEFT ); } + + + #=================================== + # Bugnote Stats + #=================================== + + # -------------------- + # Returns an array of bugnote stats + function bugnote_stats_get_events_array( $p_bugnote_id, $p_from, $p_to ) { + // MySQL + $t_user_table = config_get( 'mantis_user_table' ); + $t_bugnote_table = config_get( 'mantis_bugnote_table' ); + + if ( "" != $p_from ) { + $t_ar = explode( "/", $p_from ); # Expecting mm/dd/yyyy + $t_from = $t_ar[2] ."-". $t_ar[0] ."-". $t_ar[1]; + $c_from = " AND bn.date_submitted > '$t_from' "; + } + if ( "" != $p_to ) { + $t_ar = explode( "/", $p_to ); # Expecting mm/dd/yyyy + $t_to = $t_ar[2] ."-". $t_ar[0] ."-". $t_ar[1]; + $c_to = " AND bn.date_submitted < '$t_to' "; + } + $t_results = array(); + + $query = "SELECT username, + TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(time_tracking))),'%H:%i') sum_time_tracking + FROM $t_user_table u, $t_bugnote_table bn + WHERE u.id = bn.reporter_id AND + bn.bug_id = '$p_bugnote_id' + $c_from $c_to + GROUP BY u.id"; + $result = db_query($query); + while ($row = db_fetch_array($result)) { + $t_results[] = $row; + } + + return $t_results; + } + + # -------------------- + # Returns an array of bugnote stats + function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) { + // MySQL + $t_user_table = config_get( 'mantis_user_table' ); + $t_bugnote_table = config_get( 'mantis_bugnote_table' ); + + if ( "" != $p_from ) { + $t_ar = explode( "/", $p_from ); # Expecting mm/dd/yyyy + $t_from = $t_ar[2] ."-". $t_ar[0] ."-". $t_ar[1]; + $c_from = " AND bn.date_submitted > '$t_from' "; + } + if ( "" != $p_to ) { + $t_ar = explode( "/", $p_to ); # Expecting mm/dd/yyyy + $t_to = $t_ar[2] ."-". $t_ar[0] ."-". $t_ar[1]; + $c_to = " AND bn.date_submitted < '$t_to' "; + } + if ( ALL_PROJECTS != $p_project_id ) { + $c_project = " AND b.project_id = '$p_project_id' AND bn.bug_id = b.id "; + $t_bug_table = ", ". config_get( 'mantis_bug_table' ). " b"; + } + $t_results = array(); + + $query = "SELECT username, bn.bug_id, TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(time_tracking))),'%H:%i') sum_time_tracking + FROM $t_user_table u, $t_bugnote_table bn $t_bug_table + WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 + $c_project $c_from $c_to + GROUP BY bn.bug_id, u.id"; + $result = db_query($query); + $t_cost_min = $p_cost / 60; + while ($row = db_fetch_array($result)) { + $ar = explode(":", $row[sum_time_tracking]); + $t_total_cost = ($ar[0] * $p_cost) + ($ar[1] * $t_cost_min); + $row['cost'] = number_format($t_total_cost, 2); + $t_results[] = $row; + } + + return $t_results; + } + ?> diff --git a/core/bugnote_stats_api.php b/core/bugnote_stats_api.php new file mode 100644 index 0000000000..524b0e3aaf --- /dev/null +++ b/core/bugnote_stats_api.php @@ -0,0 +1,352 @@ + ' . $p_new_value; + } # end if DEFAULT + return array( 'note' => $t_note, 'change' => $t_change ); + } + + # -------------------- + # delete all history associated with a bug + function history_delete( $p_bug_id ) { + $c_bug_id = db_prepare_int( $p_bug_id ); + + $t_bug_history_table = config_get( 'mantis_bug_history_table' ); + + $query = "DELETE FROM $t_bug_history_table + WHERE bug_id='$c_bug_id'"; + db_query($query); + + # db_query() errors on failure so: + return true; + } +?> diff --git a/core/custom_function_api.php b/core/custom_function_api.php index bb888f3f59..3b1fb85258 100644 --- a/core/custom_function_api.php +++ b/core/custom_function_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: custom_function_api.php,v 1.29 2006-11-18 06:33:22 vboctor Exp $ + # $Id: custom_function_api.php,v 1.30 2006-12-12 18:26:29 davidnewcomb Exp $ # -------------------------------------------------------- $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; @@ -100,7 +100,7 @@ function custom_function_default_format_issue_summary( $p_issue_id, $p_context=0 function custom_function_default_checkin( $p_issue_id, $p_comment, $p_file, $p_new_version, $p_fixed ) { if ( bug_exists( $p_issue_id ) ) { history_log_event_special( $p_issue_id, CHECKIN, $p_file, $p_new_version ); - bugnote_add( $p_issue_id, $p_comment, VS_PRIVATE == config_get( 'source_control_notes_view_status' ) ); + bugnote_add( $p_issue_id, $p_comment, 0, VS_PRIVATE == config_get( 'source_control_notes_view_status' ) ); $t_status = config_get( 'source_control_set_status_to' ); if ( ( OFF != $t_status ) && $p_fixed ) { @@ -380,4 +380,4 @@ function custom_function_default_enum_categories() { # html_api.php. For each button, this function needs to generate the enclosing '
' and '