Bugzilla – Attachment 37807 Details for
Bug 13931
Date of birth in patron search result and in autocomplete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13931 - Added patron's dateofbirth to autocomplete
Bug-13931---Added-patrons-dateofbirth-to-autocompl.patch (text/plain), 4.34 KB, created by
Jiri Kozlovsky
on 2015-04-14 10:22:39 UTC
(
hide
)
Description:
Bug 13931 - Added patron's dateofbirth to autocomplete
Filename:
MIME Type:
Creator:
Jiri Kozlovsky
Created:
2015-04-14 10:22:39 UTC
Size:
4.34 KB
patch
obsolete
>From 1faf1110d654e9386e4ae102224d9aea2763d389 Mon Sep 17 00:00:00 2001 >From: jirislav <mail@jkozlovsky.cz> >Date: Tue, 14 Apr 2015 12:21:10 +0200 >Subject: [PATCH] Bug 13931 - Added patron's dateofbirth to autocomplete > >--- > circ/ysearch.pl | 71 +++++++++----------- > .../prog/en/includes/patron-search-box.inc | 2 +- > 2 files changed, 32 insertions(+), 41 deletions(-) > >diff --git a/circ/ysearch.pl b/circ/ysearch.pl >index ae4ae42..6403a6c 100755 >--- a/circ/ysearch.pl >+++ b/circ/ysearch.pl >@@ -22,63 +22,54 @@ > > =head1 ysearch.pl > >+ > =cut > >-use Modern::Perl; >+use strict; >+#use warnings; FIXME - Bug 2505 > use CGI qw ( -utf8 ); > use C4::Context; >+use C4::Members; > use C4::Auth qw/check_cookie_auth/; >-use Koha::Borrowers; >- >-use JSON qw( to_json ); >+use JSON qw(to_json); > >-my $input = new CGI; >-my $query = $input->param('term'); >+my $input = new CGI; >+my $query = $input->param('term'); > > binmode STDOUT, ":encoding(UTF-8)"; >-print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+print $input->header(-type => 'text/plain', -charset => 'UTF-8'); > >-my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } ); >-if ( $auth_status ne "ok" ) { >+my ($auth_status, $sessionID) = check_cookie_auth($input->cookie('CGISESSID'), { circulate => '*' }); >+if ($auth_status ne "ok") { > exit 0; > } > >-my $limit_on_branch; >+my $dbh = C4::Context->dbh; >+my $sql = q( >+ SELECT borrowernumber, surname, firstname, cardnumber, address, city, zipcode, country, dateofbirth >+ FROM borrowers >+ WHERE ( surname LIKE ? >+ OR firstname LIKE ? >+ OR cardnumber LIKE ? ) >+); > if ( C4::Context->preference("IndependentBranches") > && C4::Context->userenv > && !C4::Context->IsSuperLibrarian() >- && C4::Context->userenv->{'branch'} ) { >- $limit_on_branch = 1; >+ && C4::Context->userenv->{'branch'} ) >+{ >+ $sql .= " AND borrowers.branchcode =" >+ . $dbh->quote( C4::Context->userenv->{'branch'} ); > } > >-my $borrowers_rs = Koha::Borrowers->search( >- { -or => { >- surname => { -like => "$query%" }, >- firstname => { -like => "$query%" }, >- cardnumber => { -like => "$query%" }, >- ( $limit_on_branch ? { branchcode => C4::Context->userenv->{branch} } : () ), >- }, >- }, >- { >- # Get the first 10 results >- page => 1, >- rows => 10, >- order_by => [ 'surname', 'firstname' ], >- }, >-); >+$sql .= q( ORDER BY surname, firstname LIMIT 10); >+my $sth = $dbh->prepare( $sql ); >+$sth->execute("$query%", "$query%", "$query%"); >+ >+my $results = $sth->fetchall_arrayref({}); > >-my @borrowers; >-while ( my $b = $borrowers_rs->next ) { >- push @borrowers, >- { borrowernumber => $b->borrowernumber, >- surname => $b->surname // '', >- firstname => $b->firstname // '', >- cardnumber => $b->cardnumber // '', >- address => $b->address // '', >- city => $b->city // '', >- zipcode => $b->zipcode // '', >- country => $b->country // '', >- }; >+for(my $i = 0; $i < scalar @{$results}; ++$i) { >+ # Format all dateofbirths from sql datetime >+ ${$results}[$i]->{dateofbirth} = Koha::DateUtils::format_sqldatetime(${$results}[$i]->{dateofbirth}, undef, undef, 1); > } > >-print to_json( \@borrowers ); >+print to_json($results); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-box.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-box.inc >index 87f1969..464b8ad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-box.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-box.inc >@@ -14,7 +14,7 @@ $(document).ready(function(){ > .data( "ui-autocomplete" )._renderItem = function( ul, item ) { > return $( "<li></li>" ) > .data( "ui-autocomplete-item", item ) >- .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >+ .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.dateofbirth + ", " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) > .appendTo( ul ); > }; > >-- >1.7.10.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 13931
:
37801
|
37807
|
37809
|
37811
|
38045
|
38126
|
44691
|
44692
|
44693
|
44817
|
44818
|
44821
|
45062
|
45065