&DelBranchCategory
&CheckCategoryUnique
&mybranch
+ &GetBranchesCount
);
@EXPORT_OK = qw( &onlymine &mybranch get_branch_code_from_name );
}
return $sth->fetchrow_array;
}
+sub GetBranchesCount {
+ my $dbh = C4::Context->dbh();
+ my $query = "SELECT COUNT(*) AS branches_count FROM branches";
+ my $sth = $dbh->prepare( $query );
+ $sth->execute();
+ my $row = $sth->fetchrow_hashref();
+ return $row->{'branches_count'};
+}
+
1;
__END__
#use warnings; FIXME - Bug 2505
use C4::Context;
-
+use C4::Branch qw(GetBranchesCount);
use Memoize;
use DateTime;
use DateTime::Format::MySQL;
tags => [ qw/ 225a / ],
sep => ', ',
},
- ];
- my $library_facet = {
- idx => 'branch',
- label => 'Libraries',
- tags => [ qw/ 995b / ],
- expanded => '1',
- };
- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
+ ];
+
+ my $library_facet;
+ unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
+ $library_facet = {
+ idx => 'branch',
+ label => 'Libraries',
+ tags => [ qw/ 995b / ],
+ };
+ } else {
+ $library_facet = {
+ idx => 'location',
+ label => 'Location',
+ tags => [ qw/ 995c / ],
+ };
+ }
+ push( @$facets, $library_facet );
}
else {
$facets = [
sep => ', ',
},
];
+
my $library_facet;
- $library_facet = {
- idx => 'branch',
- label => 'Libraries',
- tags => [ qw/ 952b / ],
- sep => ', ',
- expanded => '1',
- };
- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
+ unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
+ $library_facet = {
+ idx => 'branch',
+ label => 'Libraries',
+ tags => [ qw / 952b / ],
+ };
+ } else {
+ $library_facet = {
+ idx => 'location',
+ label => 'Location',
+ tags => [ qw / 952c / ],
+ };
+ }
+ push( @$facets, $library_facet );
}
return $facets;
}
sub getRecords {
my (
$koha_query, $simple_query, $sort_by_ref, $servers_ref,
- $results_per_page, $offset, $expanded_facet, $branches,$itemtypes,
- $query_type, $scan
+ $results_per_page, $offset, $expanded_facet, $branches,
+ $itemtypes, $query_type, $scan, $opac
) = @_;
my @servers = @$servers_ref;
}
}
+ # also, if it's a location code, use the name instead of the code
+ if ( $link_value =~ /location/ ) {
+ $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac);
+ }
+
# but we're down with the whole label being in the link's title.
push @this_facets_array, {
facet_count => $facets_counter->{$link_value}->{$one_facet},
facet_title_value => $one_facet,
facet_link_value => $facet_link_value,
type_link_value => $link_value,
- };
+ } if ( $facet_label_value );
}
}
[% IF ( facets_loo.type_label_Series ) %]Series[% END %]
[% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %]
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
+[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
<ul>
[% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]&limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
<li class="showmore"><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %][% IF ( offset ) %]&offset=[% offset %][% END %]&expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
[% UNLESS ( singleBranchMode ) %]
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
[% END %]
+[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
<ul>
[% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]&limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value |html %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
<li class="showmore"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %][% IF ( offset ) %]&offset=[% offset %][% END %]&expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
$pasarParams .= '&simple_query=' . $simple_query;
$pasarParams .= '&query_type=' . $query_type if ($query_type);
eval {
- ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan,1);
};
}
# This sorts the facets into alphabetical order