# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
$branches = &GetBranches();
Returns informations about ALL branches, IndependentBranches Insensitive.
-GetBranchInfo() returns the same information without the problems of this function
-(namespace collision, mainly).
+GetBranchInfo() returns the same information.
Create a branch selector with the following code.
=cut
sub GetBranches {
- my ($onlymine)=@_;
+ my ($onlymine) = @_;
+
# returns a reference to a hash of references to ALL branches...
my %branches;
my $dbh = C4::Context->dbh;
my $sth;
- my $query="SELECT * FROM branches";
+ my $query = "SELECT * FROM branches";
my @bind_parameters;
- if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
- $query .= ' WHERE branchcode = ? ';
- push @bind_parameters, C4::Context->userenv->{branch};
+ if ( $onlymine && C4::Context->userenv && C4::Context->userenv->{branch} ) {
+ $query .= ' WHERE branchcode = ? ';
+ push @bind_parameters, C4::Context->userenv->{branch};
}
- $query.=" ORDER BY branchname";
+ $query .= " ORDER BY branchname";
$sth = $dbh->prepare($query);
- $sth->execute( @bind_parameters );
-
- my $nsth = $dbh->prepare(
- "SELECT categorycode FROM branchrelations WHERE branchcode = ?"
- ); # prepare once, outside while loop
+ $sth->execute(@bind_parameters);
+
+ my $relations_sth =
+ $dbh->prepare("SELECT branchcode,categorycode FROM branchrelations");
+ $relations_sth->execute();
+ my %relations;
+ while ( my $rel = $relations_sth->fetchrow_hashref ) {
+ push @{ $relations{ $rel->{branchcode} } }, $rel->{categorycode};
+ }
while ( my $branch = $sth->fetchrow_hashref ) {
- $nsth->execute( $branch->{'branchcode'} );
- while ( my ($cat) = $nsth->fetchrow_array ) {
- # FIXME - This seems wrong. It ought to be
- # $branch->{categorycodes}{$cat} = 1;
- # otherwise, there's a namespace collision if there's a
- # category with the same name as a field in the 'branches'
- # table (i.e., don't create a category called "issuing").
- # In addition, the current structure doesn't really allow
- # you to list the categories that a branch belongs to:
- # you'd have to list keys %$branch, and remove those keys
- # that aren't fields in the "branches" table.
- # $branch->{$cat} = 1;
+ foreach my $cat ( @{ $relations{ $branch->{branchcode} } } ) {
$branch->{category}{$cat} = 1;
}
$branches{ $branch->{'branchcode'} } = $branch;
$error = &ModBranch($newvalue);
-This function modify an existing branch
+This function modifies an existing branch
-C<$newvalue> is a ref to an array wich is containt all the column from branches table.
+C<$newvalue> is a ref to an array which contains all the columns from branches table.
=cut
(branchcode,branchname,branchaddress1,
branchaddress2,branchaddress3,branchzip,branchcity,branchstate,
branchcountry,branchphone,branchfax,branchemail,
- branchurl,branchip,branchprinter,branchnotes,opac_info)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ branchurl,branchip,branchprinter,branchnotes,opac_info,
+ branchreplyto, branchreturnpath)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
";
my $sth = $dbh->prepare($query);
$sth->execute(
$data->{'branchemail'}, $data->{'branchurl'},
$data->{'branchip'}, $data->{'branchprinter'},
$data->{'branchnotes'}, $data->{opac_info},
+ $data->{'branchreplyto'}, $data->{'branchreturnpath'}
);
return 1 if $dbh->err;
} else {
branchaddress2=?,branchaddress3=?,branchzip=?,
branchcity=?,branchstate=?,branchcountry=?,branchphone=?,
branchfax=?,branchemail=?,branchurl=?,branchip=?,
- branchprinter=?,branchnotes=?,opac_info=?
+ branchprinter=?,branchnotes=?,opac_info=?,
+ branchreplyto=?, branchreturnpath=?
WHERE branchcode=?
";
my $sth = $dbh->prepare($query);
$data->{'branchemail'}, $data->{'branchurl'},
$data->{'branchip'}, $data->{'branchprinter'},
$data->{'branchnotes'}, $data->{opac_info},
+ $data->{'branchreplyto'}, $data->{'branchreturnpath'},
$data->{'branchcode'},
);
}
to allow for other uses of categories.
The searchdomain bit may be better implemented as a separate module, but
the categories were already here, and minimally used.
+
=cut
#TODO manage category types. rename possibly to 'agency domains' ? as borrowergroups are called categories.
returns C<$results>, a reference to an array of hashes containing branches.
if $branchcode, just this branch, with associated categories.
if ! $branchcode && $categorytype, all branches in the category.
+
=cut
sub GetBranchInfo {