From: blake Date: Wed, 9 Aug 2017 14:28:41 +0000 (+0000) Subject: LP1655158 Patron Search by Date of Birth X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2c4a759db2c0d6be794d7ad336579e473fa9c0a3;p=evergreen%2Fpines.git LP1655158 Patron Search by Date of Birth Adds three UI boxes to the WBSC "Show Extra" patron search. One for the year, month and day. The javascript on the page is altered to deliver group "4" to the backend. Local javascript strips out non-numeric user entered data. The backend is updated to handle the new group. SQL is genereated using the DATE_PART postgres function. 1. Open the web based staff client and browse to the patron search UI. 2. Click the show more down arrow button. Notice the lack of birth date field. 3. Apply the patch, repeat step one. Notice the addition of birth date boxes. 4. Type 1975 into the birth year box and press enter. Notice search results. 5. Try searching for partial names and partial birthdates. 6. Try entering non-numeric data into the birth date boxes. 7. Try searching for patrons without including the dob. Try with only the dob. Try a mix. Signed-off-by: blake --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index bcf45087e0..9631f889ab 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -676,6 +676,7 @@ sub patron_search { # group 1 = address # group 2 = phone, ident # group 3 = barcode + # group 4 = dob # Treatment of name fields depends on whether the org has # diacritic_insensitivity turned on or off. @@ -685,6 +686,8 @@ sub patron_search { $diacritic_insensitive = ($diacritic_insensitive) ? $JSON->JSON2perl($diacritic_insensitive) : 0; my $usr; my @usrv; + my $dob; + my @dobv; if ($diacritic_insensitive) { $usr = join ' AND ', map { "evergreen.unaccent_and_squash(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '0' } keys %$search; @@ -695,6 +698,13 @@ sub patron_search { @usrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '0' } keys %$search; } + $dob = join ' AND ', map { ("CAST (DATE_PART('" . ( s/year//g ? 'year' : ( s/month//g ? 'month' : 'day' ) ) . "', dob) AS text) ~ ?") } grep { ''.$$search{$_}{group} eq '4' } keys %$search; + @dobv = map { _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '4' } keys %$search; + + $usr .= ' AND ' if ( $usr && $dob ); + $usr .= $dob if $dob; + push(@usrv, @dobv) if @dobv; + my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search; my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search; diff --git a/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 index 72e8336a76..0ae645f111 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 @@ -145,6 +145,20 @@ +
+
+ +
+
+ +
+
+ +
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index fe126d48ae..84182456af 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -1083,6 +1083,15 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, search[key].group = 1; } else if (key == 'card') { search[key].group = 3 + } else if (key.match(/dob_/)) { + // DOB should always be numeric + search[key].value = search[key].value.replace(/\D/g,''); + if (search[key].value.length == 0) { + delete search[key]; + } + else { + search[key].group = 4; + } } } });