<<

NAME

C4::Letters - Give functions for Letters management

SYNOPSIS

  use C4::Letters;

DESCRIPTION

  "Letters" is the tool used in Koha to manage informations sent to the patrons and/or the library. This include some cron jobs like
  late issues, as well as other tasks like sending a mail to users that have subscribed to a "serial issue alert" (= being warned every time a new issue has arrived at the library)

  Letters are managed through "alerts" sent by Koha on some events. All "alert" related functions are in this module too.

GetLetters

  $letters = &getletters($category);
  returns informations about letters.
  if needed, $category filters for letters given category
  Create a letter selector with the following code

in PERL SCRIPT

my $letters = GetLetters($cat); my @letterloop; foreach my $thisletter (keys %$letters) { my $selected = 1 if $thisletter eq $letter; my %row =( value => $thisletter, selected => $selected, lettername => $letters->{$thisletter}, ); push @letterloop, \%row; }

in TEMPLATE

    <select name="letter">
        <option value="">Default</option>
    <!-- TMPL_LOOP name="letterloop" -->
        <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="lettername" --></option>
    <!-- /TMPL_LOOP -->
    </select>

addalert

    parameters : 
    - $borrowernumber : the number of the borrower subscribing to the alert
    - $type : the type of alert.
    - externalid : the primary key of the object to put alert on. For issues, the alert is made on subscriptionid.
    
    create an alert and return the alertid (primary key)

delalert

    parameters :
    - alertid : the alert id
    deletes the alert

getalert

    parameters :
    - $borrowernumber : the number of the borrower subscribing to the alert
    - $type : the type of alert.
    - externalid : the primary key of the object to put alert on. For issues, the alert is made on subscriptionid.
    all parameters NON mandatory. If a parameter is omitted, the query is done without the corresponding parameter. For example, without $externalid, returns all alerts for a borrower on a topic.

findrelatedto

        parameters :
        - $type : the type of alert
        - $externalid : the id of the "object" to query
        
        In the table alert, a "id" is stored in the externalid field. This "id" is related to another table, depending on the type of the alert.
        When type=issue, the id is related to a subscriptionid and this sub returns the name of the biblio.
        When type=virtual, the id is related to a virtual shelf and this sub returns the name of the sub

SendAlerts

    parameters :
    - $type : the type of alert
    - $externalid : the id of the "object" to query
    - $letter : the letter to send.

    send an alert to all borrowers having put an alert on a given subject.

parseletter

    parameters :
    - $letter : a hash to letter fields (title & content useful)
    - $table : the Koha table to parse.
    - $pk : the primary key to query on the $table table
    parse all fields from a table, and replace values in title & content with the appropriate value
    (not exported sub, used only internally)

EnqueueLetter

my $success = EnqueueLetter( { letter => $letter, borrowernumber => '12', message_transport_type => 'email' } )

places a letter in the message_queue database table, which will eventually get processed (sent) by the process_message_queue.pl cronjob when it calls SendQueuedMessages.

return true on success

SendQueuedMessages

SendQueuedMessages()

sends all of the 'pending' items in the message queue.

my $sent = SendQueuedMessages( { verbose => 1 } )

returns number of messages sent.

GetRSSMessages

my $message_list = GetRSSMessages( { limit => 10, borrowernumber => '14' } )

returns a listref of all queued RSS messages for a particular person.

GetQueuedMessages

my $messages = GetQueuedMessage( { borrowernumber => '123', limit => 20 } );

fetches messages out of the message queue.

returns: list of hashes, each has represents a message in the message queue.

<<