From: Mark Wells Date: Tue, 18 Aug 2015 05:22:02 +0000 (-0700) Subject: display dates as real dates in Excel export, #23121, update for current RT X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=feba5016425b52740c29653383343d0d1887a592 display dates as real dates in Excel export, #23121, update for current RT --- diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm index c9bff6f36..ea3a498d6 100644 --- a/rt/lib/RT/Interface/Web_Vendor.pm +++ b/rt/lib/RT/Interface/Web_Vendor.pm @@ -423,12 +423,13 @@ sub ProcessColumnMapValue { my $value = shift; my %args = ( Arguments => [], Escape => 1, - FormatDate => \&default_FormatDate, @_ ); + my $FormatDate = $m->notes('FormatDate') || \&default_FormatDate; + if ( ref $value ) { if ( ref $value eq 'RT::Date' ) { - return $args{FormatDate}->($value); + return $FormatDate->($value); } elsif ( UNIVERSAL::isa( $value, 'CODE' ) ) { my @tmp = $value->( @{ $args{'Arguments'} } ); return ProcessColumnMapValue( ( @tmp > 1 ? \@tmp : $tmp[0] ), %args ); diff --git a/rt/share/html/Elements/ShowCustomFieldDate b/rt/share/html/Elements/ShowCustomFieldDate index 92ab7679a..1536935c5 100644 --- a/rt/share/html/Elements/ShowCustomFieldDate +++ b/rt/share/html/Elements/ShowCustomFieldDate @@ -49,7 +49,11 @@ my $content = $Object->Content; my $DateObj = RT::Date->new ( $session{'CurrentUser'} ); $DateObj->Set( Format => 'unknown', Value => $content, Timezone => 'utc' ); - $content = $DateObj->AsString(Time => 0, Timezone => 'utc'); + if ($m->notes('FormatDate')) { + $content = $m->notes('FormatDate')->($DateObj); + } else { + $content = $DateObj->AsString(Time => 0, Timezone => 'utc'); + } <%$content|n%> <%ARGS> diff --git a/rt/share/html/Elements/ShowCustomFieldDateTime b/rt/share/html/Elements/ShowCustomFieldDateTime index 2ba873aad..e179d6a4b 100644 --- a/rt/share/html/Elements/ShowCustomFieldDateTime +++ b/rt/share/html/Elements/ShowCustomFieldDateTime @@ -49,7 +49,11 @@ my $content = $Object->Content; my $DateObj = RT::Date->new ( $session{'CurrentUser'} ); $DateObj->Set( Format => 'ISO', Value => $content ); - $content = $DateObj->AsString; + if ($m->notes('FormatDate')) { + $content = $m->notes('FormatDate')->($DateObj); + } else { + $content = $DateObj->AsString; + } <%$content|n%> <%ARGS> diff --git a/rt/share/html/Search/Elements/ResultsStructuredView b/rt/share/html/Search/Elements/ResultsStructuredView index 0e9457c45..5b9db4ee1 100644 --- a/rt/share/html/Search/Elements/ResultsStructuredView +++ b/rt/share/html/Search/Elements/ResultsStructuredView @@ -54,7 +54,6 @@ $Format => undef #Callbacks $WriteHeader => sub { $RT::Logger->error('WriteHeader callback required'); '' } $WriteRow => sub { $RT::Logger->error('WriteRow callback required'); '' } -$FormatDate => sub { $_[0]->AsString } <%INIT> @@ -146,7 +145,6 @@ while ( my $Ticket = $Tickets->Next()) { push @out, ProcessColumnMapValue( $ColumnMap->{$col}{'value'}, Arguments => [ $Ticket, $row ], - FormatDate => $FormatDate, ); } #foreach $subcol $value = join('', '', @out, ''); diff --git a/rt/share/html/Search/Results.xls b/rt/share/html/Search/Results.xls index 8b94e22ba..d9d83568c 100644 --- a/rt/share/html/Search/Results.xls +++ b/rt/share/html/Search/Results.xls @@ -118,11 +118,11 @@ my $WriteRow = sub { $row++; }; -my $FormatDate = sub { +$m->notes('FormatDate', sub { my $DateObj = shift; return '' if $DateObj->Unix == 0; return time2str('%Y-%m-%dT%H:%M', $DateObj->Unix); -}; +}); # Write everything to the worksheet $m->comp('Elements/ResultsStructuredView', @@ -132,7 +132,6 @@ $m->comp('Elements/ResultsStructuredView', Format => $Format, WriteHeader => $WriteHeader, WriteRow => $WriteRow, - FormatDate => $FormatDate, ); # Set column widths