C4::ItemCirculationAlertPreference - manage preferences for sending alerts
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', });
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.
This is a constructor for an in-memory C4::ItemCirculationAlertPreference object. The database is not affected by this method.
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:
branches.branchcode
category.categorycode
itemtypes.itemtype
This can be "CHECKIN" or "CHECKOUT"
Delete an item circulation alert preference. You can delete by either passing in an id or passing in a branchcode, categorycode, item_type triplet.
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)) { # ... }
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', });
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.
These are read-only accessors for the various attributes of a preference.
C4::Circulation, admin/item_circulation_alerts.pl
John Beppu <john.beppu@liblime.com>