use strict;
use warnings;
use Exporter;
-use Sys::Syslog qw(syslog);
use C4::SIP::Sip qw(:all);
use C4::SIP::Sip::Constants qw(:all);
use C4::Auth qw(&check_api_auth);
use Koha::Patron::Attributes;
+use Koha::Items;
use UNIVERSAL::can;
# it's using the 2.00 login process, so it must support 2.00.
$protocol_version = 2;
}
- syslog( "LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", $class, substr( $msg, 0, 10 ), $msgtag, $seqno, $protocol_version );
+ siplog( "LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", $class, substr( $msg, 0, 10 ), $msgtag, $seqno, $protocol_version );
# warn "SIP PROTOCOL: $protocol_version";
if ( !exists( $handlers{$msgtag} ) ) {
- syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", $msgtag, $msg );
+ siplog( "LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", $msgtag, $msg );
return;
} elsif ( !exists( $handlers{$msgtag}->{protocol}->{$protocol_version} ) ) {
- syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", $msgtag, $protocol_version );
+ siplog( "LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", $msgtag, $protocol_version );
return;
}
$self->{fields}->{$field} = undef;
}
- syslog( "LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", $self->{name}, $msg, $proto->{template}, $proto->{template_len} );
+ siplog( "LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", $self->{name}, $msg, $proto->{template}, $proto->{template_len} );
$self->{fixed_fields} = [ unpack( $proto->{template}, $msg ) ]; # see http://perldoc.perl.org/5.8.8/functions/unpack.html
$fn = substr( $field, 0, 2 );
if ( !exists( $self->{fields}->{$fn} ) ) {
- syslog( "LOG_WARNING", "Unsupported field '%s' in %s message '%s'", $fn, $self->{name}, $msg );
+ siplog( "LOG_WARNING", "Unsupported field '%s' in %s message '%s'", $fn, $self->{name}, $msg );
} elsif ( defined( $self->{fields}->{$fn} ) ) {
- syslog( "LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", $fn, $self->{fields}->{$fn}, $self->{name}, $msg );
+ siplog( "LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", $fn, $self->{fields}->{$fn}, $self->{name}, $msg );
} else {
$self->{fields}->{$fn} = substr( $field, 2 );
}
$error_detection = 1;
if ( !verify_cksum($msg) ) {
- syslog( "LOG_WARNING", "Checksum failed on message '%s'", $msg );
+ siplog( "LOG_WARNING", "Checksum failed on message '%s'", $msg );
# REQUEST_SC_RESEND with error detection
$last_response = REQUEST_SC_RESEND_CKSUM;
# We received a non-ED message when ED is supposed to be active.
# Warn about this problem, then process the message anyway.
- syslog( "LOG_WARNING", "Received message without error detection: '%s'", $msg );
+ siplog( "LOG_WARNING", "Received message without error detection: '%s'", $msg );
$error_detection = 0;
$self = C4::SIP::Sip::MsgType->new( $msg, 0 );
} else {
return substr( $msg, 0, 2 );
}
unless ( $self->{handler} ) {
- syslog( "LOG_WARNING", "No handler defined for '%s'", $msg );
+ siplog( "LOG_WARNING", "No handler defined for '%s'", $msg );
$last_response = REQUEST_SC_RESEND;
print("$last_response\r");
return REQUEST_ACS_RESEND;
$password_rc = $patron->check_password($patron_pwd);
}
- $resp .= patron_status_string($patron);
+ $resp .= patron_status_string( $patron, $server );
$resp .= $lang . timestamp();
- $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
+ if ( defined $server->{account}->{ae_field_template} ) {
+ $resp .= add_field( FID_PERSONAL_NAME, $patron->format( $server->{account}->{ae_field_template}, $server ) );
+ } else {
+ $resp .= add_field( FID_PERSONAL_NAME, $patron->name, $server );
+ }
+
# while the patron ID we got from the SC is valid, let's
# use the one returned from the ILS, just in case...
my $msg = $patron->screen_msg;
$msg .= ' -- '. INVALID_PW if $patron_pwd && !$password_rc;
- $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server );
$resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
if ( $server->{account}->{send_patron_home_library_in_af} );
$resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
+ $resp .= $patron->build_custom_field_string( $server );
$resp .= $patron->build_patron_attributes_string( $server );
} else {
( $protocol_version >= 2 )
and $resp .= add_field( FID_VALID_PATRON, 'N', $server );
- $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
}
$resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) }, $server );
# Off-line transactions need to be recorded, but there's
# not a lot we can do about it
- syslog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} );
+ siplog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} );
$status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date );
} else {
# Does the transaction date really matter for items that are
# checkout out while the terminal is online? I'm guessing 'no'
- $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack );
+ $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack, $account );
}
$item = $status->item;
$resp .= add_field( FID_DUE_DATE, q{}, $server );
}
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
if ( $protocol_version >= 2 ) {
# it's not due, so leave the date blank
$resp .= add_field( FID_DUE_DATE, '', $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
if ( $protocol_version >= 2 ) {
}
}
+ $resp .= $item->build_additional_item_fields_string( $server ) if $item;
+
if ( $protocol_version >= 2 ) {
# Financials : return irrespective of ok status
if ( $no_block eq 'Y' ) {
# Off-line transactions, ick.
- syslog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
+ siplog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
$status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
} else {
- $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok}, $account->{cv_triggers_alert} );
+ $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account );
}
$patron = $status->patron;
if ($item) {
$resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
$resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
+ $resp .= $item->build_additional_item_fields_string( $server );
}
if ( $protocol_version >= 2 ) {
$resp .= add_field( FID_PATRON_ID, $patron->id, $server );
}
if ($item) {
-$resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type, $server );
-$resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
-$resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code, $server );
-$resp .= maybe_add( FID_CALL_NUMBER, $item->call_number, $server );
-$resp .= maybe_add( FID_HOLD_PATRON_ID, $item->hold_patron_bcode, $server );
-$resp .= add_field( FID_DESTINATION_LOCATION, $item->destination_loc, $server ) if ( $item->destination_loc || $server->{account}->{ct_always_send} );
-$resp .= maybe_add( FID_HOLD_PATRON_NAME, $item->hold_patron_name( $server->{account}->{da_field_template} ), $server );
+ $resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type, $server );
+ $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
+ $resp .= maybe_add( FID_CALL_NUMBER, $item->call_number, $server );
+ $resp .= maybe_add( FID_HOLD_PATRON_ID, $item->hold_patron_bcode, $server );
+ $resp .= add_field( FID_DESTINATION_LOCATION, $item->destination_loc, $server ) if ( $item->destination_loc || $server->{account}->{ct_always_send} );
+ $resp .= maybe_add( FID_HOLD_PATRON_NAME, $item->hold_patron_name( $server->{account}->{da_field_template} ), $server );
+
+ if ( my $CR = $server->{account}->{cr_item_field} ) {
+ $resp .= maybe_add( FID_COLLECTION_CODE, $item->{$CR}, $server );
+ } else {
+ $resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code, $server );
+ }
if ( $status->hold and $status->hold->{branchcode} ne $item->destination_loc ) {
warn 'SIP hold mismatch: $status->hold->{branchcode}=' . $status->hold->{branchcode} . '; $item->destination_loc=' . $item->destination_loc;
} elsif ( $sc_protocol_version =~ /^2\./ ) {
$new_proto = 2;
} else {
- syslog( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version );
+ siplog( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version );
$new_proto = 1;
}
if ( $new_proto != $protocol_version ) {
- syslog( "LOG_INFO", "Setting protocol level to $new_proto" );
+ siplog( "LOG_INFO", "Setting protocol level to $new_proto" );
$protocol_version = $new_proto;
}
if ( $status == SC_STATUS_PAPER ) {
- syslog( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} );
+ siplog( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} );
} elsif ( $status == SC_STATUS_SHUTDOWN ) {
- syslog( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} );
+ siplog( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} );
}
$self->{account}->{print_width} = $print_width;
my $pwd = shift;
my $status = 1; # Assume it all works
if ( !exists( $server->{config}->{accounts}->{$uid} ) ) {
- syslog( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" );
+ siplog( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" );
$status = 0;
} elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) {
- syslog( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" );
+ siplog( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" );
$status = 0;
} else {
my $auth_status = api_auth( $uid, $pwd, $inst );
if ( !$auth_status or $auth_status !~ /^ok$/i ) {
- syslog( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) );
+ siplog( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) );
$status = 0;
} else {
- syslog( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst );
+ siplog( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst );
#
# initialize connection to ILS
#
my $module = $server->{config}->{institutions}->{$inst}->{implementation};
- syslog( "LOG_DEBUG", 'login_core: ' . Dumper($module) );
+ siplog( "LOG_DEBUG", 'login_core: ' . Dumper($module) );
# Suspect this is always ILS but so we don't break any eccentic install (for now)
if ( $module eq 'ILS' ) {
}
$module->use;
if ($@) {
- syslog( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst );
+ siplog( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst );
die("Failed to load ILS implementation '$module' for $inst");
}
# like ILS->new(), I think.
$server->{ils} = $module->new( $server->{institution}, $server->{account} );
if ( !$server->{ils} ) {
- syslog( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst );
+ siplog( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst );
die("Unable to connect to ILS '$inst'");
}
}
$pwd = $fields->{ (FID_LOGIN_PWD) }; # Terminal PWD, not patron PWD.
if ( $uid_algorithm || $pwd_algorithm ) {
- syslog( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" );
+ siplog( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" );
$status = 0;
} else {
$status = login_core( $server, $uid, $pwd );
sub summary_info {
my ( $ils, $patron, $summary, $start, $end, $server ) = @_;
my $resp = '';
- my $summary_type;
#
# Map from offsets in the "summary" field of the Patron Information
{ func => $patron->can("unavail_holds"), fid => FID_UNAVAILABLE_HOLD_ITEMS },
);
- if ( ( $summary_type = index( $summary, 'Y' ) ) == -1 ) {
- return ''; # No detailed information required
- }
+ my $summary_type = index( $summary, 'Y' );
+ return q{} if $summary_type == -1; # No detailed information required.
+ return q{} if $summary_type > 5; # Positions 6-9 are not defined in the sip spec,
+ # and we have no extensions to handle them.
- syslog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} );
+ siplog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} );
my $func = $summary_map[$summary_type]->{func};
my $fid = $summary_map[$summary_type]->{fid};
my $itemlist = &$func( $patron, $start, $end, $server );
- syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) );
+ siplog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) );
foreach my $i ( @{$itemlist} ) {
$resp .= add_field( $fid, $i->{barcode}, $server );
}
$resp = (PATRON_INFO_RESP);
if ($patron) {
$patron->update_lastseen();
- $resp .= patron_status_string($patron);
+ $resp .= patron_status_string( $patron, $server );
$resp .= ( defined($lang) and length($lang) == 3 ) ? $lang : $patron->language;
$resp .= timestamp();
# while the patron ID we got from the SC is valid, let's
# use the one returned from the ILS, just in case...
$resp .= add_field( FID_PATRON_ID, $patron->id, $server );
- $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
+ if ( defined $server->{account}->{ae_field_template} ) {
+ $resp .= add_field( FID_PERSONAL_NAME, $patron->format( $server->{account}->{ae_field_template} ), $server );
+ } else {
+ $resp .= add_field( FID_PERSONAL_NAME, $patron->name, $server );
+ }
# TODO: add code for the fields
# hold items limit
if( defined( $patron_pwd ) && !$password_rc ) {
$msg .= ' -- ' . INVALID_PW;
}
- $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server );
if ( $server->{account}->{send_patron_home_library_in_af} ) {
$resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server);
}
$resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
+ $resp .= $patron->build_custom_field_string( $server );
$resp .= $patron->build_patron_attributes_string( $server );
} else {
if ( $protocol_version >= 2 ) {
$resp .= add_field( FID_VALID_PATRON, 'N', $server );
}
- $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
}
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$resp .= add_field( FID_INST_ID, $server->{ils}->institution, $server );
$resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) }, $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
my $disallow_overpayment = $server->{account}->{disallow_overpayment};
my $payment_type_writeoff = $server->{account}->{payment_type_writeoff} || q{};
+ my $register_id = $server->{account}->{register_id};
my $is_writeoff = $pay_type eq $payment_type_writeoff;
$ils->check_inst_id( $inst_id, "handle_fee_paid" );
- $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
+ my $pay_result = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment, $register_id );
+ $status = $pay_result->{status};
+ my $pay_response = $pay_result->{pay_response};
+
+ my $failmap = {
+ "no_item" => "No matching item could be found",
+ "no_checkout" => "Item is not checked out",
+ "too_soon" => "Cannot yet be renewed",
+ "too_many" => "Renewed the maximum number of times",
+ "auto_too_soon" => "Scheduled for automatic renewal and cannot yet be renewed",
+ "auto_too_late" => "Scheduled for automatic renewal and cannot yet be any more",
+ "auto_account_expired" => "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
+ "auto_renew" => "Scheduled for automatic renewal",
+ "auto_too_much_oweing" => "Scheduled for automatic renewal",
+ "on_reserve" => "On hold for another patron",
+ "patron_restricted" => "Patron is currently restricted",
+ "item_denied_renewal" => "Item is not allowed renewal",
+ "onsite_checkout" => "Item is an onsite checkout"
+ };
+ my @success = ();
+ my @fail = ();
+ foreach my $result( @{$pay_response->{renew_result}} ) {
+ my $item = Koha::Items->find({ itemnumber => $result->{itemnumber} });
+ if ($result->{success}) {
+ push @success, '"' . $item->biblio->title . '"';
+ } else {
+ push @fail, '"' . $item->biblio->title . '" : ' . $failmap->{$result->{error}};
+ }
+ }
+
+ my $msg = "";
+ if (scalar @success > 0) {
+ $msg.="The following items were renewed: " . join(", ", @success) . ". ";
+ }
+ if (scalar @fail > 0) {
+ $msg.="The following items were not renewed: " . join(", ", @fail) . ".";
+ }
+ if (length $msg > 0) {
+ $status->screen_msg($status->screen_msg . " $msg");
+ }
$resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
$resp .= add_field( FID_INST_ID, $inst_id, $server );
$resp .= add_field( FID_PATRON_ID, $patron_id, $server );
$resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id, $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$resp .= maybe_add( FID_CURRENT_LOCN, $item->current_location, $server );
$resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
+ if ( my $CR = $server->{account}->{cr_item_field} ) {
+ $resp .= maybe_add( FID_COLLECTION_CODE, $item->{$CR}, $server );
+ } else {
+ $resp .= maybe_add( FID_COLLECTION_CODE, $item->collection_code, $server );
+ }
+
if ( ( $i = $item->fee ) != 0 ) {
$resp .= add_field( FID_CURRENCY, $item->fee_currency, $server );
$resp .= add_field( FID_FEE_AMT, $i, $server );
$resp .= add_field( FID_HOLD_PICKUP_DATE, timestamp($i), $server );
}
- $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
+
+ $resp .= $item->build_additional_item_fields_string( $server );
}
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$item_props = $fields->{ (FID_ITEM_PROPS) };
if ( !defined($item_id) ) {
- syslog( "LOG_WARNING", "handle_item_status: received message without Item ID field" );
+ siplog( "LOG_WARNING", "handle_item_status: received message without Item ID field" );
} else {
$item = $ils->find_item($item_id);
}
$resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
}
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$patron_id = $fields->{ (FID_PATRON_ID) };
$patron_pwd = $fields->{ (FID_PATRON_PWD) };
- syslog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd );
+ siplog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd );
$patron = $ils->find_patron($patron_id);
# Don't enable the patron if there was an invalid password
$status = $patron->enable;
}
- $resp .= patron_status_string($patron);
+ $resp .= patron_status_string( $patron, $server );
$resp .= $patron->language . timestamp();
$resp .= add_field( FID_PATRON_ID, $patron->id, $server );
- $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
+ $resp .= add_field( FID_PERSONAL_NAME, $patron->format( $server->{account}->{ae_field_template} ), $server );
if ( defined($patron_pwd) ) {
$resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password($patron_pwd) ), $server );
}
$resp .= add_field( FID_VALID_PATRON, 'Y', $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
}
} elsif ( $hold_mode eq '*' ) {
$status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack );
} else {
- syslog( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} );
+ siplog( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} );
$status = $ils->Transaction::Hold; # new?
$status->screen_msg("System error. Please contact library staff.");
}
}
$resp .= add_field( FID_INST_ID, $ils->institution, $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$ils->check_inst_id( $fields->{ (FID_INST_ID) }, "handle_renew" );
if ( $no_block eq 'Y' ) {
- syslog( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} );
+ siplog( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} );
}
$patron_id = $fields->{ (FID_PATRON_ID) };
}
$resp .= add_field( FID_INST_ID, $ils->institution, $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$resp .= join( '', map( add_field( FID_RENEWED_ITEMS, $_ ), @renewed ), $server );
$resp .= join( '', map( add_field( FID_UNRENEWED_ITEMS, $_ ), @unrenewed ), $server );
- $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
+ $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
$resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
$self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
$retries = sprintf( "%03d", $policy->{retries} );
if ( length($retries) != 3 ) {
- syslog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries );
+ siplog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries );
$retries = '000';
}
} elsif ( $protocol_version == 2 ) {
$msg .= '2.00';
} else {
- syslog( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version );
+ siplog( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version );
$msg .= '1.00';
}
}
}
if ( length($supported_msgs) < 16 ) {
- syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
+ siplog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
}
$msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs, $server );
}
- $msg .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server, $server );
+ $msg .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server );
if ( defined( $account->{print_width} )
&& defined($print_line)
&& $account->{print_width} < length($print_line) ) {
- syslog( "LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", $print_line );
+ siplog( "LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", $print_line );
$print_line = substr( $print_line, 0, $account->{print_width} );
}
#
sub patron_status_string {
my $patron = shift;
+ my $server = shift;
+
my $patron_status;
- syslog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
+ siplog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
$patron_status = sprintf(
'%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
denied( $patron->charge_ok ),
denied( $patron->hold_ok ),
boolspace( $patron->card_lost ),
boolspace( $patron->too_many_charged ),
- boolspace( $patron->too_many_overdue ),
+ $server->{account}->{overdues_block_checkout} ? boolspace( $patron->too_many_overdue ) : q{ },
boolspace( $patron->too_many_renewal ),
boolspace( $patron->too_many_claim_return ),
boolspace( $patron->too_many_lost ),