diff options
author | Dave Whiteland <dave@mysociety.org> | 2013-02-06 15:08:23 +0000 |
---|---|---|
committer | Dave Whiteland <dave@mysociety.org> | 2013-02-06 15:08:23 +0000 |
commit | 0f24a44cd6e8b056db482cb91c85768b6d1e7d1d (patch) | |
tree | 09a90f38574ee62754f3c8ac077152ed99a38296 /perllib/FixMyStreet/SendReport/Zurich.pm | |
parent | c061769ba72f420e2f2c6064fa526648e57339f1 (diff) | |
parent | 5b2e18389734751165d2eeb21a3b3f2e8d2e8755 (diff) |
Merge remote branch 'origin/master' into oxfordshire-header
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Zurich.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Zurich.pm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm new file mode 100644 index 000000000..e0c95283e --- /dev/null +++ b/perllib/FixMyStreet/SendReport/Zurich.pm @@ -0,0 +1,58 @@ +package FixMyStreet::SendReport::Zurich; + +use Moose; + +BEGIN { extends 'FixMyStreet::SendReport::Email'; } + +sub build_recipient_list { + my ( $self, $row, $h ) = @_; + + # 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; + my $body_email = $body->endpoint; + + my @bodies = $body->bodies; + if ($body->parent && @bodies) { + # Division, might have an individual contact email address + my $contact = FixMyStreet::App->model("DB::Contact")->find( { + body_id => $body->id, + category => $row->category + } ); + $body_email = $contact->email if $contact && $contact->email; + } + + push @{ $self->to }, [ $body_email, $body->name ]; + return $body_email; +} + +sub get_template { + my ( $self, $row ) = @_; + + my $template; + if ( $row->state eq 'unconfirmed' || $row->state eq 'confirmed' ) { + $template = 'submit.txt'; + } elsif ( $row->state eq 'in progress' ) { + $template = 'submit-in-progress.txt'; + } elsif ( $row->state eq 'planned' ) { + $template = 'submit-feedback-pending.txt'; + } elsif ( $row->state eq 'closed' ) { + $template = 'submit-external.txt'; + if ( $row->extra->{third_personal} ) { + $template = 'submit-external-personal.txt'; + } + } + + my $template_path = FixMyStreet->path_to( "templates", "email", "zurich", $template )->stringify; + $template = Utils::read_file( $template_path ); + return $template; +} + +# Zurich emails come from the site itself +sub send_from { + my ( $self, $row ) = @_; + return [ FixMyStreet->config('CONTACT_EMAIL'), FixMyStreet->config('CONTACT_NAME') ]; +} + +1; |