Bugzilla – Attachment 140610 Details for
Bug 23817
Normalize phone number when searching patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23817: Normalize phone number when storing and when searching in Patrons module
Bug-23817-Normalize-phone-number-when-storing-and-.patch (text/plain), 2.81 KB, created by
David Cook
on 2022-09-14 05:18:57 UTC
(
hide
)
Description:
Bug 23817: Normalize phone number when storing and when searching in Patrons module
Filename:
MIME Type:
Creator:
David Cook
Created:
2022-09-14 05:18:57 UTC
Size:
2.81 KB
patch
obsolete
>From f1b781fa2c4a3c5ae88145371f6dc0cb215d5261 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 14 Sep 2022 04:02:10 +0000 >Subject: [PATCH] Bug 23817: Normalize phone number when storing and when > searching in Patrons module > >This patch normalizes the phone number when stored via Koha::Patron, >and normalizes the phone number when searching "Primary phone" in the Patrons >module. > >Test plan: >0. Apply patch and koha-plack --restart kohadev >1. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=51 >2. Input '1-(234)-567-8901' into the 'Primary phone' field >3. Note on the next screen the phone number is shown as 12345678901 >4. Go to http://localhost:8081/cgi-bin/koha/members/members-home.pl >5. Choose "Search field" of "Primary phone" >6. Search for '1-(234)-567-8901' >7. Note you are taken to http://localhost:8081/cgi-bin/koha/members/moremember.pl?borrowernumber=51 >8. Try out different permutations like '234 567 8901' or '5678901' >9. Note that every permutation works to find the borrower >--- > Koha/Patron.pm | 22 +++++++++++++++++++ > .../prog/en/includes/patron-search.inc | 5 ++++- > 2 files changed, 26 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 8031257304..efc926b42b 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2196,6 +2196,28 @@ sub virtualshelves { > return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves ); > } > >+=head3 phone >+ >+ my $phone = $patron->phone; >+ >+=cut >+ >+sub phone { >+ my ($self,@data) = @_; >+ if (@data){ >+ foreach my $datum (@data){ >+ $datum =~ s/[^\+0-9]//g; >+ } >+ $self->_result()->set_column( 'phone', @data ); >+ return $self; >+ } >+ else { >+ my $value = $self->_result()->get_column( 'phone' ); >+ return $value; >+ } >+} >+ >+ > =head2 Internal methods > > =head3 _type >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 3d1de0eb15..576198ad04 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -318,7 +318,10 @@ > if ( !search_fields ) { > search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; > } >- >+ if (search_fields == 'phone'){ >+ //Normalize phone numbers >+ patterns = [pattern.replace(/[^\+0-9]/g,'')]; >+ } > let subquery_and = []; > patterns.forEach(function(pattern,i){ > let sub_or = []; >-- >2.30.2
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 23817
:
140610
|
140648
|
145219
|
145221
|
151961
|
151962
|
152450
|
152451