View | Details | Raw Unified | Return to bug 19454
Collapse All | Expand All

(-)a/misc/maintenance/borrowers-force-messaging-defaults.pl (-6 / +12 lines)
Lines 39-45 sub usage { Link Here
39
39
40
40
41
sub force_borrower_messaging_defaults {
41
sub force_borrower_messaging_defaults {
42
    my ($doit, $since, $actives, $no_overwrite) = @_;
42
    my ($doit, $since, $actives, $no_overwrite, $category) = @_;
43
43
44
    $since = '0000-00-00' if (!$since);
44
    $since = '0000-00-00' if (!$since);
45
    print "Since: $since\n";
45
    print "Since: $since\n";
Lines 54-61 sub force_borrower_messaging_defaults { Link Here
54
    if( $no_overwrite ) {
54
    if( $no_overwrite ) {
55
        $sql .= " AND (SELECT COUNT(*) FROM borrower_message_preferences mp WHERE mp.borrowernumber=bo.borrowernumber) = 0"
55
        $sql .= " AND (SELECT COUNT(*) FROM borrower_message_preferences mp WHERE mp.borrowernumber=bo.borrowernumber) = 0"
56
    }
56
    }
57
    $sql .= " AND categorycode = ?" if $category;
57
    my $sth = $dbh->prepare($sql);
58
    my $sth = $dbh->prepare($sql);
58
    $sth->execute($since);
59
    $sth->execute($since, $category || () );
59
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
60
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
60
        print "$borrowernumber: $categorycode\n";
61
        print "$borrowernumber: $categorycode\n";
61
        next unless $doit;
62
        next unless $doit;
Lines 68-85 sub force_borrower_messaging_defaults { Link Here
68
}
69
}
69
70
70
71
71
my ( $doit, $since, $help, $actives, $no_overwrite );
72
my ( $doit, $since, $help, $actives, $no_overwrite, $category );
72
my $result = GetOptions(
73
my $result = GetOptions(
73
    'doit'        => \$doit,
74
    'doit'        => \$doit,
74
    'since:s'     => \$since,
75
    'since:s'     => \$since,
75
    'actives'     => \$actives,
76
    'actives'     => \$actives,
76
    'no_overwrite'  => \$no_overwrite,
77
    'no_overwrite'  => \$no_overwrite,
78
    'category:s'  => \$category,
77
    'help|h'      => \$help,
79
    'help|h'      => \$help,
78
);
80
);
79
81
80
usage() if $help;
82
usage() if $help;
81
83
82
force_borrower_messaging_defaults( $doit, $since, $actives, $no_overwrite );
84
force_borrower_messaging_defaults( $doit, $since, $actives, $no_overwrite, $category );
83
85
84
=head1 NAME
86
=head1 NAME
85
87
Lines 91-96 force-borrower-messaging-defaults Link Here
91
  force-borrower-messaging-defaults --help
93
  force-borrower-messaging-defaults --help
92
  force-borrower-messaging-defaults --doit
94
  force-borrower-messaging-defaults --doit
93
  force-borrower-messaging-defaults --doit --actives
95
  force-borrower-messaging-defaults --doit --actives
96
  force-borrower-messaging-defaults --doit -category PT
94
97
95
=head1 DESCRIPTION
98
=head1 DESCRIPTION
96
99
Lines 102-108 Filled' notice for example. Link Here
102
105
103
This script creates/overwrites messaging preferences for all borrowers and sets
106
This script creates/overwrites messaging preferences for all borrowers and sets
104
them to default values defined for the category they belong to (unless you
107
them to default values defined for the category they belong to (unless you
105
use the options -actives or -no_overwrite to update a subset).
108
use the options -actives, -no_overwrite or -category to update a subset).
106
109
107
=over 8
110
=over 8
108
111
Lines 123-128 Will only update active borrowers (borrowers who didn't pass their expiration da Link Here
123
Will only update patrons without messaging preferences and skip patrons that
126
Will only update patrons without messaging preferences and skip patrons that
124
already set their preferences.
127
already set their preferences.
125
128
129
=item B<-category>
130
131
Will only update patrons in the category specified.
132
126
=back
133
=back
127
134
128
=cut
135
=cut
129
- 

Return to bug 19454