return \@results;
}
+=head2 GetBranchCategories
+
+ my $categories = GetBranchCategories($branchcode,$categorytype);
+
+Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
+i.e. categorycode, categorydescription, categorytype, categoryname.
+if $branchcode and/or $categorytype are passed, limit set to categories that
+$branchcode is a member of , and to $categorytype.
+
+=cut
+
+sub GetBranchCategories {
+ my ($branchcode,$categorytype) = @_;
+ my $dbh = C4::Context->dbh();
+ my $query = "SELECT c.* FROM branchcategories c";
+ my (@where, @bind);
+ if($branchcode) {
+ $query .= ",branchrelations r, branches b ";
+ push @where, "c.categorycode=r.categorycode and r.branchcode=? ";
+ push @bind , $branchcode;
+ }
+ if ($categorytype) {
+ push @where, " c.categorytype=? ";
+ push @bind, $categorytype;
+ }
+ $query .= " where " . join(" and ", @where) if(@where);
+ $query .= " order by categorytype,c.categorycode";
+ my $sth=$dbh->prepare( $query);
+ $sth->execute(@bind);
+
+ my $branchcats = $sth->fetchall_arrayref({});
+ $sth->finish();
+ return( $branchcats );
+}
+
=head2 GetCategoryTypes
$categorytypes = GetCategoryTypes;
return C4::Koha::get_infos_of( $query, 'branchcode' );
}
-=head2 GetBranchCategories
-
- my $categories = GetBranchCategories($branchcode,$categorytype);
-
-Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
-i.e. categorycode, categorydescription, categorytype, categoryname.
-if $branchcode and/or $categorytype are passed, limit set to categories that
-$branchcode is a member of , and to $categorytype.
-
-=cut
-
-sub GetBranchCategories($$) {
- my ($branchcode,$categorytype) = @_;
- my $dbh = C4::Context->dbh();
- my $select = "SELECT c.* FROM branchcategories c";
- my (@where, @bind);
- if($branchcode) {
- $select .= ",branchrelations r, branches b ";
- push @where, "c.categorycode=r.categorycode and r.branchcode=? ";
- push @bind , $branchcode;
- }
- if ($categorytype) {
- push @where, " c.categorytype=? ";
- push @bind, $categorytype;
- }
- my $sth=$dbh->prepare( $select . " where " . join(" and ", @where) );
- $sth->execute(@bind);
-
- my $branchcats = $sth->fetchall_arrayref({});
- $sth->finish();
- return( $branchcats );
-}
-
=head2 GetBranchesInCategory
sub GetBranchesInCategory($) {
my ($categorycode) = @_;
- my $dbh = C4::context->dbh();
- my $sth=$dbh->prepare( "SELECT branchcode, branchname FROM branchrelations r, branches b
+ my @branches;
+ my $dbh = C4::Context->dbh();
+ my $sth=$dbh->prepare( "SELECT b.branchcode FROM branchrelations r, branches b
where r.branchcode=b.branchcode and r.categorycode=?");
$sth->execute($categorycode);
- my $branches = $sth->fetchall_hashref;
+ while (my $branch = $sth->fetchrow) {
+ push @branches, $branch;
+ }
$sth->finish();
- return( $branches );
+ return( \@branches );
}
=head2 GetBranchInfo
# decide which template to use
my $template_name;
my @params = $cgi->param("limit");
-if ((@params>=1) || ($cgi->param("q")) ) {
+if ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) ) {
$template_name = 'catalogue/results.tmpl';
}
else {
$template_name = 'catalogue/advsearch.tmpl';
}
-
# load the template
($template, $borrowernumber, $cookie) = get_template_and_user({
template_name => $template_name,
my @branch_loop;
#push @branch_loop, {value => "", branchname => "All Branches", };
for my $branch_hash (sort keys %$branches) {
- push @branch_loop, {value => "branch: $branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, };
+ push @branch_loop, {value => "branch:$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, };
}
-$template->param(branchloop => \@branch_loop,);
+
+my $categories = GetBranchCategories(undef,'searchdomain');
+
+$template->param(branchloop => \@branch_loop, searchdomainloop => $categories);
# load the itemtypes (Called Collection Codes in the template -- used for circ rules )
my $itemtypes = GetItemTypes;
my @limits;
@limits = split("\0",$params->{'limit'}) if $params->{'limit'};
+if($params->{'multibranchlimit'}) {
+push @limits, join(" or ", map { "branch: $_ "} @{GetBranchesInCategory($params->{'multibranchlimit'})}) ;
+}
+
my $available;
foreach my $limit(@limits) {
if ($limit =~/available/) {
<!-- AVAILABILITY LIMITS -->
<fieldset><legend>Location and availability: </legend>
<p>
- <label>Library</label><select name="limit" id="branchloop">
- <option value="">All Locations</option>
+ <label for="available-items">Only items currently available</label><input type="checkbox" id="available-items" name="limit" value="datedue:0000-00-00" /></p>
+ <p>
+ <label>Individual Libraries </label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
+ <option value="">All Libraries</option>
<!-- TMPL_LOOP NAME="branchloop" -->
<option value="<!-- TMPL_VAR NAME='value' -->"><!-- TMPL_VAR NAME='branchname' --></option>
<!-- /TMPL_LOOP -->
</select>
+ <!-- <input type='hidden' name='limit' value='branch: MAIN' /> -->
</p>
- <p>
- <label for="available-items">Only items currently available</label><input type="checkbox" id="available-items" name="limit" value="datedue:0000-00-00" /></p>
+ <!-- TMPL_IF NAME="searchdomainloop" -->
+ <p>OR<p> <!-- should addjs to grey out group pulldown if a library is selected. -->
+ <p>
+ <label>Groups of Libraries</label><select name="multibranchlimit" id="categoryloop">
+ <option value=""> -- none -- </option>
+ <!-- TMPL_LOOP NAME="searchdomainloop" -->
+ <option value="<!-- TMPL_VAR NAME='categorycode' -->"><!-- TMPL_VAR NAME='categoryname' --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+ </p>
+ <!-- /TMPL_IF -->
</fieldset>
<!-- /AVAILABILITY LIMITS -->