[%# First check to see if we have anything selected, otherwise we select all %]
[% selectall = 1 %]
[% FOREACH branch IN branches;
IF branch.selected;
selectall = 0;
END;
END %]
[% FOREACH branch IN branches %]
[% IF branch.selected || (selectall == 1) %]
[% ELSE %]
[% END %]