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

(-)a/acqui/addorderiso2709.pl (-21 / +49 lines)
Lines 63-73 my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ Link Here
63
    flagsrequired   => { acquisition => 'order_manage' },
63
    flagsrequired   => { acquisition => 'order_manage' },
64
});
64
});
65
65
66
my $cgiparams = $input->Vars;
66
my $cgiparams    = $input->Vars;
67
my $op = $cgiparams->{'op'} || '';
67
my $op           = $cgiparams->{'op'} || '';
68
my $booksellerid  = $input->param('booksellerid');
68
my $booksellerid = $input->param('booksellerid');
69
my $allmatch = $input->param('allmatch');
69
my $allmatch     = $input->param('allmatch');
70
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
70
my $bookseller   = Koha::Acquisition::Booksellers->find($booksellerid);
71
my $clear_fund   = $input->param('clear_fund');
71
72
72
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
73
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
73
                booksellerid => $booksellerid,
74
                booksellerid => $booksellerid,
Lines 104-110 if ($op eq ""){ Link Here
104
                     bookseller => $bookseller,
105
                     bookseller => $bookseller,
105
                     "allmatch" => $allmatch,
106
                     "allmatch" => $allmatch,
106
                     );
107
                     );
107
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
108
    import_biblios_list( $template, $cgiparams->{'import_batch_id'}, $clear_fund );
