View | Details | Raw Unified | Return to bug 9257
Collapse All | Expand All

(-)a/C4/Auth.pm (-4 / +7 lines)
Lines 383-388 sub get_template_and_user { Link Here
383
        my $opac_name = '';
383
        my $opac_name = '';
384
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
384
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
385
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
385
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
386
        } elsif ( $in->{'query'}->param('multibranchlimit') ) {
387
            $opac_name = $in->{'query'}->param('multibranchlimit');
386
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
388
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
387
            $opac_name = C4::Context->userenv->{'branch'};
389
            $opac_name = C4::Context->userenv->{'branch'};
388
        }
390
        }
Lines 391-403 sub get_template_and_user { Link Here
391
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
393
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
392
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
394
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
393
            BranchesLoop              => GetBranchesLoop($opac_name),
395
            BranchesLoop              => GetBranchesLoop($opac_name),
394
            CalendarFirstDayOfWeek      => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
396
            BranchCategoriesLoop      => GetBranchCategories( undef, undef, 1, $opac_name ),
397
            CalendarFirstDayOfWeek    => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
395
            LibraryName               => "" . C4::Context->preference("LibraryName"),
398
            LibraryName               => "" . C4::Context->preference("LibraryName"),
396
            LibraryNameTitle          => "" . $LibraryNameTitle,
399
            LibraryNameTitle          => "" . $LibraryNameTitle,
397
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
400
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
398
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
401
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
399
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
402
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
400
            OpacHighlightedWords       => C4::Context->preference("OpacHighlightedWords"),
403
            OpacHighlightedWords      => C4::Context->preference("OpacHighlightedWords"),
401
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
404
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
402
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
405
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
403
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
406
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
Lines 408-414 sub get_template_and_user { Link Here
408
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
411
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
409
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
412
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
410
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
413
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
411
            opac_css_override           => $ENV{'OPAC_CSS_OVERRIDE'},
414
            opac_css_override         => $ENV{'OPAC_CSS_OVERRIDE'},
412
            opac_search_limit         => $opac_search_limit,
415
            opac_search_limit         => $opac_search_limit,
413
            opac_limit_override       => $opac_limit_override,
416
            opac_limit_override       => $opac_limit_override,
414
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
417
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
Lines 422-428 sub get_template_and_user { Link Here
422
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
425
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
423
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
426
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
424
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
427
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
425
            OPACPatronDetails        => C4::Context->preference("OPACPatronDetails"),
428
            OPACPatronDetails         => C4::Context->preference("OPACPatronDetails"),
426
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
429
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
427
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
430
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
428
            OpacTopissue              => C4::Context->preference("OpacTopissue"),
431
            OpacTopissue              => C4::Context->preference("OpacTopissue"),
(-)a/C4/Branch.pm (-26 / +42 lines)
Lines 328-334 sub GetBranchCategory { Link Here
328
328
329
=head2 GetBranchCategories
329
=head2 GetBranchCategories
330
330
331
  my $categories = GetBranchCategories($branchcode,$categorytype);
331
  my $categories = GetBranchCategories($branchcode,$categorytype,$show_in_pulldown,$selected_in_pulldown);
332
332
333
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
333
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
334
i.e. categorycode, categorydescription, categorytype, categoryname.
334
i.e. categorycode, categorydescription, categorytype, categoryname.
Lines 338-364 $branchcode is a member of , and to $categorytype. Link Here
338
=cut
338
=cut
339
339
340
sub GetBranchCategories {
340
sub GetBranchCategories {
341
    my ($branchcode,$categorytype) = @_;
341
    my ( $branchcode, $categorytype, $show_in_pulldown, $selected_in_pulldown ) = @_;
342
	my $dbh = C4::Context->dbh();
342
    my $dbh = C4::Context->dbh();
343
	my $query = "SELECT c.* FROM branchcategories c";
343
344
	my (@where, @bind);
344
    my $query = "SELECT c.* FROM branchcategories c";
345
	if($branchcode) {
345
    my ( @where, @bind );
346
		$query .= ",branchrelations r, branches b ";
346
347
		push @where, "c.categorycode=r.categorycode and r.branchcode=? ";  
347
    if( $branchcode ) {
348
		push @bind , $branchcode;
348
        $query .= ",branchrelations r, branches b ";
349
	}
349
        push @where, "c.categorycode = r.categorycode AND r.branchcode = ? ";
350
	if ($categorytype) {
350
        push @bind , $branchcode;
351
		push @where, " c.categorytype=? ";
351
    }
352
		push @bind, $categorytype;
352
353
	}
353
    if ( $categorytype ) {
354
	$query .= " where " . join(" and ", @where) if(@where);
354
        push @where, " c.categorytype = ? ";
355
	$query .= " order by categorytype,c.categorycode";
355
        push @bind, $categorytype;
356
	my $sth=$dbh->prepare( $query);
356
    }
357
	$sth->execute(@bind);
357
358
	
358
    if ( defined( $show_in_pulldown ) ) {
359
	my $branchcats = $sth->fetchall_arrayref({});
359
        push( @where, " c.show_in_pulldown = ? " );
360
	$sth->finish();
360
        push( @bind, $show_in_pulldown );
361
	return( $branchcats );
361
    }
362
363
    $query .= " WHERE " . join(" AND ", @where) if(@where);
364
    $query .= " ORDER BY categorytype,c.categorycode";
365
    my $sth=$dbh->prepare( $query);
366
    $sth->execute(@bind);
367
368
    my $branchcats = $sth->fetchall_arrayref({});
369
    $sth->finish();
370
371
    if ( $selected_in_pulldown ) {
372
        foreach my $bc ( @$branchcats ) {
373
            $bc->{'selected'} = 1 if ( $bc->{'categorycode'} eq $selected_in_pulldown );
374
        }
375
    }
376
377
    return( $branchcats );
362
}
378
}
363
379
364
=head2 GetCategoryTypes
380
=head2 GetCategoryTypes
Lines 506-519 sub ModBranchCategoryInfo { Link Here
506
    my $dbh    = C4::Context->dbh;
522
    my $dbh    = C4::Context->dbh;
507
    if ($data->{'add'}){
523
    if ($data->{'add'}){
508
	# we are doing an insert
524
	# we are doing an insert
509
	my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)");
525
  my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)");
510
	$sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
526
        $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} );
511
	$sth->finish();		
527
	$sth->finish();		
512
    }
528
    }
513
    else {
529
    else {
514
	# modifying
530
	# modifying
515
	my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?");
531
        my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?");
516
	$sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) );
532
        $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) );
