diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index fa514eb369..89bf5b16d1 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -241,30 +241,46 @@ if ( $backends_available ) { batches => $batches ); } else { - # Commit: - # Save the changes - $request->borrowernumber($params->{borrowernumber}); - $request->biblio_id($params->{biblio_id}); - $request->batch_id($params->{batch_id}); - $request->branchcode($params->{branchcode}); - $request->price_paid($params->{price_paid}); - $request->notesopac($params->{notesopac}); - $request->notesstaff($params->{notesstaff}); - my $alias = (length $params->{status_alias} > 0) ? - $params->{status_alias} : - "-1"; - $request->status_alias($alias); - $request->store; - my $backend_result = { - error => 0, - status => '', - message => '', - op => 'edit_action', - stage => 'commit', - next => 'illlist', - value => {} - }; - handle_commit_maybe($backend_result, $request); + my $valid_patron = Koha::Patrons->find( $params->{borrowernumber} ); + my $valid_biblio = Koha::Biblios->find( $params->{biblio_id} ); + + if ( $params->{borrowernumber} && !$valid_patron || $params->{biblio_id} && !$valid_biblio ){ + my $error_result = { + error => 1, + status => $params->{borrowernumber} && !$valid_patron ? 'invalid_patron' : 'invalid_biblio', + op => 'edit_action', + stage => 'init', + next => 'illview', + }; + $template->param( + whole => $error_result, + request => $request, + ); + }else{ + $request->borrowernumber( $params->{borrowernumber} ); + $request->biblio_id( $params->{biblio_id} ); + $request->batch_id( $params->{batch_id} ); + $request->branchcode( $params->{branchcode} ); + $request->price_paid( $params->{price_paid} ); + $request->notesopac( $params->{notesopac} ); + $request->notesstaff( $params->{notesstaff} ); + my $alias = + ( length $params->{status_alias} > 0 ) + ? $params->{status_alias} + : "-1"; + $request->status_alias($alias); + $request->store; + my $backend_result = { + error => 0, + status => '', + message => '', + op => 'edit_action', + stage => 'commit', + next => 'illlist', + value => {} + }; + handle_commit_maybe( $backend_result, $request ); + } } } elsif ( $op eq 'moderate_action' ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 0c5babe9ae..49ee2e8267 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -136,7 +136,14 @@
We encountered an error:
-
[% whole.message | html %] ([% whole.status | html %])+ [% SWITCH whole.status %] + [% CASE 'invalid_patron' %] +
The patron ID you entered is invalid.+ [% CASE 'invalid_biblio' %] +
The bibliographic record ID you entered is invalid.+ [% CASE %] +
[% whole.message | html %] ([% whole.status | html %])+ [% END %] [% END %]