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

(-)a/catalogue/detail.pl (-57 / +4 lines)
Lines 61-68 use Koha::Reviews; Link Here
61
use Koha::SearchEngine::Search;
61
use Koha::SearchEngine::Search;
62
use Koha::SearchEngine::QueryBuilder;
62
use Koha::SearchEngine::QueryBuilder;
63
use Koha::Serial::Items;
63
use Koha::Serial::Items;
64
use Koha::Library::Group;
65
use Koha::Library::Groups;
66
64
67
my $query = CGI->new();
65
my $query = CGI->new();
68
66
Lines 333-401 if ( defined $dat->{'itemtype'} ) { Link Here
333
    $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }->imageurl );
331
    $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }->imageurl );
334
}
332
}
335
333
336
my $total_group_holdings_count = 0;
337
my $other_holdings_count       = 0;
338
my $branch_holdings_count      = 0;
339
if ( C4::Context->preference('SeparateHoldings') ) {
334
if ( C4::Context->preference('SeparateHoldings') ) {
340
    my $SeparateHoldingsBranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
335
    my $SeparateHoldingsBranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
341
    $branch_holdings_count =
336
    my $other_holdings_count =
342
        $items_to_display->search( { $SeparateHoldingsBranch => { '=' => C4::Context->userenv->{branch} } } )->count;
337
        $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count;
343
    $other_holdings_count = $items_to_display->count - $branch_holdings_count;
338
    $template->param( other_holdings_count => $other_holdings_count );
344
}
339
}
345
$template->param(
340
$template->param(
346
    count                  => $all_items->count,         # FIXME 'count' is used in catalog-strings.inc
341
    count                  => $all_items->count,         # FIXME 'count' is used in catalog-strings.inc
347
    other_holdings_count   => $other_holdings_count,     # But it's not a meaningful variable, we should rename it there
342
                                                         # But it's not a meaningful variable, we should rename it there
348
    all_items_count        => $all_items->count,
343
    all_items_count        => $all_items->count,
349
    items_to_display_count => $items_to_display->count,
344
    items_to_display_count => $items_to_display->count,
350
    branch_holdings_count  => $branch_holdings_count,
351
);
345
);
352
if ( C4::Context->preference('SeparateHoldingsByGroup') ) {
353
    my $branchcode        = C4::Context->userenv->{branch};
354
    my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } );
355
    my @lib_groups;
356
    my %branchcode_hash;
357
    my %holdings_count;
358
359
    foreach my $search_group (@all_search_groups) {
360
        while ( my $group = $search_group->next ) {
361
            my @all_libs = $group->all_libraries;
362
363
            # Check if library is in group
364
            if ( grep { $_->branchcode eq $branchcode } @all_libs ) {
365
366
                # Get other libraries in group
367
                my @other_libs = grep { $_->branchcode ne $branchcode } @all_libs;
368
369
                my @libs_branchcodes;
370
                push @libs_branchcodes, $branchcode;
371
372
                foreach my $lib (@other_libs) {
373
                    push @libs_branchcodes, $lib->branchcode;
374
                }
375
376
                # Build group branchcode hash
377
                $branchcode_hash{ $group->id } = \@libs_branchcodes;
378
379
                my $SeparateHoldingsBranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
380
                my $group_holdings_count =
381
                    $items_to_display->search( { $SeparateHoldingsBranch => { '-in' => \@libs_branchcodes } } )->count;
382
                $holdings_count{ $group->id } = $group_holdings_count;
383
                $total_group_holdings_count += $group_holdings_count;
384
385
                push @lib_groups, $group;
386
                $other_holdings_count = ( $items_to_display->count ) - $total_group_holdings_count;
387
            }
388
        }
389
    }
390
391
    $template->param(
392
        lib_groups                 => \@lib_groups,
393
        branchcodes                => \%branchcode_hash,
394
        holdings_count_hash        => \%holdings_count,
395
        total_group_holdings_count => $total_group_holdings_count,
396
        other_holdings_count       => $other_holdings_count,
397
    );
