diff --git a/perllib/FixMyStreet/App/Form/Waste/Request.pm b/perllib/FixMyStreet/App/Form/Waste/Request.pm index 55d6f5e5465..9442946bf23 100644 --- a/perllib/FixMyStreet/App/Form/Waste/Request.pm +++ b/perllib/FixMyStreet/App/Form/Waste/Request.pm @@ -62,9 +62,9 @@ sub validate { my $any = 0; foreach ($self->all_fields) { - $any = 1 if $_->name =~ /^container-/ && ($_->value || $self->saved_data->{$_->name}); - # Kingston special case for change-size-first-page - $any = 1 if $_->name eq 'how_many_exchange' && ($_->value || $self->saved_data->{$_->name}); + # Either a container-* has been selected, or + # Kingston/Merton special cases for change-size-first-page + $any = 1 if $_->name =~ /^container-|how_many_exchange|medical_condition/ && ($_->value || $self->saved_data->{$_->name}); } $self->add_form_error('Please specify what you need') unless $any; diff --git a/perllib/FixMyStreet/App/Form/Waste/Request/Merton/Larger.pm b/perllib/FixMyStreet/App/Form/Waste/Request/Merton/Larger.pm new file mode 100644 index 00000000000..536cf3ca5fa --- /dev/null +++ b/perllib/FixMyStreet/App/Form/Waste/Request/Merton/Larger.pm @@ -0,0 +1,95 @@ +package FixMyStreet::App::Form::Waste::Request::Merton::Larger; + +use utf8; +use HTML::FormHandler::Moose; +extends 'FixMyStreet::App::Form::Waste::Request'; + +use constant CONTAINER_REFUSE_240 => 2; + +has_page medical_condition => ( + fields => ['medical_condition', 'continue'], + title => 'Larger black bin request', + intro => 'request/intro.html', + next => sub { + my $data = shift; + return 'how_much' if $data->{medical_condition} eq 'Yes'; + return 'how_many'; + }, +); + +has_field medical_condition => ( + required => 1, + type => 'Select', + widget => 'RadioGroup', + label => 'Does anyone in your household have any medical condition that causes extra waste that cannot be recycled?', + options => [ + { value => 'Yes', label => 'Yes' }, + { value => 'No', label => 'No' }, + ], +); + +has_page about_you => ( + fields => ['name', 'email', 'phone', 'continue'], + intro => 'about_you.html', + title => 'About you', + next => 'summary', +); + +has_page how_much => ( + fields => ['how_much', 'continue'], + intro => 'request/intro.html', + title => 'Larger black bin request', + next => sub { + my $data = shift; + my $how_much = $data->{how_much}; + return 'how_many' if $how_much eq 'less1'; + return 'request_static' if $how_much eq '3more'; + $data->{'container-' . CONTAINER_REFUSE_240} = 1; + $data->{'quantity-' . CONTAINER_REFUSE_240} = 1; + $data->{'removal-' . CONTAINER_REFUSE_240} = 1; + return 'about_you'; + }, +); + +has_field how_much => ( + required => 1, + type => 'Select', + widget => 'RadioGroup', + label => 'How much non-hazardous, non-recyclable waste does your household produce due to medical conditions?', + options => [ + { value => 'less1', label => 'Less than 1 black sack a fortnight' }, + { value => '1or2', label => '1 or 2 black sacks a fortnight' }, + { value => '3more', label => '3 or more black sacks a fortnight' }, + ], +); + +has_page how_many => ( + fields => ['how_many', 'continue'], + title => 'Larger black bin request', + next => sub { + my $data = shift; + return 'request_static' if $data->{how_many} eq 'less5'; + $data->{'container-' . CONTAINER_REFUSE_240} = 1; + $data->{'quantity-' . CONTAINER_REFUSE_240} = 1; + $data->{'removal-' . CONTAINER_REFUSE_240} = 1; + return 'about_you'; + }, +); + +has_field how_many => ( + required => 1, + type => 'Select', + widget => 'RadioGroup', + label => 'How many people live in your home (include you)?', + options => [ + { value => 'less5', label => '1 to 4' }, + { value => '5more', label => '5 or more' }, + ], +); + +has_page request_static => ( + fields => [], + template => 'waste/request/static.html', +); + +1; diff --git a/perllib/FixMyStreet/Cobrand/Merton/Waste.pm b/perllib/FixMyStreet/Cobrand/Merton/Waste.pm index 8ef6d488f1d..c5fbcc0e7ba 100644 --- a/perllib/FixMyStreet/Cobrand/Merton/Waste.pm +++ b/perllib/FixMyStreet/Cobrand/Merton/Waste.pm @@ -7,6 +7,7 @@ with 'FixMyStreet::Roles::Cobrand::Adelante'; use FixMyStreet::App::Form::Waste::Report::Merton; use FixMyStreet::App::Form::Waste::Request::Merton; +use FixMyStreet::App::Form::Waste::Request::Merton::Larger; =over 4 @@ -260,6 +261,22 @@ sub staff_override_request_options { push @$rows, \%new_row; } +=head2 waste_munge_request_form_pages + +Larger bin request has a separate request flow + +=cut + +sub waste_munge_request_form_pages { + my ($self, $page_list, $field_list) = @_; + my $c = $self->{c}; + + if ($c->get_param('exchange')) { + $c->stash->{first_page} = 'medical_condition'; + $c->stash->{form_class} = "FixMyStreet::App::Form::Waste::Request::Merton::Larger"; + } +} + sub waste_request_form_first_next { my $self = shift; return sub { @@ -277,10 +294,16 @@ sub waste_munge_request_data { my $container = $c->stash->{containers}{$id}; my $quantity = $data->{"quantity-$id"} || 1; my $reason = $data->{request_reason} || ''; - my $nice_reason = $c->stash->{label_for_field}->($form, 'request_reason', $reason); + my $nice_reason = $c->stash->{label_for_field}->($form, 'request_reason', $reason) + if $reason; my ($action_id, $reason_id); - if ($reason eq 'damaged') { + if ($data->{medical_condition}) { # Filled in the larger form + $reason = 'change_capacity'; + $action_id = '2::1'; + $reason_id = '3::3'; + $id = '35::2'; + } elsif ($reason eq 'damaged') { $action_id = 3; # Replace $reason_id = 2; # Damaged } elsif ($reason eq 'missing') { diff --git a/t/app/controller/waste_merton.t b/t/app/controller/waste_merton.t index a5143d8378c..b0d65003b96 100644 --- a/t/app/controller/waste_merton.t +++ b/t/app/controller/waste_merton.t @@ -366,6 +366,43 @@ FixMyStreet::override_config { $mech->log_out_ok; }; + subtest 'Request larger refuse bin' => sub { + $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '35'; + $mech->get_ok('/waste/12345'); + $mech->follow_link_ok({ text => 'Request a larger refuse container' }); + $mech->submit_form_ok({ with_fields => { medical_condition => 'No' } }); + $mech->submit_form_ok({ with_fields => { how_many => 'less5' } }); + $mech->content_contains('Sorry, you are not eligible'); + $mech->back; + $mech->submit_form_ok({ with_fields => { how_many => '5more' } }); + $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); + $mech->back; + $mech->back; + $mech->back; + $mech->submit_form_ok({ with_fields => { medical_condition => 'Yes' } }); + $mech->submit_form_ok({ with_fields => { how_much => 'less1' } }); + $mech->content_contains('How many people live'); + $mech->back; + $mech->submit_form_ok({ with_fields => { how_much => '3more' } }); + $mech->content_contains('Clinical waste'); + $mech->back; + $mech->submit_form_ok({ with_fields => { how_much => '1or2' } }); + $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); + $mech->content_contains('name="goto" value="medical_condition"'); + $mech->submit_form_ok({ with_fields => { process => 'summary' } }); + $mech->content_contains('request has been sent'); + $mech->content_contains('consider your request'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->get_extra_field_value('uprn'), 1000000002; + is $report->detail, "Quantity: 1\n\n2 Example Street, Merton, KT1 1AA"; + is $report->title, 'Request exchange for Black rubbish bin (240L)'; + FixMyStreet::Script::Reports::send(); + my $req = Open311->test_req_used; + my $cgi = CGI::Simple->new($req->content); + is $cgi->param('attribute[Action]'), '2::1'; + is $cgi->param('attribute[Reason]'), '3::3'; + $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '1'; # Reset + }; subtest 'Report missed collection' => sub { $mech->get_ok('/waste/12345/report'); diff --git a/templates/web/base/waste/summary_request.html b/templates/web/base/waste/summary_request.html index 9d9c8eb79e5..d3e761cc395 100644 --- a/templates/web/base/waste/summary_request.html +++ b/templates/web/base/waste/summary_request.html @@ -2,7 +2,7 @@ title = 'Submit container request'; thing = 'container request'; summary_title = 'Container requests'; -step1 = 'request'; +step1 = first_page; %] [% BLOCK answers %] diff --git a/templates/web/merton/waste/_confirmation_after.html b/templates/web/merton/waste/_confirmation_after.html new file mode 100644 index 00000000000..a7b38420d59 --- /dev/null +++ b/templates/web/merton/waste/_confirmation_after.html @@ -0,0 +1,9 @@ +[% IF first_page == 'medical_condition' %] +
+ We will consider your request. We reserve the right to check the information given. +
+ ++ We will swap your bin for a larger one within 2 weeks, or if your request was unsuccessful we will contact you to let you know. +
+[% END %] diff --git a/templates/web/merton/waste/_more_services_sidebar.html b/templates/web/merton/waste/_more_services_sidebar.html index b20b35c2aa8..98b2cc3079c 100644 --- a/templates/web/merton/waste/_more_services_sidebar.html +++ b/templates/web/merton/waste/_more_services_sidebar.html @@ -14,6 +14,9 @@+You must not put hazardous clinical waste in your rubbish bin. This includes used syringes, and items contaminated with infectious body fluids. +
++We provide a separate service for collecting this, please see our +Clinical waste page. +
++You can put non-hazardous items in your rubbish bin, such as sanitary towels, nappies and incontinence pads (also known as sanpro waste). +
+ +[% END %] diff --git a/templates/web/merton/waste/request/static.html b/templates/web/merton/waste/request/static.html new file mode 100644 index 00000000000..78eeb8a4d47 --- /dev/null +++ b/templates/web/merton/waste/request/static.html @@ -0,0 +1,29 @@ +[% USE date(format='%Y%m%d') ~%] +[% PROCESS 'waste/header.html' %] + ++ Clinical waste +
++ Please visit our + Clinical Waste + page to find out about arranging a separate collection of your sanitary waste. +
+[% ELSIF form.saved_data.how_many == 'less5' %] ++ Sorry, you are not eligible for a larger bin +
++ If you recycle everything you can, including food waste, you should find that you have enough space in your rubbish bin. + Find out what you can recycle +
+[% END %] + +[% INCLUDE footer.html %] diff --git a/templates/web/peterborough/waste/summary_request.html b/templates/web/peterborough/waste/summary_request.html index 88327a2c97a..7e0552a27e0 100644 --- a/templates/web/peterborough/waste/summary_request.html +++ b/templates/web/peterborough/waste/summary_request.html @@ -1,18 +1,15 @@ -[% IF c.get_param('bags_only') %] - [% +[% +IF c.get_param('bags_only'); title = 'Submit food bags request'; thing = 'food bags request'; summary_title = 'Food bag requests'; - step1 = 'request'; - %] -[% ELSE %] - [% +ELSE; title = 'Submit bin request'; thing = 'bin request'; summary_title = 'Bin requests'; - step1 = 'request'; - %] -[% END %] +END; +step1 = first_page; +%] [% BLOCK answers %] [% FOR container IN data.keys.grep('^container-') %]