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>.
35 use C4
::Acquisition qw
/GetInvoices/;
38 use Koha
::Acquisition
::Booksellers
;
41 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user
(
43 template_name
=> 'acqui/invoices.tt',
46 flagsrequired
=> { 'acquisition' => '*' },
51 my $invoicenumber = $input->param('invoicenumber');
52 my $supplierid = $input->param('supplierid');
53 my $shipmentdatefrom = $input->param('shipmentdatefrom');
54 my $shipmentdateto = $input->param('shipmentdateto');
55 my $billingdatefrom = $input->param('billingdatefrom');
56 my $billingdateto = $input->param('billingdateto');
57 my $isbneanissn = $input->param('isbneanissn');
58 my $title = $input->param('title');
59 my $author = $input->param('author');
60 my $publisher = $input->param('publisher');
61 my $publicationyear = $input->param('publicationyear');
62 my $branch = $input->param('branch');
63 my $message_id = $input->param('message_id');
64 my $op = $input->param('op');
66 $shipmentdatefrom and $shipmentdatefrom = eval { dt_from_string
( $shipmentdatefrom ) };
67 $shipmentdateto and $shipmentdateto = eval { dt_from_string
( $shipmentdateto ) };
68 $billingdatefrom and $billingdatefrom = eval { dt_from_string
( $billingdatefrom ) };
69 $billingdateto and $billingdateto = eval { dt_from_string
( $billingdateto ) };
72 if ( $op and $op eq 'do_search' ) {
73 @
{$invoices} = GetInvoices
(
74 invoicenumber
=> $invoicenumber,
75 supplierid
=> $supplierid,
76 shipmentdatefrom
=> $shipmentdatefrom ? output_pref
( { str
=> $shipmentdatefrom, dateformat
=> 'iso' } ) : undef,
77 shipmentdateto
=> $shipmentdateto ? output_pref
( { str
=> $shipmentdateto, dateformat
=> 'iso' } ) : undef,
78 billingdatefrom
=> $billingdatefrom ? output_pref
( { str
=> $billingdatefrom, dateformat
=> 'iso' } ) : undef,
79 billingdateto
=> $billingdateto ? output_pref
( { str
=> $billingdateto, dateformat
=> 'iso' } ) : undef,
80 isbneanissn
=> $isbneanissn,
83 publisher
=> $publisher,
84 publicationyear
=> $publicationyear,
85 branchcode
=> $branch,
86 message_id
=> $message_id,
90 # Build suppliers list
91 my @suppliers = Koha
::Acquisition
::Booksellers
->search( undef, { order_by
=> { -asc
=> 'name' } } );
92 my $suppliers_loop = [];
94 foreach (@suppliers) {
96 if ($supplierid && $supplierid == $_->id ) {
98 $suppliername = $_->name;
100 push @
{$suppliers_loop},
102 suppliername
=> $_->name,
103 booksellerid
=> $_->id,
104 selected
=> $selected,
108 my $budgets = GetBudgets
();
110 foreach my $budget (@
$budgets) {
111 push @budgets_loop, $budget if CanUserUseBudget
( $loggedinuser, $budget, $flags );
114 $template->{'VARS'}->{'budgets_loop'} = \
@budgets_loop;
117 do_search
=> ( $op and $op eq 'do_search' ) ?
1 : 0,
118 invoices
=> $invoices,
119 invoicenumber
=> $invoicenumber,
120 booksellerid
=> $supplierid,
121 suppliername
=> $suppliername,
122 shipmentdatefrom
=> $shipmentdatefrom,
123 shipmentdateto
=> $shipmentdateto,
124 billingdatefrom
=> $billingdatefrom,
125 billingdateto
=> $billingdateto,
126 isbneanissn
=> $isbneanissn,
129 publisher
=> $publisher,
130 publicationyear
=> $publicationyear,
132 suppliers_loop
=> $suppliers_loop,
135 output_html_with_http_headers
$input, $cookie, $template->output;