diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm index 1e6e89ebe0d..62d2172871b 100644 --- a/perllib/FixMyStreet/App/Controller/Waste.pm +++ b/perllib/FixMyStreet/App/Controller/Waste.pm @@ -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; diff --git a/perllib/FixMyStreet/Roles/CobrandEcho.pm b/perllib/FixMyStreet/Roles/CobrandEcho.pm index dd6b0a34982..db5dc4e374b 100644 --- a/perllib/FixMyStreet/Roles/CobrandEcho.pm +++ b/perllib/FixMyStreet/Roles/CobrandEcho.pm @@ -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; @@ -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; } @@ -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 ) = @_; diff --git a/templates/web/base/waste/bulky/_bin_days_list.html b/templates/web/base/waste/bulky/_bin_days_list.html index a26c55d0574..0d23f31f9c8 100644 --- a/templates/web/base/waste/bulky/_bin_days_list.html +++ b/templates/web/base/waste/bulky/_bin_days_list.html @@ -85,3 +85,5 @@ [% END %] + +[% PROCESS 'waste/_service_missed.html' unit=bulky_missed no_default=1 %] diff --git a/templates/web/borsetshire/waste/_service_missed.html b/templates/web/borsetshire/waste/_service_missed.html index 3e2bcfed01e..a4dd7da15ff 100644 --- a/templates/web/borsetshire/waste/_service_missed.html +++ b/templates/web/borsetshire/waste/_service_missed.html @@ -10,6 +10,6 @@ -[% ELSE %] +[% ELSIF NOT no_default %] Please note that missed collections can only be reported within 2 working days of your scheduled collection day. [% END %] diff --git a/templates/web/brent/waste/_service_missed.html b/templates/web/brent/waste/_service_missed.html index 057aa6b0f16..8d875f681a0 100644 --- a/templates/web/brent/waste/_service_missed.html +++ b/templates/web/brent/waste/_service_missed.html @@ -11,9 +11,15 @@ [% ELSIF unit.report_locked_out %] - A missed collection cannot be reported, please see the last collection status above. + 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 %] + [% ELSIF unit.next AND unit.next.state == 'In progress' %] A missed collection cannot be reported on the day of collection until the crew have finished their round. -[% ELSE %] +[% ELSIF NOT no_default %] Please note that missed collections can only be reported within 2 working days of your scheduled collection. [% END %] diff --git a/templates/web/bromley/waste/_service_missed.html b/templates/web/bromley/waste/_service_missed.html index f2a4600c744..1abd495330f 100644 --- a/templates/web/bromley/waste/_service_missed.html +++ b/templates/web/bromley/waste/_service_missed.html @@ -11,8 +11,14 @@ [% ELSIF unit.report_locked_out %] - A missed collection cannot be reported, please see the last collection status above. -[% ELSE %] + 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 %] + +[% ELSIF NOT no_default %] [% IF unit.garden_overdue AND unit.garden_waste AND NOT waste_features.garden_renew_disabled %]