<<

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 Rules:

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

Deleting Rules:

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

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, and item_type.

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 })

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

Example:

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

Object Methods

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

$pref->id

$pref->branchcode

$pref->categorycode

$pref->item_type

SEE ALSO

C4::Circulation, admin/item_circulation_alerts.pl

AUTHOR

John Beppu <john.beppu@liblime.com>

<<