|
Lines 204-217
sub anonymize_last_borrowers {
Link Here
|
| 204 |
my ( $self, $params ) = @_; |
204 |
my ( $self, $params ) = @_; |
| 205 |
|
205 |
|
| 206 |
return unless C4::Context->preference("AnonymizeLastBorrower"); |
206 |
return unless C4::Context->preference("AnonymizeLastBorrower"); |
| 207 |
return unless C4::Context->preference("AnonymousPatron"); |
207 |
|
|
|
208 |
my $anonymous_patron = C4::Context->preference('AnonymousPatron'); |
| 209 |
return unless $anonymous_patron; |
| 210 |
my $anon_patron_obj = Koha::Patrons->find($anonymous_patron); |
| 211 |
return unless $anon_patron_obj; # Invalid AnonymousPatron value |
| 212 |
|
| 208 |
my $days = C4::Context->preference("AnonymizeLastBorrowerDays") || 0; |
213 |
my $days = C4::Context->preference("AnonymizeLastBorrowerDays") || 0; |
| 209 |
my ( $year, $month, $day ) = Today(); |
214 |
my ( $year, $month, $day ) = Today(); |
| 210 |
my ( $newyear, $newmonth, $newday ) = Add_Delta_Days( $year, $month, $day, (-1) * $days ); |
215 |
my ( $newyear, $newmonth, $newday ) = Add_Delta_Days( $year, $month, $day, (-1) * $days ); |
| 211 |
my $older_than_date = dt_from_string( sprintf "%4d-%02d-%02d", $newyear, $newmonth, $newday ); |
216 |
my $older_than_date = dt_from_string( sprintf "%4d-%02d-%02d", $newyear, $newmonth, $newday ); |
| 212 |
|
217 |
|
| 213 |
my $anonymous_patron = C4::Context->preference('AnonymousPatron'); |
|
|
| 214 |
|
| 215 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
218 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
| 216 |
|
219 |
|
| 217 |
# Perform bulk update directly on items_last_borrower table to avoid N+1 queries |
220 |
# Perform bulk update directly on items_last_borrower table to avoid N+1 queries |
| 218 |
- |
|
|