+
+ if ( $suggestion_only->{"STATUS"} ) {
+ if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
+ $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
+ $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number};
+ }
+ $suggestion_only->{manageddate} = dt_from_string;
+ $suggestion_only->{"managedby"} = C4::Context->userenv->{number};
+ }
+
+ my $otherreason = $input->param('other_reason');
+ if ($suggestion_only->{reason} eq 'other' && $otherreason) {
+ $suggestion_only->{reason} = $otherreason;
+ }
+
+ if ( $suggestion_only->{'suggestionid'} > 0 ) {
+ &ModSuggestion($suggestion_only);
+ } else {
+ ###FIXME:Search here if suggestion already exists.
+ my $suggestions_loop =
+ SearchSuggestion( $suggestion_only );
+ if (@$suggestions_loop>=1){
+ #some suggestion are answering the request Donot Add
+ my @messages;
+ for my $suggestion ( @$suggestions_loop ) {
+ push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
+ }
+ $template->param( messages => \@messages );
+ }
+ else {
+ ## Adding some informations related to suggestion
+ &NewSuggestion($suggestion_only);
+ }
+ # empty fields, to avoid filter in "SearchSuggestion"
+ }
+ map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
+ $op = 'else';
+
+ if( $redirect eq 'purchase_suggestions' ) {
+ print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
+ }
+ }