From 5aa18084238d7cafc2a02c734b88b165011f59a0 Mon Sep 17 00:00:00 2001 From: Barton Chittenden Date: Thu, 22 Oct 2015 14:06:10 -0700 Subject: [PATCH] bug 14504: use C4::Items::DelItemCheck in delete_items.pl Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- misc/cronjobs/delete_items.pl | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/misc/cronjobs/delete_items.pl b/misc/cronjobs/delete_items.pl index 81f11c720e..040bdc5909 100755 --- a/misc/cronjobs/delete_items.pl +++ b/misc/cronjobs/delete_items.pl @@ -56,21 +56,15 @@ $GLOBAL->{sth}->{target_items} = $dbh->prepare( $query->{target_items} . $where_ $GLOBAL->{sth}->{target_items}->execute(); DELITEM: while ( my $item = $GLOBAL->{sth}->{target_items}->fetchrow_hashref() ) { - my $issue = GetOpenIssue( $item->{itemnumber} ); - my $holds = GetItemHolds( $item->{biblionumber}, $item->{itemnumber} ); - - if( defined $issue ) { - verbose "Cannot delete '$item->{itemnumber}' -- item is checked out."; - next DELITEM; - } - - if( $holds ) { - verbose "Cannot delete '$item->{itemnumber}' -- item has open holds."; - next DELITEM; + my $del_check_options = $OPTIONS->{flags}->{commit} + ? undef + : { do_not_commit => 1 }; + my $status = C4::Items::DelItemCheck( $dbh, $item->{itemnumber}, $item->{biblionumber}, $del_check_options ); + if( $status == 1 ) { + verbose "Deleting '$item->{itemnumber}'"; + } else { + verbose "Item '$item->{itemnumber}' not deletd: $status"; } - - verbose "Deleting '$item->{itemnumber}' "; - C4::Items::DelItem( { itemnumber => $item->{itemnumber} } ) if $OPTIONS->{flags}->{commit} ; } =head1 NAME -- 2.39.5