-# makes the html for a table of branch info from reference to an array of hashs.
-
- my ($branchcode) = @_;
- my $branchinfo;
- if ($branchcode) {
- $branchinfo = getbranchinfo($branchcode);
- } else {
- $branchinfo = getbranchinfo();
- }
- my $color;
- my @loop_data =();
- foreach my $branch (@$branchinfo) {
- ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
- #
- # We export the following fields to the template. These are not
- # pre-composed as a single "address" field because the template
- # might (and should) escape what is exported here. (See bug 180)
- #
- # - color
- # - branch_name (Note: not "branchname")
- # - branch_code (Note: not "branchcode")
- # - address (containing a static error message)
- # - branchaddress1 \
- # - branchaddress2 |
- # - branchaddress3 | comprising the old "address" field
- # - branchphone |
- # - branchfax |
- # - branchemail /
- # - address-empty-p (1 if no address information, 0 otherwise)
- # - categories (containing a static error message)
- # - category_list (loop containing "categoryname")
- # - no-categories-p (1 if no categories set, 0 otherwise)
- # - value
- # - action
- #
- my %row = ();
-
- # Handle address fields separately
- my $address_empty_p = 1;
- for my $field ('branchaddress1', 'branchaddress2', 'branchaddress3',
- 'branchphone', 'branchfax', 'branchemail') {
- $row{$field} = $branch->{$field};
- if ( $branch->{$field} ) {
- $address_empty_p = 0;
- }
- }
- $row{'address-empty-p'} = $address_empty_p;
- # {{{ Leave this here until bug 180 is completely resolved in templates
- $row{'address'} = 'Your template is out of date (see bug 180)';
- # }}}
-
- # Handle categories
- my $no_categories_p = 1;
- my @categories = '';
- foreach my $cat (@{$branch->{'categories'}}) {
- my ($catinfo) = @{getcategoryinfo($cat)};
- push @categories, {'categoryname' => $catinfo->{'categoryname'}};
- $no_categories_p = 0;
- }
- # {{{ Leave this here until bug 180 is completely resolved in templates
- $row{'categories'} = 'Your template is out of date (see bug 180)';
- # }}}
- $row{'category_list'} = \@categories;
- $row{'no-categories-p'} = $no_categories_p;
-
- # Handle all other fields
- $row{'branch_name'} = $branch->{'branchname'};
- $row{'branch_code'} = $branch->{'branchcode'};
- $row{'color'} = $color;
- $row{'value'} = $branch->{'branchcode'};
- $row{'action'} = '/cgi-bin/koha/admin/branches.pl';
-
- push @loop_data, { %row };
- }
- my @branchcategories =();
- my $catinfo = getcategoryinfo();
- foreach my $cat (@$catinfo) {
- push @branchcategories, {
- categoryname => $cat->{'categoryname'},
- categorycode => $cat->{'categorycode'},
- codedescription => $cat->{'codedescription'},
- };
- }
-
- $template->param(branches => \@loop_data,
- branchcategories => \@branchcategories);
-
-}
-
-# FIXME logic seems wrong
-sub branchcategoriestable {
-#Needs to be implemented...
-
- my $categoryinfo = getcategoryinfo();
- my $color;
- foreach my $cat (@$categoryinfo) {
- ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
- $template->param(color => $color);
- $template->param(categoryname => $cat->{'categoryname'});
- $template->param(categorycode => $cat->{'categorycode'});
- $template->param(codedescription => $cat->{'codedescription'});
- }
-}