Additional field in "Note to Ticket" saved in time_accounting table

Moderator: crythias

Locked
aMescAs
Znuny newbie
Posts: 24
Joined: 05 Jan 2015, 13:27
Znuny Version: 3.3.9
Real Name: Flávio Rocha

Additional field in "Note to Ticket" saved in time_accounting table

Post by aMescAs »

Hi,

I would like to know how I could add an additional field in the "Add Note to Ticket" screen, and include that field in a new column of the table time_accounting.

I've created a dynamic field - date type - "Data do registo de horas:", and placed it exactly where i need it (as the image below shows it).

Image

But now I need it to fill the time_accounting table. I realize that would require some programming/development, and I’m ok with it (despite the low knowledge in Perl) and I’ve already looked in "..\Kernel\System\Ticket.pm"

Code: Select all


sub TicketAccountTime {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    for my $Needed (qw(TicketID ArticleID TimeUnit UserID)) {
        if ( !$Param{$Needed} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $Needed!" );
            return;
        }
    }

    # check some wrong formats
    $Param{TimeUnit} =~ s/,/\./g;
    $Param{TimeUnit} =~ s/ //g;
    $Param{TimeUnit} =~ s/^(\d{1,10}\.\d\d).+?$/$1/g;
    chomp $Param{TimeUnit};

    # db quote
    $Param{TimeUnit} = $Self->{DBObject}->Quote( $Param{TimeUnit}, 'Number' );

    # db update
    return if !$Self->{DBObject}->Do(
        SQL => "INSERT INTO time_accounting "
            . " (ticket_id, article_id, time_unit, create_time, create_by, change_time, change_by) "
            . " VALUES (?, ?, $Param{TimeUnit}, current_timestamp, ?, current_timestamp, ?)",
        Bind => [
            \$Param{TicketID}, \$Param{ArticleID}, \$Param{UserID}, \$Param{UserID},
        ],
    );
But I don't know how to get the value in the dynamic field. I've tested some code, but with no luck.
Am I on the right track? Should i forget the Dynamic Field and try to "copy" other field in code? What other files/places are relevant for this change?

Any help?

Regards,
Flávio Rocha.
OTRS 3.3.9 (private) on Windows Server 2012 with MySQL database.
Locked