Skip to content

Commit

Permalink
[Waste] Add bulky missed collection reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 21, 2023
1 parent b54ea97 commit 619ea72
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 11 deletions.
13 changes: 13 additions & 0 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,19 @@ sub construct_bin_report_form {
};
}

# XXX Should we refactor bulky into the general service data (above)?
# Plus side, gets the report missed stuff built in; minus side it
# doesn't have any next/last collection stuff which is assumed
if ($c->stash->{bulky_missed}{report_allowed}) {
my $service_id = $c->stash->{bulky_missed}{service_id};
my $service_name = $c->stash->{bulky_missed}{service_name};
push @$field_list, "service-$service_id" => {
type => 'Checkbox',
label => "$service_name collection",
option_label => "$service_name collection",
};
}

$c->cobrand->call_hook("waste_munge_report_form_fields", $field_list);

return $field_list;
Expand Down
42 changes: 41 additions & 1 deletion perllib/FixMyStreet/Roles/CobrandEcho.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ sub _parse_events {

# Only care about open requests/enquiries
my $closed = $self->_closed_event($_);
next if $type ne 'missed' && $closed;
next if $type ne 'missed' && $type ne 'bulky' && $closed;
next if $type eq 'bulky' && !$closed;

if ($type eq 'request') {
my $report = $self->problems->search({ external_id => $_->{Guid} })->first;
Expand All @@ -141,6 +142,15 @@ sub _parse_events {
}
} elsif ($type eq 'missed') {
$self->parse_event_missed($_, $closed, $events);
} elsif ($type eq 'bulky') {
my $report = $self->problems->search({ external_id => $_->{Guid} })->first;
my $resolved_date = construct_bin_date($_->{ResolvedDate});
$events->{enquiry}->{$event_type} = {
date => $resolved_date,
report => $report,
resolution => $_->{ResolutionCodeId},
state => $_->{EventStateId},
};
} else { # General enquiry of some sort
$events->{enquiry}->{$event_type} = 1;
}
Expand Down Expand Up @@ -600,6 +610,36 @@ sub clear_cached_lookups_bulky_slots {
$echo->CancelReservedSlotsForEvent($guid);
}

sub bulky_check_missed_collection {
my ($self, $events, $blocked_codes) = @_;

my $cfg = $self->feature('echo');
my $service_id = $cfg->{bulky_service_id} or return;
my $event_type_id = $cfg->{bulky_event_type_id} or return;
my $event = $events->{enquiry}{$event_type_id};
return unless $event;
my $row = {
service_name => 'Bulky waste',
service_id => $service_id,
};
my $in_time = $self->within_working_days($event->{date}, 2);
foreach my $state_id (keys %$blocked_codes) {
next unless $event->{state} eq $state_id;
foreach (keys %{$blocked_codes->{$state_id}}) {
if ($event->{resolution} == $_) {
$row->{report_locked_out} = 1;
$row->{report_locked_out_reason} = $blocked_codes->{$state_id}{$_};
}
}
}
$row->{report_allowed} = $in_time && !$row->{report_locked_out};

my $missed_events = $events->{missed}->{$event_type_id} || [];
my $recent_events = $self->_events_since_date($event->{date}, $missed_events);
$row->{report_open} = $recent_events->{open} || $recent_events->{closed};
$self->{c}->stash->{bulky_missed} = $row;
}

sub find_available_bulky_slots {
my ( $self, $property, $last_earlier_date_str, $no_cache ) = @_;

Expand Down
2 changes: 2 additions & 0 deletions templates/web/base/waste/bulky/_bin_days_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@
<!-- END #06 -->
[% END %]
</div>

[% PROCESS 'waste/_service_missed.html' unit=bulky_missed no_default=1 %]
2 changes: 1 addition & 1 deletion templates/web/borsetshire/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<input type="hidden" name="service-[% unit.service_id %]" value="1">
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
</form>
[% ELSE %]
[% ELSIF NOT no_default %]
<span class="waste-service-descriptor">Please note that missed collections can only be reported within 2 working days of your scheduled collection day.</span>
[% END %]
10 changes: 8 additions & 2 deletions templates/web/brent/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
</form>
[% ELSIF unit.report_locked_out %]
<span class="waste-service-descriptor">A missed collection cannot be reported, please see the last collection status above.</span>
<span class="waste-service-descriptor">A missed collection cannot be reported;
[% IF unit.report_locked_out_reason %]
[% unit.report_locked_out_reason %]
[% ELSE %]
please see the last collection status above.
[% END %]
</span>
[% ELSIF unit.next AND unit.next.state == 'In progress' %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">A missed collection cannot be reported on the day of collection until the crew have finished their round.</span>
[% ELSE %]
[% ELSIF NOT no_default %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">Please note that missed collections can only be reported within 2 working days of your scheduled collection.</span>
[% END %]
10 changes: 8 additions & 2 deletions templates/web/bromley/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
</form>
[% ELSIF unit.report_locked_out %]
<span class="waste-service-descriptor">A missed collection cannot be reported, please see the last collection status above.</span>
[% ELSE %]
<span class="waste-service-descriptor">A missed collection cannot be reported;
[% IF unit.report_locked_out_reason %]
[% unit.report_locked_out_reason %]
[% ELSE %]
please see the last collection status above.
[% END %]
</span>
[% ELSIF NOT no_default %]
[% IF unit.garden_overdue AND unit.garden_waste AND NOT waste_features.garden_renew_disabled %]
<div class="govuk-warning-text overdue">
<div class="govuk-warning-text__img">
Expand Down
10 changes: 8 additions & 2 deletions templates/web/kingston/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
</form>
[% ELSIF unit.report_locked_out %]
<span class="waste-service-descriptor">A missed collection cannot be reported, please see the last collection status above.</span>
<span class="waste-service-descriptor">A missed collection cannot be reported;
[% IF unit.report_locked_out_reason %]
[% unit.report_locked_out_reason %]
[% ELSE %]
please see the last collection status above.
[% END %]
</span>
[% ELSIF unit.next AND unit.next.state == 'In progress' %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">A missed collection cannot be reported on the day of collection until the crew have finished their round.</span>
[% ELSE %]
[% ELSIF NOT no_default %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">Please note that missed collections can only be reported after the collection on your street was completed and for 2 working days after your scheduled collection.</span>
[% END %]
2 changes: 1 addition & 1 deletion templates/web/peterborough/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
[% END %]
</form>
[% ELSE %]
[% ELSIF NOT no_default %]
[% IF unit.next AND unit.next.date.ymd == date.format(date.now, "%Y-%m-%d") %]
<span class="waste-service-descriptor">The crew have not recorded your street as complete and may still be planning to attend. You will not be able to report a missed bin at this time.</span>
[% ELSE %]
Expand Down
10 changes: 8 additions & 2 deletions templates/web/sutton/waste/_service_missed.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
<input type="submit" value="Report a [% unit.service_name FILTER lower %] collection as missed" class="waste-service-descriptor waste-service-link">
</form>
[% ELSIF unit.report_locked_out %]
<span class="waste-service-descriptor">A missed collection cannot be reported, please see the last collection status above.</span>
<span class="waste-service-descriptor">A missed collection cannot be reported;
[% IF unit.report_locked_out_reason %]
[% unit.report_locked_out_reason %]
[% ELSE %]
please see the last collection status above.
[% END %]
</span>
[% ELSIF unit.next AND unit.next.state == 'In progress' %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">A missed collection cannot be reported on the day of collection until the crew have finished their round.</span>
[% ELSE %]
[% ELSIF NOT no_default %]
<span class="waste-service-descriptor" style="margin-top: 1.5em;">Please note that missed collections can only be reported after 6pm on your collection day and for 2 working days after your collection.</span>
[% END %]

0 comments on commit 619ea72

Please sign in to comment.