Lines 33-54
use C4::Members qw/ DelMember /;
Link Here
|
33 |
|
33 |
|
34 |
my $help; |
34 |
my $help; |
35 |
my $confirm; |
35 |
my $confirm; |
|
|
36 |
my $verbose; |
36 |
|
37 |
|
37 |
GetOptions( |
38 |
GetOptions( |
38 |
'h|help' => \$help, |
39 |
'h|help' => \$help, |
39 |
'c|confirm' => \$confirm, |
40 |
'c|confirm' => \$confirm, |
|
|
41 |
'v|verbose' => \$verbose, |
40 |
); |
42 |
); |
41 |
my $usage = << 'ENDUSAGE'; |
43 |
my $usage = << 'ENDUSAGE'; |
42 |
|
44 |
|
43 |
This script remove confirmed OPAC based patron registrations |
45 |
This script removes confirmed OPAC based patron registrations |
44 |
that have not been changed from the patron category specified |
46 |
that have not been changed from the patron category specified |
45 |
in the system preference PatronSelfRegistrationDefaultCategory |
47 |
in the system preference PatronSelfRegistrationDefaultCategory |
46 |
within the required time period. |
48 |
within the required time period. |
47 |
|
49 |
|
48 |
This script has the following parameters : |
50 |
NOTE: If you do not use self registration, do NOT run this script. |
49 |
-h --help: This message |
51 |
If you use self registration, but you do not use a temporary |
|
|
52 |
category for new registrations, do NOT run this script too. |
50 |
|
53 |
|
|
|
54 |
This script has the following parameters : |
51 |
-c --confirm: Without this flag set, this script will do nothing. |
55 |
-c --confirm: Without this flag set, this script will do nothing. |
|
|
56 |
-h --help: Print this message. |
57 |
-v --verbose: Print number of removed patrons. |
58 |
|
52 |
ENDUSAGE |
59 |
ENDUSAGE |
53 |
|
60 |
|
54 |
if ( $help || !$confirm ) { |
61 |
if ( $help || !$confirm ) { |
Lines 56-62
if ( $help || !$confirm ) {
Link Here
|
56 |
exit; |
63 |
exit; |
57 |
} |
64 |
} |
58 |
|
65 |
|
59 |
## Delete accounts that haven't been upgraded from the 'temporary' category code' |
66 |
# Delete accounts that haven't been upgraded from the 'temporary' category code |
60 |
my $delay = |
67 |
my $delay = |
61 |
C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay'); |
68 |
C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay'); |
62 |
my $category_code = |
69 |
my $category_code = |
Lines 68-80
my $query = "
Link Here
|
68 |
WHERE |
75 |
WHERE |
69 |
categorycode = ? |
76 |
categorycode = ? |
70 |
AND |
77 |
AND |
71 |
DATEDIFF( DATE( NOW() ), DATE(dateenrolled) ) = ? ) |
78 |
DATEDIFF( NOW(), dateenrolled ) > ? |
72 |
"; |
79 |
"; |
73 |
|
80 |
|
74 |
my $dbh = C4::Context->dbh; |
81 |
my $dbh = C4::Context->dbh; |
75 |
my $sth = $dbh->prepare($query); |
82 |
my $sth = $dbh->prepare($query); |
76 |
$sth->execute( $category_code, $delay ); |
83 |
$sth->execute( $category_code, $delay ); |
77 |
|
84 |
|
|
|
85 |
my $cnt=0; |
78 |
while ( my ($borrowernumber) = $sth->fetchrow_array() ) { |
86 |
while ( my ($borrowernumber) = $sth->fetchrow_array() ) { |
79 |
DelMember($borrowernumber); |
87 |
DelMember($borrowernumber); |
|
|
88 |
$cnt++; |
80 |
} |
89 |
} |
81 |
- |
90 |
print "Removed $cnt expired self-registered borrowers in category $category_code\n" if $verbose; |