@@ -, +, @@ --- C4/Members/Attributes.pm | 35 +++++++++++- .../prog/en/modules/members/memberentrygen.tt | 11 +++- members/memberentry.pl | 8 ++- t/db_dependent/Members_Attributes.t | 65 +++++++++++++--------- 4 files changed, 86 insertions(+), 33 deletions(-) --- a/C4/Members/Attributes.pm +++ a/C4/Members/Attributes.pm @@ -71,7 +71,6 @@ marked for OPAC display are returned. sub GetBorrowerAttributes { my $borrowernumber = shift; my $opac_only = @_ ? shift : 0; - my $branch_limit = @_ ? shift : 0; my $dbh = C4::Context->dbh(); my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class @@ -220,8 +219,8 @@ sub SetBorrowerAttributes { my $attr_list = shift; my $dbh = C4::Context->dbh; - my $delsth = $dbh->prepare("DELETE FROM borrower_attributes WHERE borrowernumber = ?"); - $delsth->execute($borrowernumber); + + DeleteBorrowerAttributes( $borrowernumber ); my $sth = $dbh->prepare("INSERT INTO borrower_attributes (borrowernumber, code, attribute, password) VALUES (?, ?, ?, ?)"); @@ -236,6 +235,36 @@ sub SetBorrowerAttributes { return 1; # borrower attributes successfully set } +=head2 DeleteBorrowerAttributes + + DeleteBorrowerAttributes($borrowernumber); + +Delete borrower attributes for the patron identified by C<$borrowernumber>. + +=cut + +sub DeleteBorrowerAttributes { + my $borrowernumber = shift; + my $no_branch_limit = @_ ? shift : 0; + my $branch_limit = $no_branch_limit + ? 0 + : C4::Context->userenv ? C4::Context->userenv->{"branch"} : 0; + + my $dbh = C4::Context->dbh; + my $query = q{ + DELETE FROM borrower_attributes + }; + $query .= q{ + LEFT JOIN borrower_attribute_types_branches ON bat_code = code + WHERE b_branchcode = ? OR b_branchcode IS NULL + } if $branch_limit; + $query .= q{ + WHERE borrowernumber = ? + }; + + $dbh->do( $query, undef, $branch_limit ? $branch_limit : (), $borrowernumber ); +} + =head2 DeleteBorrowerAttribute DeleteBorrowerAttribute($borrowernumber, $attribute); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1022,8 +1022,12 @@ [% END %]
    [% FOREACH patron_attribute IN pa_loo.items %] -
  1. - + [% IF patron_attribute.limited_to_another_branch %] + + + [% ELSE %] +
  2. + [% IF ( patron_attribute.use_dropdown ) %]