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

(-)a/acqui/invoices.pl (-32 / +17 lines)
Lines 105-126 $template->param( Link Here
105
);
105
);
106
106
107
# Build suppliers list
107
# Build suppliers list
108
my @suppliers      = Koha::Acquisition::Booksellers->search( undef, { order_by => { -asc => 'name' } } )->as_list;
108
my $supplier;
109
my $suppliers_loop = [];
109
$supplier = Koha::Acquisition::Booksellers->find($supplierid) if $supplierid;
110
my $suppliername;
111
foreach (@suppliers) {
112
    my $selected = 0;
113
    if ($supplierid && $supplierid == $_->id ) {
114
        $selected = 1;
115
        $suppliername = $_->name;
116
    }
117
    push @{$suppliers_loop},
118
      {
119
        suppliername => $_->name,
120
        booksellerid   => $_->id,
121
        selected     => $selected,
122
      };
123
}
124
110
125
my $budgets = GetBudgets();
111
my $budgets = GetBudgets();
126
my @budgets_loop;
112
my @budgets_loop;
Lines 140-163 for my $sub ( @{$invoices} ) { Link Here
140
$template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
126
$template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
141
127
142
$template->param(
128
$template->param(
143
    openedinvoices => \@openedinvoices,
129
    openedinvoices   => \@openedinvoices,
144
    closedinvoices => \@closedinvoices,
130
    closedinvoices   => \@closedinvoices,
145
    do_search => ( $op and $op eq 'do_search' ) ? 1 : 0,
131
    do_search        => ( $op and $op eq 'do_search' ) ? 1 : 0,
146
    invoices => $invoices,
132
    invoices         => $invoices,
147
    invoicenumber   => $invoicenumber,
133
    invoicenumber    => $invoicenumber,
148
    booksellerid    => $supplierid,
134
    booksellerid     => $supplierid,
149
    suppliername    => $suppliername,
135
    supplier         => $supplier,
150
    shipmentdatefrom => $shipmentdatefrom,
136
    shipmentdatefrom => $shipmentdatefrom,
151
    shipmentdateto   => $shipmentdateto,
137
    shipmentdateto   => $shipmentdateto,
152
    billingdatefrom => $billingdatefrom,
138
    billingdatefrom  => $billingdatefrom,
153
    billingdateto   => $billingdateto,
139
    billingdateto    => $billingdateto,
154
    isbneanissn     => $isbneanissn,
140
    isbneanissn      => $isbneanissn,
155
    title           => $title,
141
    title            => $title,
156
    author          => $author,
142
    author           => $author,
157
    publisher       => $publisher,
143
    publisher        => $publisher,
158
    publicationyear => $publicationyear,
144
    publicationyear  => $publicationyear,
159
    branch          => $branch,
145
    branch           => $branch,
160
    suppliers_loop  => $suppliers_loop,
161
);
146
);
162
147
163
output_html_with_http_headers $input, $cookie, $template->output;
148
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (-9 / +48 lines)
Lines 317-330 Link Here
317
                            </li>
317
                            </li>
318
                            <li>
318
                            <li>
319
                                <label for="supplier">Vendor:</label>
319
                                <label for="supplier">Vendor:</label>
320
                                <select id="supplier" name="supplierid">
320
                                <select id="supplierid" name="supplierid">
321
                                    <option value="">All</option>
321
                                    [% IF ( supplier ) %]
322
                                    [% FOREACH supplier IN suppliers_loop %]
322
                                        <option selected="selected" value="[% supplier.id | html %]">[% supplier.name | html %]</option>
323
                                        [% IF ( supplier.selected ) %]
324
                                            <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
325
                                        [% ELSE %]
326
                                            <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option>
327
                                        [% END %]
328
                                    [% END %]
323
                                    [% END %]
329
                                </select>
324
                                </select>
330
                            </li>
325
                            </li>
Lines 425-430 Link Here
425
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
420
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
426
    [% INCLUDE 'datatables.inc' %]
421
    [% INCLUDE 'datatables.inc' %]
427
    [% INCLUDE 'calendar.inc' %]
422
    [% INCLUDE 'calendar.inc' %]
423
    [% INCLUDE 'select2.inc' %]
428
    <script>
424
    <script>
429
        $(document).ready(function() {
425
        $(document).ready(function() {
430
            $('[id^="CheckAll"]').click( function() {
426
            $('[id^="CheckAll"]').click( function() {
Lines 527-532 Link Here
527
                    $('#merge_invoices').show();
523
                    $('#merge_invoices').show();
528
                }
524
                }
529
            });
525
            });
526
527
            function display_vendor(vendor) {
528
                var $text;
529
                $text = $('<span>'+vendor.text+'</span>');
530
                return $text;
531
            }
532
533
            $("#supplierid").kohaSelect({
534
                width: '50%',
535
                allowClear: false,
536
                ajax: {
537
                    url: '/api/v1/acquisitions/vendors',
538
                    delay: 300, // wait 300 milliseconds before triggering the request
539
                    cache: true,
540
                    dataType: 'json',
541
                    data: function (params) {
542
                        var search_term = (params.term === undefined) ? '' : params.term;
543
                        var query = {
544
                            "q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}),
545
                            "_order_by": "name",
546
                            "_page": params.page
547
                        };
548
549
                        return query;
550
                    },
551
                    processResults: function (data) {
552
                        var results = [];
553
                        data.results.forEach( function ( vendor ) {
554
                            results.push(
555
                                {
556
                                    "id": vendor.id,
557
                                    "text": vendor.name.escapeHtml()
558
                                }
559
                            );
560
                        });
561
                        return { "results": results, "pagination": { "more": data.pagination.more } };
562
                    }
563
                },
564
                templateResult: display_vendor,
565
                templateSelection: display_vendor
566
            });
567
568
569
530
        });
570
        });
531
    </script>
571
    </script>
532
[% END %]
572
[% END %]
533
- 

Return to bug 36233