[Solved]Print ticket advanced formatting

Moderator: crythias

Locked
sale1902
Znuny newbie
Posts: 13
Joined: 23 Dec 2011, 11:44
Znuny Version: 3.0.8
Real Name: Aleksandar Jovanović
Company: M.A.I. Trade

[Solved]Print ticket advanced formatting

Post by sale1902 »

Hi,

what i am trying to accomplish is this:

if certain dynamic field value is selected and article number is max(article number)
printticket in pdf without last article

Basically: if a dynamic field value is selected, dont print last article of a ticket.
My problem is that i am not that good with perl (developing in Python), so i am stuck at the /Kernel/Modules/AgentTicketPrint.pm part. I think this is correct place for me to accomplish this, i managed to not print certain article number with this code (second line):

Code: Select all

 for my $ArticleTmp ( @{ $Param{ArticleData} } ) {
        next if($ArticleCounter == 2);
        if ( $ArticleCounter == 1) {
            $Self->{PDFObject}->PositionSet(
However, i can't seem to find a variable in the code that i could control, in order to exclude last article from print, i can only put random number in bolded line in the code upwards.
Dynamic field value part, i haven't even touched.
Has anyone done anything similar to this, and has a correct path for me to proceed?
Last edited by sale1902 on 04 Jun 2013, 11:54, edited 1 time in total.
OTRS v3.2.7. on Ubuntu server 11.10.
MySQL database
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Print ticket advanced formatting

Post by reneeb »

In Kernel/Modules/AgentTicketPrint.pm

old:

Code: Select all

    # get content
    my %Ticket = $Self->{TicketObject}->TicketGet(
        TicketID => $Self->{TicketID},
        UserID   => $Self->{UserID},
    );
    my @ArticleBox = $Self->{TicketObject}->ArticleContentIndex(
        TicketID                   => $Self->{TicketID},
        StripPlainBodyAsAttachment => 1,
        UserID                     => $Self->{UserID},
        DynamicFields              => 0,
    );

    # check if only one article need printed
    if ($ArticleID) {
        my @NewArticleBox;
        for my $Article (@ArticleBox) {
            if ( $Article->{ArticleID} == $ArticleID ) {
                @NewArticleBox = ($Article);
            }
        }
        if (@NewArticleBox) {
            @ArticleBox = @NewArticleBox;
        }
    }
new:

Code: Select all

    # get content
    my %Ticket = $Self->{TicketObject}->TicketGet(
        TicketID => $Self->{TicketID},
        UserID   => $Self->{UserID},
        DynamicFields => 1,
    );
    my @ArticleBox = $Self->{TicketObject}->ArticleContentIndex(
        TicketID                   => $Self->{TicketID},
        StripPlainBodyAsAttachment => 1,
        UserID                     => $Self->{UserID},
        DynamicFields              => 0,
    );

    # check if only one article need printed
    if ($ArticleID) {
        my @NewArticleBox;
        for my $Article (@ArticleBox) {
            if ( $Article->{ArticleID} == $ArticleID ) {
                @NewArticleBox = ($Article);
            }
        }
        if (@NewArticleBox) {
            @ArticleBox = @NewArticleBox;
        }
    }
    elsif ( $Ticket{DynamicField_<name>} eq '<value_to_check_for>' ) {
        pop @ArticleBox;
    }

You have to replace "<name>" with the name of the DynamicField and "<value_to_check_for>" with the value that should trigger the omission of the last article. If the DynamicField is a checkbox the value is "1".

(untested)
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
sale1902
Znuny newbie
Posts: 13
Joined: 23 Dec 2011, 11:44
Znuny Version: 3.0.8
Real Name: Aleksandar Jovanović
Company: M.A.I. Trade

[Solved]Re: Print ticket advanced formatting

Post by sale1902 »

Thanks alot man :) This actually works...much appreciated! :)
OTRS v3.2.7. on Ubuntu server 11.10.
MySQL database
Locked