[Koha-cvs] koha/C4 Members.pm
Antoine Farnault
antoine at koha-fr.org
Wed Jul 12 09:49:07 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Changes by: Antoine Farnault <toins> 06/07/12 07:49:07
Modified files:
C4 : Members.pm
Log message:
2 functions added : GetBorrowersFromSurname & GetBranchCodeFromBorrowers
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Members.pm?cvsroot=koha&r1=1.29&r2=1.30
Patches:
Index: Members.pm
===================================================================
RCS file: /sources/koha/koha/C4/Members.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- Members.pm 4 Jul 2006 14:36:51 -0000 1.29
+++ Members.pm 12 Jul 2006 07:49:06 -0000 1.30
@@ -19,7 +19,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: Members.pm,v 1.29 2006/07/04 14:36:51 toins Exp $
+# $Id: Members.pm,v 1.30 2006/07/12 07:49:06 toins Exp $
use strict;
require Exporter;
@@ -31,7 +31,7 @@
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
-$VERSION = do { my @v = '$Revision: 1.29 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.30 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
=head1 NAME
@@ -54,7 +54,6 @@
#'
@ISA = qw(Exporter);
- at EXPORT = qw();
@EXPORT = qw(
&BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber &modmember &newmember &changepassword &borrissues &allissues
@@ -64,7 +63,7 @@
&borrowercategories &getborrowercategory
&fixEthnicity
ðnicitycategories get_institutions add_member_orgs
- &get_age
+ &get_age &GetBorrowersFromSurname &GetBranchCodeFromBorrowers
);
@@ -1307,6 +1306,65 @@
} # 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;
More information about the Koha-cvs
mailing list