aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/send-reports17
-rw-r--r--conf/general-example8
-rw-r--r--templates/emails/submit-council13
3 files changed, 26 insertions, 12 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 2f5902842..92b40eec4 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.19 2007-03-09 12:12:43 matthew Exp $
+# $Id: send-reports,v 1.20 2007-03-19 10:03:25 matthew Exp $
use strict;
require 5.8.0;
@@ -34,15 +34,18 @@ BEGIN {
);
}
+use mySociety::Dress;
+
die "No arguments or specify --nomail" if (@ARGV>1);
my $nomail = 0;
$nomail = 1 if (@ARGV==1 && $ARGV[0] eq '--nomail');
my %notgot;
my $unsent = dbh()->selectall_arrayref(
- "SELECT id, council, title, detail, name, email, phone, used_map
+ "SELECT id, council, title, detail, name, email, phone, used_map, easting, northing
FROM problem WHERE state in ('confirmed','fixed') AND whensent IS NULL
AND council IS NOT NULL", { Slice => {} });
+
foreach my $row (@$unsent) {
# XXX Needs locks!
my @councils = split ',', $row->{council};
@@ -72,15 +75,17 @@ foreach my $row (@$unsent) {
push @recips, mySociety::Config::get('CONTACT_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};
+ my %h = map { $_ => $row->{$_} } qw/title detail name email phone/;
+ $h{phone} = "Phone: $h{phone}\n\n" if $h{phone};
$h{url} = mySociety::Config::get('BASE_URL') . '/?id=' . $row->{id};
$h{councils_name} = join(' and ', map { $areas_info->{$_}->{name} } @councils);
$h{fuzzy} = $row->{used_map} ? 'To view a map of the precise location of this issue'
: 'The user could not locate the problem on a map, but to see the area around the location they entered';
$h{multiple} = @councils>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{closest_address} = mySociety::Dress::find_nearest($row->{easting}, $row->{northing});
+ $h{closest_address} = "The closest address to the location of this problem is: $h{closest_address}\n\n"
+ if ($h{closest_address});
my $email = mySociety::Email::construct_email({
_template_ => $template,
_parameters_ => \%h,
@@ -102,7 +107,7 @@ foreach my $row (@$unsent) {
}
}
-print "Council email addresses that need checking:\n ";
+print "Council email addresses that need checking:\n";
foreach (keys %notgot) {
print $notgot{$_} . ' ' . $_ . "\n";
}
diff --git a/conf/general-example b/conf/general-example
index f531a042a..ab7bf650e 100644
--- a/conf/general-example
+++ b/conf/general-example
@@ -14,7 +14,7 @@
* Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
* Email: francis@mysociety.org; WWW: http://www.mysociety.org
*
- * $Id: general-example,v 1.8 2007-02-08 18:36:02 matthew Exp $
+ * $Id: general-example,v 1.9 2007-03-19 10:03:25 matthew Exp $
*
*/
@@ -25,6 +25,12 @@ define('OPTION_BCI_DB_NAME', 'bci');
define('OPTION_BCI_DB_USER', 'bci');
define('OPTION_BCI_DB_PASS', '');
+define('OPTION_DRESS_DB_HOST', 'localhost');
+define('OPTION_DRESS_DB_PORT', '5432');
+define('OPTION_DRESS_DB_NAME', 'dress');
+define('OPTION_DRESS_DB_USER', 'dress');
+define('OPTION_DRESS_DB_PASS', '');
+
define('OPTION_BASE_URL', 'http://www.example.org');
define('OPTION_CONTACT_EMAIL', 'team@example.org');
define('OPTION_CONTACT_NAME', 'Neighbourhood Fix-It');
diff --git a/templates/emails/submit-council b/templates/emails/submit-council
index f839d0464..e489f8b91 100644
--- a/templates/emails/submit-council
+++ b/templates/emails/submit-council
@@ -2,8 +2,7 @@ Subject: Problem Report: <?=$values['title']?>
Dear <?=$values['councils_name']?>,
-<?=$values['multiple']?>A user
-of Neighbourhood Fix-It, <?=$values['user_details']?>,
+<?=$values['multiple']?>A user of Neighbourhood Fix-It
has submitted the following report of a local problem that
they believe might require your attention.
@@ -14,11 +13,15 @@ please visit the following link:
----------
-<?=$values['title']?>
+Name: <?=$values['name']?>
-<?=$values['detail']?>
+Email: <?=$values['email']?>
-----------
+<?=$values['phone']?>Subject: <?=$values['title']?>
+
+Details: <?=$values['detail']?>
+
+<?=$values['closest_address']?>----------
Replies to this email will go to the user who submitted the problem.