[% END %]
[% END %]
</h1>
+ [% FOR m IN messages %]
+ <div class="alert alert-[% m.type %]">
+ [% SWITCH m.code %]
+ [% CASE 'already_exists' %]
+ The suggestion has not been inserted. The same suggestion already exists.
+ [% CASE 'success_on_inserted' %]
+ Your suggestion has been submitted.
+ [% CASE %]
+ [% m.code %]
+ [% END %]
+ </div>
+ [% END %]
[% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
- [% IF ( submitted ) %]<div class="alert alert-info">Your suggestion has been submitted.</div>[% END %]
[% IF ( suggestions_loop ) %]
[% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
delete $$suggestion{$_} foreach qw<op suggestedbyme>;
$op = 'else' unless $op;
-my ( $template, $borrowernumber, $cookie );
+my ( $template, $borrowernumber, $cookie, @messages );
my $deleted = $input->param('deleted');
my $submitted = $input->param('submitted');
if ( $op eq "add_confirm" ) {
if (@$suggestions_loop>=1){
#some suggestion are answering the request Donot Add
+ for my $suggestion ( @$suggestions_loop ) {
+ push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
+ last;
+ }
}
else {
my $scrubber = C4::Scrubber->new();
$$suggestion{$_}='' foreach qw<title author publishercode copyrightdate place collectiontitle isbn STATUS>;
$suggestions_loop =
&SearchSuggestion( $suggestion );
+ push @messages, { type => 'info', code => 'success_on_inserted' };
}
- $op = 'else';
- print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&submitted=1");
- exit;
+ $op = 'else';
}
if ( $op eq "delete_confirm" ) {
&DelSuggestion( $borrowernumber, $delete_field );
}
$op = 'else';
- print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else&deleted=1");
+ print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else");
exit;
}
map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop;
patron_reason_loop => $patron_reason_loop,
showall => $allsuggestions,
"op_$op" => 1,
+ $op => 1,
+ messages => \@messages,
suggestionsview => 1,
);