Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions perllib/FixMyStreet/App/Form/Waste/Enquiry/Bromley.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package FixMyStreet::App::Form::Waste::Enquiry::Bromley;

use utf8;
use HTML::FormHandler::Moose;
extends 'FixMyStreet::App::Form::Waste::Enquiry';

has_page missed_collection_intro => (
title => 'Missed collection',
intro => 'enquiry_missed_intro.html',
fields => [],
);

has_page missed_collection_intro_not_presented => (
title => 'Missed collection',
intro => 'enquiry_missed_intro.html',
fields => ['continue'],
next => 'missed_collection_declaration'
);

has_page missed_collection_declaration => (
title => 'Missed collection',
intro => 'enquiry_missed_declaration.html',
fields => ['declaration', 'warning', 'continue'],
next => 'enquiry',
);

# Any field not on a page gets shown on all pages. We have this dummy page so
# that the notice fields are only shown if manually added by the cobrand code
has_page notices => (
fields => ['bromley_missed_notice_not_presented', 'bromley_missed_notice'],
);

has_field bromley_missed_notice_not_presented => (
widget => 'NoRender',
required => 0,
type => 'Notice',
order => -1,
build_label_method => sub {
my $self = shift;
my $service_id = $self->parent->{c}->get_param('service_id');
return "Do not use this form to report a missed collection. Instead, please <a href='enquiry?category=Return+request&amp;service_id=$service_id'>Report a missed collection</a>";
},
);

has_field bromley_missed_notice => (
widget => 'NoRender',
required => 0,
type => 'Notice',
order => -1,
build_label_method => sub {
my $self = shift;
my $service_id = $self->parent->{c}->get_param('service_id');
return "We cannot accept missed collection reports through this form. If you believe you are eligible for re-collection, please visit <a href='enquiry?category=Return+request&amp;service_id=$service_id'>My bin was not collected</a>";
},
);

has_field declaration => (
type => 'Multiple',
widget => 'CheckboxGroup',
label => 'To request a missed collection, please confirm the following:',
required => 1,
options => [
{ label => 'My rubbish was presented before 7am', value => '7am' },
{ label => 'My bin was presented within arm’s reach of the pavement', value => 'arm' },
],
validate_method => sub {
my $self = shift;
my $vals = $self->value;
$self->add_error('Please confirm all options') if @$vals < 2;
},
);

has_field warning => (
widget => 'NoRender',
required => 0,
type => 'Notice',
label => '<strong>Please note all our waste and recycling vehicles are fitted with CCTV and disputed missed collections may be investigated before the collection teams are instructed to return.</strong>',
);

1;
89 changes: 89 additions & 0 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use Hash::Util qw(lock_hash);
use Integrations::Echo;
use BromleyParks;
use FixMyStreet::App::Form::Waste::Request::Bromley;
use FixMyStreet::App::Form::Waste::Enquiry::Bromley;
use FixMyStreet::DB;
use Moo;
use WasteWorks::Costs;
Expand Down Expand Up @@ -56,6 +57,7 @@ my %EVENT_TYPE_IDS = (
request => 2104,
bulky => 2175,
garden => 2106,
return_request => 3240,
);
lock_hash(%EVENT_TYPE_IDS);

Expand All @@ -69,9 +71,26 @@ my %ALLOW_CLOSED_EVENT_TYPE_IDS = (
2162 => 'crew_behaviour',
2163 => 'damage_to_property',
2186 => 'wrongful_removal',
3240 => 'return_request',
);
lock_hash(%ALLOW_CLOSED_EVENT_TYPE_IDS);

my %RESOLUTION_CODES = (
33 => 'contaminated', # Contaminated
66 => 'not-presented',
522 => 'contaminated', # Con - Paper & Card
523 => 'contaminated', # Con - Food
524 => 'contaminated', # Con - Textiles
525 => 'contaminated', # Con - Tetra Pack
526 => 'contaminated', # Con - Electrical Items
527 => 'contaminated', # Con - Nappies
528 => 'contaminated', # Con - Rigid Plastics
529 => 'contaminated', # Con - Other
674 => 'contaminated', # Con - Refuse
802 => 'contaminated', # Con - Clinical
);
lock_hash(%RESOLUTION_CODES);

