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 327-333 sub GetBranchCategory { Link Here
327
327
328
=head2 GetBranchCategories
328
=head2 GetBranchCategories
329
329
330
  my $categories = GetBranchCategories($branchcode,$categorytype);
330
  my $categories = GetBranchCategories($branchcode,$categorytype,$show_in_pulldown,$selected_in_pulldown);
331
331
332
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
332
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
333
i.e. categorycode, categorydescription, categorytype, categoryname.
333
i.e. categorycode, categorydescription, categorytype, categoryname.
Lines 337-363 $branchcode is a member of , and to $categorytype. Link Here
337
=cut
337
=cut
338
338
339
sub GetBranchCategories {
339
sub GetBranchCategories {
340
    my ($branchcode,$categorytype) = @_;
340
    my ( $branchcode, $categorytype, $show_in_pulldown, $selected_in_pulldown ) = @_;
341
	my $dbh = C4::Context->dbh();
341
    my $dbh = C4::Context->dbh();
342
	my $query = "SELECT c.* FROM branchcategories c";
342
343
	my (@where, @bind);
343
    my $query = "SELECT c.* FROM branchcategories c";
344
	if($branchcode) {
344
    my ( @where, @bind );
345
		$query .= ",branchrelations r, branches b ";
345
346
		push @where, "c.categorycode=r.categorycode and r.branchcode=? ";  
346
    if( $branchcode ) {
347
		push @bind , $branchcode;
347
        $query .= ",branchrelations r, branches b ";
348
	}
348
        push @where, "c.categorycode = r.categorycode AND r.branchcode = ? ";  
349
	if ($categorytype) {
349
        push @bind , $branchcode;
350
		push @where, " c.categorytype=? ";
350
    }
351
		push @bind, $categorytype;
351
352
	}
352
    if ( $categorytype ) {
353
	$query .= " where " . join(" and ", @where) if(@where);
353
        push @where, " c.categorytype = ? ";
354
	$query .= " order by categorytype,c.categorycode";
354
        push @bind, $categorytype;
355
	my $sth=$dbh->prepare( $query);
355
    }
356
	$sth->execute(@bind);
356
357
	
357
    if ( defined( $show_in_pulldown ) ) {
358
	my $branchcats = $sth->fetchall_arrayref({});
358
        push( @where, " c.show_in_pulldown = ? " );
359
	$sth->finish();
359
        push( @bind, $show_in_pulldown );
360
	return( $branchcats );
360
    }
361
362
    $query .= " WHERE " . join(" AND ", @where) if(@where);
363
    $query .= " ORDER BY categorytype,c.categorycode";
364
    my $sth=$dbh->prepare( $query);
365
    $sth->execute(@bind);
366
367
    my $branchcats = $sth->fetchall_arrayref({});
368
    $sth->finish();
369
    
370
    if ( $selected_in_pulldown ) {
371
        foreach my $bc ( @$branchcats ) {
372
            $bc->{'selected'} = 1 if ( $bc->{'categorycode'} eq $selected_in_pulldown );
373
        }
374
    }
375
    
376
    return( $branchcats );
361
}
377
}
362
378
363
=head2 GetCategoryTypes
379
=head2 GetCategoryTypes
Lines 505-518 sub ModBranchCategoryInfo { Link Here
505
    my $dbh    = C4::Context->dbh;
521
    my $dbh    = C4::Context->dbh;
506
    if ($data->{'add'}){
522
    if ($data->{'add'}){
507
	# we are doing an insert
523
	# we are doing an insert
508
	my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)");
524
	my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)");
509
	$sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
525
	$sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} );
510
	$sth->finish();		
526
	$sth->finish();		
511
    }
527
    }
512
    else {
528
    else {
513
	# modifying
529
	# modifying
514
	my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?");
530
	my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?");
515
	$sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) );
531
	$sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) );
516
	$sth->finish();
532
	$sth->finish();
517
    }
533
    }
518
}
534
}
(-)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 6134-6139 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6134
    SetVersion ($DBversion);
6134
    SetVersion ($DBversion);
6135
}
6135
}
6136
6136
6137
$DBversion = "3.11.00.XXX";
6138
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6139
    $dbh->do(q{
6140
        ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6141
        ADD INDEX ( show_in_pulldown )
6142
    });
6143
    print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
6144
    SetVersion ($DBversion);
6145
}
6146
6137
=head1 FUNCTIONS
6147
=head1 FUNCTIONS
6138
6148
6139
=head2 TableExists($table)
6149
=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" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
77
        <input type="text" 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