diff options
author | Dave Whiteland <dave@mysociety.org> | 2012-05-29 15:57:41 +0100 |
---|---|---|
committer | Dave Whiteland <dave@mysociety.org> | 2012-05-29 15:57:41 +0100 |
commit | 67da8efc720d2d0bd22bd9fe8655b7e983b35bb4 (patch) | |
tree | 38b8570647124df06c637d4b923f6010211ef328 /perllib/FixMyStreet/SendReport/EmptyHomes.pm | |
parent | 40b3a51d33caefa8f5fb97ce9be18ef936c7e260 (diff) | |
parent | 131ff6e9bf3626d6a8fff6ae54669d250148a63a (diff) |
Merge remote branch 'origin/master' into fmb-read-only
Conflicts:
bin/send-reports
perllib/FixMyStreet/Cobrand/Default.pm
perllib/FixMyStreet/Cobrand/FixMyStreet.pm
templates/web/fixmystreet/alert/index.html
templates/web/fixmystreet/around/display_location.html
web/cobrands/fixmystreet/_layout.scss
web/js/map-OpenLayers.js
Diffstat (limited to 'perllib/FixMyStreet/SendReport/EmptyHomes.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/EmptyHomes.pm | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/SendReport/EmptyHomes.pm b/perllib/FixMyStreet/SendReport/EmptyHomes.pm new file mode 100644 index 000000000..9453b4ca5 --- /dev/null +++ b/perllib/FixMyStreet/SendReport/EmptyHomes.pm @@ -0,0 +1,51 @@ +package FixMyStreet::SendReport::EmptyHomes; + +use Moose; +use namespace::autoclean; + +BEGIN { extends 'FixMyStreet::SendReport::Email'; } + +sub build_recipient_list { + my $self = shift; + my $row = shift; + my $areas_info = shift; + my %recips; + + my $all_confirmed = 1; + foreach my $council ( keys %{ $self->councils } ) { + my $contact = FixMyStreet::App->model("DB::Contact")->find( { + deleted => 0, + area_id => $council, + category => 'Empty property', + } ); + + my ($council_email, $confirmed, $note) = ( $contact->email, $contact->confirmed, $contact->note ); + + $council_email = essex_contact($row->latitude, $row->longitude) if $council == 2225; + $council_email = oxfordshire_contact($row->latitude, $row->longitude) if $council == 2237 && $council_email eq 'SPECIAL'; + + unless ($confirmed) { + $all_confirmed = 0; + #$note = 'Council ' . $row->council . ' deleted' + #unless $note; + $council_email = 'N/A' unless $council_email; + #$notgot{$council_email}{$row->category}++; + #$note{$council_email}{$row->category} = $note; + } + + push @{ $self->to }, [ $council_email, $self->councils->{ $council } ]; + $recips{$council_email} = 1; + + my $country = $areas_info->{$council}->{country}; + if ($country eq 'W') { + $recips{ 'shelter@' . mySociety::Config::get('EMAIL_DOMAIN') } = 1; + } else { + $recips{ 'eha@' . mySociety::Config::get('EMAIL_DOMAIN') } = 1; + } + } + + return () unless $all_confirmed; + return keys %recips; +} + +1; |