diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index b1f1701ddc..c9e98cf3c2 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -38,12 +38,26 @@ use Koha::DateUtils; my $input = CGI->new; my $op = $input->param('op') || 'else'; my $biblionumber = $input->param('biblionumber'); -my $suggestion = $input->Vars; my $negcaptcha = $input->param('negcap'); my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0; my $title_filter = $input->param('title_filter'); my $need_confirm = 0; +my $suggestion = { + title => scalar $input->param('title'), + author => scalar $input->param('author'), + copyrightdate => scalar $input->param('copyrightdate'), + isbn => scalar $input->param('isbn'), + publishercode => scalar $input->param('publishercode'), + collectiontitle => scalar $input->param('collectiontitle'), + place => scalar $input->param('place'), + quantity => scalar $input->param('quantity'), + itemtype => scalar $input->param('itemtype'), + branchcode => scalar $input->param('branchcode'), + patronreason => scalar $input->param('patronreason'), + note => scalar $input->param('note'), +}; + # If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return. if ($negcaptcha ) { print $input->redirect("/cgi-bin/koha/opac-suggestions.pl"); @@ -80,11 +94,6 @@ else { ); } -# don't pass 'negcap' column to DB, else DBI::Class will error -# DBIx::Class::Row::store_column(): No such column 'negcap' on Koha::Schema::Result::Suggestion at Koha/C4/Suggestions.pm -delete $suggestion->{negcap}; -delete $suggestion->{$_} foreach qw; - if ( $op eq 'else' ) { if ( C4::Context->preference("OPACViewOthersSuggestions") ) { if ( $borrowernumber ) { @@ -152,12 +161,12 @@ if ( $op eq "add_confirm" ) { elsif ( @$suggestions_loop >= 1 ) { #some suggestion are answering the request Donot Add - for my $suggestion (@$suggestions_loop) { + for my $s (@$suggestions_loop) { push @messages, { type => 'error', code => 'already_exists', - id => $suggestion->{suggestionid} + id => $s->{suggestionid} }; last; } @@ -172,6 +181,7 @@ if ( $op eq "add_confirm" ) { } $suggestion->{suggesteddate} = dt_from_string; $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"}; + $suggestion->{STATUS} = 'ASKED'; &NewSuggestion($suggestion); $patrons_pending_suggestions_count++;