517
	$sth->finish();
533
	$sth->finish();
518
    }
534
    }
519
}
535
}
(-)a/admin/branches.pl (+3 lines)
Lines 168-173 elsif ( $op eq 'addcategory_validate' ) { Link Here
168
    $template->param( else => 1 );
168
    $template->param( else => 1 );
169
    # confirm settings change...
169
    # confirm settings change...
170
    my $params = $input->Vars;
170
    my $params = $input->Vars;
171
    $params->{'show_in_pulldown'} = ( $params->{'show_in_pulldown'} eq 'on' ) ? 1 : 0;
172
171
    unless ( $params->{'categorycode'} && $params->{'categoryname'} ) {
173
    unless ( $params->{'categorycode'} && $params->{'categoryname'} ) {
172
        default("MESSAGE4",$template);
174
        default("MESSAGE4",$template);
173
    }
175
    }
Lines 294-299 sub editcatform { Link Here
294
            categorycode    => $data->{'categorycode'},
296
            categorycode    => $data->{'categorycode'},
295
            categoryname    => $data->{'categoryname'},
297
            categoryname    => $data->{'categoryname'},
296
            codedescription => $data->{'codedescription'},
298
            codedescription => $data->{'codedescription'},
299
            show_in_pulldown => $data->{'show_in_pulldown'},
297
		);
300
		);
298
    }
301
    }
