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

(-)a/catalogue/detail.pl (+47 lines)
Lines 60-65 use Koha::Reviews; Link Here
60
use Koha::SearchEngine::Search;
60
use Koha::SearchEngine::Search;
61
use Koha::SearchEngine::QueryBuilder;
61
use Koha::SearchEngine::QueryBuilder;
62
use Koha::Serial::Items;
62
use Koha::Serial::Items;
63
use Koha::Library::Group;
64
use Koha::Library::Groups;
63
65
64
my $query = CGI->new();
66
my $query = CGI->new();
65
67
Lines 336-341 if ( C4::Context->preference('SeparateHoldings') ) { Link Here
336
        $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count;
338
        $items_to_display->search( { $SeparateHoldingsBranch => { '!=' => C4::Context->userenv->{branch} } } )->count;
337
    $template->param( other_holdings_count => $other_holdings_count );
339
    $template->param( other_holdings_count => $other_holdings_count );
338
}
340
}
341
342
if ( C4::Context->preference('SeparateHoldingsByGroup') ) {
343
    my $branchcode        = C4::Context->userenv->{branch};
344
    my @all_search_groups = Koha::Library::Groups->get_search_groups( { interface => 'staff' } );
345
    my @lib_groups;
346
    my %branchcode_hash;
347
    my %holdings_count;
348
349
    foreach my $search_group (@all_search_groups) {
350
        while ( my $group = $search_group->next ) {
351
            my @all_libs = $group->all_libraries;
352
353
            # Check if library is in group
354
            if ( grep { $_->branchcode eq $branchcode } @all_libs ) {
355
356
                # Get other libraries in group
357
                my @other_libs = grep { $_->branchcode ne $branchcode } @all_libs;
358
                my @libs_branchcodes;
359
360
                foreach my $lib (@other_libs) {
361
                    push @libs_branchcodes, $lib->branchcode;
362
                }
363
364
                # Push logged in branchcode
365
                push @libs_branchcodes, $branchcode;
366
367
                # Build group branchcode hash
368
                $branchcode_hash{ $group->id } = \@libs_branchcodes;
369
370
                my $group_holdings_count =
371
                    $items_to_display->search( { homebranch => { '-in' => \@libs_branchcodes } } )->count;
372
                $holdings_count{ $group->id } = $group_holdings_count;
373
374
                push @lib_groups, $group;
375
            }
376
        }
377
    }
378
379
    $template->param(
380
        lib_groups     => \@lib_groups,
381
        branchcodes    => \%branchcode_hash,
382
        holdings_count => \%holdings_count,
383
    );
384
}
385
339
$template->param(
386
$template->param(
340
    count                  => $all_items->count,         # FIXME 'count' is used in catalog-strings.inc
387
    count                  => $all_items->count,         # FIXME 'count' is used in catalog-strings.inc
341
                                                         # But it's not a meaningful variable, we should rename it there
388
                                                         # But it's not a meaningful variable, we should rename it there
(-)a/installer/data/mysql/atomicupdate/bug_35211_separate_holdings_by_group.pl (+22 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  => "35211",
6
    description => "",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Do you stuffs here
12
        $dbh->do(
13
            q{
14
                INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15
                VALUES ('SeparateHoldingsByGroup',NULL,'','Separate current branch holdings and holdings from libraries in the same group','YesNo')
16
                }
17
        );
18
19
        # Other information
20
        say_success( $out, "Added new system preference 'SeparateHoldingsByGroup'" );
21
    },
22
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 737-742 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
737
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
737
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
738
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
738
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
739
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
739
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
740
('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'),
740
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
741
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
741
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
742
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
742
('SerialsSearchResultsLimit', '', NULL, 'Serials search results limit', 'integer'),
743
('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 291-296 Link Here
291
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
291
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
292
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
292
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
293
        };
293
        };
294
295
        const branchcodes = {
296
          [% FOREACH key IN branchcodes.keys %]
297
            "[% key | html %]": [
298
              [% FOREACH code IN branchcodes.$key %]
299
                "[% code | html %]"[% UNLESS loop.last %], [% END %]
300
              [% END %]
301
            ][% UNLESS loop.last %], [% END %]
302
          [% END %]
303
        };
304
294
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
305
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
295
306
296
            let table_dt;
307
            let table_dt;
Lines 316-321 Link Here
316
                }
