-my $suggestions_loop= &searchsuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
-$template->param(suggestions_loop => $suggestions_loop,
- title => $title,
- author => $author,
- publishercode => $publishercode,
- status => $status,
- suggestedbyme => $suggestedbyme,
- "op_$op" => 1,
+if ( $op eq "delete_confirm" ) {
+ my @delete_field = $input->param("delete_field");
+ foreach my $delete_field (@delete_field) {
+ &DelSuggestion( $borrowernumber, $delete_field );
+ }
+ $op = 'else';
+ print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
+ exit;
+}
+map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
+my $supportlist=GetSupportList();
+foreach my $support(@$supportlist){
+ if ($$support{'imageurl'}){
+ $$support{'imageurl'}= getitemtypeimagelocation( 'opac', $$support{'imageurl'} );
+ }
+ else {
+ delete $$support{'imageurl'}
+ }
+}
+
+foreach my $suggestion(@$suggestions_loop) {
+ if($suggestion->{'suggestedby'} == $borrowernumber) {
+ $suggestion->{'showcheckbox'} = $borrowernumber;
+ } else {
+ $suggestion->{'showcheckbox'} = 0;
+ }
+ if($suggestion->{'patronreason'}){
+ $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
+ }
+}
+
+my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
+
+# Is the person allowed to choose their branch
+if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
+ my ( $borr ) = GetMemberDetails( $borrowernumber );
+
+# pass the pickup branch along....
+ my $userbranch = '';
+ if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
+ }
+ my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
+
+# make branch selection options...
+ my $branchloop = GetBranchesLoop($branch);
+ $template->param( branchloop => $branchloop );
+}
+
+$template->param(
+ %$suggestion,
+ itemtypeloop=> $supportlist,
+ suggestions_loop => $suggestions_loop,
+ patron_reason_loop => $patron_reason_loop,
+ showall => $allsuggestions,
+ "op_$op" => 1,
+ suggestionsview => 1,