[Koha-cvs] koha/C4 Members.pm [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Thu Nov 30 18:20:22 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/11/30 17:20:22

Modified files:
	C4             : Members.pm 

Log message:
	Some functions has moved from Search.pm to Members.pm.
	Some of theses were duplicated. (in Search & in Members.pm)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Members.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.32.2.23&r2=1.32.2.24

Patches:
Index: Members.pm
===================================================================
RCS file: /sources/koha/koha/C4/Members.pm,v
retrieving revision 1.32.2.23
retrieving revision 1.32.2.24
diff -u -b -r1.32.2.23 -r1.32.2.24
--- Members.pm	27 Nov 2006 14:55:39 -0000	1.32.2.23
+++ Members.pm	30 Nov 2006 17:20:22 -0000	1.32.2.24
@@ -17,7 +17,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.32.2.23 2006/11/27 14:55:39 toins Exp $
+# $Id: Members.pm,v 1.32.2.24 2006/11/30 17:20:22 toins Exp $
 
 use strict;
 require Exporter;
@@ -29,7 +29,7 @@
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
 
-$VERSION = do { my @v = '$Revision: 1.32.2.23 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.32.2.24 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -49,12 +49,13 @@
 
 =cut
 
-#'
-
 @ISA = qw(Exporter);
 
 @EXPORT = qw(
-  &BornameSearch &GetMember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber   &modmember &newmember &changepassword &borrissues &allissues
+  &BornameSearch &GetMember
+  &borrdata &borrdata2
+  &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch
+  &modmember &newmember &changepassword &borrissues &allissues
   &checkuniquemember &getzipnamecity &getidcity &getguarantordata &getcategorytype
   &DeleteBorrower
   &calcexpirydate &checkuserpassword
@@ -690,25 +691,41 @@
     return $cardnumber;
 }
 
+=head2 findguarantees
+
+  ($num_children, $children_arrayref) = &findguarantees($parent_borrno);
+  $child0_cardno = $children_arrayref->[0]{"cardnumber"};
+  $child0_borrno = $children_arrayref->[0]{"borrowernumber"};
+
+C<&findguarantees> takes a borrower number (e.g., that of a patron
+with children) and looks up the borrowers who are guaranteed by that
+borrower (i.e., the patron's children).
+
+C<&findguarantees> returns two values: an integer giving the number of
+borrowers guaranteed by C<$parent_borrno>, and a reference to an array
+of references to hash, which gives the actual results.
+
+=cut
+
+#'
 sub findguarantees {
     my ($borrowernumber) = @_;
     my $dbh              = C4::Context->dbh;
-    my $sth              = $dbh->prepare(
-        "select cardnumber,borrowernumber from borrowers where
-  guarantorid=?"
+    my $sth              =
+      $dbh->prepare(
+"select cardnumber,borrowernumber, firstname, surname from borrowers where guarantor=?"
     );
     $sth->execute($borrowernumber);
+
     my @dat;
-    my $i = 0;
     while ( my $data = $sth->fetchrow_hashref ) {
-        $dat[$i] = $data;
-        $i++;
+        push @dat, $data;
     }
     $sth->finish;
-    return ( $i, \@dat );
+    return ( scalar(@dat), \@dat );
 }
 
-=item findguarantor
+=head2 findguarantor
 
   $guarantor = &findguarantor($borrower_no);
   $guarantor_cardno = $guarantor->{"cardnumber"};
@@ -728,10 +745,15 @@
 sub findguarantor {
     my ($borrowernumber) = @_;
     my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare("Select * from borrowers where borrowernumber=?");
+    my $sth              =
+      $dbh->prepare("select guarantor from borrowers where borrowernumber=?");
     $sth->execute($borrowernumber);
     my $data = $sth->fetchrow_hashref;
     $sth->finish;
+    $sth = $dbh->prepare("Select * from borrowers where borrowernumber=?");
+    $sth->execute( $data->{'guarantor'} );
+    $data = $sth->fetchrow_hashref;
+    $sth->finish;
     return ($data);
 }
 
@@ -820,28 +842,6 @@
     return ( $cnt, \@results );
 }
 
-=item NewBorrowerNumber
-
-  $num = &NewBorrowerNumber();
-
-Allocates a new, unused borrower number, and returns it.
-
-=cut
-
-#'
-# FIXME - This is identical to C4::Circulation::Borrower::NewBorrowerNumber.
-# Pick one and stick with it. Preferably use the other one. This function
-# doesn't belong in C4::Search.
-sub NewBorrowerNumber {
-    my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare("Select max(borrowernumber) from borrowers");
-    $sth->execute;
-    my $data = $sth->fetchrow_hashref;
-    $sth->finish;
-    $data->{'max(borrowernumber)'}++;
-    return ( $data->{'max(borrowernumber)'} );
-}
-
 =head2 borrissues
 
   ($count, $issues) = &borrissues($borrowernumber);





More information about the Koha-cvs mailing list