327
                }
317
            [% END %]
328
            [% END %]
318
329
330
            [% IF Koha.Preference('SeparateHoldingsByGroup') %]
331
                if ( tab_id.includes('group_holdings') ) {
332
                    user_colvis[tab_id] = {};
333
                    items_table_settings[tab_id] = [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %];
334
335
                    const id = tab_id.replace("group_holdings_", "");
336
337
                    let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]';
338
                    default_filters[branch] = branchcodes[id];
339
340
                }
341
            [% END %]
342
319
            [% IF hidden_count %]
343
            [% IF hidden_count %]
320
                default_filters.lost_status = "0";
344
                default_filters.lost_status = "0";
321
            [% END %]
345
            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +7 lines)
Lines 301-306 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."
304
        -
310
        -
305
            - pref: AlwaysShowHoldingsTableFilters
311
            - pref: AlwaysShowHoldingsTableFilters
306
              choices:
312
              choices:
Lines 408-411 Cataloging: Link Here
408
            - "<br/>"
414
            - "<br/>"
409
            - "All values of repeating tags and subfields will be printed with the given RIS tag."
415
            - "All values of repeating tags and subfields will be printed with the given RIS tag."
410
            - "<br/>"
416
            - "<br/>"
411
            - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing."
417
            - "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 (-2 / +29 lines)
Lines 337-342 Link Here
337
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
337
                    <span>Holdings ([% items_to_display_count || 0 | html %])</span>
338
                [% END %]
338
                [% END %]
339
            [% END %]
339
            [% END %]
340
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
341
                [% FOREACH group IN lib_groups %]
342
                    [% IF ( holdings_count.${group.id} > 0 ) %]
343
                        [% WRAPPER tab_item tabname="group_holdings_" _ group.id %]
344
                            <span>[% group.title | html %] - Group ([% holdings_count.${group.id} | html %])</span>
345
                        [% END %]
346
                    [% END %]
347
                [% END %]
348
            [% END %]
349
340
            [% IF Koha.Preference('EnableItemGroups') %]
350
            [% IF Koha.Preference('EnableItemGroups') %]
341
                [% WRAPPER tab_item tabname= "item_groups" %]
351
                [% WRAPPER tab_item tabname= "item_groups" %]
342
                    <span>Item groups</span>
352
                    <span>Item groups</span>
Lines 476-481 Link Here
476
                    [% PROCESS items_table tab="otherholdings" %]
486
                    [% PROCESS items_table tab="otherholdings" %]
477
                [% END # /tab_panel %]
487
                [% END # /tab_panel %]
478
            [% END %]
488
            [% END %]
489
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
490
                [% FOREACH group IN lib_groups %]
491
                    [% IF ( holdings_count.${group.id} > 0 ) %]
492
                        [% SET group_tab = "group_holdings_" _ group.id %]
493
                        [% WRAPPER tab_panel tabname=group_tab %]
494
                            [% PROCESS items_table tab=group_tab %]
495
                        [% END # /tab_panel %]
496
                    [% END %]
497
                [% END %]
498
            [% END %]
479
499
480
            [% IF ( MARCNOTES ) %]
500
            [% IF ( MARCNOTES ) %]
481
                [% WRAPPER tab_panel tabname="description" %]
501
                [% WRAPPER tab_panel tabname="description" %]
Lines 1734-1740 Link Here
1734
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1754
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1735
        [% END %]
1755
        [% END %]
1736
1756
1737
        let items_tab_ids = [ 'holdings', 'otherholdings' ];
1757
        let items_tab_ids = [
1758
            'holdings',
1759
            'otherholdings'
1760
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
1761
                [% FOREACH group IN lib_groups %]
1762
                , 'group_holdings_[% group.id | html %]'
1763
                [% END %]
1764
            [% END %]
1765
        ];
1738
        items_tab_ids.forEach( function( tab_id, index ) {
1766
        items_tab_ids.forEach( function( tab_id, index ) {
1739
1767
1740
            // Early return if the tab is not shown (ie. no table)
1768
            // Early return if the tab is not shown (ie. no table)
1741
- 

Return to bug 35211