Bugzilla – Attachment 40886 Details for
Bug 14512
Add support for AV field to Koha's SIP2 Server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14512 - Add support for AV field to Koha's SIP2 Server
Bug-14512---Add-support-for-AV-field-to-Kohas-SIP2.patch (text/plain), 7.94 KB, created by
Kyle M Hall (khall)
on 2015-07-09 14:01:20 UTC
(
hide
)
Description:
Bug 14512 - Add support for AV field to Koha's SIP2 Server
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-07-09 14:01:20 UTC
Size:
7.94 KB
patch
obsolete
>From be3b7839df8a7a26f7e4714079c1e5b5d0dc0687 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 9 Jul 2015 09:53:31 -0400 >Subject: [PATCH] Bug 14512 - Add support for AV field to Koha's SIP2 Server > >Koha's SIP2 server should have support for the AV field ( field items ). >The biggest problem with this field is that its' contents are not really >defined in SIP2 protocol specification. All it says is "this field >should be sent for each fine item". Due to this, I think the contents of >the field need to be configurable at the login level, so that the >contents can be defined based on the SIP2 devices requirements for the >AV field. > >Test Plan: >1) Apply this patch >2) Find a patron with outstanding fines >3) Run a patron information request using misc/sip_cli_emulator.pl using the new -s option with the value " Y " >4) Note there is an AV field for each fee containing the description and amount >5) Edit your sip config, add an av_field_template parameter to the login you are using such as > av_field_template="TEST [% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >6) Restart your SIP server >7) Repeat the patron information request >8) Note your custom AV field is being used! >--- > C4/SIP/ILS/Patron.pm | 33 ++++++++++++++++++++++++++++++++- > C4/SIP/Sip/MsgType.pm | 16 ++++++++-------- > etc/SIPconfig.xml | 3 ++- > misc/sip_cli_emulator.pl | 17 +++++++++++++---- > 4 files changed, 55 insertions(+), 14 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index 4e9c152..4f2c836 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -295,8 +295,39 @@ sub charged_items { > return $self->x_items('items', @_); > } > sub fine_items { >+ require Koha::Database; >+ require Template; >+ > my $self = shift; >- return $self->x_items('fine_items', @_); >+ my $start = shift; >+ my $end = shift; >+ my $server = shift; >+ >+ my @fees = Koha::Database->new()->schema()->resultset('Accountline')->search( >+ { >+ borrowernumber => $self->{borrowernumber}, >+ amountoutstanding => { '>' => '0' }, >+ } >+ ); >+ >+ $start = $start ? $start - 1 : 0; >+ $end = $end ? $end : scalar @fees - 1; >+ >+ my $av_field_template = $server ? $server->{account}->{av_field_template} : undef; >+ $av_field_template ||= "[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"; >+ >+ my $tt = Template->new(); >+ >+ my @return_values; >+ for ( my $i = $start; $i <= $end; $i++ ) { >+ my $fee = $fees[$i]; >+ >+ my $output; >+ $tt->process( \$av_field_template, { accountline => $fee }, \$output ); >+ push( @return_values, { barcode => $output } ); >+ } >+ >+ return \@return_values; > } > sub recall_items { > my $self = shift; >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 6b387cf..c392fa2 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -890,7 +890,7 @@ sub handle_login { > # and we're going to believe it. > # > sub summary_info { >- my ($ils, $patron, $summary, $start, $end) = @_; >+ my ($ils, $patron, $summary, $start, $end, $server) = @_; > my $resp = ''; > my $summary_type; > # >@@ -898,11 +898,11 @@ sub summary_info { > # message to the corresponding field and handler > # > my @summary_map = ( >- { func => $patron->can( "hold_items"), fid => FID_HOLD_ITEMS }, >- { func => $patron->can("overdue_items"), fid => FID_OVERDUE_ITEMS }, >- { func => $patron->can("charged_items"), fid => FID_CHARGED_ITEMS }, >- { func => $patron->can( "fine_items"), fid => FID_FINE_ITEMS }, >- { func => $patron->can( "recall_items"), fid => FID_RECALL_ITEMS }, >+ { func => $patron->can("hold_items"), fid => FID_HOLD_ITEMS }, >+ { func => $patron->can("overdue_items"), fid => FID_OVERDUE_ITEMS }, >+ { func => $patron->can("charged_items"), fid => FID_CHARGED_ITEMS }, >+ { func => $patron->can("fine_items"), fid => FID_FINE_ITEMS }, >+ { func => $patron->can("recall_items"), fid => FID_RECALL_ITEMS }, > { func => $patron->can("unavail_holds"), fid => FID_UNAVAILABLE_HOLD_ITEMS }, > ); > >@@ -915,7 +915,7 @@ sub summary_info { > > my $func = $summary_map[$summary_type]->{func}; > my $fid = $summary_map[$summary_type]->{fid}; >- my $itemlist = &$func($patron, $start, $end); >+ my $itemlist = &$func($patron, $start, $end, $server); > > syslog("LOG_DEBUG", "summary_info: list = (%s)", join(", ", @{$itemlist})); > foreach my $i (@{$itemlist}) { >@@ -991,7 +991,7 @@ sub handle_patron_info { > # fine_items > # recall_items > >- $resp .= summary_info($ils, $patron, $summary, $start, $end); >+ $resp .= summary_info($ils, $patron, $summary, $start, $end, $server); > > $resp .= maybe_add(FID_HOME_ADDR, $patron->address); > $resp .= maybe_add(FID_EMAIL, $patron->email_addr); >diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml >index 8d2d77b..c9a6fc5 100644 >--- a/etc/SIPconfig.xml >+++ b/etc/SIPconfig.xml >@@ -42,7 +42,8 @@ > <login id="lpl-sc" password="1234" institution="LPL" /> > <login id="lpl-sc-beacock" password="xyzzy" > delimiter="|" error-detect="enabled" institution="LPL" >- send_patron_home_library_in_af="1" > >+ send_patron_home_library_in_af="1" >+ av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" > > <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" /> > <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" /> > </login> >diff --git a/misc/sip_cli_emulator.pl b/misc/sip_cli_emulator.pl >index ca8ba07..f1799ee 100755 >--- a/misc/sip_cli_emulator.pl >+++ b/misc/sip_cli_emulator.pl >@@ -40,6 +40,8 @@ my $location_code; > my $patron_identifier; > my $patron_password; > >+my $summary; >+ > my $item_identifier; > > my $fee_acknowledged = 0; >@@ -55,13 +57,15 @@ GetOptions( > "sp|sip_pass=s" => \$login_password, # sip password > "l|location|location_code=s" => \$location_code, # sip location code > >- "patron=s" => \$patron_identifier, # patron cardnumber or login >- "password=s" => \$patron_password, # patron's password >+ "patron=s" => \$patron_identifier, # patron cardnumber or login >+ "password=s" => \$patron_password, # patron's password > > "i|item=s" => \$item_identifier, > > "fa|fee-acknowledged" => \$fee_acknowledged, > >+ "s|summary=s" => \$summary, >+ > "t|terminator=s" => \$terminator, > > "m|message=s" => \@messages, >@@ -126,8 +130,9 @@ my $handlers = { > patron_identifier => $patron_identifier, > terminal_password => $terminal_password, > patron_password => $patron_password, >+ summary => $summary, > }, >- optional => [ 'patron_password', ], >+ optional => [ 'patron_password', 'summary' ], > }, > item_information => { > name => 'Item Information', >@@ -312,8 +317,9 @@ sub build_patron_information_command_message { > my $patron_identifier = $params->{patron_identifier}; > my $terminal_password = $params->{terminal_password}; > my $patron_password = $params->{patron_password}; >+ my $summary = $params->{summary}; > >- my $summary = " "; >+ $summary //= " "; > > return > PATRON_INFO >@@ -484,6 +490,9 @@ Options: > --patron ILS patron cardnumber or username > --password ILS patron password > >+ -s --summary Optionally define the patron information request summary field. >+ Please refer to the SIP2 protocol specification for details >+ > --item ILS item identifier ( item barcode ) > > -t --terminator SIP2 message terminator, either CR, or CRLF >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14512
:
40885
|
40886
|
41238
|
49657