-# make the page ...
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "circ/bookcount.tt",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { circulate => "circulate_remaining_permissions" },
- debug => 1,
- }
-);
-
-my $branchloop = GetBranchesLoop(C4::Context->userenv->{branch});
-foreach (@$branchloop) {
- my $date = lastseenat( $itm, $_->{value} );
- my ($datechunk, $timechunk) = slashdate($date);
- $_->{issues} = issuesat($itm, $_->{value});
- $_->{seen} = $datechunk;
- $_->{seentime} = $timechunk;
+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;