Bugzilla – Attachment 55589 Details for
Bug 14874
Add ability to search for patrons by date of birth from checkout and patron quick searches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14874 - Use a syspref to determine the 'standard' search fileds
Bug-14874---Use-a-syspref-to-determine-the-standar.patch (text/plain), 6.58 KB, created by
Nick Clemens (kidclamp)
on 2016-09-15 16:22:18 UTC
(
hide
)
Description:
Bug 14874 - Use a syspref to determine the 'standard' search fileds
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-09-15 16:22:18 UTC
Size:
6.58 KB
patch
obsolete
>From f04d29f1b644ca5176da049a5029db14a45efce4 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 15 Sep 2016 16:18:53 +0000 >Subject: [PATCH] Bug 14874 - Use a syspref to determine the 'standard' search > fileds > >This patch adds a new syspef 'DefaultPatronSearchFields' which defines >the fields that should be used when searching for a patron if none are >defined. > >To test: >1 - Aply patch, updatedatabase >2 - Ensure patron search has not changed >3 - Add dateofbirth to new pref >4 - Ensure things work wll >5 - Experiment with adding and removing other fields from borrowers >table >6 - prove t/db_dependent/Utils/Datatables_Members.t >--- > C4/Utils/DataTables/Members.pm | 8 ++------ > installer/data/mysql/sysprefs.sql | 1 + > .../intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref | 4 ++++ > t/db_dependent/Utils/Datatables_Members.t | 7 ++++--- > 4 files changed, 11 insertions(+), 9 deletions(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index d9904ff..a421dea 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -59,7 +59,7 @@ sub search { > } > > my $searchfields = { >- standard => 'surname,firstname,othernames,cardnumber,userid', >+ standard => C4::Context->preference('DefaultPatronSearchFields'), > surname => 'surname', > email => 'email,emailpro,B_email', > borrowernumber => 'borrowernumber', >@@ -87,15 +87,11 @@ sub search { > foreach my $term (@terms) { > next unless $term; > >- my $termsearchfieldstype; >- > my $term_dt = eval { local $SIG{__WARN__} = {}; output_pref( { str => $term, dateonly => 1, dateformat => 'sql' } ); }; > > if ($term_dt) { >- $termsearchfieldstype = 'dateofbirth'; > $term = $term_dt; > } else { >- $termsearchfieldstype = $searchfieldstype; > $term .= '%' # end with anything > if $term !~ /%$/; > $term = "%$term" # begin with anythin unless start_with >@@ -103,7 +99,7 @@ sub search { > } > > my @where_strs_or; >- for my $searchfield ( split /,/, $searchfields->{$termsearchfieldstype} ) { >+ for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { > push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; > push @where_args, $term; > } >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 5dc6bb9..0781239 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -116,6 +116,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'), > ('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'), > ('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'), >+('DefaultPatronSearchFields', 'surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search','free'); > ('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), > ('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'), > ('DefaultToLoggedInLibraryCircRules', '0', NULL , 'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 2f2faa0..b8a2a30 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -109,6 +109,10 @@ Patrons: > class: integer > - results per page in the staff client. > - >+ - pref: DefaultPatronSearchFields >+ class: multi >+ - "Comma separated list defining the default fields to be used during a patron search" >+ - > - pref: PatronQuickAddFields > class: multi > - (separate columns with |) >diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t >index 2cfc559..13285b8 100644 >--- a/t/db_dependent/Utils/Datatables_Members.t >+++ b/t/db_dependent/Utils/Datatables_Members.t >@@ -355,6 +355,7 @@ my %dates_in_pref = ( > ); > foreach my $dateformloo (@datetimeprefs){ > t::lib::Mocks::mock_preference('dateformat', $dateformloo); >+ t::lib::Mocks::mock_preference('DefaultPatronSearchFields', 'surname,firstname,othernames,userid,dateofbirth'); > $search_results = C4::Utils::DataTables::Members::search({ > searchmember => $dates_in_pref{$dateformloo}[0], > searchfieldstype => 'standard', >@@ -364,7 +365,7 @@ foreach my $dateformloo (@datetimeprefs){ > }); > > is( $search_results->{ iTotalDisplayRecords }, 2, >- "dateformat: $dateformloo Two borrowers have dob $dates_in_pref{$dateformloo}[0], standard search fields overriden"); >+ "dateformat: $dateformloo Two borrowers have dob $dates_in_pref{$dateformloo}[0], standard search fields plus dob works"); > > $search_results = C4::Utils::DataTables::Members::search({ > searchmember => $dates_in_pref{$dateformloo}[2], >@@ -375,7 +376,7 @@ foreach my $dateformloo (@datetimeprefs){ > }); > > is( $search_results->{ iTotalDisplayRecords }, 1, >- "dateformat: $dateformloo One borrower has dob $dates_in_pref{$dateformloo}[2], standard search fields overriden"); >+ "dateformat: $dateformloo One borrower has dob $dates_in_pref{$dateformloo}[2], standard search fields plus dob works"); > > $search_results = C4::Utils::DataTables::Members::search({ > searchmember => $dates_in_pref{$dateformloo}[1], >@@ -408,7 +409,7 @@ foreach my $dateformloo (@datetimeprefs){ > }); > > is( $search_results->{ iTotalDisplayRecords }, 0, >- "dateformat: $dateformloo No borrowers have dob $dates_in_pref{$dateformloo}[3], standard search field overridden"); >+ "dateformat: $dateformloo No borrowers have dob $dates_in_pref{$dateformloo}[3], standard search fields p[lus dob works"); > } > > # End >-- >2.1.4
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 14874
:
51503
|
51504
|
51505
|
51652
|
51653
|
51654
|
51971
|
51972
|
52079
|
52998
|
52999
|
53000
|
53001
|
55589
|
55899
|
55912
|
55913
|
55919
|
55920
|
56027
|
56028
|
57009