diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Zurich.pm | 25 |
3 files changed, 23 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index 1ff476da3..9006e2f11 100644 --- a/perllib/FixMyStreet/SendReport/Email.pm +++ b/perllib/FixMyStreet/SendReport/Email.pm @@ -87,6 +87,7 @@ sub send { { _template_ => $self->get_template( $row ), _parameters_ => $h, + _line_indent => $row->cobrand eq 'zurich' ? '' : undef, # XXX Access to Cobrand module here? To => $self->to, From => $self->send_from( $row ), }, diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index 61f59f725..1ad7f5b05 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -43,7 +43,7 @@ sub send { my $revert = 0; # Extra bromley fields - if ( $row->bodies_str == 2482 ) { + if ( $row->bodies_str eq '2482' ) { $revert = 1; @@ -57,7 +57,7 @@ sub send { push @$extra, { name => 'report_title', value => $row->title }; push @$extra, { name => 'public_anonymity_required', value => $row->anonymous ? 'TRUE' : 'FALSE' }; push @$extra, { name => 'email_alerts_requested', value => 'FALSE' }; # always false as can never request them - push @$extra, { name => 'requested_datetime', value => DateTime::Format::W3CDTF->format_datetime($row->confirmed_local->set_nanosecond(0)) }; + push @$extra, { name => 'requested_datetime', value => DateTime::Format::W3CDTF->format_datetime($row->confirmed->set_nanosecond(0)) }; push @$extra, { name => 'email', value => $row->user->email }; $row->extra( $extra ); diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm index e0c95283e..d46561e9e 100644 --- a/perllib/FixMyStreet/SendReport/Zurich.pm +++ b/perllib/FixMyStreet/SendReport/Zurich.pm @@ -9,12 +9,14 @@ sub build_recipient_list { # Only one body ever, most of the time with an email endpoint my $body = @{ $self->bodies }[0]; - $body = FixMyStreet::App->model("DB::Body")->find( { id => $row->external_body } ) - if $row->external_body; + if ( $row->external_body ) { + $body = FixMyStreet::App->model("DB::Body")->find( { id => $row->external_body } ); + $h->{bodies_name} = $body->name; + } my $body_email = $body->endpoint; - my @bodies = $body->bodies; - if ($body->parent && @bodies) { + my $parent = $body->parent; + if ($parent && !$parent->parent) { # Division, might have an individual contact email address my $contact = FixMyStreet::App->model("DB::Contact")->find( { body_id => $body->id, @@ -49,9 +51,22 @@ sub get_template { return $template; } -# Zurich emails come from the site itself +# Zurich emails come from the site itself, unless it's to an external body, +# in which case it's from the category/body sub send_from { my ( $self, $row ) = @_; + + if ( $row->external_body ) { + my $body = @{ $self->bodies }[0]; + my $body_email = $body->endpoint; + my $contact = FixMyStreet::App->model("DB::Contact")->find( { + body_id => $body->id, + category => $row->category + } ); + $body_email = $contact->email if $contact && $contact->email; + return [ $body_email, FixMyStreet->config('CONTACT_NAME') ]; + } + return [ FixMyStreet->config('CONTACT_EMAIL'), FixMyStreet->config('CONTACT_NAME') ]; } |