|
Lines 625-662
if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransact
Link Here
|
| 625 |
|
625 |
|
| 626 |
if ($labels) { |
626 |
if ($labels) { |
| 627 |
print "Purging item label batches last added to more than $labels days ago.\n" if $verbose; |
627 |
print "Purging item label batches last added to more than $labels days ago.\n" if $verbose; |
| 628 |
$sth = $dbh->prepare( |
628 |
my $count = PurgeCreatorBatches($labels, 'labels', $confirm); |
| 629 |
q{ |
629 |
if ($verbose) { |
| 630 |
DELETE from creator_batches |
630 |
say $confirm |
| 631 |
WHERE batch_id in |
631 |
? sprintf "Done with purging %d item label batches last added to more than %d days ago.\n", $count, $labels |
| 632 |
(SELECT batch_id |
632 |
: sprintf "%d item label batches would have been purged.", $count; |
| 633 |
FROM (SELECT batch_id |
633 |
} |
| 634 |
FROM creator_batches |
|
|
| 635 |
WHERE creator='labels' |
| 636 |
GROUP BY batch_id |
| 637 |
HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a) |
| 638 |
} |
| 639 |
); |
| 640 |
$sth->execute($labels) or die $dbh->errstr; |
| 641 |
print "Done with purging item label batches last added to more than $labels days ago.\n" if $verbose; |
| 642 |
} |
634 |
} |
| 643 |
|
635 |
|
| 644 |
if ($cards) { |
636 |
if ($cards) { |
| 645 |
print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose; |
637 |
print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose; |
| 646 |
$sth = $dbh->prepare( |
638 |
my $count = PurgeCreatorBatches($labels, 'patroncards', $confirm); |
| 647 |
q{ |
639 |
if ($verbose) { |
| 648 |
DELETE from creator_batches |
640 |
say $confirm |
| 649 |
WHERE batch_id in |
641 |
? sprintf "Done with purging %d card creator batches last added to more than %d days ago.\n", $count, $labels |
| 650 |
(SELECT batch_id |
642 |
: sprintf "%d card creator batches would have been purged.", $count; |
| 651 |
FROM (SELECT batch_id |
643 |
} |
| 652 |
FROM creator_batches |
|
|
| 653 |
WHERE creator='patroncards' |
| 654 |
GROUP BY batch_id |
| 655 |
HAVING max(timestamp) < date_sub(curdate(),interval ? day)) a); |
| 656 |
} |
| 657 |
); |
| 658 |
$sth->execute($cards) or die $dbh->errstr; |
| 659 |
print "Done with purging card creator batches last added to more than $cards days ago.\n" if $verbose; |
| 660 |
} |
644 |
} |
| 661 |
|
645 |
|
| 662 |
exit(0); |
646 |
exit(0); |
|
Lines 747-752
sub PurgeDebarments {
Link Here
|
| 747 |
return $count; |
731 |
return $count; |
| 748 |
} |
732 |
} |
| 749 |
|
733 |
|
|
|
734 |
sub PurgeCreatorBatches { |
| 735 |
require C4::Labels::Batch; |
| 736 |
my ( $days, $creator, $doit ) = @_; |
| 737 |
my $count = 0; |
| 738 |
$sth = $dbh->prepare( |
| 739 |
q{ |
| 740 |
SELECT batch_id, branch_code FROM creator_batches |
| 741 |
WHERE batch_id in |
| 742 |
(SELECT batch_id |
| 743 |
FROM (SELECT batch_id |
| 744 |
FROM creator_batches |
| 745 |
WHERE creator=? |
| 746 |
GROUP BY batch_id |
| 747 |
HAVING max(timestamp) <= date_sub(curdate(),interval ? day)) a) |
| 748 |
} |
| 749 |
); |
| 750 |
$sth->execute( $creator, $days ) or die $dbh->errstr; |
| 751 |
while ( my ( $batch_id, $branch_code ) = $sth->fetchrow_array ) { |
| 752 |
C4::Labels::Batch::delete( |
| 753 |
batch_id => $batch_id, |
| 754 |
branch_code => $branch_code |
| 755 |
) if $doit; |
| 756 |
$count++; |
| 757 |
} |
| 758 |
return $count; |
| 759 |
} |
| 760 |
|
| 750 |
sub DeleteExpiredSelfRegs { |
761 |
sub DeleteExpiredSelfRegs { |
| 751 |
my $cnt= C4::Members::DeleteExpiredOpacRegistrations(); |
762 |
my $cnt= C4::Members::DeleteExpiredOpacRegistrations(); |
| 752 |
print "Removed $cnt expired self-registered borrowers\n" if $verbose; |
763 |
print "Removed $cnt expired self-registered borrowers\n" if $verbose; |
| 753 |
- |
|
|