@@ -, +, @@ https://github.com/bywatersolutions/koha-plugin-barcode-transformer/releases/download/v1.0.1/koha-plugin-barcode-transformer-v1.0.1.kpz cardnumber, type in some cardnumbers but prefix them with A and postfix them with A or B, e.g. A12345A, A12345B --- 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(-) --- a/C4/SIP/Sip/MsgType.pm +++ a/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'; --- a/Koha/Patron.pm +++ a/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"); --- a/circ/circulation.pl +++ a/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; --- a/members/memberentry.pl +++ a/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' --- a/opac/sco/sco-main.pl +++ a/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; } --