From: Bill Erickson Date: Wed, 9 Sep 2020 19:48:21 +0000 (-0400) Subject: more patron info fields; date handling X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ca14e22238e922431660cebef3c0123277374e88;p=working%2FEvergreen.git more patron info fields; date handling Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2.pm index e0ed21b445..0c55354c56 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2.pm @@ -215,6 +215,7 @@ sub handle_patron_info { $response->{code} = '64'; return $response unless $pdetails; + my $patron = $pdetails->{patron}; push( @{$response->{fixed_fields}}, @@ -226,6 +227,15 @@ sub handle_patron_info { $SC->count4($pdetails->{unavail_holds_count}) ); + push( + @{$response->{fields}}, + {BE => $patron->email}, + {PA => $SC->sipymd($patron->expire_date)}, + {PB => $SC->sipymd($patron->dob, 1)}, + {PC => $patron->profile->name}, + {XI => $patron->id} + ); + if ($list_items eq 'hold_items') { for my $hold (@{$pdetails->{hold_items}}) { push(@{$response->{fields}}, {AS => $hold}); @@ -327,13 +337,9 @@ sub patron_response_common_data { fields => [ {AO => $session->config->{institution}}, {AA => $barcode}, - {BL => $SC->sipbool(1)}, # valid patron - {BV => $pdetails->{balance_owed}}, # fee amount - {CQ => $SC->sipbool($password)}, # password verified if exists - {PA => $SC->format_date($session, $patron->expire_date)}, - ($patron->dob ? - {PB => $SC->format_date($session, $patron->dob, 'dob')} : ()), - {PC => $patron->profile->name} + {BL => $SC->sipbool(1)}, # valid patron + {BV => $pdetails->{balance_owed}}, # fee amount + {CQ => $SC->sipbool($password)} # password verified if exists ] }; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Common.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Common.pm index 304c647d3a..8433775dc7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Common.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Common.pm @@ -10,44 +10,20 @@ sub sipdate { return $date->strftime(SIP_DATE_FORMAT); } -sub format_date { - my ($class, $session, $date, $type) = @_; - $type ||= ''; +sub sipymd { + my ($class, $date_str, $to_local_tz) = @_; + return '' unless $date_str; - return "" unless $date; - - my $dt = DateTime::Format::ISO8601->new-> parse_datetime(clean_ISO8601($date)); + my $dt = DateTime::Format::ISO8601->new + ->parse_datetime(clean_ISO8601($date_str)); # actor.usr.dob stores dates without time/timezone, which causes - # DateTime to assume the date is stored as UTC. Tell DateTime - # to use the local time zone, instead. - # Other dates will have time zones and should be parsed as-is. - $dt->set_time_zone('local') if $type eq 'dob'; - - my @time = localtime($dt->epoch); - - my $year = $time[5]+1900; - my $mon = $time[4]+1; - my $day = $time[3]; - my $hour = $time[2]; - my $minute = $time[1]; - my $second = $time[0]; - - $date = sprintf("%04d%02d%02d", $year, $mon, $day); - - # Due dates need hyphen separators and time of day as well - if ($type eq 'due') { - - if ($session->config->{due_date_use_sip_date_format}) { - $date = $class->sipdate($dt); - - } else { - $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", - $year, $mon, $day, $hour, $minute, $second); - } - } + # DateTime to assume the date is stored as UTC. Tell DateTime to + # use the local time zone, instead. Other dates will have time + # zones and should be parsed as-is. + $dt->set_time_zone('local') if $to_local_tz; - return $date; + return $dt->strftime('%Y%m%d'); } # False == 'N' diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Patron.pm index 04ec361e50..b619cf9be9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Patron.pm @@ -328,8 +328,6 @@ sub set_patron_privileges { my $expire = DateTime::Format::ISO8601->new ->parse_datetime(clean_ISO8601($patron->expire_date)); - $details->{expire_date} = $SC->format_date($patron->expire_date); - if ($expire < DateTime->now) { $logger->info("SIP2 Patron account is expired; all privileges blocked"); $details->{charge_denied} = 1;