+ my $toggle;
+ my $i;
+ my @loop_data = ();
+ foreach my $branch (@$branchinfo) {
+ ( $i % 2 ) ? ( $toggle = 1 ) : ( $toggle = 0 );
+
+ #
+ # 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',
+ 'branchip', 'branchprinter'
+ )
+ {
+ $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) = @{ GetBranchCategory($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{'toggle'} = $toggle;
+ $row{'value'} = $branch->{'branchcode'};
+ $row{'action'} = '/cgi-bin/koha/admin/branches.pl';
+
+ push @loop_data, {%row};
+ $i++;