<<

NAME

C4::ItemCirculationAlertPreference - manage preferences for sending alerts

SYNOPSIS

Basics:

    use C4::ItemCirculationAlertPreference;

    # a short-cut to reduce typing the long package name over and over again
    my $preferences = 'C4::ItemCirculationAlertPreference';

Creating a restriction on sending messages:

    my $pref = $preferences->create({
        branchcode   => 'CPL',
        categorycode => 'YA',
        item_type    => 'BK',
        notification => 'CHECKOUT',
    });

Removing a restriction on sending messages:

    $preferences->delete({
        branchcode   => 'CPL',
        categorycode => 'YA',
        item_type    => 'BK',
        notification => 'CHECKOUT',
    });

DESCRIPTION

This class is used to manage the preferences for when an alert may be sent. By default, item circulation alerts are enabled for every branch, patron category and item type.

However, if you would like to prevent item circulation alerts from being sent for any combination of these 3 variables, a preference can be inserted into the item_circulation_alert_preferences table to make that a policy.

API

Class Methods

C4::ItemCirculationAlertPreference->new(\%opts)

This is a constructor for an in-memory C4::ItemCirculationAlertPreference object. The database is not affected by this method.

C4::ItemCirculationAlertPreference->create(\%opts)

This will find or create an item circulation alert preference. You must pass it a branchcode, categorycode, item_type, and notification. Valid values for these attributes are as follows:

branchcode

branches.branchcode

categorycode

category.categorycode

item_type

itemtypes.itemtype

notification

This can be "CHECKIN" or "CHECKOUT"

C4::ItemCirculationAlertPreference->delete(\%opts)

Delete an item circulation alert preference. You can delete by either passing in an id or passing in a branchcode, categorycode, item_type triplet.

C4::ItemCirculationAlertPreference->is_enabled_for(\%opts)

Based on the existing preferences in the item_circulation_alert_preferences table, can an alert be sent for the given branchcode, categorycode, and itemtype?

Example:

    my $alert = 'C4::ItemCirculationAlertPreference';
    my $conditions = {
        branchcode   => 'CPL',
        categorycode => 'IL',
        item_type    => 'MU',
    };

    if ($alert->is_enabled_for($conditions)) {
        # ...
    }

C4::ItemCirculationAlertPreference->find({ branchcode => $bc, notification => $type })

This method returns all the item circulation alert preferences for a given branch and notification.

Example:

    my @branch_prefs = C4::ItemCirculationAlertPreference->find({
        branchcode   => 'CPL',
        notification => 'CHECKIN',
    });

C4::ItemCirculationAlertPreference->grid({ branchcode => $c, notification => $type })

Return a 2D arrayref for the grid view in admin/item_circulation_alert_preferences.pl. Each row represents a category (like 'Patron' or 'Young Adult') and each column represents an itemtype (like 'Book' or 'Music').

Each cell contains...

Example:

    use Data::Dump 'pp';
    my $grid = C4::ItemCirculationAlertPreference->grid({
        branchcode   => 'CPL',
        notification => 'CHECKOUT',
    });
    warn pp($grid);

See admin/item_circulation_alerts.pl to see how this method is used.

Object Methods

These are read-only accessors for the various attributes of a preference.

$pref->id

$pref->branchcode

$pref->categorycode

$pref->item_type

$pref->notification

SEE ALSO

C4::Circulation, admin/item_circulation_alerts.pl

AUTHOR

John Beppu <john.beppu@liblime.com>

<<