398
}
399
346
400
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
347
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
401
    {
348
    {
(-)a/installer/data/mysql/atomicupdate/bug_41624.pl (+31 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "41624",
6
    description => "Remove SeparateHoldingsByGroup system preference",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Check if the preference exists before removing
12
        my ($exists) = $dbh->selectrow_array(
13
            q{
14
                SELECT COUNT(*) 
15
                FROM systempreferences 
16
                WHERE variable = 'SeparateHoldingsByGroup'
17
            }
18
        );
19
20
        if ($exists) {
21
            $dbh->do(
22
                q{
23
                    DELETE FROM systempreferences 
24
                    WHERE variable = 'SeparateHoldingsByGroup'
25
                }
26
            );
27
        }
28
29
        say_success( $out, "Removed system preference 'SeparateHoldingsByGroup'" );
30
    },
31
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 lines)
Lines 742-748 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
742
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','Free'),
742
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','Free'),
743
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
743
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
744
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
744
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
745
('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'),
746
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
745
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
747
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
746
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
748
('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'Integer'),
747
('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-27 / +1 lines)
Lines 296-312 Link Here
296
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
296
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
297
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
297
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
298
        };
298
        };
299
300
        const branchcodes = {
301
          [% FOREACH key IN branchcodes.keys %]
302
            "[% key | html %]": [
303
              [% FOREACH code IN branchcodes.$key %]
304
                "[% code | html %]"[% UNLESS loop.last %], [% END %]
305
              [% END %]
306
            ][% UNLESS loop.last %], [% END %]
307
          [% END %]
308
        };
309
310
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
299
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
311
300
312
            let table_dt;
301
            let table_dt;
Lines 328-349 Link Here
328
                if ( tab_id == 'holdings' ) {
317
                if ( tab_id == 'holdings' ) {
329
                    default_filters[branch] = '[% Branches.GetLoggedInBranchcode() | html %]';
318
                    default_filters[branch] = '[% Branches.GetLoggedInBranchcode() | html %]';
330
                } else {
319
                } else {
331
                    let all_branchcodes = Object.values(branchcodes).flat();
320
                    default_filters[branch] = { '!=': '[% Branches.GetLoggedInBranchcode() | html  %]' };
332
                    all_branchcodes.push('[% Branches.GetLoggedInBranchcode() | html %]');
333
                    default_filters[branch] = { '-not_in' : all_branchcodes };
334
                }
335
            [% END %]
336
337
            [% IF Koha.Preference('SeparateHoldingsByGroup') %]
338
                if ( tab_id.includes('group_holdings') ) {
339
                    user_colvis[tab_id] = {};
340
                    items_table_settings[tab_id] = [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %];
341
342
                    const id = tab_id.replace("group_holdings_", "");
343
344
                    let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]';
345
                    default_filters[branch] = branchcodes[id];
346
347
                }
321
                }
348
            [% END %]
322
            [% END %]
349
323
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-7 / +1 lines)
Lines 301-312 Cataloging: Link Here
301
                homebranch: 'home library'
301
                homebranch: 'home library'
302
                holdingbranch: 'holding library'
302
                holdingbranch: 'holding library'
303
            - "is the logged in user's library. The second tab will contain all other items."
303
            - "is the logged in user's library. The second tab will contain all other items."
304
        -
305
            - pref: SeparateHoldingsByGroup
306
              choices:
307
                  1: Separate
308
                  0: "Don't separate"
309
            - "holdings by library group in subsequent tabs that contain items whose home library is the logged in library branch."
310
        -
304
        -
311
            - pref: AlwaysShowHoldingsTableFilters
305
            - pref: AlwaysShowHoldingsTableFilters
312
              choices:
306
              choices:
Lines 414-417 Cataloging: Link Here
414
            - "<br/>"
408
            - "<br/>"
415
            - "All values of repeating tags and subfields will be printed with the given RIS tag."
409
            - "All values of repeating tags and subfields will be printed with the given RIS tag."
416
            - "<br/>"
410
            - "<br/>"
417
            - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing."
411
            - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing."
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-47 / +8 lines)
Lines 335-369 Link Here
335
    [% WRAPPER tabs id= "bibliodetails" %]
335
    [% WRAPPER tabs id= "bibliodetails" %]
336
        [% WRAPPER tabs_nav %]
336
        [% WRAPPER tabs_nav %]
337
            [% IF Koha.Preference('SeparateHoldings') %]
337
            [% IF Koha.Preference('SeparateHoldings') %]
338
                [% IF branch_holdings_count %]
338
                [% IF items_to_display_count - ( other_holdings_count || 0 ) %]
339
                    [% WRAPPER tab_item tabname= "holdings" %]
339
                    [% WRAPPER tab_item tabname= "holdings" %]
340
                        <span>[% Branches.GetLoggedInBranchname | html %] holdings ([% branch_holdings_count | html %])</span>
340
                        <span>[% Branches.GetLoggedInBranchname | html %] holdings ([% items_to_display_count - ( other_holdings_count || 0 ) - ( hidden_count || 0 ) || 0 | html %])</span>
