% if ( $type =~ /^image\/\w+$/ ) {
% } else {
Download <% $partnames[$selected_index] %>
% }
% }
% } elsif ($selected_part->isa('MIME::Head')) {
<% encode_entities( $cust_msg->header ) %>
% }
<& /elements/footer.html &>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied" unless $curuser->access_right('View email logs');
my ($custmsgnum) = $cgi->keywords;
$custmsgnum =~ /^(\d+)$/ or die "illegal custmsgnum";
my $cust_msg = qsearchs('cust_msg', { 'custmsgnum' => $custmsgnum });
my $date = '';
$date = time2str('%Y-%m-%d %T', $cust_msg->_date) if ( $cust_msg->_date );
my $env_to = join(' | ', split(',', $cust_msg->env_to));
my %label = (
'sent' => 'Sent:',
'failed' => 'Attempted: ',
'prepared' => 'Not sent',
);
my $partname = sub {
my %friendly_name = ( 'text/plain' => 'Text', 'text/html' => 'HTML' );
my $part = shift;
$part->head->recommended_filename
|| $friendly_name{$part->mime_type}
|| $part->mime_type;
};
my @parts = $cust_msg->parts;
my @partnames = map { &{$partname}($_) } @parts;
push @parts, $cust_msg->entity->head;
push @partnames, mt('Header');
my $selected_part;
my $selected_index = 0;
if ( $cgi->param('part') =~ /^(\d+)$/ ) {
$selected_index = $1 if $1 < scalar(@parts);
}
$selected_part = $parts[$selected_index];
$cgi->delete('part'); # for self_url
%init>
|