From c7edb822200a51a791d1b1420b6651cb7481def7 Mon Sep 17 00:00:00 2001 From: toins Date: Wed, 12 Jul 2006 07:49:06 +0000 Subject: [PATCH] 2 functions added : GetBorrowersFromSurname & GetBranchCodeFromBorrowers --- C4/Members.pm | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index b5bcaa179e..761a4c6278 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -54,7 +54,6 @@ This module contains routines for adding, modifying and deleting members/patrons #' @ISA = qw(Exporter); -@EXPORT = qw(); @EXPORT = qw( &BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber &modmember &newmember &changepassword &borrissues &allissues @@ -64,7 +63,7 @@ This module contains routines for adding, modifying and deleting members/patrons &borrowercategories &getborrowercategory &fixEthnicity ðnicitycategories get_institutions add_member_orgs - &get_age + &get_age &GetBorrowersFromSurname &GetBranchCodeFromBorrowers ); @@ -1307,6 +1306,65 @@ sub add_member_orgs { } # sub add_member_orgs +=head2 GetBorrowersFromSurname + +=over 4 + +\@resutlts = GetBorrowersFromSurname($surname) +this function get the list of borrower names like $surname. +return : +the table of results in @results + +=back + +=cut +sub GetBorrowersFromSurname { + my ($searchstring)=@_; + my $dbh = C4::Context->dbh; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query = qq| + SELECT surname,firstname + FROM borrowers + WHERE (surname like ?) + ORDER BY surname + |; + my $sth=$dbh->prepare($query); + $sth->execute("$data[0]%"); + my @results; + my $count = 0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $count++; + } + $sth->finish; + return ($count,\@results); +} + +=head2 GetBranchCodeFromBorrowers + +=over 4 + +$sth = GetBranchCodeFromBorrowers(); + +this function just prepare the SQL request. +After this function, don't forget to execute it by using $sth->execute($borrowernumber) +return : +$sth = $dbh->prepare($query). + +=back + +=cut +sub GetBranchCodeFromBorrowers { + my $dbh = C4::Context->dbh; + my $query = qq| + SELECT flags, branchcode + FROM borrowers + WHERE borrowernumber = ? + |; + return $dbh->prepare($query); +} END { } # module clean-up code here (global destructor) 1; -- 2.39.5