return false;
}
+
+
+/* collect the useful variables */
+var copy = environment.copy;
+var volume = environment.volume;
+var title = environment.title;
+var recDescriptor = environment.titleDescriptor;
+var patron = environment.patron;
+var isRenewal = environment.isRenewal;
+var patronItemsOut = environment.patronItemsOut;
+var patronOverdueCount = environment.patronOverdueCount;
+var patronFines = environment.patronFines;
+var patronProfile;
+var copyStatus;
+
+if( patron.profile ) patronProfile = patron.profile.name.toLowerCase();
+if( copy.status ) copyStatus = copy.status.name.toLowerCase();
+
+
+
+/*
+- at some point we should add a library of objects that map
+codes to names (item_form, item_type, etc.)
+load_lib('item_form_map.js');
+var form_name = item_form_map[env.record_descriptor.item_form];
+*/
+
+
+
+/* logs a load of info */
+function log_vars( prefix ) {
+
+ var str = prefix + ' : ';
+
+ if(patron) {
+ str += ' Patron=' + patron.id;
+ str += ', Patron Barcode=' + patron.card.barcode;
+ str += ', Patron Username='+ patron.usrname;
+ str += ', Patron Library=' + patron.home_ou.name;
+ str += ', Patron Fines=' + patronFines;
+ str += ', Patron OverdueCount=' + patronOverdueCount;
+ str += ', Patron Items Out=' + patronItemsOut;
+ }
+
+ if(copy) {
+ str += ', Copy=' + copy.id;
+ str += ', Copy Barcode=' + copy.barcode;
+ str += ', Copy status=' + copyStatus;
+ str += ', Copy location=' + copy.location.name;
+ }
+
+ if(volume) str += ', Volume=' + volume.id;
+ if(title) str += ', Record=' + title.id;
+
+ if(recDescriptor) {
+ str += ', Record Descriptor=' + recDescriptor.id;
+ str += ', Item Type=' + recDescriptor.item_type;
+ str += ', Item Form=' + recDescriptor.item_form;
+ str += ', Item Lang=' + recDescriptor.item_lang;
+ str += ', Item Audience=' + recDescriptor.audience;
+ }
+
+ str += ' Is Renewal: ' + ( (isTrue(isRenewal)) ? "yes" : "no" );
+
+
+ log_debug(str);
+}
+
+
+
/* load the lib script */
load_lib('circ_lib.js');
-
-/* collect some useful variables */
-var copy = environment.copy;
-var patron = environment.patron;
-var volume = environment.volume;
-var title = environment.title;
-var recDescriptor = environment.titleDescriptor;
-var patronProfile = patron.profile.name.toLowerCase();
-var copyStatus = copy.status.name.toLowerCase();
-var isRenewal = environment.isRenewal;
-
-/*
-- at some point we should add a library of objects that map
-codes to names (item_form, item_type, etc.)
-load_lib('item_form_map.js');
-var form_name = item_form_map[env.record_descriptor.item_form];
-*/
-
-
-log_debug('circ_permit_copy: permit circ on ' +
- ' Copy: ' + copy.id +
- ', Patron:' + patron.id +
- ', Patron Username:' + patron.usrname +
- ', Patron Library: ' + patron.home_ou.name +
- ', Copy status: ' + copyStatus +
- ', Copy location: ' + copy.location.name +
- ', Is Renewal: ' + ( (isTrue(isRenewal)) ? "yes" : "no" ) +
- ', Item Type: ' + recDescriptor.item_type +
- ', Item Form: ' + recDescriptor.item_form +
- ', Item Lang: ' + recDescriptor.item_lang +
- ', Item Audience: ' + recDescriptor.audience +
- '');
+log_vars('circ_permit_copy');
function go() {
-/* load the lib script */
+/* load the script library */
load_lib('circ_lib.js');
+log_vars('circ_permit_patron');
-/* collect some useful variables */
-var patron = environment.patron;
-var patronProfile = patron.profile.name.toLowerCase();
-var patronItemsOut = environment.patronItemsOut;
-var patronFines = environment.patronFines;
-var isRenewal = environment.isRenewal;
-
-
-log_debug('circ_permit_patron: permit circ on ' +
- ', Patron:' + patron.id +
- ', Patron Username:' + patron.usrname +
- ', Patron Profile: ' + patronProfile +
- ', Patron copies: ' + patronItemsOut +
- ', Patron Library: ' + patron.home_ou.name +
- ', Patron fines: ' + patronFines +
- ', Is Renewal: ' + ( (isRenewal) ? "yes" : "no" ) +
- '');
-
+/* make sure they are not barred */
if( isTrue(patron.barred) )
result.events.push('PATRON_BARRED');
-/* define the items out limits */
-var PROFILES = {
+/* ---------------------------------------------------------------------
+ Set up the limits for the various profiles.
+ values of -1 mean there is no limit
+ --------------------------------------------------------------------- */
+var PROFILES = {};
+PROFILES['class'] = { itemsOutLimit : 10 };
+PROFILES['patrons'] = { itemsOutLimit : 10 };
+PROFILES['restricted'] = { itemsOutLimit : 2 };
+PROFILES['circulators'] = { itemsOutLimit : -1 };
+PROFILES['local system administrator'] = { itemsOutLimit : -1 };
+/* add profiles as necessary ... */
- restricted : {
- itemsOutLimit : 2,
- },
- patrons : {
- itemsOutLimit : 10,
- },
- 'class' : {
- itemsOutLimit : 10,
- },
- 'local system administrator' : {
- itemsOut : -1,
- },
- circulators : {
- itemsOut : -1,
- }
- /* Add profiles as necessary ... */
-}
-
+/* ---------------------------------------------------------------------
+ Check the items out count
+ --------------------------------------------------------------------- */
var profile = PROFILES[patronProfile];
if( profile ) {
if( patronItemsOut > 0 && patronItemsOut > profile.itemsOutLimit )
/* load the lib script */
load_lib('../circ/circ_lib.js');
+log_vars('patron_penalty');
-/* collect some useful variables */
-var patron = environment.patron;
-var patronProfile = patron.profile.name.toLowerCase();
-var patronFines = environment.patronFines;
-var patronOverdueCount = environment.patronOverdueCount;
-
-
-log_debug('Patron penalty script: ' +
- ', Patron:' + patron.id +
- ', Patron Username:' + patron.usrname +
- ', Patron Profile: ' + patronProfile +
- ', Patron Library: ' + patron.home_ou.name +
- ', Patron fines: ' + patronFines +
- ', Patron overdue: ' + patronOverdueCount +
- '');
-
-
-var PROFILES = {
- restricted : {
- fineLimit : 0,
- overdueLimit : 0,
- },
- patrons : {
- fineLimit : 10,
- overdueLimit : 10,
- },
- 'class' : {
- fineLimit : 10,
- overdueLimit : 10,
- },
- circulators : {
- fineLimit : -1,
- overdueLimit : -1,
- },
- 'local system administrator' : {
- fineLimit : -1,
- overdueLimit : -1,
- }
-
- /* Add profiles as necessary ... */
-}
-
-
+var PROFILES = {};
+PROFILES['class'] = { fineLimit : 10, overdueLimit : 10 };
+PROFILES['patrons'] = { fineLimit : 10, overdueLimit : 10 };
+PROFILES['restricted'] = { fineLimit : 0, overdueLimit : 0 };
+PROFILES['circulators'] = { fineLimit : -1, overdueLimit : -1 };
+PROFILES['local system administrator'] = { fineLimit : -1, overdueLimit : -1 };
+/* add profiles as necessary ... */
var profile = PROFILES[patronProfile];
use OpenILS::Utils::CStoreEditor qw/:funcs/;
use OpenILS::Application::AppUtils;
use OpenILS::Application::Actor;
+use OpenSRF::Utils::Logger qw/$logger/;
my $U = "OpenILS::Application::AppUtils";
use Data::Dumper;
$runner->insert( "$evt.requestor", $ctx->{requestor}, 1);
$runner->insert( "$evt.titleDescriptor", $ctx->{titleDescriptor}, 1);
- $runner->insert( "$evt.patronItemsOut", $ctx->{patronItemsOut} );
- $runner->insert( "$evt.patronOverdueCount", $ctx->{patronOverdue} );
- $runner->insert( "$evt.patronFines", $ctx->{patronFines} );
+ $runner->insert( "$evt.patronItemsOut", $ctx->{patronItemsOut}, 1 );
+ $runner->insert( "$evt.patronOverdueCount", $ctx->{patronOverdue}, 1 );
+ $runner->insert( "$evt.patronFines", $ctx->{patronFines}, 1 );
# circ script result
$runner->insert("result", {});
@GROUP_LIST = @$s;
}
- warn 'patron profile = ' . $patron->profile . "\n";
$patron->profile(
grep { $_->id == $patron->profile } @GROUP_LIST )
unless ref $patron->profile;
- warn 'patron profile = ' . $patron->profile->name . "\n";
+
+ $patron->card($e->retrieve_actor_card($patron->card));
$ctx->{requestor} = $ctx->{requestor} || $e->requestor;
my $fines = 0;
$fines += $_->balance_owed for @$fxacts;
$ctx->{patronFines} = $fines;
+
+ $logger->debug("script_builder: patron fines determined to be $fines");
+ $logger->debug("script_builder: patron overdue count is " . $ctx->{patronOverdue});
}
return undef;
{ fatal_penalties => \@fatals, info_penalties => \@infos });
# - update the penalty info in the db if necessary
+ $logger->debug("update penalty settings = " . $$args{update});
+
$evt = update_patron_penalties(
- patron => $patron,
+ patron => $args->{patron},
penalties => $all ) if $$args{update};
# - The caller won't know it failed, so log it
my %args = @_;
my $patron = $args{patron};
my $penalties = $args{penalties};
+ my $pid = $patron->id;
+
+ $logger->debug("updating penalties for patron $pid => @$penalties");
my $session = $U->start_db_session();
- my $pid = ($patron) ? $patron->id : $args{patronid};
# - fetch the current penalties
my $existing = $session->request(
# ---------------------------------------------------------------------
# SCRIPT VARS
# ----------------------------------------------------------------------
-my $patronid = 3;
+#my $patronid = 3;
+my $patronid = 1000502;
my $copyid = 8000107;
my $patron_items_out = 11;
my $patron_overdue_count = 11;