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

Return to bug 25311