[Koha-bugs] [Bug 15163] Patron attributes with branch limiits are not saved when invisible

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jan 8 10:55:25 CET 2016


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15163

--- Comment #11 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Jesse, yes it should be the way to go but..
I have already tried something and was stuck. I have a wip branch but I don't
remember what was wrong.

Looking at the diff it seems that I have tried to add a
DeleteBorrowerAttributes subroutines and the code looks quite complicated:

+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 );
+}

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list