-if ($op eq "delete_record") {
- # delete all reading records for items returned
- # uses a hardcoded date ridiculously far in the future
- my ($rows,$err_history_not_deleted) = AnonymiseIssueHistory('2999-12-12',$borrowernumber);
- # confirm the user the deletion has been done
- if ( !$err_history_not_deleted ) {
- $template->param( 'deleted' => 1 );
+elsif ( $op eq "delete_record" ) {
+
+ my $holds = $query->param('holds');
+ my $checkouts = $query->param('checkouts');
+ my $all = $query->param('all');
+
+ $template->param( delete_all_quested => 1 )
+ if $all;
+
+ if ( $all or $checkouts ) {
+
+ # delete all reading records for items returned
+ my $rows = eval { $patron->old_checkouts->anonymize + 0 };
+
+ $template->param(
+ (
+ $@ ? ( error_deleting_checkouts_history => 1 )
+ : $rows ? ( deleted_checkouts => int($rows) )
+ : ( no_checkouts_to_delete => 1 )
+ ),
+ delete_checkouts_requested => 1,
+ );