use C4::Koha;
- $date = slashifyDate("01-01-2002")
-
=head1 DESCRIPTION
Koha.pm provides many functions for Koha scripts.
sub getbranches {
# returns a reference to a hash of references to branches...
+ my ($type) = @_;
my %branches;
my $dbh = C4::Context->dbh;
my $sth;
$sth->execute;
while (my $branch=$sth->fetchrow_hashref) {
my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");
- $nsth->execute($branch->{'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;
# that aren't fields in the "branches" table.
$branch->{$cat} = 1;
}
- $branches{$branch->{'branchcode'}}=$branch;
+ if ($type) {
+ $branches{$branch->{'branchcode'}}=$branch;
+ }
+ }
+ if (!$type){
+ $branches{$branch->{'branchcode'}}=$branch;
+ }
}
return (\%branches);
}