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

(-)a/Koha/Exporter/Record.pm (-3 / +4 lines)
Lines 63-69 sub _get_biblio_for_export { Link Here
63
    my $biblionumber = $params->{biblionumber};
63
    my $biblionumber = $params->{biblionumber};
64
    my $itemnumbers  = $params->{itemnumbers};
64
    my $itemnumbers  = $params->{itemnumbers};
65
    my $export_items = $params->{export_items} // 1;
65
    my $export_items = $params->{export_items} // 1;
66
    my $only_export_items_for_branch = $params->{only_export_items_for_branch};
66
    my $only_export_items_for_branches = $params->{only_export_items_for_branches};
67
67
68
    my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); };
68
    my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); };
69
69
Lines 71-82 sub _get_biblio_for_export { Link Here
71
71
72
    if ($export_items) {
72
    if ($export_items) {
73
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, $itemnumbers );
73
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, $itemnumbers );
74
        if ($only_export_items_for_branch) {
74
        if ($only_export_items_for_branches && @$only_export_items_for_branches) {
75
            my %export_items_for_branches = map { $_ => 1 } @$only_export_items_for_branches;
75
            my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' );    # Should be GetFrameworkCode( $biblionumber )?
76
            my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' );    # Should be GetFrameworkCode( $biblionumber )?
76
77
77
            for my $itemfield ( $record->field($homebranchfield) ) {
78
            for my $itemfield ( $record->field($homebranchfield) ) {
78
                my $homebranch = $itemfield->subfield($homebranchsubfield);
79
                my $homebranch = $itemfield->subfield($homebranchsubfield);
79
                if ( $only_export_items_for_branch ne $homebranch ) {
80
                unless ( $export_items_for_branches{$homebranch} ) {
80
                    $record->delete_field($itemfield);
81
                    $record->delete_field($itemfield);
81
                }
82
                }
82
            }
83
            }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt (-3 / +3 lines)
Lines 96-102 $(document).ready(function() { Link Here
96
        </li>
96
        </li>
97
        
97
        
98
        <li>
98
        <li>
99
            <label>Library: </label>
99
            <label>With items owned by the following libraries: </label>
100
            [% INCLUDE 'branch-selector.inc' branches = libraries %]
100
            [% INCLUDE 'branch-selector.inc' branches = libraries %]
101
        </li>
101
        </li>
102
    </ol>
102
    </ol>
Lines 146-153 $(document).ready(function() { Link Here
146
        <input id="dont_export_item" type="checkbox" name="dont_export_item" />
146
        <input id="dont_export_item" type="checkbox" name="dont_export_item" />
147
        </li>
147
        </li>
148
        <li>
148
        <li>
149
        <label for="strip_nonlocal_items">Remove non-local items:</label>
149
        <label for="strip_items_not_from_libraries">Remove items not owned by selected libraries:</label>
150
        <input id="strip_nonlocal_items" type="checkbox" name="strip_nonlocal_items" />
150
        <input id="strip_items_not_from_libraries" type="checkbox" name="strip_items_not_from_libraries" />
151
        </li>
151
        </li>
152
        <li>
152
        <li>
153
        <label for="export_remove_fields">Don't export fields:</label>
153
        <label for="export_remove_fields">Don't export fields:</label>
(-)a/tools/export.pl (-5 / +4 lines)
Lines 87-99 if ( $op eq "export" ) { Link Here
87
    my $export_remove_fields = $query->param("export_remove_fields") || q||;
87
    my $export_remove_fields = $query->param("export_remove_fields") || q||;
88
    my @biblionumbers      = $query->multi_param("biblionumbers");
88
    my @biblionumbers      = $query->multi_param("biblionumbers");
89
    my @itemnumbers        = $query->multi_param("itemnumbers");
89
    my @itemnumbers        = $query->multi_param("itemnumbers");
90
    my $strip_nonlocal_items =  $query->param('strip_nonlocal_items');
90
    my $strip_items_not_from_libraries =  $query->param('strip_items_not_from_libraries');
91
    my @sql_params;
91
    my @sql_params;
92
    my $sql_query;
92
    my $sql_query;
93
93
94
    my $libraries = $strip_nonlocal_items
94
    my $libraries = Koha::Libraries->search_filtered->unblessed;
95
        ? [ Koha::Libraries->find(C4::Context->userenv->{branch})->unblessed ]
95
    my $only_export_items_for_branches = $strip_items_not_from_libraries ? \@branch : undef;
96
        : Koha::Libraries->search_filtered->unblessed;
97
    my @branchcodes;
96
    my @branchcodes;
98
    for my $branchcode ( @branch ) {
97
    for my $branchcode ( @branch ) {
99
        if ( grep { $_->{branchcode} eq $branchcode } @$libraries ) {
98
        if ( grep { $_->{branchcode} eq $branchcode } @$libraries ) {
Lines 209-214 if ( $op eq "export" ) { Link Here
209
                dont_export_fields => $export_remove_fields,
208
                dont_export_fields => $export_remove_fields,
210
                csv_profile_id     => $csv_profile_id,
209
                csv_profile_id     => $csv_profile_id,
211
                export_items       => (not $dont_export_items),
210
                export_items       => (not $dont_export_items),
211
                only_export_items_for_branches => $only_export_items_for_branches,
212
            }
212
            }
213
        );
213
        );
214
    }
214
    }
215
- 

Return to bug 18201