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 under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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;