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

(-)a/Koha/Patron.pm (+45 lines)
Lines 1053-1058 sub generate_userid { Link Here
1053
1053
1054
}
1054
}
1055
1055
1056
1057
=head3 add_guarantor
1058
1059
    my @relationships = $patron->add_guarantor(
1060
        {
1061
            borrowernumber => $borrowernumber,
1062
            surname        => $surname,
1063
            firstname      => $firstname,
1064
            relationships  => $relationship,
1065
        }
1066
    );
1067
1068
    Adds a new guarantor to a patron, requires either an id ( borrowernumber ) or surname.
1069
1070
=cut
1071
1072
sub add_guarantor {
1073
    my ( $self, $params ) = @_;
1074
1075
    my $guarantor_id = $params->{guarantor_id};
1076
    my $surname      = $params->{surname};
1077
    my $firstname    = $params->{firstname};
1078
    my $relationship = $params->{relationship};
1079
1080
    if ($guarantor_id) {
1081
        return Koha::Patron::Relationship->new(
1082
            {
1083
                guarantee_id => $self->id,
1084
                guarantor_id => $guarantor_id,
1085
                relationship => $relationship
1086
            }
1087
        )->store();
1088
    }
1089
    elsif ($surname) {
1090
        return Koha::Patron::Relationship->new(
1091
            {
1092
                guarantee_id => $self->id,
1093
                surname      => $surname,
1094
                firstname    => $firstname,
1095
                relationship => $relationship
1096
            }
1097
        )->store();
1098
    }
1099
}
1100
1056
=head2 Internal methods
1101
=head2 Internal methods
1057
1102
1058
=head3 _type
1103
=head3 _type
(-)a/members/memberentry.pl (-23 / +13 lines)
Lines 414-420 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
414
	if ($op eq 'insert'){
414
	if ($op eq 'insert'){
415
		# we know it's not a duplicate borrowernumber or there would already be an error
415
		# we know it's not a duplicate borrowernumber or there would already be an error
416
        $borrowernumber = &AddMember(%newdata);
416
        $borrowernumber = &AddMember(%newdata);
417
        add_guarantors( $borrowernumber, $input );
417
        $patron = Koha::Patrons->find( $borrowernumber );
418
        add_guarantors( $patron, $input );
418
        $newdata{'borrowernumber'} = $borrowernumber;
419
        $newdata{'borrowernumber'} = $borrowernumber;
419
420
420
        # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
421
        # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
Lines 512-518 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
512
                                                                # updating any columns in the borrowers table,
513
                                                                # updating any columns in the borrowers table,
513
                                                                # which can happen if we're only editing the
514
                                                                # which can happen if we're only editing the
514
                                                                # patron attributes or messaging preferences sections
515
                                                                # patron attributes or messaging preferences sections
515
        add_guarantors( $borrowernumber, $input );
516
        add_guarantors( $patron, $input );
516
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
517
        if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
517
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
518
            C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
518
        }
519
        }
Lines 892-898 sub patron_attributes_form { Link Here
892
}
893
}
893
894
894
sub add_guarantors {
895
sub add_guarantors {
895
    my ( $borrowernumber, $input ) = @_;
896
    my ( $patron, $input ) = @_;
896
897
897
    my @new_guarantor_id           = $input->multi_param('new_guarantor_id');
898
    my @new_guarantor_id           = $input->multi_param('new_guarantor_id');
898
    my @new_guarantor_surname      = $input->multi_param('new_guarantor_surname');
899
    my @new_guarantor_surname      = $input->multi_param('new_guarantor_surname');
Lines 905-929 sub add_guarantors { Link Here
905
        my $firstname    = $new_guarantor_firstname[$i];
906
        my $firstname    = $new_guarantor_firstname[$i];
906
        my $relationship = $new_guarantor_relationship[$i];
907
        my $relationship = $new_guarantor_relationship[$i];
907
908
908
        if ($guarantor_id) {
909
        $patron->add_guarantor(
909
            Koha::Patron::Relationship->new(
910
            {
910
                {
911
                guarantee_id => $patron->id,
911
                    guarantee_id => $borrowernumber,
912
                guarantor_id => $guarantor_id,
912
                    guarantor_id => $guarantor_id,
913
                surname      => $surname,
913
                    relationship => $relationship
914
                firstname    => $firstname,
914
                }
915
                relationship => $relationship
915
            )->store();
916
            }
916
        }
917
        );
917
        elsif ($surname) {
918
            Koha::Patron::Relationship->new(
919
                {
920
                    guarantee_id => $borrowernumber,
921
                    surname      => $surname,
922
                    firstname    => $firstname,
923
                    relationship => $relationship
924
                }
925
            )->store();
926
        }
927
    }
918
    }
928
}
919
}
929
920
930
- 

Return to bug 14570