aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-reports
diff options
context:
space:
mode:
Diffstat (limited to 'bin/send-reports')
-rwxr-xr-xbin/send-reports22
1 files changed, 14 insertions, 8 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 8db6595a4..45927b06b 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.3 2007-02-02 11:40:02 matthew Exp $
+# $Id: send-reports,v 1.4 2007-02-02 16:17:17 matthew Exp $
use strict;
require 5.8.0;
@@ -40,28 +40,34 @@ my $unsent = dbh()->selectall_arrayref(
foreach my $row (@$unsent) {
# XXX Needs locks!
print 'Need to send problem #' . $row->{id} . ' to council ' . $row->{council} . "\n";
- my $council_email = dbh()->selectrow_array('SELECT email FROM contacts WHERE area_id=?', {}, $row->{council});
- throw Error::Simple('Missing email!') unless $council_email;
- my $area_info = mySociety::MaPit::get_voting_area_info($row->{council});
+ my @councils = split ',', $row->{council};
+ my $areas_info = mySociety::MaPit::get_voting_areas_info(\@councils);
+ my (@to, @recips);
+ foreach my $council (@councils) {
+ my $council_email = dbh()->selectrow_array('SELECT email FROM contacts WHERE area_id=?', {}, $council);
+ throw Error::Simple('Missing email!') unless $council_email;
+ push @to, [ $council_email, $areas_info->{$council}->{name} ];
+ push @recips, $council_email;
+ }
my $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/submit-council");
my %h = map { $_ => $row->{$_} } qw/title detail/;
$h{user_details} = $row->{name} . ' <' . $row->{email} . '>';
$h{user_details} .= ' (' . $row->{phone} . ')' if $row->{phone};
$h{url} = mySociety::Config::get('BASE_URL') . '/?id=' . $row->{id};
- $h{council_name} = $area_info->{name};
+ $h{councils_name} = join(' and ', map { $areas_info->{$_}->{name} } @councils);
my $email = mySociety::Email::construct_email({
_template_ => $template,
_parameters_ => \%h,
- From => [mySociety::Config::get('CONTACT_EMAIL'), 'Neighbourhood Fix-It'],
- To => [[$council_email, $area_info->{name}]],
+ From => [ mySociety::Config::get('CONTACT_EMAIL'), mySociety::Config::get('CONTACT_NAME') ],
+ To => \@to,
});
my $result;
if (mySociety::Config::get('STAGING_SITE')) {
$result = -1;
} else {
- $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $council_email);
+ $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), @recips);
}
if ($result == mySociety::Util::EMAIL_SUCCESS) {
dbh()->do('UPDATE problem SET whensent=ms_current_timestamp() WHERE id=?', {}, $row->{id});