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 733-738 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
733
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
733
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
734
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
734
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
735
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
735
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
736
('SeparateHoldingsByGroup','0',NULL,'Separate current branch holdings and holdings from libraries in the same library groups','YesNo'),
736
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
737
('SerialsDefaultEmailAddress', '', NULL, 'Default email address used as reply-to for notices sent by the serials module.', 'Free'),
737
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
738
('SerialsDefaultReplyTo', '', NULL, 'Default email address that serials notices are sent from.', 'Free'),
738
('SerialsSearchResultsLimit', NULL, NULL, 'Serials search results limit', 'integer'),
739
('SerialsSearchResultsLimit', NULL, NULL, 'Serials search results limit', 'integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (+24 lines)
Lines 290-295 Link Here
290
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
290
            holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
291
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
291
            otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
292
        };
292
        };
293
294
        const branchcodes = {
295
          [% FOREACH key IN branchcodes.keys %]
296
            "[% key | html %]": [
297
              [% FOREACH code IN branchcodes.$key %]
298
                "[% code | html %]"[% UNLESS loop.last %], [% END %]
299
              [% END %]
300
            ][% UNLESS loop.last %], [% END %]
301
          [% END %]
302
        };
303
293
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
304
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
294
305
295
            let table_dt;
306
            let table_dt;
Lines 315-320 Link Here
315
                }
326
                }
316
            [% END %]
327
            [% END %]
317
328
329
            [% IF Koha.Preference('SeparateHoldingsByGroup') %]
330
                if ( tab_id.includes('group_holdings') ) {
331
                    user_colvis[tab_id] = {};
332
                    items_table_settings[tab_id] = [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %];
333
334
                    const id = tab_id.replace("group_holdings_", "");
335
336
                    let branch = '[% IF SeparateHoldingsBranch == 'homebranch' %]me.home_library_id[% ELSE %]me.holding_library_id[% END %]';
337
                    default_filters[branch] = branchcodes[id];
338
339
                }
340
            [% END %]
341
318
            [% IF hidden_count %]
342
            [% IF hidden_count %]
319
                default_filters.lost_status = "0";
343
                default_filters.lost_status = "0";
320
            [% END %]
344
            [% 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 1730-1736 Link Here
1730
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1750
            var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1731
        [% END %]
1751
        [% END %]
1732
1752
1733
        let items_tab_ids = [ 'holdings', 'otherholdings' ];
1753
        let items_tab_ids = [
1754
            'holdings',
1755
            'otherholdings'
1756
            [% IF Koha.Preference('SeparateHoldingsByGroup') && lib_groups %]
1757
                [% FOREACH group IN lib_groups %]
1758
                , 'group_holdings_[% group.id | html %]'
1759
                [% END %]
1760
            [% END %]
1761
        ];
1734
        items_tab_ids.forEach( function( tab_id, index ) {
1762
        items_tab_ids.forEach( function( tab_id, index ) {
1735
1763
1736
            // Early return if the tab is not shown (ie. no table)
1764
            // Early return if the tab is not shown (ie. no table)
1737
- 

Return to bug 35211