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

(-)a/C4/Circulation.pm (-8 / +13 lines)
Lines 2861-2875 sub AnonymiseIssueHistory { Link Here
2861
    my $dbh            = C4::Context->dbh;
2861
    my $dbh            = C4::Context->dbh;
2862
    my $query          = "
2862
    my $query          = "
2863
        UPDATE old_issues
2863
        UPDATE old_issues
2864
        SET    borrowernumber = ?
2865
        WHERE  returndate < ?
2866
          AND borrowernumber IS NOT NULL
2867
    ";
2864
    ";
2868
2865
2869
    # The default of 0 does not work due to foreign key constraints
2866
    # If there is no preference for 'AnonymousPatron' we update borrowernumber to NULL
2870
    # The anonymisation will fail quietly if AnonymousPatron is not a valid entry
2867
    my (@bind_params, $anonymouspatron);
2871
    my $anonymouspatron = (C4::Context->preference('AnonymousPatron')) ? C4::Context->preference('AnonymousPatron') : 0;
2868
    if ($anonymouspatron = (C4::Context->preference('AnonymousPatron'))){
2872
    my @bind_params = ($anonymouspatron, $date);
2869
        $query .= " SET borrowernumber = ?";
2870
        @bind_params = ($anonymouspatron, $date);
2871
    }else {
2872
        $query .= " SET borrowernumber = NULL";
2873
        @bind_params = ($date);
2874
    }
2875
2876
    $query .= " WHERE  returndate < ?
2877
        AND borrowernumber IS NOT NULL";
2878
2873
    if (defined $borrowernumber) {
2879
    if (defined $borrowernumber) {
2874
       $query .= " AND borrowernumber = ?";
2880
       $query .= " AND borrowernumber = ?";
2875
       push @bind_params, $borrowernumber;
2881
       push @bind_params, $borrowernumber;
2876
- 

Return to bug 9730