aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-reports
diff options
context:
space:
mode:
Diffstat (limited to 'bin/send-reports')
-rwxr-xr-xbin/send-reports18
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/send-reports b/bin/send-reports
index c4f632ec7..9af93f54a 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: send-reports,v 1.25 2007-03-21 16:38:40 matthew Exp $
+# $Id: send-reports,v 1.26 2007-03-21 21:53:51 matthew Exp $
use strict;
require 5.8.0;
@@ -49,13 +49,16 @@ my $unsent = dbh()->selectall_arrayref(
foreach my $row (@$unsent) {
# XXX Needs locks!
- my @councils = split ',', $row->{council};
- my $areas_info = mySociety::MaPit::get_voting_areas_info(\@councils);
+ my @all_councils = split /,\|/, $row->{council};
+ my ($councils, $missing) = $row->{council} =~ /^([\d,]+)(?:\|([\d,]+))?/;
+ my @councils = split /,/, $councils;
+ my @missing = split /,/, $missing;
+ my $areas_info = mySociety::MaPit::get_voting_areas_info(\@all_councils);
my (@to, @dear, %recips);
my $all_confirmed = 1;
foreach my $council (@councils) {
my $name = $areas_info->{$council}->{name};
- my ($council_email,$confirmed) = dbh()->selectrow_array(
+ my ($council_email, $confirmed) = dbh()->selectrow_array(
"SELECT email,confirmed FROM contacts WHERE deleted='f'
and area_id=? AND category=?", {}, $council, $row->{category});
next unless $council_email; # Ignore missing councils, or non-responsible councils
@@ -93,6 +96,13 @@ foreach my $row (@$unsent) {
: 'The user could not locate the problem on a map, but to see the area around the location they entered';
$h{multiple} = @dear>1 ? "This email has been sent to both councils covering the location of the problem; please ignore it if you're not the correct council to deal with the issue.\n\n"
: '';
+ $h{missing} = '';
+ if ($missing) {
+ my $name = $areas_info->{$missing}->{name};
+ $h{missing} = 'We realise this problem might be the responsibility of ' . $name
+ . "; however, we don't have any contact details for them. If you know of an
+ appropriate contact address, please get in touch.\n\n";
+ }
$h{closest_address} = '';
my ($address, $distance) = mySociety::Dress::find_nearest($row->{easting}, $row->{northing});