# 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.
$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;
@usrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '0' } keys %$search;
}
+ while (($key, $value) = each (%$search)) {
+ if($$search{$key}{group} eq '4') {
+ my $tval = $key;
+ $tval =~ s/dob_//g;
+ my $right = "RIGHT('0'|| ";
+ my $end = ", 2)";
+ $end = $right = '' if lc $tval eq 'year';
+ $dob .= $right."CAST(DATE_PART('$tval', dob) AS text)$end ~ ? AND ";
+ }
+ }
+ # Trim the last " AND "
+ $dob = substr($dob,0,-4);
+ @dobv = map { _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '4' } keys %$search;
+ $usr .= ' AND ' if ( $usr && $dob );
+ $usr .= $dob if $dob; # $dob not in-line above in case $usr doesn't have any search vals (only searched for 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;
</div>
</div>
</div>
+ <div class="form-group" ng-show="showExtras">
+ <div class="col-md-2">
+ <input type="text" class="form-control" ng-model="searchArgs.dob_year"
+ placeholder="[% l('DOB Year') %]" title="[% l('DOB Year') %]"/>
+ </div>
+ <div class="col-md-2">
+ <input type="text" class="form-control" ng-model="searchArgs.dob_month"
+ placeholder="[% l('DOB Month') %]" title="[% l('DOB Month') %]"/>
+ </div>
+ <div class="col-md-2">
+ <input type="text" class="form-control" ng-model="searchArgs.dob_day"
+ placeholder="[% l('DOB Day') %]" title="[% l('DOB Day') %]"/>
+ </div>
+ </div>
</form>
</div>
</div>
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 {
+ if (!key.match(/year/)) {
+ search[key].value = ('0'+search[key].value).slice(-2);
+ }
+ search[key].group = 4;
+ }
}
}
});
--- /dev/null
+Patron Search by Birth Date
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* Now you can include the patron birth year and/or birth month and/or
+ birth day when searching for patrons using the web based staff client.
+* Day and month values are exact matches. E.g. month "1" (or "01")
+ matches January, "12" matches December.
+* Year searches are "contains" searches. E.g. year "15" matches 2015,
+ 1915, 1599, etc. For exact matches use the full 4-digit year.
\ No newline at end of file