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

(-)a/catalogue/detail.pl (-47 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 339-389 if ( C4::Context->preference('SeparateHoldings') ) { Link Here
339
        $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count;
337
        $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count;
340
    $template->param( other_holdings_count => $other_holdings_count );
338
    $template->param( other_holdings_count => $other_holdings_count );
341
}
339
}
342
343
if ( C4::Context->preference('SeparateHoldingsByGroup') ) {
344
    my $branchcode        = C4::Context->userenv->{branch};
345
    my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } );
346
    my @lib_groups;
347
    my %branchcode_hash;
348
    my %holdings_count;
349
350
    foreach my $search_group (@all_search_groups) {
351
        while ( my $group = $search_group->next ) {
352
            my @all_libs = $group->all_libraries;
353
354
            # Check if library is in group
355
            if ( grep { $_->branchcode eq $branchcode } @all_libs ) {
356
357
                # Get other libraries in group
358
                my @other_libs = grep { $_->branchcode ne $branchcode } @all_libs;
359
                my @libs_branchcodes;
360
361
                foreach my $lib (@other_libs) {
362
                    push @libs_branchcodes, $lib->branchcode;
363
                }
364
365
                # Push logged in branchcode
366
                push @libs_branchcodes, $branchcode;
367
368
                # Build group branchcode hash
369
                $branchcode_hash{ $group->id } = \@libs_branchcodes;
370
371
                my $group_holdings_count =
372
                    $items_to_display->search( { homebranch => { '-in' => \@libs_branchcodes } } )->count;
373
                $holdings_count{ $group->id } = $group_holdings_count;
374
375
                push @lib_groups, $group;
376
            }
377
        }
378
    }
379
380
    $template->param(
381
        lib_groups     => \@lib_groups,
382
        branchcodes    => \%branchcode_hash,
383
        holdings_count => \%holdings_count,
384
    );
385
}
386
387
$template->param(
340
$template->param(
388
    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
389
                                                         # 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
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 lines)
Lines 741-747 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
741
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','Free'),
741
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','Free'),
742
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
742
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
743
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
743
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
744
('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'),
745
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
744
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
746
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
745
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
747
('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'Integer'),
746
('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-24 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 332-350 Link Here
332
                }
321
                }
333
            [% END %]
322
            [% END %]
334
323
335
            [% IF Koha.Preference('SeparateHoldingsByGroup') %]
336
                if ( tab_id.includes('group_holdings') ) {
337
                    user_colvis[tab_id] = {};
338
                    items_table_settings[tab_id] = [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %];
339
340
                    const id = tab_id.replace("group_holdings_", "");
341
342
                    let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]';
343
                    default_filters[branch] = branchcodes[id];
344
345
                }
346
            [% END %]
347
348
            [% IF hidden_count %]
324
            [% IF hidden_count %]
349
                default_filters.lost_status = "0";
325
                default_filters.lost_status = "0";
350
            [% END %]
326
            [% END %]
(-)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 (-30 / +1 lines)
Lines 350-365 Link Here
350
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
350
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
351
                [% END %]
351
                [% END %]
352
            [% END %]
352
            [% END %]
353
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
354
                [% FOREACH group IN lib_groups %]
355
                    [% IF ( holdings_count.${group.id} > 0 ) %]
356
                        [% WRAPPER tab_item tabname="group_holdings_" _ group.id %]
357
                            <span>[% group.title | html %] - Group ([% holdings_count.${group.id} | html %])</span>
358
                        [% END %]
359
                    [% END %]
360
                [% END %]
361
            [% END %]
362
363
            [% IF Koha.Preference('EnableItemGroups') %]
353
            [% IF Koha.Preference('EnableItemGroups') %]
364
                [% WRAPPER tab_item tabname= "item_groups" %]
354
                [% WRAPPER tab_item tabname= "item_groups" %]
365
                    <span>Item groups</span>
355
                    <span>Item groups</span>
Lines 499-514 Link Here
499
                    [% PROCESS items_table tab="otherholdings" %]
489
                    [% PROCESS items_table tab="otherholdings" %]
500
                [% END # /tab_panel %]
490
                [% END # /tab_panel %]
501
            [% END %]
491
            [% END %]
502
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
503
                [% FOREACH group IN lib_groups %]
504
                    [% IF ( holdings_count.${group.id} > 0 ) %]
505
                        [% SET group_tab = "group_holdings_" _ group.id %]
506
                        [% WRAPPER tab_panel tabname=group_tab %]
507
                            [% PROCESS items_table tab=group_tab %]
508
                        [% END # /tab_panel %]
509
                    [% END %]
510
                [% END %]
511
            [% END %]
512
492
513
            [% IF ( MARCNOTES ) %]
493
            [% IF ( MARCNOTES ) %]
514
                [% WRAPPER tab_panel tabname="description" %]
494
                [% WRAPPER tab_panel tabname="description" %]
Lines 1767-1781 Link Here
1767
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1747
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1768
        [% END %]
1748
        [% END %]
1769
1749
1770
        let items_tab_ids = [
1750
        let items_tab_ids = [ 'holdings', 'otherholdings' ];
1771
            'holdings',
1772
            'otherholdings'
1773
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
1774
                [% FOREACH group IN lib_groups %]
1775
                , 'group_holdings_[% group.id | html %]'
1776
                [% END %]
1777
            [% END %]
1778
        ];
1779
        items_tab_ids.forEach( function( tab_id, index ) {
1751
        items_tab_ids.forEach( function( tab_id, index ) {
1780
1752
1781
            // Early return if the tab is not shown (ie. no table)
1753
            // Early return if the tab is not shown (ie. no table)
1782
- 

Return to bug 41624