X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FShowTransaction;fp=rt%2Fshare%2Fhtml%2FElements%2FShowTransaction;h=1018ec6186a32f84c68f691daa74adb37623ff69;hb=1c538bfabc2cd31f27067505f0c3d1a46cba6ef0;hp=0000000000000000000000000000000000000000;hpb=4f5619288413a185e9933088d9dd8c5afbc55dfa;p=freeside.git diff --git a/rt/share/html/Elements/ShowTransaction b/rt/share/html/Elements/ShowTransaction new file mode 100644 index 000000000..1018ec618 --- /dev/null +++ b/rt/share/html/Elements/ShowTransaction @@ -0,0 +1,265 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +
+ + +
+<%PERL> +$m->comp('/Elements/ShowCustomFields', Object => $Transaction, HideEmpty => 1 ) if $HasTxnCFs; +$m->comp( + 'ShowTransactionAttachments', + %ARGS, + Parent => 0 +) if $ShowBody; + +
+% $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterContent' ); +
+ +<%ARGS> +$Transaction +$Object => $Transaction->Object + +$Attachments => undef +$AttachmentContent => undef +$HasTxnCFs => 1 + +$ShowBody => 1 +$ShowActions => 1 +$RowNum => 1 + +$DisplayPath => undef +$AttachmentPath => undef +$UpdatePath => undef +$ForwardPath => undef +$EncryptionPath => undef +$EmailRecordPath => undef + + +<%ONCE> + + +<%INIT> +my $record_type = $Object->RecordType; +my $type_class = $Object->ClassifyTransaction( $Transaction ); + +$m->callback( + CallbackName => 'MassageTypeClass', + Transaction => $Transaction, + TypeClassRef => \$type_class, + ARGSRef => \%ARGS, +); + +my @classes = ( + "transaction", + "$record_type-transaction", + $type_class, + ($RowNum % 2 ? 'odd' : 'even') +); + +my $desc = $Transaction->BriefDescriptionAsHTML; +if ( $Object->id != $Transaction->ObjectId ) { + # merged objects + $desc = join " - ", + $m->interp->apply_escapes( + loc("[_1] #[_2]:", loc($record_type), $Transaction->ObjectId), 'h'), + $desc; +} + +my $date = $Transaction->CreatedAsString; + +my $time = ''; +$time = loc('[quant,_1,minute,minutes]', $Transaction->TimeTaken) + if $Transaction->TimeTaken; + +if ( $ShowBody && !$Attachments ) { + $ARGS{'Attachments'} = $Attachments = {}; + + my $attachments = $Transaction->Attachments( WithHeaders => 1 ); + push @{ $Attachments->{ $_->Parent || 0 } ||= [] }, $_ + foreach @{ $attachments->ItemsArrayRef }; +} + +my @actions = (); +my $txn_type = $Transaction->Type; +if ( $txn_type =~ /EmailRecord$/ ) { + push @actions, { + title => loc('Show'), + target => '_blank', + path => $EmailRecordPath + .'?id='. $Object->id + .'&Transaction='. $Transaction->id + .'&Attachment='. ( $Attachments->{0}[0] && $Attachments->{0}[0]->id ), + } if $EmailRecordPath; + + $ShowBody = 0; +} + +# If the transaction has anything attached to it at all +elsif ( %$Attachments && $ShowActions ) { + my %has_right = map { + $_ => RT::ACE->CanonicalizeRightName( $_ . $record_type ) + } qw(Modify CommentOn ReplyTo); + $has_right{'Forward'} = RT::ACE->CanonicalizeRightName('ForwardMessage'); + + my $can_modify = $has_right{'Modify'} + && $Object->CurrentUserHasRight( $has_right{'Modify'} ); + + if ( $UpdatePath && $has_right{'ReplyTo'} + && ( $can_modify + || $Object->CurrentUserHasRight( $has_right{'ReplyTo'} ) + ) + ) { + push @actions, { + class => "reply-link", + title => loc('Reply'), + path => $UpdatePath + .'?id='. $Object->id + .'&QuoteTransaction='. $Transaction->id + .'&Action=Respond' + , + }; + } + if ( $UpdatePath && $has_right{'CommentOn'} + && ( $can_modify + || $Object->CurrentUserHasRight( $has_right{'CommentOn'} ) + ) + ) { + push @actions, { + class => "comment-link", + title => loc('Comment'), + path => $UpdatePath + .'?id='. $Object->id + .'&QuoteTransaction='. $Transaction->id + .'&Action=Comment' + , + }; + } + if ( $ForwardPath && $has_right{'Forward'} + && $Object->CurrentUserHasRight( $has_right{'Forward'} ) + ) { + push @actions, { + class => "forward-link", + title => loc('Forward'), + path => $ForwardPath + .'?id='. $Object->id + .'&QuoteTransaction='. $Transaction->id + , + }; + } + if ( $EncryptionPath && $can_modify + && RT->Config->Get('Crypt')->{'Enable'} + && RT->Config->Get('Crypt')->{'AllowEncryptDataInDB'} + ) { + push @actions, { + class => "encryption-link", + title => loc('Encrypt/Decrypt'), + path => $EncryptionPath + .'?id='. $Transaction->id + .'&QuoteTransaction='. $Transaction->id + , + }; + } +} + +$m->callback( + %ARGS, + Transaction => $Transaction, + Object => $Object, + + Classes => \@classes, + Actions => \@actions, + Created => \$date, + TimeTaken => \$time, + Description => \$desc, + ShowBody => \$ShowBody, +); + +my $actions = ''; +if ( @actions ) { + my $i = $m->interp; + + foreach my $a ( @actions ) { + $a = '{'target'} + ? ' target="'. $i->apply_escapes( $a->{'target'}, 'h' ) .'"' + : '' + ) + . ($a->{'class'} + ? ' class="'. $i->apply_escapes( $a->{'class'}, 'h' ) .'"' + : '' + ) + .'>'. $i->apply_escapes( $a->{'title'}, 'h' ) .'' + ; + } + $actions = join ' ', map "[$_]", @actions; +} + +# make date unbreakable +$date = $m->interp->apply_escapes( $date, 'h' ); +$date =~ s/\s/ /g; +