my $borrower_data;
my $NoUpdateLogin;
my $userenv = C4::Context->userenv;
+my @messages;
## Deal with guarantor stuff
$template->param( relationships => scalar $patron->guarantor_relationships ) if $patron;
# FIXME Urgent error handling here, we cannot fail without relevant feedback
# Lot of code will need to be removed from this script to handle exceptions raised by Koha::Patron->store
warn "Patron creation failed! - $@"; # Maybe we must die instead of just warn
+ push @messages, {error => 'error_on_insert_patron'};
+ $op = "add";
} else {
add_guarantors( $patron, $input );
$borrowernumber = $patron->borrowernumber;
}
}
- if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {
+ if ( $patron && (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) ) {
C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'});
}
$hsbnd_chooser = 1 if $input->param('housebound_chooser');
$hsbnd_deliverer = 1 if $input->param('housebound_deliverer');
# Only create a HouseboundRole if patron has a role.
- if ( $hsbnd_chooser || $hsbnd_deliverer ) {
+ if ( $patron && ( $hsbnd_chooser || $hsbnd_deliverer ) ) {
Koha::Patron::HouseboundRole->new({
borrowernumber_id => $borrowernumber,
housebound_chooser => $hsbnd_chooser,
}
}
- if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
- $patron->extended_attributes->filter_by_branch_limitations->delete;
- $patron->extended_attributes($extended_patron_attributes);
- }
+ if ( $patron ) {
+ if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
+ $patron->extended_attributes->filter_by_branch_limitations->delete;
+ $patron->extended_attributes($extended_patron_attributes);
+ }
- if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) {
- # If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission
- $destination = 'not_circ';
+ if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) {
+ # If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission
+ $destination = 'not_circ';
+ }
+ print scalar( $destination eq "circ" )
+ ? $input->redirect(
+ "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber")
+ : $input->redirect(
+ "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"
+ );
+ exit; # You can only send 1 redirect! After that, content or other headers don't matter.
}
- print scalar( $destination eq "circ" )
- ? $input->redirect(
- "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber")
- : $input->redirect(
- "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"
- );
- exit; # You can only send 1 redirect! After that, content or other headers don't matter.
}
if ($delete){
$template->param( languages => $translated_languages );
}
+$template->param( messages => \@messages );
output_html_with_http_headers $input, $cookie, $template->output;
sub parse_extended_patron_attributes {