<<

NAME

overdue_notices.pl - prepare messages to be sent to patrons for overdue items

SYNOPSIS

overdue_notices.pl [ -n ][ -library <branchcode> ][ -library <branchcode> ... ] [ -max <number of days> ][ -csv [<filename>] ][ -itemscontent <field list> ] [ -email <email_type> ... ]

 Options:
   -help                          brief help message
   -man                           full documentation
   -n                             No email will be sent
   -max          <days>           maximum days overdue to deal with
   -library      <branchname>     only deal with overdues from this library (repeatable : several libraries can be given)
   -csv          <filename>       populate CSV file
   -html         <directory>      Output html to a file in the given directory
   -text         <directory>      Output plain text to a file in the given directory
   -itemscontent <list of fields> item information in templates
   -borcat       <categorycode>   category code that must be included
   -borcatout    <categorycode>   category code that must be excluded
   -email        <email_type>     type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable.

OPTIONS

-help

Print a brief help message and exits.

-man

Prints the manual page and exits.

-v

Verbose. Without this flag set, only fatal errors are reported.

-n

Do not send any email. Overdue notices that would have been sent to the patrons or to the admin are printed to standard out. CSV data (if the -csv flag is set) is written to standard out or to any csv filename given.

-max

Items older than max days are assumed to be handled somewhere else, probably the longoverdues.pl script. They are therefore ignored by this program. No notices are sent for them, and they are not added to any CSV files. Defaults to 90 to match longoverdues.pl.

-library

select overdues for one specific library. Use the value in the branches.branchcode table. This option can be repeated in order to select overdues for a group of libraries.

-csv

Produces CSV data. if -n (no mail) flag is set, then this CSV data is sent to standard out or to a filename if provided. Otherwise, only overdues that could not be emailed are sent in CSV format to the admin.

-html

Produces html data. If patron does not have an email address or -n (no mail) flag is set, an HTML file is generated in the specified directory. This can be downloaded or futher processed by library staff. The file will be called notices-YYYY-MM-DD.html and placed in the directory specified.

-text

Produces plain text data. If patron does not have an email address or -n (no mail) flag is set, a text file is generated in the specified directory. This can be downloaded or futher processed by library staff. The file will be called notices-YYYY-MM-DD.txt and placed in the directory specified.

-itemscontent

comma separated list of fields that get substituted into templates in places of the <<items.content>> placeholder. This defaults to due date,title,barcode,author

Other possible values come from fields in the biblios, items and issues tables.

-borcat

Repetable field, that permit to select only few of patrons categories.

-borcatout

Repetable field, permis to exclude some patrons categories.

-t | --triggered

This option causes a notice to be generated if and only if an item is overdue by the number of days defined in a notice trigger.

By default, a notice is sent each time the script runs, which is suitable for less frequent run cron script, but requires syncing notice triggers with the cron schedule to ensure proper behavior. Add the --triggered option for daily cron, at the risk of no notice being generated if the cron fails to run on time.

-list-all

Default items.content lists only those items that fall in the range of the currently processing notice. Choose list-all to include all overdue items in the list (limited by -max setting).

-date

use it in order to send overdues on a specific date and not Now.

-email

Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable.

DESCRIPTION

This script is designed to alert patrons and administrators of overdue items.

Configuration

This script pays attention to the overdue notice configuration performed in the "Overdue notice/status triggers" section of the "Tools" area of the staff interface to Koha. There, you can choose which letter templates are sent out after a configurable number of days to patrons of each library. More information about the use of this section of Koha is available in the Koha manual.

The templates used to craft the emails are defined in the "Tools: Notices" section of the staff interface to Koha.

Outgoing emails

Typically, messages are prepared for each patron with overdue items. Messages for whom there is no email address on file are collected and sent as attachments in a single email to each library administrator, or if that is not set, then to the email address in the KohaAdminEmailAddress system preference.

These emails are staged in the outgoing message queue, as are messages produced by other features of Koha. This message queue must be processed regularly by the misc/cronjobs/process_message_queue.pl program.

In the event that the -n flag is passed to this program, no emails are sent. Instead, messages are sent on standard output from this program. They may be redirected to a file if desired.

Templates

Templates can contain variables enclosed in double angle brackets like <<this>>. Those variables will be replaced with values specific to the overdue items or relevant patron. Available variables are:

<<bib>>

the name of the library

<<items.content>>

one line for each item, each line containing a tab separated list of title, author, barcode, issuedate

<<borrowers.*>>

any field from the borrowers table

<<branches.*>>

any field from the branches table

CSV output

The -csv command line option lets you specify a file to which overdues data should be output in CSV format.

With the -n flag set, data about all overdues is written to the file. Without that flag, only information about overdues that were unable to be sent directly to the patrons will be written. In other words, this CSV file replaces the data that is typically sent to the administrator email address.

USAGE EXAMPLES

overdue_notices.pl - In this most basic usage, with no command line arguments, all libraries are procesed individually, and notices are prepared for all patrons with overdue items for whom we have email addresses. Messages for those patrons for whom we have no email address are sent in a single attachment to the library administrator's email address, or to the address in the KohaAdminEmailAddress system preference.

overdue_notices.pl -n -csv /tmp/overdues.csv - sends no email and populates /tmp/overdues.csv with information about all overdue items.

overdue_notices.pl -library MAIN max 14 - prepare notices of overdues in the last 2 weeks for the MAIN library.

SEE ALSO

The misc/cronjobs/advance_notices.pl program allows you to send messages to patrons in advance of thier items becoming due, or to alert them of items that have just become due.

INTERNAL METHODS

These methods are internal to the operation of overdue_notices.pl.

parse_letter

parses the letter template, replacing the placeholders with data specific to this patron, biblio, or item

named parameters: letter - required hashref borrowernumber - required integer substitute - optional hashref of other key/value pairs that should be substituted in the letter content

returns the letter hashref, with the content updated to reflect the substituted keys and values.

prepare_letter_for_printing

returns a string of text appropriate for printing in the event that an overdue notice will not be sent to the patron's email address. Depending on the desired output format, this may be a CSV string, or a human-readable representation of the notice.

required parameters: letter borrowernumber

optional parameters: outputformat

<<