|
Lines 128-134
sub SetBorrowerAttributes {
Link Here
|
| 128 |
|
128 |
|
| 129 |
my $dbh = C4::Context->dbh; |
129 |
my $dbh = C4::Context->dbh; |
| 130 |
|
130 |
|
| 131 |
DeleteBorrowerAttributes( $borrowernumber, $no_branch_limit ); |
131 |
my $attributes = Koha::Patrons->find($borrowernumber)->get_extended_attributes; |
|
|
132 |
|
| 133 |
unless ( $no_branch_limit ) { |
| 134 |
$attributes = $attributes->filter_by_branch_limitations; |
| 135 |
} |
| 136 |
$attributes->delete; |
| 132 |
|
137 |
|
| 133 |
my $sth = $dbh->prepare("INSERT INTO borrower_attributes (borrowernumber, code, attribute) |
138 |
my $sth = $dbh->prepare("INSERT INTO borrower_attributes (borrowernumber, code, attribute) |
| 134 |
VALUES (?, ?, ?)"); |
139 |
VALUES (?, ?, ?)"); |
|
Lines 142-180
sub SetBorrowerAttributes {
Link Here
|
| 142 |
return 1; # borrower attributes successfully set |
147 |
return 1; # borrower attributes successfully set |
| 143 |
} |
148 |
} |
| 144 |
|
149 |
|
| 145 |
=head2 DeleteBorrowerAttributes |
|
|
| 146 |
|
| 147 |
DeleteBorrowerAttributes($borrowernumber); |
| 148 |
|
| 149 |
Delete borrower attributes for the patron identified by C<$borrowernumber>. |
| 150 |
|
| 151 |
=cut |
| 152 |
|
| 153 |
sub DeleteBorrowerAttributes { |
| 154 |
my $borrowernumber = shift; |
| 155 |
my $no_branch_limit = @_ ? shift : 0; |
| 156 |
my $branch_limit = $no_branch_limit |
| 157 |
? 0 |
| 158 |
: C4::Context->userenv ? C4::Context->userenv->{"branch"} : 0; |
| 159 |
|
| 160 |
my $dbh = C4::Context->dbh; |
| 161 |
my $query = q{ |
| 162 |
DELETE borrower_attributes FROM borrower_attributes |
| 163 |
}; |
| 164 |
|
| 165 |
$query .= $branch_limit |
| 166 |
? q{ |
| 167 |
LEFT JOIN borrower_attribute_types_branches ON bat_code = code |
| 168 |
WHERE ( b_branchcode = ? OR b_branchcode IS NULL ) |
| 169 |
AND borrowernumber = ? |
| 170 |
} |
| 171 |
: q{ |
| 172 |
WHERE borrowernumber = ? |
| 173 |
}; |
| 174 |
|
| 175 |
$dbh->do( $query, undef, $branch_limit ? $branch_limit : (), $borrowernumber ); |
| 176 |
} |
| 177 |
|
| 178 |
=head2 DeleteBorrowerAttribute |
150 |
=head2 DeleteBorrowerAttribute |
| 179 |
|
151 |
|
| 180 |
DeleteBorrowerAttribute($borrowernumber, $attribute); |
152 |
DeleteBorrowerAttribute($borrowernumber, $attribute); |