From f7fc1e6f602745565c89b82cfc08e8ee3316182d Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 28 Dec 2012 18:16:37 -0800 Subject: record support time on ticket create transactions, #20743 --- rt/lib/RT/Action/Accumulate.pm | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'rt/lib') diff --git a/rt/lib/RT/Action/Accumulate.pm b/rt/lib/RT/Action/Accumulate.pm index 14675b894..03ac8e4ae 100644 --- a/rt/lib/RT/Action/Accumulate.pm +++ b/rt/lib/RT/Action/Accumulate.pm @@ -23,20 +23,38 @@ the same name, and should be single-valued fields. sub Prepare { my $self = shift; my $cfname = $self->Argument or return 0; - $self->{'inc_by'} = $self->TransactionObj->FirstCustomFieldValue($cfname) - || ''; - return ( $self->{'inc_by'} =~ /^(\d+)$/ ); + RT::Logger->info('Accumulate::Prepare called on transaction '. + $self->TransactionObj->Id." field $cfname"); + my $TransObj = $self->TransactionObj; + my $TicketObj = $self->TicketObj; + if ( $TransObj->Type eq 'Create' and + !defined($TransObj->FirstCustomFieldValue($cfname)) ) { + # special case: we're creating a new ticket, and the initial value + # may have been set on the ticket instead of the transaction, so + # update the transaction to match + $self->{'obj'} = $TransObj; + $self->{'inc_by'} = $TicketObj->FirstCustomFieldValue($cfname); + } else { + # the usual case when updating an existing ticket + $self->{'obj'} = $TicketObj; + $self->{'inc_by'} = $TransObj->FirstCustomFieldValue($cfname) + || ''; + } + return ( $self->{'inc_by'} =~ /^(\d+)$/ ); # else it's empty } sub Commit { my $self = shift; my $cfname = $self->Argument; + my $obj = $self->{'obj'}; my $newval = $self->{'inc_by'} + - ($self->TicketObj->FirstCustomFieldValue($cfname) || 0); - my ($val) = $self->TicketObj->AddCustomFieldValue( - Field => 'Support time', - Value => $newval, - RecordTransaction => 0, + ($obj->FirstCustomFieldValue($cfname) || 0); + RT::Logger->info('Accumulate::Commit called on '.ref($obj).' '. + $obj->Id." field $cfname"); + my ($val) = $obj->AddCustomFieldValue( + Field => $cfname, + Value => $newval, + RecordTransaction => 0, ); return $val; } -- cgit v1.2.1 From 2d8d1b6665db8f3a676147e190fea28a71c84598 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 28 Dec 2012 18:18:37 -0800 Subject: turn off debug --- rt/lib/RT/Action/Accumulate.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rt/lib') diff --git a/rt/lib/RT/Action/Accumulate.pm b/rt/lib/RT/Action/Accumulate.pm index 03ac8e4ae..0da7d2ef5 100644 --- a/rt/lib/RT/Action/Accumulate.pm +++ b/rt/lib/RT/Action/Accumulate.pm @@ -23,8 +23,8 @@ the same name, and should be single-valued fields. sub Prepare { my $self = shift; my $cfname = $self->Argument or return 0; - RT::Logger->info('Accumulate::Prepare called on transaction '. - $self->TransactionObj->Id." field $cfname"); + #RT::Logger->info('Accumulate::Prepare called on transaction '. + # $self->TransactionObj->Id." field $cfname"); my $TransObj = $self->TransactionObj; my $TicketObj = $self->TicketObj; if ( $TransObj->Type eq 'Create' and @@ -49,8 +49,8 @@ sub Commit { my $obj = $self->{'obj'}; my $newval = $self->{'inc_by'} + ($obj->FirstCustomFieldValue($cfname) || 0); - RT::Logger->info('Accumulate::Commit called on '.ref($obj).' '. - $obj->Id." field $cfname"); + #RT::Logger->info('Accumulate::Commit called on '.ref($obj).' '. + # $obj->Id." field $cfname"); my ($val) = $obj->AddCustomFieldValue( Field => $cfname, Value => $newval, -- cgit v1.2.1 From 949114e0f65232b405e084bcfcff37b1fd9a2926 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 3 Jan 2013 12:47:41 -0800 Subject: more reasonable solution for #17067 --- rt/lib/RT/URI/freeside/Internal.pm | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'rt/lib') diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index 61b256ef9..b0962860d 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -143,7 +143,7 @@ sub small_custview { } -sub _FreesideURILabelLong { +sub AsStringLong { my $self = shift; @@ -161,30 +161,28 @@ sub _FreesideURILabelLong { } elsif ( $table eq 'cust_svc' ) { my $string = ''; - # we now do this within the UI - #my $cust = $self->CustomerResolver; - #if ( $cust ) { - # $string = $cust->AsStringLong; - #} - $string .= $self->AsString; + my $cust = $self->CustomerResolver; + if ( $cust ) { + # the customer's small_custview + $string = $cust->AsStringLong(); + } + # + the service label and link + $string .= $self->ShortLink; return $string; } else { - return $self->_FreesideURILabel(); + return $self->SUPER::AsStringLong; } } -sub AsString { +sub ShortLink { + # because I don't want AsString to sometimes return a hunk of HTML, but + # on the other hand AsStringLong does something specific. my $self = shift; - if ( $self->{'fstable'} eq 'cust_svc' ) { - return '' . - $self->_FreesideURILabel . ''; - } else { - $self->SUPER::AsString; - } + '' . $self->_FreesideURILabel . ''; } sub CustomerResolver { -- cgit v1.2.1