<item name='item status update' value='false'/>
<item name='patron enable' value='false'/>
<item name='hold' value='false'/>
- <item name='renew' value='true'/>
+ <item name='renew' value='true'/>
<item name='renew all' value='false'/>
</supports>
+
+ <scripts>
+ <path>/openils/var/</path>
+ <item_config>circ/circ_item_config.js</item_config>
+ <scripts>
+
</implementation_config>
</institution>
maxFine : "overdue_mid"
};
+/* this will set defaults even if no one asked for them */
+log_debug("Calling getItemConfig() to force defaults..");
+getItemConfig();
+log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
+
function getItemConfig() {
config = MARC_ITEM_TYPE_MAP[marcType];
}
- if( config ) {
- /* go ahead and set some default result
- data (which may be overidden) */
- for( var i in config )
- result[i] = config[i];
+ /* if no config could be found, default to 'book' */
+ if(!config) {
+ log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
+ config = CIRC_MOD_MAP['book'];
+ }
+
+ /* go ahead and set some default result
+ data (which may be overidden) */
+ for( var i in config ) {
+ log_debug("item_config setting result defaults: "+i+" = " +config[i]);
+ result[i] = config[i];
}
return config;
my $self = {};
$config = $institution;
- syslog("LOG_DEBUG", "new ILS '%s'", $institution->{id});
+ syslog("LOG_DEBUG", "OILS: new ILS '%s'", $institution->{id});
$self->{institution} = $institution;
my $bsconfig = $institution->{implementation_config}->{bootstrap};
- syslog('LOG_DEBUG', "loading bootstrap config: $bsconfig");
+ syslog('LOG_DEBUG', "OILS: loading bootstrap config: $bsconfig");
local $/ = "\n";
OpenSRF::System->bootstrap_client(config_file => $bsconfig);
- syslog('LOG_DEBUG', "bootstrap loaded..");
+ syslog('LOG_DEBUG', "OILS: bootstrap loaded..");
$self->{osrf_config} = OpenSRF::Utils::SettingsClient->new;
return editor();
}
+sub config {
+ return $config;
+}
+
# Creates the global editor object
sub make_editor {
my $e = OpenILS::Utils::CStoreEditor->new(xact => 1);
# gnarly cstore hack to re-gen autogen methods after IDL is loaded
if(!UNIVERSAL::can($e, 'search_actor_card')) {
- syslog("LOG_WARNING", "Reloading CStoreEditor...");
+ syslog("LOG_WARNING", "OILS: Reloading CStoreEditor...");
delete $INC{'OpenILS/Utils/CStoreEditor.pm'};
require OpenILS::Utils::CStoreEditor;
$e = OpenILS::Utils::CStoreEditor->new(xact =>1);
sub login {
my( $self, $username, $password ) = @_;
- syslog('LOG_DEBUG', "OpenILS: Logging in with username $username");
+ syslog('LOG_DEBUG', "OILS: Logging in with username $username");
my $seed = $U->simplereq(
'open-ils.auth',
if( my $code = $U->event_code($response) ) {
my $txt = $response->{textcode};
- syslog('LOG_WARNING', "OpenILS: Login failed for $username. $txt:$code");
+ syslog('LOG_WARNING', "OILS: Login failed for $username. $txt:$code");
return undef;
}
my $key = $response->{payload}->{authtoken};
- syslog('LOG_INFO', "OpenILS: Login succeeded for $username : authkey = $key");
+ syslog('LOG_INFO', "OILS: Login succeeded for $username : authkey = $key");
return $self->{authtoken} = $key;
}
my ($self, $id, $whence) = @_;
if ($id ne $self->{institution}->{id}) {
syslog("LOG_WARNING",
- "%s: received institution '%s', expected '%s'",
+ "OILS: %s: received institution '%s', expected '%s'",
$whence, $id, $self->{institution}->{id});
}
}
sub checkout {
my ($self, $patron_id, $item_id, $sc_renew) = @_;
- syslog('LOG_DEBUG', "OpenILS::Checkout attempt: patron=$patron_id, item=$item_id");
+ syslog('LOG_DEBUG', "OILS: OpenILS::Checkout attempt: patron=$patron_id, item=$item_id");
my $xact = OpenILS::SIP::Transaction::Checkout->new( authtoken => $self->{authtoken} );
my $patron = $self->find_patron($patron_id);
return $xact;
}
- syslog('LOG_DEBUG', "OpenILS::Checkout data loaded OK, checking out...");
+ syslog('LOG_DEBUG', "OILS: OpenILS::Checkout data loaded OK, checking out...");
$xact->do_checkout();
if ($item->{patron} && ($item->{patron} ne $patron_id)) {
if( $xact->ok ) {
#editor()->commit;
- syslog("LOG_DEBUG", "OpenILS::Checkout: " .
+ syslog("LOG_DEBUG", "OILS: OpenILS::Checkout: " .
"patron %s checkout %s succeeded", $patron_id, $item_id);
} else {
#editor()->xact_rollback;
- syslog("LOG_DEBUG", "OpenILS::Checkout: " .
+ syslog("LOG_DEBUG", "OILS: OpenILS::Checkout: " .
"patron %s checkout %s FAILED, rolling back xact...", $patron_id, $item_id);
}
my ($self, $item_id, $trans_date, $return_date,
$current_loc, $item_props, $cancel) = @_;
- syslog('LOG_DEBUG', "OpenILS::Checkin on item=$item_id");
+ syslog('LOG_DEBUG', "OILS: OpenILS::Checkin on item=$item_id");
my $patron;
my $xact = OpenILS::SIP::Transaction::Checkin->new(authtoken => $self->{authtoken});
$xact->patron($patron = $self->find_patron($item->{patron}));
delete $item->{patron};
delete $item->{due_date};
- syslog('LOG_INFO', "OpenILS: Checkin succeeded");
+ syslog('LOG_INFO', "OILS: Checkin succeeded");
#editor()->commit;
} else {
#editor()->xact_rollback;
- syslog('LOG_WARNING', "OpenILS: Checkin failed");
+ syslog('LOG_WARNING', "OILS: Checkin failed");
}
# END TRANSACTION
use OpenILS::SIP;
use OpenILS::SIP::Transaction;
use OpenILS::Application::AppUtils;
+use OpenILS::Application::Circ::ScriptBuilder;
+use Data::Dumper;
my $U = 'OpenILS::Application::AppUtils';
my %item_db;
my $type = ref($class) || $class;
my $self = bless( {}, $type );
- syslog('LOG_DEBUG', "Loading item $item_id...");
+ syslog('LOG_DEBUG', "OILS: Loading item $item_id...");
return undef unless $item_id;
my $e = OpenILS::SIP->editor();
- # FLESH ME
my $copy = $e->search_asset_copy(
[
{ barcode => $item_id },
]
);
+
$copy = $$copy[0];
if(!$copy) {
- syslog("LOG_DEBUG", "OpenILS: Item '%s' : not found", $item_id);
+ syslog("LOG_DEBUG", "OILS: Item '%s' : not found", $item_id);
return undef;
}
$self->{patron} = $bc;
$self->{patron_object} = $user;
- syslog('LOG_DEBUG', "Open circulation exists on $item_id : user = $bc");
+ syslog('LOG_DEBUG', "OILS: Open circulation exists on $item_id : user = $bc");
}
$self->{id} = $item_id;
$self->{record} = $copy->call_number->record;
$self->{mods} = $U->record_to_mvr($self->{record}) if $self->{record}->marc;
- syslog("LOG_DEBUG", "Item('$item_id'): found with title '%s'", $self->title_id);
+ syslog("LOG_DEBUG", "OILS: Item('$item_id'): found with title '%s'", $self->title_id);
return $self;
}
+sub run_attr_script {
+ my $self = shift;
+ return 1 if $self->{ran_script};
+ $self->{ran_script} = 1;
+
+ my $config = OpenILS::SIP->config();
+ my $path = $config->{implementation_config}->{scripts}->{path};
+ my $item_config_script = $config->{implementation_config}->{scripts}->{item_config};
+
+ syslog('LOG_DEBUG', "OILS: Script path = $path, Item config script = $item_config_script");
+
+ my $runner =
+ OpenILS::Application::Circ::ScriptBuilder->build(
+ {
+ copy => $self->{copy},
+ editor => OpenILS::SIP->editor(),
+ }
+ );
+
+ $runner->add_path($path);
+ $runner->load($item_config_script);
+
+ unless( $self->{item_config_result} = $runner->run ) {
+ warn "Item config script [$path : $item_config_script] failed to run: $@\n";
+ syslog('LOG_ERR', "OILS: Item config script [$path : $item_config_script] failed to run: $@");
+ return undef;
+ }
+
+ return 1;
+}
+
sub magnetic {
my $self = shift;
- return 0;
+ return 0 unless $self->run_attr_script;
+ syslog('LOG_DEBUG', "OILS: ITEM CONFIG => ". Dumper($self->{item_config_result}));
+ my $mag = $self->{item_config_result}->{magneticMedia};
+ syslog('LOG_DEBUG', "OILS: magnetic = $mag");
+ return ($mag and $mag eq 't') ? 1 : 0;
}
sub sip_media_type {
use OpenILS::SIP;
use OpenILS::Application::AppUtils;
use OpenILS::Application::Actor;
+use OpenSRF::Utils qw/:datetime/;
+use DateTime::Format::ISO8601;
my $U = 'OpenILS::Application::AppUtils';
our (@ISA, @EXPORT_OK);
my $type = ref($class) || $class;
my $self = {};
- syslog("LOG_DEBUG", "new OpenILS Patron(%s): searching...", $patron_id);
+ syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s): searching...", $patron_id);
my $e = OpenILS::SIP->editor();
}
if(!$user) {
- syslog("LOG_WARNING", "Unable to find patron %s", $patron_id);
+ syslog("LOG_WARNING", "OILS: Unable to find patron %s", $patron_id);
return undef;
}
$self->{id} = $patron_id;
$self->{editor} = $e;
- syslog("LOG_DEBUG", "new OpenILS Patron(%s): found patron : barred=%s, card:active=%s",
+ syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s): found patron : barred=%s, card:active=%s",
$patron_id, $self->{user}->barred, $self->{user}->card->active );
my $self = shift;
my $u = $self->{user};
my $addr = $u->billing_address;
+ $addr = $u->mailing_address unless $addr;
my $str = __addr_string($addr);
- my $maddr = $u->mailing_address;
- $str .= "\n" . __addr_string($maddr)
- if $maddr and $maddr->id ne $addr->id;
+ syslog('LOG_DEBUG', "OILS: Patron address: $str");
+ #my $maddr = $u->mailing_address;
+ #$str .= "\n" . __addr_string($maddr)
+ #if $maddr and $maddr->id ne $addr->id;
return $str;
}
}
sub sip_birthdate {
- my $self = shift;
- return $self->{user}->dob;
+ my $self = shift;
+ my $dob = $self->{user}->dob;
+ return "" unless $dob;
+
+ $dob = DateTime::Format::ISO8601->new->
+ parse_datetime(OpenSRF::Utils::clense_ISO8601($dob));
+ my @time = localtime($dob->epoch);
+
+ my $year = $time[5]+1900;
+ my $mon = $time[4]+1;
+ my $day = $time[3];
+
+ $mon =~ s/^(\d)$/0$1/;
+ $day =~ s/^(\d)$/0$1/;
+ $dob = "$year$mon$day";
+
+ syslog('LOG_DEBUG', "OILS: Patron DOB = $dob");
+
+ return $dob;
}
sub ptype {
sub __copy_to_title {
my( $e, $copy ) = @_;
- syslog('LOG_DEBUG', "copy_to_title(%s)", $copy->id);
+ syslog('LOG_DEBUG', "OILS: copy_to_title(%s)", $copy->id);
return $copy->dummy_title if $copy->call_number == -1;
my $vol = $e->retrieve_asset_call_number($copy->call_number);
return __volume_to_title($e, $vol);
sub __volume_to_title {
my( $e, $volume ) = @_;
- syslog('LOG_DEBUG', "volume_to_title(%s)", $volume->id);
+ syslog('LOG_DEBUG', "OILS: volume_to_title(%s)", $volume->id);
return __record_to_title($e, $volume->record);
}
sub __record_to_title {
my( $e, $title_id ) = @_;
- syslog('LOG_DEBUG', "record_to_title($title_id)");
+ syslog('LOG_DEBUG', "OILS: record_to_title($title_id)");
my $mods = $U->simplereq(
'open-ils.search',
'open-ils.search.biblio.record.mods_slim.retrieve', $title_id );
sub __metarecord_to_title {
my( $e, $m_id ) = @_;
- syslog('LOG_DEBUG', "metarecord_to_title($m_id)");
+ syslog('LOG_DEBUG', "OILS: metarecord_to_title($m_id)");
my $mods = $U->simplereq(
'open-ils.search',
'open-ils.search.biblio.metarecord.mods_slim.retrieve', $m_id);
- return ($mods) ? $mods->title : "";
+ return ($U->event_code($mods)) ? "<unknown>" : $mods->title;
}
my @o;
for my $circid (@overdues) {
next unless $circid;
- syslog('LOG_DEBUG', "overdue_items() fleshing circ $circid");
+ syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circ $circid");
push( @o, __circ_to_title($self->{editor}, $circid) );
}
@overdues = @o;
my @c;
for my $circid (@charges) {
next unless $circid;
- syslog('LOG_DEBUG', "charged_items() fleshing circ $circid");
+ syslog('LOG_DEBUG', "OILS: charged_items() fleshing circ $circid");
push( @c, __circ_to_title($self->{editor}, $circid) );
}
@charges = @c;
my $u = $self->{user};
my $e = $self->{editor} = OpenILS::SIP->reset_editor();
- syslog('LOG_INFO', "Blocking user %s", $u->card->barcode );
+ syslog('LOG_INFO', "OILS: Blocking user %s", $u->card->barcode );
return $self if $u->card->active eq 'f';
$u->card->active('f');
if( ! $e->update_actor_card($u->card) ) {
- syslog('LOG_ERR', "Block card update failed: %s", $e->event->{textcode});
+ syslog('LOG_ERR', "OILS: Block card update failed: %s", $e->event->{textcode});
$e->xact_rollback;
return $self;
}
$u->alert_message($note);
if( ! $e->update_actor_user($u) ) {
- syslog('LOG_ERR', "Block: patron alert update failed: %s", $e->event->{textcode});
+ syslog('LOG_ERR', "OILS: Block: patron alert update failed: %s", $e->event->{textcode});
$e->xact_rollback;
return $self;
}
my $e = OpenILS::SIP->editor();
$INET_PRIVS = $e->retrieve_all_config_net_access_level() unless $INET_PRIVS;
my ($level) = grep { $_->id eq $self->{user}->net_access_level } @$INET_PRIVS;
- return $level->name;
+ my $name = $level->name;
+ syslog('LOG_DEBUG', "OILS: Patron inet_privs = $name");
+ return $name;
}
bless $self, $class;
$self->authtoken($args{authtoken});
- syslog('LOG_DEBUG', "OpenILS: Created new transaction with authtoken %s", $self->authtoken);
+ syslog('LOG_DEBUG', "OILS: Created new transaction with authtoken %s", $self->authtoken);
my $e = OpenILS::SIP->editor();
$e->{authtoken} = $self->authtoken;
if( my $code = $U->event_code($resp) ) {
my $txt = $resp->{textcode};
- syslog('LOG_INFO', "Checkin failed with event $code : $txt");
- $self->ok(0);
- return 0;
+ if( $txt ne 'ROUTE_ITEM' ) {
+ syslog('LOG_INFO', "OILS: Checkin failed with event $code : $txt");
+ $self->ok(0);
+ return 0;
+ }
}
my $circ = $resp->{payload}->{circ};
+ unless( $circ ) {
+ $self->ok(0);
+ return 0;
+ }
+
$self->{item}->{patron} =
OpenILS::SIP->editor->search_actor_card(
{ usr => $circ->usr, active => 't' } )->[0]->barcode;
# XXX Set $self->ok(0) on any errors
sub do_checkout {
my $self = shift;
- syslog('LOG_DEBUG', "OpenILS: performing checkout...");
+ syslog('LOG_DEBUG', "OILS: performing checkout...");
$self->ok(0);
if( ref($resp) eq 'ARRAY' ) {
my @e;
push( @e, $_->{textcode} ) for @$resp;
- syslog('LOG_INFO', "Checkout permit failed with events: @e");
+ syslog('LOG_INFO', "OILS: Checkout permit failed with events: @e");
return 0;
}
if( my $code = $U->event_code($resp) ) {
my $txt = $resp->{textcode};
- syslog('LOG_INFO', "Checkout permit failed with event $code : $txt");
+ syslog('LOG_INFO', "OILS: Checkout permit failed with event $code : $txt");
return 0;
}
my $key;
if( $key = $resp->{payload} ) {
- syslog('LOG_INFO', "OpenILS: circ permit key => $key");
+ syslog('LOG_INFO', "OILS: circ permit key => $key");
} else {
- syslog('LOG_WARN', "OpenILS: Circ permit failed :\n" . Dumper($resp) );
+ syslog('LOG_WARN', "OILS: Circ permit failed :\n" . Dumper($resp) );
return 0;
}
if( my $code = $U->event_code($resp) ) {
my $txt = $resp->{textcode};
- syslog('LOG_INFO', "Checkout failed with event $code : $txt");
+ syslog('LOG_INFO', "OILS: Checkout failed with event $code : $txt");
return 0;
}
- syslog('LOG_INFO', "OpenILS: Checkout succeeded");
+ syslog('LOG_INFO', "OILS: Checkout succeeded");
my $circ = $resp->{payload}->{circ};
$self->{'due'} = $circ->due_date;