diff options
-rwxr-xr-x | bin/send-reports | 30 | ||||
-rw-r--r-- | templates/emails/submit-brent | 4 | ||||
-rw-r--r-- | templates/emails/submit-council | 4 |
3 files changed, 22 insertions, 16 deletions
diff --git a/bin/send-reports b/bin/send-reports index 9da9b6238..3e6a7fef6 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -49,10 +49,12 @@ my $base_url = mySociety::Config::get('BASE_URL'); my $site = CronFns::site($base_url); my $query = "SELECT id, council, category, title, detail, name, email, phone, - used_map, easting, northing, (photo is not null) as has_photo, lang, + used_map, latitude, longitude, (photo is not null) as has_photo, lang, cobrand, cobrand_data - FROM problem WHERE state in ('confirmed','fixed') AND whensent IS NULL - AND council IS NOT NULL"; + FROM problem + WHERE state in ('confirmed','fixed') + AND whensent IS NULL + AND council IS NOT NULL"; my $unsent = dbh()->selectall_arrayref($query, { Slice => {} }); my (%notgot, %note); @@ -81,7 +83,7 @@ foreach my $row (@$unsent) { # Template variables for the email my $email_base_url = Cobrand::base_url_for_emails($cobrand, $cobrand_data); - my %h = map { $_ => $row->{$_} } qw/title detail name email phone category easting northing/; + my %h = map { $_ => $row->{$_} } qw/title detail name email phone category latitude longitude/; $h{url} = $email_base_url . '/report/' . $row->{id}; $h{phone_line} = $h{phone} ? _('Phone:') . " $h{phone}\n\n" : ''; if ($row->{has_photo}) { @@ -137,8 +139,8 @@ foreach my $row (@$unsent) { my ($council_email, $confirmed, $note) = dbh()->selectrow_array( "SELECT email,confirmed,note FROM contacts WHERE deleted='f' and area_id=? AND category=?", {}, $council, $row->{category}); - $council_email = essex_contact($row->{easting}, $row->{northing}) if $council == 2225; - $council_email = oxfordshire_contact($row->{easting}, $row->{northing}) if $council == 2237 && $council_email eq 'SPECIAL'; + $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' @@ -255,13 +257,19 @@ if ($verbose) { } } +sub _get_district_for_contact { + my ( $lat, $lon ) = @_; + my $district = + mySociety::MaPit::call( 'point', "4326/$lon,$lat", type => 'DIS' ); + ($district) = keys %$district; + return $district; +} + # Essex has different contact addresses depending upon the district # Might be easier if we start storing in the db all areas covered by a point # Will do for now :) sub essex_contact { - my ($E, $N) = @_; - my $district = mySociety::MaPit::call('point', "27700/$E,$N", type => 'DIS'); - ($district) = keys %$district; + my $district = _get_district_for_contact(@_); my $email; $email = 'eastarea' if $district == 2315 || $district == 2312; $email = 'midarea' if $district == 2317 || $district == 2314 || $district == 2316; @@ -273,9 +281,7 @@ sub essex_contact { # Oxfordshire has different contact addresses depending upon the district sub oxfordshire_contact { - my ($E, $N) = @_; - my $district = mySociety::MaPit::call('point', "27700/$E,$N", type => 'DIS'); - ($district) = keys %$district; + my $district = _get_district_for_contact(@_); my $email; $email = 'northernarea' if $district == 2419 || $district == 2420 || $district == 2421; $email = 'southernarea' if $district == 2417 || $district == 2418; diff --git a/templates/emails/submit-brent b/templates/emails/submit-brent index 6cb226209..a93f59fcb 100644 --- a/templates/emails/submit-brent +++ b/templates/emails/submit-brent @@ -21,9 +21,9 @@ Email: <?=$values['email']?> Details: <?=$values['detail']?> -Easting: <?=$values['easting']?> +Latitude: <?=$values['latitude']?> -Northing: <?=$values['northing']?> +Longitude: <?=$values['longitude']?> <?=$values['closest_address_machine']?>---------- diff --git a/templates/emails/submit-council b/templates/emails/submit-council index d3a4a0c64..6281e6b94 100644 --- a/templates/emails/submit-council +++ b/templates/emails/submit-council @@ -21,9 +21,9 @@ Email: <?=$values['email']?> Details: <?=$values['detail']?> -Easting: <?=$values['easting']?> +Latitude: <?=$values['latitude']?> -Northing: <?=$values['northing']?> +Longitude: <?=$values['longitude']?> <?=$values['closest_address']?>---------- |