-if ($op eq "delete_record") {
- # delete all reading records for items returned
- # uses a hardcoded date ridiculously far in the future
- AnonymiseIssueHistory('2999-12-12',$borrowernumber);
- # confirm the user the deletion has been done
- $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,
+ );
+ }
+
+ if ( $all or $holds ) {
+
+ my $rows = eval { $patron->old_holds->anonymize + 0 };
+
+ $template->param(
+ (
+ $@ ? ( error_deleting_holds_history => 1 )
+ : $rows ? ( deleted_holds => int($rows) )
+ : ( no_holds_to_delete => 1 )
+ ),
+ delete_holds_requested => 1,
+ );
+ }