Bugzilla – Attachment 109533 Details for
Bug 26352
Add plugin hooks to transform patron barcodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26352: Add plugin hooks to transform patron barcodes
Bug-26352-Add-plugin-hooks-to-transform-patron-bar.patch (text/plain), 7.57 KB, created by
Kyle M Hall (khall)
on 2020-09-02 13:35:03 UTC
(
hide
)
Description:
Bug 26352: Add plugin hooks to transform patron barcodes
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-09-02 13:35:03 UTC
Size:
7.57 KB
patch
obsolete
>From e015d3e9c8a070dbeac000ba2e7a97e533721bf9 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 2 Sep 2020 09:22:57 -0400 >Subject: [PATCH] Bug 26352: Add plugin hooks to transform patron barcodes > >Some of our partners have unusual barcode requirements that have >required us to transform scanned barcodes using javascript. This is not >the most reliable method. It would make more sense to have Koha >transform the barcodes on the backend using a plugin. We should add >hooks to transform and generate new item and patron barcodes. > >Test Plan: >1) Apply this patch >2) Download and install the Barcode Transformer plugin > https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/download/v1.0.1/koha-plugin-barcode-transformer-v1.0.1.kpz >3) Go to the plugin configuration page, set the configuration to the example configuration from the same page >4) In the patron search and anywhere else you can scan a patron > cardnumber, type in some cardnumbers but prefix them with A and postfix > them with A or B, e.g. A12345A, A12345B >5) Note the letters are removed by Koha! >6) Try a cardnumber like X123456Y >7) Note Koha converts it to Z13456Z > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > C4/SIP/Sip/MsgType.pm | 16 ++++++++++++++++ > Koha/Patron.pm | 8 +++++++- > circ/circulation.pl | 1 + > members/memberentry.pl | 4 ++++ > opac/sco/sco-main.pl | 1 + > 5 files changed, 29 insertions(+), 1 deletion(-) > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index a365107c8a..a748525338 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -19,6 +19,7 @@ use CGI qw ( -utf8 ); > use C4::Auth qw(&check_api_auth); > > use Koha::Patron::Attributes; >+use Koha::Plugins; > use Koha::Items; > > use UNIVERSAL::can; >@@ -519,6 +520,7 @@ sub handle_checkout { > $fields = $self->{fields}; > > $patron_id = $fields->{ (FID_PATRON_ID) }; >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); > $item_id = $fields->{ (FID_ITEM_ID) }; > my $fee_ack = $fields->{ (FID_FEE_ACK) }; > >@@ -735,6 +737,8 @@ sub handle_block_patron { > $patron_id = $fields->{ (FID_PATRON_ID) }; > $terminal_pwd = $fields->{ (FID_TERMINAL_PWD) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > # Terminal passwords are different from account login > # passwords, but I have no idea what to do with them. So, > # I'll just ignore them for now. >@@ -959,6 +963,8 @@ sub handle_patron_info { > $start = $fields->{ (FID_START_ITEM) }; > $end = $fields->{ (FID_END_ITEM) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > $patron = $ils->find_patron($patron_id); > > $resp = (PATRON_INFO_RESP); >@@ -1116,6 +1122,8 @@ sub handle_fee_paid { > $fee_id = $fields->{ (FID_FEE_ID) }; > $trans_id = $fields->{ (FID_TRANSACTION_ID) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > $ils->check_inst_id( $inst_id, "handle_fee_paid" ); > > 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 ); >@@ -1306,6 +1314,8 @@ sub handle_patron_enable { > $patron_id = $fields->{ (FID_PATRON_ID) }; > $patron_pwd = $fields->{ (FID_PATRON_PWD) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > siplog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd ); > > $patron = $ils->find_patron($patron_id); >@@ -1369,6 +1379,8 @@ sub handle_hold { > $title_id = $fields->{ (FID_TITLE_ID) } || ''; > $fee_ack = $fields->{ (FID_FEE_ACK) } || 'N'; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > if ( $hold_mode eq '+' ) { > $status = $ils->add_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack ); > } elsif ( $hold_mode eq '-' ) { >@@ -1434,6 +1446,8 @@ sub handle_renew { > $item_props = $fields->{ (FID_ITEM_PROPS) }; > $fee_ack = $fields->{ (FID_FEE_ACK) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > $status = $ils->renew( $patron_id, $patron_pwd, $item_id, $title_id, $no_block, $nb_due_date, $third_party, $item_props, $fee_ack ); > > $patron = $status->patron; >@@ -1515,6 +1529,8 @@ sub handle_renew_all { > $terminal_pwd = $fields->{ (FID_TERMINAL_PWD) }; > $fee_ack = $fields->{ (FID_FEE_ACK) }; > >+ ($patron_id) = Koha::Plugins->call('barcode_transform', 'patron', $patron_id ); >+ > $status = $ils->renew_all( $patron_id, $patron_pwd, $fee_ack ); > > $resp .= $status->ok ? '1' : '0'; >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 5436ccc448..f1d26c8235 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -110,7 +110,10 @@ Autogenerate next cardnumber from highest value found in database > > sub fixup_cardnumber { > my ( $self ) = @_; >- my $max = Koha::Patrons->search({ >+ >+ my ( $max ) = Koha::Plugins->call( 'barcode_generate', 'patron', $self ); >+ >+ $max ||= Koha::Patrons->search({ > cardnumber => {-regexp => '^-?[0-9]+$'} > }, { > select => \'CAST(cardnumber AS SIGNED)', >@@ -197,6 +200,9 @@ sub store { > > $self->trim_whitespaces; > >+ my ( $new_cardnumber ) = Koha::Plugins->call( 'barcode_transform', 'patron', $self->cardnumber ); >+ $self->cardnumber( $new_cardnumber ); >+ > # Set surname to uppercase if uppercasesurname is true > $self->surname( uc($self->surname) ) > if C4::Context->preference("uppercasesurnames"); >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 0ba39cabd1..2164f636a1 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -229,6 +229,7 @@ if ( @$barcodes == 0 && $charges eq 'yes' ) { > # > my $message; > if ($findborrower) { >+ ( $findborrower ) = Koha::Plugins->call( 'barcode_transform', 'patron', $findborrower ); > my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); > if ( $patron ) { > $borrowernumber = $patron->borrowernumber; >diff --git a/members/memberentry.pl b/members/memberentry.pl >index fd684c5005..c84804d990 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -45,6 +45,7 @@ use Koha::Patron::Attribute::Types; > use Koha::Patron::Categories; > use Koha::Patron::HouseboundRole; > use Koha::Patron::HouseboundRoles; >+use Koha::Plugins; > use Koha::Token; > use Email::Valid; > use Koha::SMS::Providers; >@@ -327,6 +328,9 @@ if ($op eq 'save' || $op eq 'insert'){ > # If the cardnumber is blank, treat it as null. > $newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; > >+ my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'patron', $newdata{'cardnumber'} ); >+ $newdata{'cardnumber'} = $new_barcode; >+ > if (my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ > push @errors, $error_code == 1 > ? 'ERROR_cardnumber_already_exists' >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index fbf2d064d9..d2c1bb7b86 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -125,6 +125,7 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { > > my ( $borrower, $patron ); > if ( $patronid ) { >+ ( $patronid ) = Koha::Plugins->call( 'barcode_transform', 'patron', $patronid ); > $patron = Koha::Patrons->find( { cardnumber => $patronid } ); > $borrower = $patron->unblessed if $patron; > } >-- >2.24.1 (Apple Git-126)
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 26352
:
109533
|
109547
|
113579
|
113580
|
113880
|
113885
|
113886
|
113887
|
113888
|
115167
|
115168
|
115169
|
115170
|
115171
|
118691
|
118692
|
118693
|
118694
|
118695
|
122428
|
122429
|
122430
|
122431
|
122432