108
    if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) {
109
    if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) {
109
        # prepare empty item form
110
        # prepare empty item form
110
        my $cell = PrepareItemrecordDisplay( '', '', undef, 'ACQ' );
111
        my $cell = PrepareItemrecordDisplay( '', '', undef, 'ACQ' );
Lines 393-403 if ($op eq ""){ Link Here
393
    exit;
394
    exit;
394
}
395
}
395
396
396
my $budgets = GetBudgets();
397
my $budgets   = GetBudgets();
397
my $budget_id = @$budgets[0]->{'budget_id'};
398
my $budget_id = $clear_fund ? "" : @$budgets[0]->{'budget_id'};
399
398
# build bookfund list
400
# build bookfund list
399
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
401
my $patron = Koha::Patrons->find($loggedinuser)->unblessed;
400
my $budget = GetBudget($budget_id);
401
402
402
# build budget list
403
# build budget list
403
my %budget_loops;
404
my %budget_loops;
Lines 461-467 sub import_batches_list { Link Here
461
}
462
}
462
463
463
sub import_biblios_list {
464
sub import_biblios_list {
464
    my ($template, $import_batch_id) = @_;
465
    my ( $template, $import_batch_id, $clear_fund ) = @_;
465
    my $batch = GetImportBatch($import_batch_id,'staged');
466
    my $batch = GetImportBatch($import_batch_id,'staged');
466
    return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/;
467
    return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/;
467
    my $import_records = Koha::Import::Records->search({
468
    my $import_records = Koha::Import::Records->search({
Lines 508-530 sub import_biblios_list { Link Here
508
        );
509
        );
509
        my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information";
510
        my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information";
510
511
511
        my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']);
512
        my $infos = get_infos_syspref(
512
        my $price = looks_like_number($infos->{price}) ? $infos->{price} : GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') );
513
            'MarcFieldsToOrder', $marcrecord,
514
            [ 'price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice' ]
515
        );
516
        my $price =
517
            looks_like_number( $infos->{price} )
518
            ? $infos->{price}
519
            : GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') );
513
        my $replacementprice = $infos->{replacementprice};
520
        my $replacementprice = $infos->{replacementprice};
514
        my $quantity = $infos->{quantity};
521
        my $quantity         = $infos->{quantity};
515
        my $budget_code = $infos->{budget_code};
522
        my $budget_code      = $infos->{budget_code};
516
        my $discount = $infos->{discount};
523
        my $discount         = $infos->{discount};
517
        my $sort1 = $infos->{sort1};
524
        my $sort1            = $infos->{sort1};
518
        my $sort2 = $infos->{sort2};
525
        my $sort2            = $infos->{sort2};
519
        my $budget_id;
526
        my $budget_id        = "";
520
527
521
        if ($budget_code) {
528
        if ( $budget_code and not $clear_fund ) {
522
            my $biblio_budget = GetBudgetByCode($budget_code);
529
            my $biblio_budget = GetBudgetByCode($budget_code);
523
            if ($biblio_budget) {
530
            if ($biblio_budget) {
524
                $budget_id = $biblio_budget->{budget_id};
531
                $budget_id = $biblio_budget->{budget_id};
525
            }
532
            }
526
        }
533
        }
527
534
535
        my %budget_loops;
536
        my $budgets_hierarchy = GetBudgetHierarchy;
537
        foreach my $r ( @{$budgets_hierarchy} ) {
538
            unless ( defined $budget_loops{ $r->{budget_period_id} } ) {
539
                $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description};
540
                $budget_loops{ $r->{budget_period_id} }->{active}      = $r->{budget_period_active};
541
                $budget_loops{ $r->{budget_period_id} }->{funds}       = [];
542
            }
543
            push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, {
544
                b_id            => $r->{budget_id},
545
                b_txt           => $r->{budget_name},
546
                b_code          => $r->{budget_code},
547
                b_sort1_authcat => $r->{'sort1_authcat'},
548
                b_sort2_authcat => $r->{'sort2_authcat'},
549
                b_active        => $r->{budget_period_active},
550
                b_sel           => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
551
                b_level         => $r->{budget_level},
552
            };
553
        }
554
        $cellrecord{budget_loop} = \%budget_loops;
555
528
        # Items
556
        # Items
529
        my @itemlist = ();
557
        my @itemlist = ();
530
        my $all_items_quantity = 0;
558
        my $all_items_quantity = 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-1 / +1 lines)
Lines 213-219 Link Here
213
                                                                        <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
213
                                                                        <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
214
                                                                        <select id="fund_record_[% biblio.import_record_id | html %]" name="budget_id_[% biblio.import_record_id | html %]">
214
                                                                        <select id="fund_record_[% biblio.import_record_id | html %]" name="budget_id_[% biblio.import_record_id | html %]">
215
                                                                            <option value="">Select a fund (will use default if set)</option>
215
                                                                            <option value="">Select a fund (will use default if set)</option>
216
                                                                            [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" %]
216
                                                                            [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" budget_loop = biblio.budget_loop %]
217
                                                                        </select>
217
                                                                        </select>
218
                                                                        <span class="required" style="display:none">Required</span>
218
                                                                        <span class="required" style="display:none">Required</span>
219
                                                                    [% END %]
219
                                                                    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt (-1 / +9 lines)
Lines 429-434 Link Here
429
                })
429
                })
430
            });
430
            });
431
            [% IF job_enqueued %]
431
            [% IF job_enqueued %]
432
                $("#job_callback").after($('<label for="clear_fund">Ignore fund from incoming record?</label><input type="checkbox" id="clear_fund" name="clear_fund" value="1">'));
432
                updateProgress([% job_id | html %], {
433
                updateProgress([% job_id | html %], {
433
                    finish_callback : function(){
434
                    finish_callback : function(){
434
                        $.getJSON('/api/v1/jobs/[% job_id | html %]', function(job){
435
                        $.getJSON('/api/v1/jobs/[% job_id | html %]', function(job){
Lines 442-447 Link Here
442
                        });
443
                        });
443
                    }
444
                    }
444
                });
445
                });
446
                $("#clear_fund").change(function(){
447
                    var addbasketlink = $("#addtobasket").prop("href");
448
                    if (this.checked) {
449
                        $("#addtobasket").prop("href",addbasketlink+"&clear_fund=1");
450
                    } else {
451
                        $("#addtobasket").prop("href",addbasketlink.substring(0,addbasketlink.indexOf("&clear_fund=1")));
452
                    }
453
                });
445
            [% END %]
454
            [% END %]
446
        });
455
        });
447
456
448
- 

Return to bug 31606