C4::Branch - Koha branch module
use C4::Branch;
The functions in this module deal with branches.
$branches = &GetBranches();
Returns informations about ALL branches, IndependantBranches Insensitive. GetBranchInfo() returns the same information without the problems of this function (namespace collision, mainly).
Create a branch selector with the following code.
my $branches = GetBranches;
my @branchloop;
foreach my $thisbranch (sort keys %$branches) {
my $selected = 1 if $thisbranch eq $branch;
my %row =(value => $thisbranch,
selected => $selected,
branchname => $branches->{$thisbranch}->{branchname},
);
push @branchloop, \%row;
}
<select name="branch" id="branch">
<option value=""></option>
[% FOREACH branchloo IN branchloop %]
[% IF ( branchloo.selected ) %]
<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
[% ELSE %]
<option value="[% branchloo.value %]" >[% branchloo.branchname %]</option>
[% END %]
[% END %]
</select>
$error = &ModBranch($newvalue);
This function modify an existing branch
$newvalue is a ref to an array wich is containt all the column from branches table.
$results = GetBranchCategory($categorycode);
$results is an ref to an array.
my $categories = GetBranchCategories($branchcode,$categorytype);
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table, i.e. categorycode, categorydescription, categorytype, categoryname. if $branchcode and/or $categorytype are passed, limit set to categories that $branchcode is a member of , and to $categorytype.
$categorytypes = GetCategoryTypes; returns a list of category types. Currently these types are HARDCODED. type: 'searchdomain' defines a group of agencies that the calling library may search in. Other usage of agency categories falls under type: 'properties'. 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.
$branch = GetBranch( $query, $branches );
$branch = &GetBranchDetail($branchcode);
Given the branch code, the function returns a hashref for the corresponding row in the branches table.
my $branches = GetBranchesInCategory($categorycode);
Returns a href: keys %$branches eq (branchcode,branchname) .
$results = GetBranchInfo($branchcode);
returns $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.
&DelBranch($branchcode);
&ModBranchCategoryInfo($data); sets the data from the editbranch form, and writes to the database...
if (CheckCategoryUnique($categorycode)){ # do something }
DeleteBranchCategory($categorycode);
$number_rows_affected = CheckBranchCategorycode($categorycode);
Koha Development Team <http://koha-community.org/>