-# make the page ...
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "circ/bookcount.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { circulate => 1 },
- debug => 1,
- }
-);
-
-my @branchloop;
-
-foreach my $branchcode ( keys %$branches ) {
- my %linebranch;
- $linebranch{issues} = issuesat( $itm, $branchcode );
- my $date = lastseenat( $itm, $branchcode );
- $linebranch{seen} = slashdate($date);
- $linebranch{branchname} = $branches->{$branchcode}->{'branchname'};
- push( @branchloop, \%linebranch );
+my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
+for my $library ( @$libraries ) {
+ $library->{selected} = 1 if $library->{branchcode} eq C4::Context->userenv->{branch};
+ $library->{issues} = issuesat($itm, $library->{branchcode});
+ $library->{seen} = lastseenat( $itm, $library->{branchcode} ) || undef;