3 # Copyright 2011 BibLibre SARL
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
36 use C4
::Acquisition qw
/GetInvoices/;
37 use C4
::Bookseller qw
/GetBookSeller/;
38 use C4
::Branch qw
/GetBranches/;
42 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user
(
44 template_name
=> 'acqui/invoices.tt',
48 flagsrequired
=> { 'acquisition' => '*' },
53 my $invoicenumber = $input->param('invoicenumber');
54 my $supplierid = $input->param('supplierid');
55 my $shipmentdatefrom = $input->param('shipmentdatefrom');
56 my $shipmentdateto = $input->param('shipmentdateto');
57 my $billingdatefrom = $input->param('billingdatefrom');
58 my $billingdateto = $input->param('billingdateto');
59 my $isbneanissn = $input->param('isbneanissn');
60 my $title = $input->param('title');
61 my $author = $input->param('author');
62 my $publisher = $input->param('publisher');
63 my $publicationyear = $input->param('publicationyear');
64 my $branch = $input->param('branch');
65 my $op = $input->param('op');
68 if ( $op and $op eq 'do_search' ) {
69 my $shipmentdatefrom_iso = C4
::Dates
->new($shipmentdatefrom)->output('iso');
70 my $shipmentdateto_iso = C4
::Dates
->new($shipmentdateto)->output('iso');
71 my $billingdatefrom_iso = C4
::Dates
->new($billingdatefrom)->output('iso');
72 my $billingdateto_iso = C4
::Dates
->new($billingdateto)->output('iso');
73 @
{$invoices} = GetInvoices
(
74 invoicenumber
=> $invoicenumber,
75 supplierid
=> $supplierid,
76 shipmentdatefrom
=> $shipmentdatefrom_iso,
77 shipmentdateto
=> $shipmentdateto_iso,
78 billingdatefrom
=> $billingdatefrom_iso,
79 billingdateto
=> $billingdateto_iso,
80 isbneanissn
=> $isbneanissn,
83 publisher
=> $publisher,
84 publicationyear
=> $publicationyear,
89 # Build suppliers list
90 my @suppliers = GetBookSeller
(undef);
91 my $suppliers_loop = [];
93 foreach (@suppliers) {
95 if ($supplierid && $supplierid == $_->{id
} ) {
97 $suppliername = $_->{name
};
99 push @
{$suppliers_loop},
101 suppliername
=> $_->{name
},
102 booksellerid
=> $_->{id
},
103 selected
=> $selected,
107 # Build branches list
108 my $branches = GetBranches
();
109 my $branches_loop = [];
111 foreach ( sort keys %$branches ) {
113 if ( $branch && $branch eq $_ ) {
115 $branchname = $branches->{$_}->{'branchname'};
117 push @
{$branches_loop},
120 branchname
=> $branches->{$_}->{branchname
},
121 selected
=> $selected,
125 my $budgets = GetBudgets
();
127 foreach my $budget (@
$budgets) {
128 push @budgets_loop, $budget if CanUserUseBudget
( $loggedinuser, $budget, $flags );
131 $template->{'VARS'}->{'budgets_loop'} = \
@budgets_loop;
134 do_search
=> ( $op and $op eq 'do_search' ) ?
1 : 0,
135 invoices
=> $invoices,
136 invoicenumber
=> $invoicenumber,
137 booksellerid
=> $supplierid,
138 suppliername
=> $suppliername,
139 billingdatefrom
=> $billingdatefrom,
140 billingdateto
=> $billingdateto,
141 isbneanissn
=> $isbneanissn,
144 publisher
=> $publisher,
145 publicationyear
=> $publicationyear,
147 branchname
=> $branchname,
148 suppliers_loop
=> $suppliers_loop,
149 branches_loop
=> $branches_loop,
152 output_html_with_http_headers
$input, $cookie, $template->output;