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

(-)a/Koha/MarcOrder.pm (-4 / +25 lines)
Lines 52-58 use C4::Biblio qw( Link Here
52
    GetMarcPrice
52
    GetMarcPrice
53
);
53
);
54
use C4::Items   qw( AddItemFromMarc );
54
use C4::Items   qw( AddItemFromMarc );
55
use C4::Budgets qw( GetBudgetByCode );
55
use C4::Budgets qw( GetBudgetByCode GetBudgetHierarchy );
56
56
57
use Koha::Database;
57
use Koha::Database;
58
use Koha::ImportBatchProfiles;
58
use Koha::ImportBatchProfiles;
Lines 651-662 sub import_batches_list { Link Here
651
For an import batch, this function reads the files and creates all the relevant data pertaining to that file
651
For an import batch, this function reads the files and creates all the relevant data pertaining to that file
652
It then returns this to the template to be shown in the UI
652
It then returns this to the template to be shown in the UI
653
653
654
Koha::MarcOrder->import_biblios_list( $cgiparams->{'import_batch_id'} );
654
    Koha::MarcOrder->import_biblios_list( $cgiparams->{'import_batch_id'}, $clear_fund );
655
655
656
=cut
656
=cut
657
657
658
sub import_biblios_list {
658
sub import_biblios_list {
659
    my ( $self, $import_batch_id ) = @_;
659
    my ( $self, $import_batch_id, $clear_fund ) = @_;
660
    my $batch = GetImportBatch( $import_batch_id, 'staged' );
660
    my $batch = GetImportBatch( $import_batch_id, 'staged' );
661
    return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/;
661
    return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/;
662
    my $import_records = Koha::Import::Records->search(
662
    my $import_records = Koha::Import::Records->search(
Lines 733-745 sub import_biblios_list { Link Here
733
        my $sort2            = $infos->{sort2}            || undef;
733
        my $sort2            = $infos->{sort2}            || undef;
734
        my $budget_id;
734
        my $budget_id;
735
735
736
        if ($budget_code) {
736
        if ( $budget_code and not $clear_fund ) {
737
            my $biblio_budget = GetBudgetByCode($budget_code);
737
            my $biblio_budget = GetBudgetByCode($budget_code);
738
            if ($biblio_budget) {
738
            if ($biblio_budget) {
739
                $budget_id = $biblio_budget->{budget_id};
739
                $budget_id = $biblio_budget->{budget_id};
740
            }
740
            }
741
        }
741
        }
742
742
743
        my %budget_loops;
744
        my $budgets_hierarchy = GetBudgetHierarchy;
745
        foreach my $r ( @{$budgets_hierarchy} ) {
746
            unless ( defined $budget_loops{ $r->{budget_period_id} } ) {
747
                $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description};
748
                $budget_loops{ $r->{budget_period_id} }->{active}      = $r->{budget_period_active};
749
                $budget_loops{ $r->{budget_period_id} }->{funds}       = [];
750
            }
751
            push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, {
752
                b_id            => $r->{budget_id},
753
                b_txt           => $r->{budget_name},
754
                b_code          => $r->{budget_code},
755
                b_sort1_authcat => $r->{'sort1_authcat'},
756
                b_sort2_authcat => $r->{'sort2_authcat'},
757
                b_active        => $r->{budget_period_active},
758
                b_sel           => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
759
                b_level         => $r->{budget_level},
760
            };
761
        }
762
        $cellrecord{budget_loop} = \%budget_loops;
763
743
        # Items
764
        # Items
744
        my @itemlist           = ();
765
        my @itemlist           = ();
745
        my $all_items_quantity = 0;
766
        my $all_items_quantity = 0;
(-)a/acqui/addorderiso2709.pl (-3 / +3 lines)
Lines 71-76 my $op = $cgiparams->{'op'} || ''; Link Here
71
my $booksellerid = $input->param('booksellerid');
71
my $booksellerid = $input->param('booksellerid');
72
my $allmatch     = $input->param('allmatch');
72
my $allmatch     = $input->param('allmatch');
73
my $bookseller   = Koha::Acquisition::Booksellers->find($booksellerid);
73
my $bookseller   = Koha::Acquisition::Booksellers->find($booksellerid);
74
my $clear_fund   = $input->param('clear_fund');
74
75
75
$template->param(
76
$template->param(
76
    scriptname     => "/cgi-bin/koha/acqui/addorderiso2709.pl",
77
    scriptname     => "/cgi-bin/koha/acqui/addorderiso2709.pl",
Lines 116-122 if ( $op eq "" ) { Link Here
116
        bookseller => $bookseller,
117
        bookseller => $bookseller,
117
        "allmatch" => $allmatch,
118
        "allmatch" => $allmatch,
118
    );
119
    );
119
    my $biblios_list   = Koha::MarcOrder->import_biblios_list( $cgiparams->{'import_batch_id'} );
120
    my $biblios_list   = Koha::MarcOrder->import_biblios_list( $cgiparams->{'import_batch_id'}, $clear_fund );
120
    my $overlay_action = $biblios_list->{overlay_action};
121
    my $overlay_action = $biblios_list->{overlay_action};
121
    my $nomatch_action = $biblios_list->{nomatch_action};
122
    my $nomatch_action = $biblios_list->{nomatch_action};
122
    my $item_action    = $biblios_list->{item_action};
123
    my $item_action    = $biblios_list->{item_action};
Lines 307-317 if ( $op eq "" ) { Link Here
307
}
308
}
308
309
309
my $budgets   = GetBudgets();
310
my $budgets   = GetBudgets();
310
my $budget_id = @$budgets[0]->{'budget_id'};
311
my $budget_id = $clear_fund ? "" : @$budgets[0]->{'budget_id'};
311
312
312
# build bookfund list
313
# build bookfund list
313
my $patron = Koha::Patrons->find($loggedinuser)->unblessed;
314
my $patron = Koha::Patrons->find($loggedinuser)->unblessed;
314
my $budget = GetBudget($budget_id);
315
315
316
# build budget list
316
# build budget list
317
my %budget_loops;
317
my %budget_loops;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/stage_marc_for_import.inc (+6 lines)
Lines 42-47 Link Here
42
                <a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% report.import_batch_id | html %]&basketno=[% report.basket_id | html %]&booksellerid=[% report.vendor_id | html %]"
42
                <a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% report.import_batch_id | html %]&basketno=[% report.basket_id | html %]&booksellerid=[% report.vendor_id | html %]"
43
                    >Add staged files to basket</a
43
                    >Add staged files to basket</a
44
                >
44
                >
45
                <a
46
                    id="addtobasket_nofund"
47
                    class="btn btn-default"
48
                    href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% report.import_batch_id | html %]&basketno=[% report.basket_id | html %]&booksellerid=[% report.vendor_id | html %]&clear_fund=1"
49
                    >Add staged files to basket and ignore incoming fund</a
50
                >
45
            </p>
51
            </p>
46
        [% END %]
52
        [% END %]
47
    [% END %]
53
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-1 / +1 lines)
Lines 273-279 Link Here
273
                                                                        <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
273
                                                                        <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
274
                                                                        <select id="fund_record_[% biblio.import_record_id | html %]" name="budget_id_[% biblio.import_record_id | html %]">
274
                                                                        <select id="fund_record_[% biblio.import_record_id | html %]" name="budget_id_[% biblio.import_record_id | html %]">
275
                                                                            <option value="">Select a fund (will use default if set)</option>
275
                                                                            <option value="">Select a fund (will use default if set)</option>
276
                                                                            [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" %]
276
                                                                            [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" budget_loop = biblio.budget_loop %]
277
                                                                        </select>
277
                                                                        </select>
278
                                                                        <span class="required" style="display:none">Required</span>
278
                                                                        <span class="required" style="display:none">Required</span>
279
                                                                    [% END %]
279
                                                                    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt (-2 / +1 lines)
Lines 436-442 Link Here
436
                            let basket_id = job.data.report.basket_id;
436
                            let basket_id = job.data.report.basket_id;
437
                            let vendor_id = job.data.report.vendor_id;
437
                            let vendor_id = job.data.report.vendor_id;
438
                            if ( basket_id && vendor_id ) {
438
                            if ( basket_id && vendor_id ) {
439
                                $('<p><a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s">%s</a></p>'.format(import_batch_id, basket_id, vendor_id, _("Add staged files to basket"))).appendTo("#job_callback");
439
                                $('<p><a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s">%s</a> <a id="addtobasket_nofund" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s&clear_fund=1">%s</a></p>'.format(import_batch_id, basket_id, vendor_id, _("Add staged files to basket"), import_batch_id, basket_id, vendor_id, _("Add staged files to basket and ignore incoming fund"))).appendTo("#job_callback");
440
                            }
440
                            }
441
                        });
441
                        });
442
                    }
442
                    }
443
- 

Return to bug 31606