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

(-)a/misc/cronjobs/advance_notices.pl (-23 / +113 lines)
Lines 41-46 the OPAC. Link Here
41
use strict;
41
use strict;
42
use warnings;
42
use warnings;
43
use Getopt::Long;
43
use Getopt::Long;
44
use Pod::Usage;
44
use Data::Dumper;
45
use Data::Dumper;
45
BEGIN {
46
BEGIN {
46
    # find Koha's Perl modules
47
    # find Koha's Perl modules
Lines 56-61 use C4::Members::Messaging; Link Here
56
use C4::Overdues;
57
use C4::Overdues;
57
use Koha::DateUtils;
58
use Koha::DateUtils;
58
59
60
=head1 NAME
61
62
advance_notices.pl - prepare messages to be sent to patrons for nearly due, or due, items
63
64
=head1 SYNOPSIS
65
66
advance_notices.pl
67
  [ -n ][ -m <number of days> ][ --itemscontent <comma separated field list> ][ -c ]
68
69
=head1 OPTIONS
70
71
=over 8
72
73
=item B<--help>
74
75
Print a brief help message and exits.
76
77
=item B<--man>
78
79
Prints the manual page and exits.
80
81
=item B<-v>
82
83
Verbose. Without this flag set, only fatal errors are reported.
84
85
=item B<-n>
86
87
Do not send any email. Advanced or due notices that would have been sent to
88
the patrons are printed to standard out.
89
90
=item B<-m>
91
92
Defines the maximum number of days in advance to send advance notices.
93
94
95
96
=item B<--itemscontent>
97
98
comma separated list of fields that get substituted into templates in
99
places of the E<lt>E<lt>items.contentE<gt>E<gt> placeholder. This
100
defaults to due date,title,author,barcode
101
102
Other possible values come from fields in the biblios, items and
103
issues tables.
104
105
=back
106
107
=head1 DESCRIPTION
108
109
This script is designed to alert patrons when items are due, or coming due
110
111
=head2 Configuration
112
113
This script pays attention to the advanced notice configuration
114
performed by borrowers in the OPAC, or by staff in the patron detail page of the intranet. The content of the messages is configured in Tools -> Notices and slips. Advanced notices use the PREDUE template, due notices use DUE. More information about the use of this
115
section of Koha is available in the Koha manual.
116
117
=head2 Outgoing emails
118
119
Typically, messages are prepared for each patron with due
120
items, and who have selected (or the library has elected for them) Advance or Due notices.
121
122
These emails are staged in the outgoing message queue, as are messages
123
produced by other features of Koha. This message queue must be
124
processed regularly by the
125
F<misc/cronjobs/process_message_queue.pl> program.
126
127
In the event that the C<-n> flag is passed to this program, no emails
128
are sent. Instead, messages are sent on standard output from this
129
program. They may be redirected to a file if desired.
130
131
=head2 Templates
132
133
Templates can contain variables enclosed in double angle brackets like
134
E<lt>E<lt>thisE<gt>E<gt>. Those variables will be replaced with values
135
specific to the overdue items or relevant patron. Available variables
136
are:
137
138
=over
139
140
=item E<lt>E<lt>items.contentE<gt>E<gt>
141
142
one line for each item, each line containing a tab separated list of
143
title, author, barcode, issuedate
144
145
=item E<lt>E<lt>borrowers.*E<gt>E<gt>
146
147
any field from the borrowers table
148
149
=item E<lt>E<lt>branches.*E<gt>E<gt>
150
151
any field from the branches table
152
153
=back
154
155
=head1 SEE ALSO
156
157
The F<misc/cronjobs/overdue_notices.pl> program allows you to send
158
messages to patrons when their messages are overdue.
159
=cut
59
160
60
# These are defaults for command line options.
161
# These are defaults for command line options.
61
my $confirm;                                                        # -c: Confirm that the user has read and configured this script.
162
my $confirm;                                                        # -c: Confirm that the user has read and configured this script.
Lines 64-89 my $nomail; # -n: No mai Link Here
64
my $mindays     = 0;                                                # -m: Maximum number of days in advance to send notices
165
my $mindays     = 0;                                                # -m: Maximum number of days in advance to send notices
65
my $maxdays     = 30;                                               # -e: the End of the time period
166
my $maxdays     = 30;                                               # -e: the End of the time period
66
my $verbose     = 0;                                                # -v: verbose
167
my $verbose     = 0;                                                # -v: verbose
67
my $itemscontent = join(',',qw( issuedate title barcode author ));
168
my $itemscontent = join(',',qw( date_due title author barcode ));
68
169
69
GetOptions( 'c'              => \$confirm,
170
my $help    = 0;
171
my $man     = 0;
172
173
GetOptions(
174
            'help|?'         => \$help,
175
            'man'            => \$man,
176
            'c'              => \$confirm,
70
            'n'              => \$nomail,
177
            'n'              => \$nomail,
71
            'm:i'            => \$maxdays,
178
            'm:i'            => \$maxdays,
72
            'v'              => \$verbose,
179
            'v'              => \$verbose,
73
            'itemscontent=s' => \$itemscontent,
180
            'itemscontent=s' => \$itemscontent,
74
       );
181
       )or pod2usage(2);
75
my $usage = << 'ENDUSAGE';
182
pod2usage(1) if $help;
76
183
pod2usage( -verbose => 2 ) if $man;;
77
This script prepares pre-due and item due reminders to be sent to
78
patrons. It queues them in the message queue, which is processed by
79
the process_message_queue.pl cronjob.
80
See the comments in the script for directions on changing the script.
81
This script has the following parameters :
82
    -c Confirm and remove this help & warning
83
    -m maximum number of days in advance to send advance notices.
84
    -n send No mail. Instead, all mail messages are printed on screen. Usefull for testing purposes.
85
    -v verbose
86
ENDUSAGE
87
184
88
# Since advance notice options are not visible in the web-interface
185
# Since advance notice options are not visible in the web-interface
89
# unless EnhancedMessagingPreferences is on, let the user know that
186
# unless EnhancedMessagingPreferences is on, let the user know that
Lines 97-111 To change this, edit the "EnhancedMessagingPreferences" syspref. Link Here
97
194
98
END_WARN
195
END_WARN
99
}
196
}
100
101
unless ($confirm) {
197
unless ($confirm) {
102
    print $usage;
198
     pod2usage(1);
103
    print "Do you wish to continue? (y/n)";
104
    chomp($_ = <STDIN>);
105
    exit unless (/^y/i);
106
	
107
}
199
}
108
109
# The fields that will be substituted into <<items.content>>
200
# The fields that will be substituted into <<items.content>>
110
my @item_content_fields = split(/,/,$itemscontent);
201
my @item_content_fields = split(/,/,$itemscontent);
111
202
112
- 

Return to bug 9499