{CK => $details->{media_type}},
{CM => $details->{hold_pickup_date}},
{CT => $details->{destination_loc}},
- {CY => $details->{hold_patron_barcode}}
+ {CY => $details->{hold_patron_barcode}},
+ $SC->stat_cat_sip_fields($details->{item})
]
};
}
$response->{code} = '64';
- #return $response unless $details;
unless ($details) {
push(
@{$response->{fixed_fields}},
push(
@{$response->{fields}},
- {BE => $patron->email},
+ {AQ => $patron->home_ou->name},
{PA => $SC->sipymd($patron->expire_date)},
{PB => $SC->sipymd($patron->dob, 1)},
{PC => $patron->profile->name},
- {XI => $patron->id}
+ {XI => $patron->id},
+ $SC->stat_cat_sip_fields($details->{item})
);
+ $SC->maybe_add_field($response, BD => $details->{patron_address});
+ $SC->maybe_add_field($response, BE => $patron->email);
+ $SC->maybe_add_field($response, BF => $details->{patron_phone});
+ $SC->maybe_add_field($response,
+ PI => $patron->net_access_level ? $patron->net_access_level->name : '');
+
if ($list_items eq 'hold_items') {
for my $hold (@{$details->{hold_items}}) {
push(@{$response->{fields}}, {AS => $hold});
);
}
+# $source is either an actor.usr or an asset.copy.
+# Returns a list of extra fields.
+sub stat_cat_sip_fields {
+ my ($class, $source) = @_;
+ my @extras;
+
+ for my $entry_map (@{$source->stat_cat_entries}) {
+ my $stat_cat = $entry_map->stat_cat;
+ next unless $stat_cat->sip_field;
+
+ my $value = $entry_map->stat_cat_entry;
+ my $format = $stat_cat->sip_format;
+
+ if (defined $format) {
+
+ if ($format =~ /^\|(.*)\|$/) { # Is format a regex?
+
+ if ($value =~ /($1)/) {
+ # Regex has matched.
+
+ if (defined $2) {
+ # We have an embedded capture group. Use it.
+ $value = $2;
+ } else {
+ # No embedded capture group
+ $value = $1; # Use our outer one
+ }
+ } else {
+ # No match
+ # Empty string. Will be checked for below.
+ $value = '';
+ }
+ } else { # Not a regex
+
+ # Try sprintf match (looking for a %s, if any)
+ $value = sprintf($format, $value);
+ }
+ }
+
+ next unless length($value) > 0; # No value = no export
+
+ push(@extras, {$stat_cat->sip_field => $value});
+ }
+
+ return @extras;
+}
+
1;
billing_address
mailing_address
profile
+ home_ou
+ net_access_level
stat_cat_entries
/],
actscecm => [qw/stat_cat/]
my $patron = $details->{patron} = $card->usr;
$card->usr($card->usr->id);
$patron->card($card);
+ $details->{patron_phone} =
+ $patron->day_phone || $patron->evening_phone || $patron->other_phone;
+
+ if (my $addr = $patron->billing_address || $patron->mailing_address) {
+
+ my $addrstr = join(' ', map {$_ || ''} (
+ $addr->street1,
+ $addr->street2,
+ $addr->city . ',',
+ $addr->county,
+ $addr->state,
+ $addr->country,
+ $addr->post_code
+ ));
+
+ $addrstr =~ s/\s+/ /sg; # Compress spaces
+
+ $details->{patron_address} = $addrstr;
+ }
if (defined $password) {
# SIP still replies with the patron data if the password