sub report_validation {
my ($self, $report, $errors) = @_;

Expand Down Expand Up @@ -458,6 +477,21 @@ Ingore any updates from Echo that aren't New/Completed and don't have a resoluti
sub open311_waste_update_extra {
my ($self, $cfg, $event) = @_;

my $esc;
if ($event->{EventTypeId} == $EVENT_TYPE_IDS{return_request}) {
# Could have got here with a full event (pull) or subset (push)
if (!$event->{Data}) {
$event = $cfg->{echo}->GetEvent($event->{Guid});
}
my $data = Integrations::Echo::force_arrayref($event->{Data}, 'ExtensibleDatum');
foreach (@$data) {
if ($_->{DatatypeName} eq 'Investigation Outcome') {
$esc = 'Approved' if $_->{Value} == 1;
$esc = 'Declined' if $_->{Value} == 2;
}
}
}

my $override_status;
my $event_type = $cfg->{event_types}{$event->{EventTypeId}};
my $state_id = $event->{EventStateId};
Expand All @@ -472,6 +506,7 @@ sub open311_waste_update_extra {

return (
defined $override_status ? (status => $override_status ) : (),
defined $esc ? (external_status_code => $esc) : (),
);
}

Expand Down Expand Up @@ -957,6 +992,60 @@ sub waste_munge_report_data {
$self->_set_user_source;
}


=head2 waste_munge_enquiry_form_pages

We are using an enquiry form to report a disputed missed collection.

So we add an extra page to inform whether a dispute can be raised and an extra page
for the user to confirm they would like to raise a dispute with a declaration
their container was correctly placed, which they only reach
if they they are able to dispute the missed collection

=cut

sub return_request_option {
my $self = shift;
my $c = $self->{c};

my $service_id = $c->get_param('service_id');
my $service = $c->stash->{services}{$service_id};
my $last = $service->{last};
my $next = $service->{next};
my $next_state = $next->{state} || '';

return 'too-late' unless $service->{report_within_time};

my $resolution_id = $last->{resolution_id} || 0;
return $RESOLUTION_CODES{$resolution_id} if exists $RESOLUTION_CODES{$resolution_id};
return '';
}

sub waste_munge_enquiry_form_pages {
my ($self, $pages, $fields) = @_;
my $c = $self->{c};
my $category = $c->get_param('category');
my $reason = $self->return_request_option;

$c->stash->{form_class} = 'FixMyStreet::App::Form::Waste::Enquiry::Bromley';

if ($category eq 'Return request') {
# If we have a reason, we need to start with a special page
if ($reason eq 'not-presented') {
$c->stash->{first_page} = 'missed_collection_intro_not_presented';
} elsif ($reason eq 'contaminated' || $reason eq 'too-late') {
$c->stash->{first_page} = 'missed_collection_intro';
}
} elsif ($category eq 'General Enquiry') {
# If we have a reason, add a notice to the start of the Other form
if ($reason eq 'not-presented') {
unshift @{$pages->[1]{fields}}, 'bromley_missed_notice_not_presented';
} elsif ($reason eq 'contaminated' || $reason eq 'too-late') {
unshift @{$pages->[1]{fields}}, 'bromley_missed_notice';
}
}
}

sub waste_munge_enquiry_data {
my ($self, $data) = @_;

Expand Down
5 changes: 4 additions & 1 deletion perllib/FixMyStreet/Roles/Cobrand/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ sub bin_services_for_address {
my $ref = join(',', @{$row->{last}{ref}});
$task_ref_to_row{$ref} = $row;

$row->{report_allowed} = $self->within_working_days($row->{last}{date}, 2);
my $within = $self->within_working_days($row->{last}{date}, 2);
$row->{report_within_time} = $within;
$row->{report_allowed} = $within; # This may be overridden by task resolutions

my $events_unit = $self->_parse_events($calls->{"GetEventsForObject ServiceUnit $_->{Id}"});
$row->{events} = $events->combine($events_unit)->filter({ service => $service_id, since => $row->{last}{date} });
Expand Down Expand Up @@ -581,6 +583,7 @@ sub waste_task_resolutions {
$row->{last}{state} = $state unless $state eq 'Completed' || $state eq 'Not Completed' || $state eq 'Outstanding' || $state eq 'Allocated';
$row->{last}{completed} = $completed;
$row->{last}{resolution} = $resolution;
$row->{last}{resolution_id} = $resolution_id;

# Special handling if last instance is today e.g. if it's before a
# particular hour and outstanding, show it as in progress
Expand Down
Loading