Page 3 of 4

Posted: 13 Jul 2006, 17:28
by cas
put these entries in your custom_strings_inc.php:
$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';
Perhaps all is fixed now.

cas

Re: Reports

Posted: 08 Aug 2006, 13:37
by mschipperheyn
I installed it, but after rentering one time entry, when I call the print_time_tracking_page.php I see that entry 13 times. I entered the entry as administrator. Don't know if I should do something special here.

Also, shouldn't the report show up in the summary as well?

Thanks,

Marc

Posted: 08 Aug 2006, 18:49
by cas
Did you check the entries in the database also ?
Are you using the script listed here or the original ?

Cas

Same issue in 1.0.5 and in 4 hours i cant make it go :(

Posted: 06 Oct 2006, 07:11
by mirai
tried to follow all the advice of these posts but still can not make it go. even with using the new page posted here. any suggestons from all you wonderfullly helpful people. this module would close the loop for me!

APPLICATION WARNING #100: Configuration option 'username' not found.

APPLICATION WARNING #100: Configuration option 'password' not found.
Missing file: /home/vs02053/public_html/test_site/mantis-1.0.3/core/adodb/drivers/adodb-localhost.inc.php

ADONewConnection: Unable to load database driver ''

Fatal error: Call to a member function on a non-object in /home/vs02053/public_html/test_site/mantis-1.0.3/core/database_api.php on line 43

Posted: 06 Oct 2006, 17:44
by cas
Can you provide a link and/or some credentials to check this behavior ?

Cas

I got it!! thanks for your offer to help!

Posted: 20 Oct 2006, 00:09
by mirai
i didn't copy the final two characters into the main file from the post. as so often happens a semicolon or some other insignificant thing, kills me! :(

Now will try to get reporting going!

Nice tool

Posted: 14 Dec 2006, 21:02
by preyer
This is a sleek tool.
I was able to get it working on Mantis 1.0.6 with MSSQL. Initial testing seems good. Once it is stable I will post some documentation.
Thanks.

Got to start working on geting the reporting mechanism in now :-)

Posted: 19 Dec 2006, 19:36
by cemper
great.... just found this addon and can't wait to get it onto my 1.1 installation...

cheers,christoph

Posted: 27 Jan 2007, 15:34
by bungybunny
Just wanted to add my applause for this addon. Proving to be a very good basis for something I'm working on.

Nice one.

Install question

Posted: 07 Feb 2007, 17:47
by jkpalmer52
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?

Posted: 01 Mar 2007, 09:57
by sigmer
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:

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>&nbsp;</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>&nbsp;</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, ',', '.'); ?> &euro;</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>&nbsp;</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>&nbsp;</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, ',', '.'); ?> &euro;</b></div></td> -->
<?php //} ?>
      <td>&nbsp;</td>
      <td>&nbsp;</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?

Posted: 06 Mar 2007, 14:20
by Jim.Thurrock
sigmer 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.
Great! Then let's get this thing opened up, maintained and improved :)

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

SQL server friendly version

Posted: 06 Mar 2007, 19:00
by spottmedia
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

Posted: 07 Mar 2007, 07:52
by Jim.Thurrock
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

Posted: 07 Mar 2007, 10:58
by ed
You are aware that this is being worked on here:

http://www.mantisbt.org/bugs/view.php?id=4428