341
                    [% END %]
342
                [% END %]
343
            [% ELSE %]
344
                [% WRAPPER tab_item tabname= "holdings" %]
345
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
346
                [% END %]
347
            [% END %]
348
349
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
350
                [% FOREACH group IN lib_groups %]
351
                    [% IF ( holdings_count_hash.${group.id} > 0 ) %]
352
                        [% WRAPPER tab_item tabname="group_holdings_" _ group.id %]
353
                            <span>[% group.title | html %] holdings ([% holdings_count_hash.${group.id} | html %])</span>
354
                        [% END %]
355
                    [% END %]
341
                    [% END %]
356
                [% END %]
342
                [% END %]
357
            [% END %]
343
                [% IF other_holdings_count %]
358
359
            [% IF Koha.Preference('SeparateHoldings') %]
360
                [% IF other_holdings_count > 0 %]
361
                    [% WRAPPER tab_item tabname= "otherholdings" %]
344
                    [% WRAPPER tab_item tabname= "otherholdings" %]
362
                        <span>Other holdings ([% other_holdings_count || 0 | html %])</span>
345
                        <span>Other holdings ([% other_holdings_count || 0 | html %])</span>
363
                    [% END %]
346
                    [% END %]
364
                [% END %]
347
                [% END %]
348
            [% ELSE %]
349
                [% WRAPPER tab_item tabname= "holdings" %]
350
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
351
                [% END %]
365
            [% END %]
352
            [% END %]
366
367
            [% IF Koha.Preference('EnableItemGroups') %]
353
            [% IF Koha.Preference('EnableItemGroups') %]
368
                [% WRAPPER tab_item tabname= "item_groups" %]
354
                [% WRAPPER tab_item tabname= "item_groups" %]
369
                    <span>Item groups</span>
355
                    <span>Item groups</span>
Lines 503-518 Link Here
503
                    [% PROCESS items_table tab="otherholdings" %]
489
                    [% PROCESS items_table tab="otherholdings" %]
504
                [% END # /tab_panel %]
490
                [% END # /tab_panel %]
505
            [% END %]
491
            [% END %]
506
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
507
                [% FOREACH group IN lib_groups %]
508
                    [% IF ( holdings_count_hash.${group.id} > 0 ) %]
509
                        [% SET group_tab = "group_holdings_" _ group.id %]
510
                        [% WRAPPER tab_panel tabname=group_tab %]
511
                            [% PROCESS items_table tab=group_tab %]
512
                        [% END # /tab_panel %]
513
                    [% END %]
514
                [% END %]
515
            [% END %]
516
492
517
            [% IF ( MARCNOTES ) %]
493
            [% IF ( MARCNOTES ) %]
518
                [% WRAPPER tab_panel tabname="description" %]
494
                [% WRAPPER tab_panel tabname="description" %]
Lines 1763-1791 Link Here
1763
    [% END %]
1739
    [% END %]
1764
    <script>
1740
    <script>
1765
        var browser;
1741
        var browser;
1766
        var group_tabs;
1767
        browser = KOHA.browser("[% searchid | html %]", parseInt(biblionumber, 10));
1742
        browser = KOHA.browser("[% searchid | html %]", parseInt(biblionumber, 10));
1768
        browser.show();
1743
        browser.show();
1769
        let group_tabs_array = new Array;
1770
        [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
1771
            [% FOREACH group IN lib_groups %]
1772
               group_tabs = "group_holdings_[% group.id | html %]"
1773
               group_tabs_array.push(group_tabs);
1774
            [% END %]
1775
          [% END %]
1776
1744
1777
        [% IF bundlesEnabled %]
1745
        [% IF bundlesEnabled %]
1778
            var bundle_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','bundle_tables','json') | $raw %];
1746
            var bundle_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','bundle_tables','json') | $raw %];
1779
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1747
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1780
        [% END %]
1748
        [% END %]
1781
1749
1782
        let items_tab_ids_default = [
1750
        let items_tab_ids = [ 'holdings', 'otherholdings' ];
1783
            'holdings',
1784
            'otherholdings'
1785
        ];
1786
1787
        let items_tab_ids = items_tab_ids_default.concat(group_tabs_array);
1788
1789
        items_tab_ids.forEach( function( tab_id, index ) {
1751
        items_tab_ids.forEach( function( tab_id, index ) {
1790
1752
1791
            // Early return if the tab is not shown (ie. no table)
1753
            // Early return if the tab is not shown (ie. no table)
1792
- 

Return to bug 41624