View | Details | Raw Unified | Return to bug 25311
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+2 lines)
Lines 62-67 legend:hover { Link Here
62
                    [% SWITCH message.error %]
62
                    [% SWITCH message.error %]
63
                        [% CASE 'error_on_insert_patron' %]
63
                        [% CASE 'error_on_insert_patron' %]
64
                            <div class="dialog alert">Something went wrong when creating the patron. Check the logs.</div>
64
                            <div class="dialog alert">Something went wrong when creating the patron. Check the logs.</div>
65
                        [% CASE 'error_on_update_patron' %]
66
                            <div class="dialog alert">Something went wrong when updating the patron. Check the logs.</div>
65
                        [% CASE %]Unhandled error: [% message.error %]
67
                        [% CASE %]Unhandled error: [% message.error %]
66
                    [% END %]
68
                    [% END %]
67
                [% END %]
69
                [% END %]
(-)a/members/memberentry.pl (-42 / +53 lines)
Lines 437-442 if ( defined $sms ) { Link Here
437
$nok = $nok || scalar(@errors);
437
$nok = $nok || scalar(@errors);
438
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
438
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
439
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
439
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
440
    my $success;
440
	if ($op eq 'insert'){
441
	if ($op eq 'insert'){
441
		# we know it's not a duplicate borrowernumber or there would already be an error
442
		# we know it's not a duplicate borrowernumber or there would already be an error
442
        delete $newdata{password2};
443
        delete $newdata{password2};
Lines 448-453 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
448
            push @messages, {error => 'error_on_insert_patron'};
449
            push @messages, {error => 'error_on_insert_patron'};
449
            $op = "add";
450
            $op = "add";
450
        } else {
451
        } else {
452
            $success = 1;
451
            add_guarantors( $patron, $input );
453
            add_guarantors( $patron, $input );
452
            $borrowernumber = $patron->borrowernumber;
454
            $borrowernumber = $patron->borrowernumber;
453
            $newdata{'borrowernumber'} = $borrowernumber;
455
            $newdata{'borrowernumber'} = $borrowernumber;
Lines 507-538 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
507
509
508
    } elsif ($op eq 'save') {
510
    } elsif ($op eq 'save') {
509
511
510
        # Update or create our HouseboundRole if necessary.
511
        my $housebound_role = Koha::Patron::HouseboundRoles->find($borrowernumber);
512
        my ( $hsbnd_chooser, $hsbnd_deliverer ) = ( 0, 0 );
513
        $hsbnd_chooser = 1 if $input->param('housebound_chooser');
514
        $hsbnd_deliverer = 1 if $input->param('housebound_deliverer');
515
        if ( $housebound_role ) {
516
            if ( $hsbnd_chooser || $hsbnd_deliverer ) {
517
                # Update our HouseboundRole.
518
                $housebound_role
519
                    ->housebound_chooser($hsbnd_chooser)
520
                    ->housebound_deliverer($hsbnd_deliverer)
521
                    ->store;
522
            } else {
523
                $housebound_role->delete; # No longer needed.
524
            }
525
        } else {
526
            # Only create a HouseboundRole if patron has a role.
527
            if ( $hsbnd_chooser || $hsbnd_deliverer ) {
528
                $housebound_role = Koha::Patron::HouseboundRole->new({
529
                    borrowernumber_id    => $borrowernumber,
530
                    housebound_chooser   => $hsbnd_chooser,
531
                    housebound_deliverer => $hsbnd_deliverer,
532
                })->store;
533
            }
534
        }
535
536
        if ($NoUpdateLogin) {
512
        if ($NoUpdateLogin) {
537
            delete $newdata{'password'};
513
            delete $newdata{'password'};
538
            delete $newdata{'userid'};
514
            delete $newdata{'userid'};
Lines 542-565 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
542
        $newdata{debarredcomment} = $newdata{debarred_comment};
518
        $newdata{debarredcomment} = $newdata{debarred_comment};
543
        delete $newdata{debarred_comment};
519
        delete $newdata{debarred_comment};
544
        delete $newdata{password2};
520
        delete $newdata{password2};
545
        $patron->set(\%newdata)->store if scalar(keys %newdata) > 1; # bug 4508 - avoid crash if we're not
546
                                                                # updating any columns in the borrowers table,
547
                                                                # which can happen if we're only editing the
548
                                                                # patron attributes or messaging preferences sections
549
550
        # should never raise an exception as password validity is checked above
551
        my $password = $newdata{password};
552
        if ( $password and $password ne '****' ) {
553
            $patron->set_password({ password => $password });
554
        }
555
521
556
        add_guarantors( $patron, $input );
522
        eval {
557
        if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {
523
            $patron->set(\%newdata)->store if scalar(keys %newdata) > 1; # bug 4508 - avoid crash if we're not
558
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
524
                                                                    # updating any columns in the borrowers table,
525
                                                                    # which can happen if we're only editing the
526
                                                                    # patron attributes or messaging preferences sections
527
        };
528
        if ( $@ ) {
529
            warn "Patron modification failed! - $@"; # Maybe we must die instead of just warn
530
            push @messages, {error => 'error_on_update_patron'};
531
            $op = "modify";
532
        } else {
533
534
            $success = 1;
535
            # Update or create our HouseboundRole if necessary.
536
            my $housebound_role = Koha::Patron::HouseboundRoles->find($borrowernumber);
537
            my ( $hsbnd_chooser, $hsbnd_deliverer ) = ( 0, 0 );
538
            $hsbnd_chooser = 1 if $input->param('housebound_chooser');
539
            $hsbnd_deliverer = 1 if $input->param('housebound_deliverer');
540
            if ( $housebound_role ) {
541
                if ( $hsbnd_chooser || $hsbnd_deliverer ) {
542
                    # Update our HouseboundRole.
543
                    $housebound_role
544
                        ->housebound_chooser($hsbnd_chooser)
545
                        ->housebound_deliverer($hsbnd_deliverer)
546
                        ->store;
547
                } else {
548
                    $housebound_role->delete; # No longer needed.
549
                }
550
            } else {
551
                # Only create a HouseboundRole if patron has a role.
552
                if ( $hsbnd_chooser || $hsbnd_deliverer ) {
553
                    $housebound_role = Koha::Patron::HouseboundRole->new({
554
                        borrowernumber_id    => $borrowernumber,
555
                        housebound_chooser   => $hsbnd_chooser,
556
                        housebound_deliverer => $hsbnd_deliverer,
557
                    })->store;
558
                }
559
            }
560
561
            # should never raise an exception as password validity is checked above
562
            my $password = $newdata{password};
563
            if ( $password and $password ne '****' ) {
564
                $patron->set_password({ password => $password });
565
            }
566
567
            add_guarantors( $patron, $input );
568
            if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) {
569
                C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
570
            }
559
        }
571
        }
560
	}
572
    }
561
573
562
    if ( $patron ) {
574
    if ( $success ) {
563
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
575
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
564
            $patron->extended_attributes->filter_by_branch_limitations->delete;
576
            $patron->extended_attributes->filter_by_branch_limitations->delete;
565
            $patron->extended_attributes($extended_patron_attributes);
577
            $patron->extended_attributes($extended_patron_attributes);
566
- 

Return to bug 25311