/* load the lib script */
load_lib('circ_lib.js');
-
-/* collect some useful variables */
-var copy = environment.copy;
-var patron = environment.patron;
-var patronProfile = patron.profile.name.toLowerCase();
-var copyStatus = copy.status.name.toLowerCase();
-var patronItemsOut = environment.patronItemsOut;
-var patronFines = environment.patronFines;
-var isRenewal = environment.isRenewal;
-
+log_vars('circ_duration');
/* set sane defaults */
result.durationLevel = copy.loan_duration;
-
-
-return;
-
-
} go();
var __scratchKey = 0;
var __SCRATCH = {};
+
+/* useful functions for creating wrappers around system functions */
function scratchKey() { return '_' + __scratchKey++; };
function scratchPad(key) { return '__SCRATCH.'+ key; }
function getScratch(key) { return __SCRATCH[ key ]; }
function scratchClear() { for( var o in __SCRATCH ) __SCRATCH[o] = null; }
-
-/* -- Copy functions ----------------------------------------------------- */
-try {
- if( environment.copy ) {
- environment.copy.fetchHolds = function() {
- var key = scratchKey();
- environment.copy.__OILS_FUNC_fetch_hold(scratchPad(key));
- var val = getScratch(key);
- return (val) ? val : null;
- }
- }
-} catch(e) {}
-
-
/* note: returns false if the value is 'f' or 'F' ... */
function isTrue(d) {
if( d &&
/* collect the useful variables */
+var result = environment.result = {};
+result.event = 'SUCCESS';
+result.events = [];
+result.fatalEvents = [];
+result.infoEvents = [];
+
var copy = environment.copy;
var volume = environment.volume;
var title = environment.title;
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 patronProfile = patron.profile.name.toLowerCase();
-var copyStatus = copy.status.name.toLowerCase();
-var patronItemsOut = environment.patronItemsOut;
-var patronFines = environment.patronFines;
-var isRenewal = environment.isRenewal;
+log_vars('circ_max_fine');
return result.maxFine = "books";
-
-
} go();
-function go() {
-
-var patron = environment.patron;
-var title = environment.title;
-var copy = environment.copy;
-var volume = environment.volume;
-var title = environment.title;
-var requestor = environment.requestor;
-var requestLib = environment.requestLib;
-var titleDescriptor = environment.titleDescriptor;
-
-log_debug('circ_permit_hold: permit circ on ' +
- ' Copy: ' + copy.id +
- ', Patron:' + patron.id +
- ', Patron Username:' + patron.usrname +
- ', Patron Library: ' + patron.home_ou.name +
- ', Copy location: ' + copy.location.name +
- ', Item Type: ' + titleDescriptor.item_type +
- ', Item Form: ' + titleDescriptor.item_form +
- ', Item Lang: ' + titleDescriptor.item_lang +
- ', Item Audience: ' + titleDescriptor.audience +
- '');
+function go() {
+load_lib('circ_lib.js');
+log_vars('circ_permit_hold');
-if( titleDescriptor.item_type == 'g' /* projected medium */
+if( recDescriptor.item_type == 'g' /* projected medium */
&& copy.circ_lib != patron.home_ou.id )
return result.event = 'CIRC_EXCEEDS_COPY_RANGE';
log_vars('circ_permit_patron');
-
/* make sure they are not barred */
if( isTrue(patron.barred) )
result.events.push('PATRON_BARRED');
/* load the lib script */
load_lib('circ_lib.js');
-
-/* collect some useful variables */
-var copy = environment.copy;
-var patron = environment.patron;
-var patronProfile = patron.profile.name.toLowerCase();
-var copyStatus = copy.status.name.toLowerCase();
-var patronItemsOut = environment.patronItemsOut;
-var patronFines = environment.patronFines;
-var isRenewal = environment.isRenewal;
+log_vars('circ_recurring_fines');
/**
Set some sane defaults. Valid values for result.recurringFinesLevel
# ---------------------------------------------------------------------
$logger->debug("Running circ script: " . $scripts{circ_permit_patron});
- #$runner->load($scripts{circ_permit_patron});
- $runner->run($scripts{circ_permit_patron}) or
+ $runner->load($scripts{circ_permit_patron});
+ my $result = $runner->run or
throw OpenSRF::EX::ERROR ("Circ Permit Patron Script Died: $@");
- my $patron_events = $runner->retrieve('result.events');
- $patron_events = [ split(/,/, $patron_events) ];
+ my $patron_events = $result->{events};
$ctx->{circ_permit_patron_events} = $patron_events;
$logger->activity("circ_permit_patron for returned @$patron_events") if @$patron_events;
# Capture all of the copy permit events
# ---------------------------------------------------------------------
$runner->load($scripts{circ_permit_copy});
- $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Copy Script Died: $@");
+ $result = $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Copy Script Died: $@");
+ my $copy_events = $result->{events};
- my $copy_events = $runner->retrieve('result.events');
- $copy_events = [ split(/,/, $copy_events) ];
$ctx->{circ_permit_copy_events} = $copy_events;
$logger->activity("circ_permit_copy for copy ".
"$barcode returned events: @$copy_events") if @$copy_events;
$runner->insert('result.maxFine');
$runner->load($scripts{circ_duration});
- $runner->run or throw OpenSRF::EX::ERROR ("Circ Duration Script Died: $@");
- my $duration = $runner->retrieve('result.durationRule');
+ my $result = $runner->run or throw OpenSRF::EX::ERROR ("Circ Duration Script Died: $@");
+ my $duration = $result->{durationRule};
+ my $dur_level = $result->{durationLevel};
$logger->debug("Circ duration script yielded a duration rule of: $duration");
$runner->load($scripts{circ_recurring_fines});
- $runner->run or throw OpenSRF::EX::ERROR ("Circ Recurring Fines Script Died: $@");
- my $recurring = $runner->retrieve('result.recurringFinesRule');
+ $result = $runner->run or throw OpenSRF::EX::ERROR ("Circ Recurring Fines Script Died: $@");
+ my $recurring = $result->{recurringFinesRule};
+ my $rec_fines_level = $result->{recurringFinesLevel};
$logger->debug("Circ recurring fines script yielded a rule of: $recurring");
$runner->load($scripts{circ_max_fines});
- $runner->run or throw OpenSRF::EX::ERROR ("Circ Max Fine Script Died: $@");
- my $max_fine = $runner->retrieve('result.maxFine');
+ $result = $runner->run or throw OpenSRF::EX::ERROR ("Circ Max Fine Script Died: $@");
+ my $max_fine = $result->{maxFine};
$logger->debug("Circ max_fine fines script yielded a rule of: $max_fine");
($duration, $evt) = $U->fetch_circ_duration_by_name($duration);
($max_fine, $evt) = $U->fetch_max_fine_by_name($max_fine);
return $evt if $evt;
- $ctx->{duration_level} = $runner->retrieve('result.durationLevel');
- $ctx->{recurring_fines_level} = $runner->retrieve('result.recurringFinesLevel');
+ $ctx->{duration_level} = $dur_level;
+ $ctx->{recurring_fines_level} = $rec_fines_level;
$ctx->{duration_rule} = $duration;
$ctx->{recurring_fines_rule} = $recurring;
$ctx->{max_fine_rule} = $max_fine;
$U->logmark;
$runner->load($scripts{circ_permit_renew});
- $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Renew Script Died: $@");
+ my $result = $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Renew Script Died: $@");
+ my $events = $result->{events};
- my $events = $runner->retrieve('result.events');
- $events = [ split(/,/, $events) ];
$logger->activity("circ_permit_renew for user ".
$ctx->{patron}->id." returned events: @$events") if @$events;
$runner->insert( "$evt.patronFines", $ctx->{patronFines}, 1 );
# circ script result
- $runner->insert("result", {});
- $runner->insert("result.event", 'SUCCESS');
- $runner->insert("result.events", []);
- $runner->insert('result.fatalEvents', []);
- $runner->insert('result.infoEvents', []);
+ #$runner->insert("result", {});
+ #$runner->insert("result.event", 'SUCCESS');
+ #$runner->insert("result.events", []);
+ #$runner->insert('result.fatalEvents', []);
+ #$runner->insert('result.infoEvents', []);
$runner->insert("$evt.$_", $ctx->{_direct}->{$_}) for keys %{$ctx->{_direct}};
# - Load up the script and run it
$runner->add_path($path);
- $runner->run($script) or
- throw OpenSRF::EX::ERROR ("Patron Penalty Script Died: $@");
+ $runner->load($script);
+ my $result = $runner->run or throw OpenSRF::EX::ERROR ("Patron Penalty Script Died: $@");
- # array items are returned as a comma-separated list of strings
- my @fatals = split( /,/, $runner->retrieve($fatal_key) );
- my @infos = split( /,/, $runner->retrieve($info_key) );
+ my @fatals = @{$result->{fatalEvents}};
+ my @infos = @{$result->{infoEvents}};
my $all = [ @fatals, @infos ];
$logger->info("penalty: script returned fatal events [@fatals] and info events [@infos]");
}
);
-# my $runner = OpenILS::Utils::ScriptRunner->new;
-#
-# $runner->insert( "$k.patron", $$params{patron}, 1);
-# $runner->insert( "$k.title", $$params{title}, 1);
-# $runner->insert( "$k.copy", $$params{copy}, 1);
-# $runner->insert( "$k.requestor", $$params{requestor}, 1);
-# $runner->insert( "$k.requestLib", $$params{request_lib}, 1);
-# $runner->insert( "$k.pickupLib", $$params{pickup_lib}, 1);
-# $runner->insert( "$k.titleDescriptor", $$params{title_descriptor},1);
-
-# # we get the script result from the event
-# $runner->insert( "result.event", 'SUCCESS' );
-# $runner->insert( "result.events", [] );
-
$logger->debug("Running permit_copy_hold on copy " . $$params{copy}->id);
load_scripts($runner);
- $runner->run or throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@");
- my $evtname = $runner->retrieve('result.event');
-
+ my $result = $runner->run or throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@");
# --------------------------------------------------------------
# Extract and uniquify the event list
# --------------------------------------------------------------
- my $events = $runner->retrieve('result.events');
- $events = [ split(/,/, $events) ];
+ my $events = $result->{events};
$logger->debug("circ_permit_hold for user ".$params->{patron}->id." returned events: @$events");
my @allevents;