299
	for my $ctype (GetCategoryTypes()) {
302
	for my $ctype (GetCategoryTypes()) {
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 340-346 CREATE TABLE `branchcategories` ( -- information related to library/branch group Link Here
340
  `categoryname` varchar(32), -- name of the library/branch group
340
  `categoryname` varchar(32), -- name of the library/branch group
341
  `codedescription` mediumtext, -- longer description of the library/branch group
341
  `codedescription` mediumtext, -- longer description of the library/branch group
342
  `categorytype` varchar(16), -- says whether this is a search group or a properties group
342
  `categorytype` varchar(16), -- says whether this is a search group or a properties group
343
  PRIMARY KEY  (`categorycode`)
343
  `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled
344
  PRIMARY KEY  (`categorycode`),
345
  KEY `show_in_pulldown` (`show_in_pulldown`)
344
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
346
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
345
347
346
--
348
--
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 6339-6344 if ( CheckVersion($DBversion) ) { Link Here
6339
   SetVersion ($DBversion);
6339
   SetVersion ($DBversion);
6340
}
6340
}
6341
6341
6342
$DBversion = "3.11.00.XXX";
6343
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6344
    $dbh->do(q{
6345
        ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6346
        ADD INDEX ( show_in_pulldown )
6347
    });
6348
    print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
6349
    SetVersion ($DBversion);
6350
}
6351
6342
=head1 FUNCTIONS
6352
=head1 FUNCTIONS
6343
6353
6344
=head2 TableExists($table)
6354
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (+8 lines)
Lines 346-351 tinyMCE.init({ Link Here
346
            [% END %]
346
            [% END %]
347
            </select>
347
            </select>
348
		</li>
348
		</li>
349
        <li>
350
            <label for="show_in_pulldown">Show in search pulldown: </label>
351
            [% IF ( show_in_pulldown ) %]
352
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
353
            [% ELSE %]
354
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
355
            [% END %]
356
        </li>
349
		</ol>
357
		</ol>
350
    </fieldset>
358
    </fieldset>
351
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
359
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
(-)a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc (-1 / +27 lines)
Lines 156-168 Link Here
156
        [% ELSE %]
156
        [% ELSE %]
157
            <div id="libraries" class="mobile-hidden">
157
            <div id="libraries" class="mobile-hidden">
158
        [% END %]
158
        [% END %]
159
      <select name="limit" id="select_library" class="left">
159
160
      <select name="limit" id="select_library" class="left" onchange="select_library_changed();">
160
         <option value="">All libraries</option>
161
         <option value="">All libraries</option>
161
         [% FOREACH BranchesLoo IN BranchesLoop %]
162
         [% FOREACH BranchesLoo IN BranchesLoop %]
162
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
163
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
163
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
164
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
164
         [% END %]
165
         [% END %]
166
         [% IF BranchCategoriesLoop %]
167
             <option value="__GROUPS__">-- GROUPS --</option>
168
             [% FOREACH bc IN BranchCategoriesLoop %]
169
                 [% IF ( bc.selected ) %]
170
                     <option selected="selected" value="[% bc.categorycode %]">[% bc.categoryname %]</option>
171
                 [% ELSE %]
172
                     <option value="[% bc.categorycode %]">[% bc.categoryname %]</option>
173
                 [% END %]
174
             [% END %]
175
         [% END %]
165
      </select>
176
      </select>
177
      [% IF BranchCategoriesLoop %]
178
          <script type="text/javascript">
179
              $(document).ready(function() {
180
                  $("#select_library option[value='__GROUPS__']").attr("disabled","disabled");
181
              });
182
183
              function select_library_changed() {
184
                  if ( $("#select_library option:selected").index() > $("#select_library option[value='__GROUPS__']").index() ) {
185
                      $("#select_library").attr("name", "multibranchlimit");
186
                  } else {
187
                      $("#select_library").attr("name", "limit");
188
                  }
189
              };
190
          </script>
191
      [% END %]
166
    </div>
192
    </div>
167
   [% ELSE %]
193
   [% ELSE %]
168
      [% IF ( opac_limit_override ) %]
194
      [% IF ( opac_limit_override ) %]
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc (-2 / +26 lines)
Lines 77-89 Link Here
77
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
77
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
78
[% END %]
78
[% END %]
79
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
79
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
80
      <select name="limit" id="select_library" class="left">
80
      <select name="limit" id="select_library" class="left" onchange="select_library_changed();">
81
         <option value="">All libraries</option>
81
         <option value="">All libraries</option>
82
         [% FOREACH BranchesLoo IN BranchesLoop %]
82
         [% FOREACH BranchesLoo IN BranchesLoop %]
83
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
83
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
84
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
84
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
85
         [% END %]
85
         [% END %]
86
         [% IF BranchCategoriesLoop %]
87
             <option value="__GROUPS__">-- GROUPS --</option>
88
             [% FOREACH bc IN BranchCategoriesLoop %]
89
                 [% IF ( bc.selected ) %]
90
                     <option selected="selected" value="[% bc.categorycode %]">[% bc.categoryname %]</option>
91
                 [% ELSE %]
92
                     <option value="[% bc.categorycode %]">[% bc.categoryname %]</option>
93
                 [% END %]
94
             [% END %]
95
         [% END %]
86
      </select>
96
      </select>
97
      [% IF BranchCategoriesLoop %]
98
          <script type="text/javascript">
99
              $(document).ready(function() {
100
                  $("#select_library option[value='__GROUPS__']").attr("disabled","disabled");
101
              });
102
103
              function select_library_changed() {
104
                  if ( $("#select_library option:selected").index() > $("#select_library option[value='__GROUPS__']").index() ) {
105
                      $("#select_library").attr("name", "multibranchlimit");
106
                  } else {
107
                      $("#select_library").attr("name", "limit");
108
                  }
109
              };
110
          </script>
111
      [% END %]
87
   [% ELSE %]
112
   [% ELSE %]
88
      [% IF ( opac_limit_override ) %]
113
      [% IF ( opac_limit_override ) %]
89
          [% IF ( opac_search_limit ) %]
114
          [% IF ( opac_search_limit ) %]
90
- 

Return to bug 9257