-sub branchinfotable {
-
-# makes the html for a table of branch info from reference to an array of hashs.
-
- my ($branchcode,$innertemplate) = @_;
- my $branchinfo = $branchcode ? GetBranchInfo($branchcode) : GetBranchInfo();
- my @loop_data = ();
- foreach my $branch (@$branchinfo) {
- #
- # 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)
- #
- # - branch_name (Note: not "branchname")
- # - branch_code (Note: not "branchcode")
- # - address (containing a static error message)
- # - branchaddress1 \
- # - branchaddress2 |
- # - branchaddress3 | comprising the old "address" field
- # - branchzip |
- # - branchcity |
- # - branchcountry |
- # - branchphone |
- # - branchfax |
- # - branchemail /
- # - branchurl /
- # - opac_info (can contain HTML)
- # - 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
- #
- my %row = ();
-
- # Handle address fields separately
- my $address_empty_p = 1;
- for my $field (
- 'branchaddress1', 'branchaddress2',
- 'branchaddress3', 'branchzip',
- 'branchcity', 'branchstate', 'branchcountry',
- 'branchphone', 'branchfax',
- 'branchemail', 'branchurl', 'opac_info',
- 'branchip', 'branchprinter', 'branchnotes'
- )
- {
- $row{$field} = $branch->{$field};
- $address_empty_p = 0 if ( $branch->{$field} );
- }
- $row{'address-empty-p'} = $address_empty_p;
-
- # Handle categories
- my $no_categories_p = 1;
- my @categories;
- foreach my $cat ( @{ $branch->{'categories'} } ) {
- my ($catinfo) = @{ GetBranchCategory($cat) };
- push @categories, { 'categoryname' => $catinfo->{'categoryname'} };
- $no_categories_p = 0;
- }
-
- $row{'category_list'} = \@categories;
- $row{'no-categories-p'} = $no_categories_p;
- $row{'branch_name'} = $branch->{'branchname'};
- $row{'branch_code'} = $branch->{'branchcode'};
- $row{'value'} = $branch->{'branchcode'};
-
- push @loop_data, \%row;
- }
- my @branchcategories = ();
- for my $ctype ( GetCategoryTypes() ) {
- my $catinfo = GetBranchCategories(undef,$ctype);
- my @categories;
- foreach my $cat (@$catinfo) {
- push @categories, {
- categoryname => $cat->{'categoryname'},
- categorycode => $cat->{'categorycode'},
- codedescription => $cat->{'codedescription'},
- categorytype => $cat->{'categorytype'},
- };
- }
- push @branchcategories, { categorytype => $ctype , $ctype => 1 , catloop => ( @categories ? \@categories : undef) };
- }
- $innertemplate->param(
- branches => \@loop_data,
- branchcategories => \@branchcategories
- );
-