load_lib('circ/circ_lib.js');
log_debug('loading circ_item_config.js ...');
+
+/* SIP media types
+000 Other
+001 Book
+002 Magazine
+003 Bound journal
+004 Audio tape
+005 Video tape
+006 CD/CDROM
+007 Diskette
+008 Book with diskette
+009 Book with CD
+010 Book with audio tape
+*/
+
/* -----------------------------------------------------------------------------
Configure the duration rules for the various item types and circ modifiers
var MARC_ITEM_TYPE_MAP = {
a : { /* Language material [Books] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
t : { /* Manuscript language material [Books] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
g : { /* Projected medium [Videos, etc.] */
+ SIPMediaType : '005',
magneticMedia : 'f',
durationRule : '7_days_0_renew',
recurringFinesRule : '10_cent_per_day',
},
k : { /* Two-dimensional nonprojectable graphic [Card, charts, etc.] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '3_month_0_renew',
recurringFinesRule : '10_cent_per_day',
},
r : { /* Three-dimensional artifact or naturally occurring object [Models, games, etc.] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
o : { /* Kit [Mixture of item types] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
p : { /* Mixed materials [Mixture of item types] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
e : { /* Cartographic material [Map] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
f : { /* Manuscript cartographic material [Map] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '3_days_1_renew',
recurringFinesRule : '50_cent_per_day',
},
c : { /* Notated music [Printed music] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
d : { /* Manuscript notated music [Printed music] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
i : { /* Nonmusical sound recording [Audiobooks, sound effects, etc.] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
j : { /* Musical sound recording [Music] */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
m : { /* Computer file */
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
var CIRC_MOD_MAP = {
'art' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '3_month_0_renew',
recurringFinesRule : '10_cent_per_day',
},
'atlas' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
'audiobook' : {
+ SIPMediaType : '004',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'av' : {
+ SIPMediaType : '005',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
'bestseller' : {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
'bestsellernh' : {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
'book' : {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'cd' : {
+ SIPMediaType : '006',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'dvd' : {
+ SIPMediaType : '006',
magneticMedia : 'f',
durationRule : '7_days_0_renew',
recurringFinesRule : '50_cent_per_day',
},
'e-book' : {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '3_days_1_renew',
recurringFinesRule : '50_cent_per_day',
},
'equipment' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '3_days_1_renew',
recurringFinesRule : '50_cent_per_day',
},
'filmstrip' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'kit' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'magazine' : {
+ SIPMediaType : '002',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'map' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '3_days_1_renew',
recurringFinesRule : '50_cent_per_day',
},
'microform' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'music' : {
+ SIPMediaType : '004',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'record' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'software' : {
+ SIPMediaType : '006',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '10_cent_per_day',
},
'talking book' : {
+ SIPMediaType : '006',
magneticMedia : 'f',
durationRule : 'unlimited',
},
'toy' : {
+ SIPMediaType : '000',
magneticMedia : 'f',
durationRule : '7_days_2_renew',
recurringFinesRule : '50_cent_per_day',
},
'video' : {
+ SIPMediaType : '005',
magneticMedia : 'f',
durationRule : '7_days_0_renew',
recurringFinesRule : '50_cent_per_day',
CIRC_MOD_MAP['REALIA'] = CIRC_MOD_MAP['book'];
CIRC_MOD_MAP['RESERVE'] = CIRC_MOD_MAP['book'];
CIRC_MOD_MAP['STATE-BOOK'] = {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '35_days_1_renew',
recurringFinesRule : "10_cent_per_day",
maxFine : "overdue_mid"
};
CIRC_MOD_MAP['STATE-MFRM'] = {
+ SIPMediaType : '001',
magneticMedia : 'f',
durationRule : '14_days_2_renew',
recurringFinesRule : "10_cent_per_day",
use OpenILS::Application::AppUtils;
use OpenILS::Application::Circ::ScriptBuilder;
use Data::Dumper;
+use OpenILS::Const qw/:const/;
+use OpenSRF::Utils qw/:datetime/;
+use DateTime::Format::ISO8601;
my $U = 'OpenILS::Application::AppUtils';
my %item_db;
sub magnetic {
my $self = shift;
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 {
my $self = shift;
- return '001';
+ return 0 unless $self->run_attr_script;
+ my $media = $self->{item_config_result}->{SIPMediaType};
+ syslog('LOG_DEBUG', "OILS: media type = $media");
+ return ($media) ? $media : '001';
}
sub sip_item_properties {
# 13 Missing
sub sip_circulation_status {
my $self = shift;
- return '03' if $self->{copy}->status->name =~ /available/i;
- return '04' if $self->{copy}->status->name =~ /checked out/i;
- return '06' if $self->{copy}->status->name =~ /in process/i;
- return '08' if $self->{copy}->status->name =~ /on holds shelf/i;
- return '09' if $self->{copy}->status->name =~ /reshelving/i;
- return '10' if $self->{copy}->status->name =~ /in transit/i;
- return '12' if $self->{copy}->status->name =~ /lost/i;
+ my $stat = $self->{copy}->status->id;
+
+ return '02' if $stat == OILS_COPY_STATUS_ON_ORDER;
+ return '03' if $stat == OILS_COPY_STATUS_AVAILABLE;
+ return '04' if $stat == OILS_COPY_STATUS_CHECKED_OUT;
+ return '06' if $stat == OILS_COPY_STATUS_IN_PROCESS;
+ return '08' if $stat == OILS_COPY_STATUS_ON_HOLDS_SHELF;
+ return '09' if $stat == OILS_COPY_STATUS_RESHELVING;
+ return '10' if $stat == OILS_COPY_STATUS_IN_TRANSIT;
+ return '12' if $stat == OILS_COPY_STATUS_LOST;
+ return '13' if $stat == OILS_COPY_STATUS_MISSING;
+
return 01;
}
sub fee_currency {
- my $self = shift;
- 'USD';
+ my $self = shift;
+ return OpenILS::SIP->config()->{implementation_config}->{currency};
}
sub owner {
} )->[0];
}
- return $circ->due_date if $circ;
- return 0;
+ return 0 unless $circ;
+ my $due = OpenILS::SIP->format_date($circ->due_date);
+ syslog('LOG_DEBUG', "Item due date = $due");
+ return $due;
}
sub recall_date {
sub sip_birthdate {
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";
-
+ my $dob = OpenILS::SIP->format_date($self->{user}->dob);
syslog('LOG_DEBUG', "OILS: Patron DOB = $dob");
-
return $dob;
}
sub __copy_to_title {
my( $e, $copy ) = @_;
- syslog('LOG_DEBUG', "OILS: 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', "OILS: 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', "OILS: 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', "OILS: 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);
#$overdues[$_] = __circ_to_title($self->{editor}, $overdues[$_]) for @overdues;
my @o;
+ syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues");
for my $circid (@overdues) {
next unless $circid;
- syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circ $circid");
push( @o, __circ_to_title($self->{editor}, $circid) );
}
@overdues = @o;
#$charges[$_] = __circ_to_title($self->{editor}, $charges[$_]) for @charges;
my @c;
+ syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges");
for my $circid (@charges) {
next unless $circid;
- syslog('LOG_DEBUG', "OILS: charged_items() fleshing circ $circid");
push( @c, __circ_to_title($self->{editor}, $circid) );
}
@charges = @c;