[Koha-cvs] koha/C4 Koha.pm

Robert Lyon bob at katipo.co.nz
Wed Jun 7 00:48:00 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Robert Lyon <bob_lyon>	06/06/06 22:48:00

Modified files:
	C4             : Koha.pm 

Log message:
	Merging katipo changes...
	
	Modified getbranches so you can pass it a branch type and it will only
	return branches of that type

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&r1=1.35&r2=1.36

Patches:
Index: Koha.pm
===================================================================
RCS file: /sources/koha/koha/C4/Koha.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- Koha.pm	22 May 2006 23:13:56 -0000	1.35
+++ Koha.pm	6 Jun 2006 22:48:00 -0000	1.36
@@ -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: Koha.pm,v 1.35 2006/05/22 23:13:56 rangi Exp $
+# $Id: Koha.pm,v 1.36 2006/06/06 22:48:00 bob_lyon Exp $
 
 use strict;
 require Exporter;
@@ -25,7 +25,7 @@
 
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = do { my @v = '$Revision: 1.35 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.36 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -36,8 +36,6 @@
   use C4::Koha;
 
 
-  $date = slashifyDate("01-01-2002")
-
 =head1 DESCRIPTION
 
 Koha.pm provides many functions for Koha scripts.
@@ -120,6 +118,7 @@
 
 sub getbranches {
 # returns a reference to a hash of references to branches...
+        my ($type) = @_;
 	my %branches;
 	my $dbh = C4::Context->dbh;
 	my $sth;
@@ -134,7 +133,12 @@
 	$sth->execute;
 	while (my $branch=$sth->fetchrow_hashref) {
 		my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");
+	        if ($type){
+		    $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ? and categorycode = ?");
+		    $nsth->execute($branch->{'branchcode'},$type);
+		} else {
 		$nsth->execute($branch->{'branchcode'});
+		}
 		while (my ($cat) = $nsth->fetchrow_array) {
 			# FIXME - This seems wrong. It ought to be
 			# $branch->{categorycodes}{$cat} = 1;
@@ -147,8 +151,14 @@
 			# that aren't fields in the "branches" table.
 			$branch->{$cat} = 1;
 			}
+                        if ($type) {
 			$branches{$branch->{'branchcode'}}=$branch;
 	}
+	        }
+                if (!$type){
+		    $branches{$branch->{'branchcode'}}=$branch;
+		}
+	}
 	return (\%branches);
 }
 





More information about the Koha-cvs mailing list