Mantis Add-On - Time Tracker - Easy to run & install
Moderators: Developer, Contributor
-
- Posts: 2
- Joined: 27 Jan 2007, 15:33
-
- Posts: 78
- Joined: 23 Feb 2005, 17:29
- Location: US-Chicago area
Install question
The install.txt file states -
"- Add this line in the language Files (or copy the content):
# MODIFICATION GAMBIT: Time Tracking
include "modules/time_tracking/strings_german_add.php";
Where / what is the "language Files" in my installation? Is this line to be inserted into a file and, if so, which one?
"- Add this line in the language Files (or copy the content):
# MODIFICATION GAMBIT: Time Tracking
include "modules/time_tracking/strings_german_add.php";
Where / what is the "language Files" in my installation? Is this line to be inserted into a file and, if so, which one?
Thanks to all the people who've posted updated code and help .. without this thread i would of been completely lost. Having just laboured through the process myself i've compiled a list of steps to get it working. Haven't tested this on anything other than on my own installation so would be interested to hear whether they work out for you or not. Am running Mantis 1.0.6.
1. Open time_tracker.php and replace the entire contents with those below and save:
2. Save the modules folder with the updated time_tracker.php into the root of your Mantis folder.
3. Add these lines to the config_inc.php file:
### MODIFICATION GAMBIT: Time Tracking
include "modules/time_tracking/config_inc_add.php";
4. Add these lines to your custom_strings_inc.php:
### MODIFICATION GAMBIT: Time Tracking
$s_time_tracking = '<b>Time Tracking:</b> You are a Developer and have worked on this case? Document your work here.';
$s_time_user = 'User';
$s_time_expenditure_date = 'Allocation Date';
$s_time_hours = 'Hours';
$s_time_information = 'Information';
$s_time_mandays = 'Mandays';
$s_time_costs_auto = 'Costs (automatic)';
$s_time_entry_date = 'Entry Date (automatic)';
$s_time_submit = 'Submit';
$s_time_sum = 'Sum';
$s_time_tracking_delete = 'Delete Entry!';
$s_time_value_error = 'Please enter a valid number in Field Hours/Mandays!';
$s_time_tracking_history = 'Time allocated';
$s_time_tracking_deleted = 'Deleted';
$s_summary_time_tracking_link = 'Time tracking';
$s_print_time_tracking_informer = 'User';
$s_print_time_tracking_all_informers = 'All';
$s_print_time_tracking_from = 'From';
$s_print_time_tracking_to = 'To';
$s_print_time_tracking_update = 'Update';
$s_project = 'Project';
$s_my_time_link = 'My Time';
4. Add these lines to all the bug pages you would like the module to appear in, (maybe someone else here can provide a complete list of bug pages and line numbers to add the module to). To get them to appear in their own table, rather than nested inside another, add the code just AFTER a closing </table> tag:
<tr>
<td class="center" colspan="6">
<?php
// MODIFICATION GAMBIT: Time Tracking
include 'modules/time_tracking/time_tracking.php';
?>
</td>
</tr>
5. Run this sql command to generate the table structure for the add-on (this is slightly different from the sql provided in the module install.txt):
CREATE TABLE `mantis_module_timetracking` (
`id` int(11) NOT NULL auto_increment,
`bugid` int(11) default NULL,
`user` int(11) default NULL,
`expenditure_date` date default NULL,
`hours` double(15,3) default NULL,
`costs` double(15,3) default NULL,
`time_unit` enum('md','hr') default 'hr',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`info` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
..and your done. Hopefully having followed these instructions you now have the time tracker module working.
Btw. is the original author still updating the module? Is there any possibility the module could be updated to work, out of the box, so to speak?
1. Open time_tracker.php and replace the entire contents with those below and save:
Code: Select all
<?php
########################################################
# Mantis Bugtracker Add-On
#
# Time Tracker
#
# by Elmar Schumacher (elmar.schumacher@web.de)
# GAMBIT Consulting GmbH
########################################################
$bug_id = gpc_get_int( 'bug_id' );
$table = config_get("timetracking_table");
# Time record POST
if( isset($_REQUEST['time_value']) ){
# Current UserID
$user = auth_get_current_user_id();
$time_info = db_prepare_string($_REQUEST["time_info"]);
# Work on Time-Entry so we can eval it
$time_value = $_REQUEST["time_value"];
$time_value = strtr( $time_value, ",", ".");
$time_value = doubleval($time_value);
$time_unit = $_REQUEST["time_unit"];
# Trigger in case of non-evaluable entry
if ( $time_value == 0 ) {
trigger_error( lang_get( 'time_value_error' ), ERROR );
}
# Converting mandays into hours for unified database values
if($_REQUEST["time_unit"] == "md"){
$time_value = $time_value * config_get('consultant_manday_definition');
}
# For record-keeping we also calc the costs according to the hourly charges
$costs = $time_value * config_get('consultant_hourly_charge');
# Write Post-Data to DB
//if( db_connect( config_get('hostname'), config_get('username'), config_get('password'), config_get('database_name') )){
$now = date("Y-m-d G:i:s");
$year = $_REQUEST["year"];
$month = $_REQUEST["month"];
$day = $_REQUEST["day"];
$query = "INSERT INTO $table
( user, bugid, expenditure_date, hours, costs, time_unit, timestamp, info )
VALUES
( '$user', '$bug_id', '$year-$month-$day', '$time_value', '$costs', '$time_unit', NOW(), '$time_info')";
if(!db_query($query)){
trigger_error( ERROR_DB_QUERY_FAILED, ERROR );
}
# Event is logged in the project
history_log_event_direct( $bug_id, lang_get( 'time_tracking_history' ). ": " . $time_info, "$day.$month.$year: $time_value h.", "set", $user );
//} else {
// trigger_error( ERROR_DB_CONNECT_FAILED, ERROR );
//}
}
# DELETE Entry: A time record needs to be deleted
if( isset($_REQUEST['delete_id']) ){
$delete_id = $_REQUEST['delete_id'];
if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) {
//if( db_connect( config_get('hostname'), config_get('username'), config_get('password'), config_get('database_name') )){
$query_pull_timerecords = "SELECT * FROM $table WHERE id = $delete_id ORDER BY expenditure_date DESC";
$result_pull_timerecords = db_query($query_pull_timerecords);
$row = db_fetch_array( $result_pull_timerecords );
$query_delete = "DELETE FROM $table WHERE id = $delete_id";
db_query($query_delete);
# Event is logged in the project
history_log_event_direct( $bug_id, lang_get( 'time_tracking_history' ). " " . lang_get('time_tracking_deleted') . ": " . $row['info'], date("d.m.Y", strtotime($row["expenditure_date"])) . ": " . number_format($row["hours"], 2, ',', '.') . " h.", "deleted", $user );
//} else {
// trigger_error( ERROR_DB_CONNECT_FAILED, ERROR );
//}
}
}
# Pull all Time-Record entries for the current Bug
//if( db_connect( config_get('hostname'), config_get('username'), config_get('password'), config_get('database_name') )){
$query_pull_timerecords = "SELECT * FROM $table WHERE bugid = $bug_id ORDER BY expenditure_date DESC";
$result_pull_timerecords = db_query($query_pull_timerecords);
$num_timerecords = db_num_rows( $result_pull_timerecords );
//} else {
// trigger_error( ERROR_DB_CONNECT_FAILED, ERROR );
//}
# Get Sum for this bug
//if( db_connect( config_get('hostname'), config_get('username'), config_get('password'), config_get('database_name') )){
$table = config_get("timetracking_table");
$query_pull_costs_hours = "SELECT SUM(costs) as costs, SUM(hours) as hours FROM $table WHERE bugid = $bug_id";
$result_pull_costs_hours = db_query($query_pull_costs_hours);
$row_pull_costs_hours = db_fetch_array( $result_pull_costs_hours );
//} else {
// trigger_error( ERROR_DB_CONNECT_FAILED, ERROR );
//}
if(access_has_bug_level( config_get( 'timetracking_add_threshold' ), $f_bug_id )) {
?>
<tr>
<td class="center" colspan="6">
<br>
<?php
//if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) {
// $colspan=7;
//} else {
$colspan=6;
//} ?>
<table class="width100" cellspacing="1">
<tr>
<td colspan="<?php echo $colspan ?>" class="row-category"><div align="left"><a name="timerecord"></a><?php echo lang_get( 'time_tracking' ); ?></div>
</td>
</tr>
<tr class="row-category">
<td><div align="center"><?php echo lang_get( 'time_user' ); ?></div>
</td>
<td><div align="center"><?php echo lang_get( 'time_expenditure_date' ); ?></div>
</td>
<td><div align="center"><?php echo lang_get( 'time_hours' ); ?>/<?php echo lang_get( 'time_mandays' ); ?></div>
</td>
<td><div align="center"><?php echo lang_get( 'time_information' ); ?></div>
</td>
<?php //if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) { ?>
<!-- <td><div align="center"><?php echo lang_get( 'time_costs_auto' ); ?></div>
</td> -->
<?php //} ?>
<td><div align="center"><?php echo lang_get( 'time_entry_date' ); ?></div>
</td>
<td> </td>
</tr>
<?php if ( access_has_bug_level( config_get( 'timetracking_add_threshold' ), $bug_id ) ) { ?>
<form name="time_tracking" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>#timerecord">
<? # Nesessary Parameter. Due to base inconsistency we have a double entry ?>
<input type="hidden" name="bug_id" value="<?php echo $bug_id; ?>">
<input type="hidden" name="id" value="<?php echo $bug_id; ?>">
<tr <?php echo helper_alternate_class() ?>>
<td><? echo user_get_name( auth_get_current_user_id() ) ?></td>
<td nowrap><div align="center">
<?php
$current_date = explode ("-", date("Y-m-d"));
?>
<select tabindex="5" name="day">
<?php print_day_option_list( $current_date[2] ) ?>
</select>
<select tabindex="6" name="month">
<?php print_month_option_list( $current_date[1] ) ?>
</select>
<select tabindex="7" name="year">
<?php print_year_option_list( $current_date[0] ) ?>
</select>
</div>
</td>
<td><table width="100%" border="0" cellspacing="1">
<tr>
<td><div align="right">
<select name="time_unit">
<option value="hr" selected><?php echo lang_get( 'time_hours' ) ?></option>
<option value="md"><?php echo lang_get( 'time_mandays' ) ?></option>
</select>
</div>
</td>
<td><div align="left">
<input name="time_value" type="text">
</div>
</td>
</tr>
</table>
</td>
<td><div align="center">
<input type="text" name="time_info">
</div>
</td>
<?php //if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) { ?>
<!-- <td> </td> -->
<?php // } ?>
<td>
</td>
<td><input name="<?php echo lang_get( 'time_submit' ) ?>" type="submit" value="<?php echo lang_get( 'time_submit' ) ?>">
</td>
</tr>
</form>
<? } # END Access Control ?>
<?php
for ( $i=0; $i < $num_timerecords; $i++ ) {
$row = db_fetch_array( $result_pull_timerecords );
?>
<tr <?php echo helper_alternate_class() ?>>
<td><? echo user_get_name($row["user"]); ?></td>
<td><div align="center"><?php echo date("d.m.Y", strtotime($row["expenditure_date"])); ?> </div>
</td>
<?
$mdBold = "";
$mdBoldStop = "";
$hrBold = "";
$hrBoldStop = "";
if($row["time_unit"]=="md"){
$mdBold = "<b>";
$mdBoldStop = "</b>";
$hrBold = "";
$hrBoldStop = "";
} else {
$mdBold = "";
$mdBoldStop = "";
$hrBold = "<b>";
$hrBoldStop = "</b>";
}
?>
<td><div align="right"><?php echo $hrBold.number_format($row["hours"], 2, ',', '.').$hrBoldStop; ?> / <?php echo $mdBold.number_format($row["hours"]/config_get('consultant_manday_definition'), 2, ',', '.').$mdBoldStop; ?></div>
</td>
<td><?php echo $row["info"]; ?> </td>
<?php //if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) { ?>
<!-- <td><div align="right"><?php echo number_format($row["costs"], 2, ',', '.'); ?> €</div> -->
<?php //} ?>
</td>
<td><div align="center"><?php echo date("d.m.Y G:i:s", strtotime($row["timestamp"])); ?> </div>
</td>
<td>
<?php # DELETE Button just available for 'Delete-Bug Users'
if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) {?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?bug_id=<?php echo $bug_id; ?>&id=<?php echo $bug_id; ?>&delete_id=<?php echo $row["id"]; ?>#timerecord"><?php echo lang_get( 'time_tracking_delete' ) ?></a></td>
<?php } ?>
</tr>
<?php } ?>
<tr class="row-category">
<td><?php echo lang_get( 'time_sum' ) ?></td>
<td> </td>
<td><div align="center"><b><?php echo number_format($row_pull_costs_hours['hours'], 2, ',', '.'); ?> / <?php echo number_format($row_pull_costs_hours['hours']/config_get('consultant_manday_definition'), 2, ',', '.'); ?></b></div></td>
<td> </td>
<?php //if ( access_has_bug_level( config_get( 'timetracking_delete_threshold' ), $bug_id ) ) { ?>
<!-- <td><div align="center"><b><?php echo number_format($row_pull_costs_hours['costs'], 2, ',', '.'); ?> €</b></div></td> -->
<?php //} ?>
<td> </td>
<td> </td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
2. Save the modules folder with the updated time_tracker.php into the root of your Mantis folder.
3. Add these lines to the config_inc.php file:
### MODIFICATION GAMBIT: Time Tracking
include "modules/time_tracking/config_inc_add.php";
4. Add these lines to your custom_strings_inc.php:
### MODIFICATION GAMBIT: Time Tracking
$s_time_tracking = '<b>Time Tracking:</b> You are a Developer and have worked on this case? Document your work here.';
$s_time_user = 'User';
$s_time_expenditure_date = 'Allocation Date';
$s_time_hours = 'Hours';
$s_time_information = 'Information';
$s_time_mandays = 'Mandays';
$s_time_costs_auto = 'Costs (automatic)';
$s_time_entry_date = 'Entry Date (automatic)';
$s_time_submit = 'Submit';
$s_time_sum = 'Sum';
$s_time_tracking_delete = 'Delete Entry!';
$s_time_value_error = 'Please enter a valid number in Field Hours/Mandays!';
$s_time_tracking_history = 'Time allocated';
$s_time_tracking_deleted = 'Deleted';
$s_summary_time_tracking_link = 'Time tracking';
$s_print_time_tracking_informer = 'User';
$s_print_time_tracking_all_informers = 'All';
$s_print_time_tracking_from = 'From';
$s_print_time_tracking_to = 'To';
$s_print_time_tracking_update = 'Update';
$s_project = 'Project';
$s_my_time_link = 'My Time';
4. Add these lines to all the bug pages you would like the module to appear in, (maybe someone else here can provide a complete list of bug pages and line numbers to add the module to). To get them to appear in their own table, rather than nested inside another, add the code just AFTER a closing </table> tag:
<tr>
<td class="center" colspan="6">
<?php
// MODIFICATION GAMBIT: Time Tracking
include 'modules/time_tracking/time_tracking.php';
?>
</td>
</tr>
5. Run this sql command to generate the table structure for the add-on (this is slightly different from the sql provided in the module install.txt):
CREATE TABLE `mantis_module_timetracking` (
`id` int(11) NOT NULL auto_increment,
`bugid` int(11) default NULL,
`user` int(11) default NULL,
`expenditure_date` date default NULL,
`hours` double(15,3) default NULL,
`costs` double(15,3) default NULL,
`time_unit` enum('md','hr') default 'hr',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`info` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
..and your done. Hopefully having followed these instructions you now have the time tracker module working.
Btw. is the original author still updating the module? Is there any possibility the module could be updated to work, out of the box, so to speak?
-
- Posts: 4
- Joined: 06 Mar 2007, 14:11
Great! Then let's get this thing opened up, maintained and improvedsigmer wrote:Thanks to all the people who've posted updated code and help .. without this thread i would of been completely lost. Having just laboured through the process myself i've compiled a list of steps to get it working. Haven't tested this on anything other than on my own installation so would be interested to hear whether they work out for you or not. Am running Mantis 1.0.6.
I've set up a google code project for this here:
http://code.google.com/p/mantis-timetracking-module/
To checkout the code, see here:
http://code.google.com/p/mantis-timetra ... ule/source
I'm just the lowly project creator, so please e-mail me if you want access, and I'll give it to you.
sigmer - you okay for project leader?
Jim
jim.thurrock@gmail.com
-
- Posts: 1
- Joined: 06 Mar 2007, 18:46
SQL server friendly version
Hi Jim,
I couldn't find anything in the subversion repository, sorry I was in a hurry I didn't contact you.
Anyway I created a SQL server friendly version of the code including reports, (and updated sql script in install file) for anyone who just wants to get started. this has been tested on SQL 2000 and Mantis 1.0.3.
http://www.spottmedia.co.uk/timetrackin ... server.zip
I would def like to know when subversion is ready.
Cheers
Simon
I couldn't find anything in the subversion repository, sorry I was in a hurry I didn't contact you.
Anyway I created a SQL server friendly version of the code including reports, (and updated sql script in install file) for anyone who just wants to get started. this has been tested on SQL 2000 and Mantis 1.0.3.
http://www.spottmedia.co.uk/timetrackin ... server.zip
I would def like to know when subversion is ready.
Cheers
Simon
-
- Posts: 4
- Joined: 06 Mar 2007, 14:11
The subversion repo has two branches - 0.19.1 and 1.06:
http://mantis-timetracking-module.googl ... /branches/
1.0.6 can be moved to trunk as soon as you like.
Jim
jim.thurrock@gmail.com
http://mantis-timetracking-module.googl ... /branches/
1.0.6 can be moved to trunk as soon as you like.
Jim
jim.thurrock@gmail.com
CVS can be viewed here:
http://mantisbt.cvs.sourceforge.net/mantisbt/mantisbt/
Some changes where made 2 months ago.
http://mantisbt.cvs.sourceforge.net/mantisbt/mantisbt/
Some changes where made 2 months ago.
-
- Posts: 4
- Joined: 06 Mar 2007, 14:11
-
- Posts: 4
- Joined: 06 Mar 2007, 14:11
-
- Posts: 8
- Joined: 14 Feb 2005, 10:50
Suppose I had better say hello as I am writting the TimeTracking intergration featured at : http://www.mantisbt.org/bugs/view.php?id=4428
It's not dead - I'm close to completion. I just wanted to intergrate the filtering mechanism into the statistics. So many people have so many different ideas on the best way to do billing that I need to take a step back and have a think. That feature may have to wait until the next version
It's not dead - I'm close to completion. I just wanted to intergrate the filtering mechanism into the statistics. So many people have so many different ideas on the best way to do billing that I need to take a step back and have a think. That feature may have to wait until the next version