From 20a3b135164cd6a719af6c9c7b54f9abc121a9e7 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 10 Mar 2023 20:32:56 -1000 Subject: [PATCH] Bug 33204: Add the ability to filter on patron library for borrowers-force-messaging-defaults.pl Like filter on category Bug 19454, it would be helpful to filter on a specified library for misc/maintenance/borrowers-force-messaging-defaults.pl Test plan: 1) Select two patrons A and B in say libraries L1 and L2. 2) Change the msg prefs for A and B away from defaults. 3) Run misc/maintenance/borrowers-force-messaging-defaults.pl -doit -library L1 Verify that patron A changed and patron B did not. 4) Run with both category and library filters Signed-off-by: Sam Lau Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../borrowers-force-messaging-defaults.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl index 22cb01a706..ee5125e24a 100755 --- a/misc/maintenance/borrowers-force-messaging-defaults.pl +++ b/misc/maintenance/borrowers-force-messaging-defaults.pl @@ -34,7 +34,7 @@ sub usage { sub force_borrower_messaging_defaults { - my ($doit, $since, $not_expired, $no_overwrite, $category ) = @_; + my ($doit, $since, $not_expired, $no_overwrite, $category, $branchcode ) = @_; print "Since: $since\n" if $since; @@ -56,8 +56,9 @@ WHERE 1|; $sql .= " AND mp.borrowernumber IS NULL"; } $sql .= " AND bo.categorycode = ?" if $category; + $sql .= " AND bo.branchcode = ?" if $branchcode; my $sth = $dbh->prepare($sql); - $sth->execute($since || (), $category || () ); + $sth->execute($since || (), $category || (), $branchcode || () ); my $cnt = 0; while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { print "$borrowernumber: $categorycode\n"; @@ -73,19 +74,20 @@ WHERE 1|; } -my ( $doit, $since, $help, $not_expired, $no_overwrite, $category ); +my ( $doit, $since, $help, $not_expired, $no_overwrite, $category, $branchcode ); my $result = GetOptions( 'doit' => \$doit, 'since:s' => \$since, 'not-expired' => \$not_expired, 'no-overwrite' => \$no_overwrite, 'category:s' => \$category, + 'library:s' => \$branchcode, 'help|h' => \$help, ); usage() if $help; -force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category ); +force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category, $branchcode ); =head1 NAME @@ -98,6 +100,7 @@ borrowers-force-messaging-defaults.pl borrowers-force-messaging-defaults.pl --doit borrowers-force-messaging-defaults.pl --doit --not-expired borrowers-force-messaging-defaults.pl --doit --category PT + borrowers-force-messaging-defaults.pl --doit --library CPL =head1 DESCRIPTION @@ -134,6 +137,10 @@ already set their preferences. Will only update patrons in the category specified. +=item B<--library> + +Will only update patrons in the library specified. + =item B<--since> Will only update borrowers enrolled since the specified date. -- 2.39.5