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',
47 flagsrequired
=> { 'acquisition' => '*' },
52 my $invoicenumber = $input->param('invoicenumber');
53 my $supplierid = $input->param('supplierid');
54 my $shipmentdatefrom = $input->param('shipmentdatefrom');
55 my $shipmentdateto = $input->param('shipmentdateto');
56 my $billingdatefrom = $input->param('billingdatefrom');
57 my $billingdateto = $input->param('billingdateto');
58 my $isbneanissn = $input->param('isbneanissn');
59 my $title = $input->param('title');
60 my $author = $input->param('author');
61 my $publisher = $input->param('publisher');
62 my $publicationyear = $input->param('publicationyear');
63 my $branch = $input->param('branch');
64 my $message_id = $input->param('message_id');
65 my $op = $input->param('op');
67 $shipmentdatefrom and $shipmentdatefrom = eval { dt_from_string
( $shipmentdatefrom ) };
68 $shipmentdateto and $shipmentdateto = eval { dt_from_string
( $shipmentdateto ) };
69 $billingdatefrom and $billingdatefrom = eval { dt_from_string
( $billingdatefrom ) };
70 $billingdateto and $billingdateto = eval { dt_from_string
( $billingdateto ) };
73 if ( $op and $op eq 'do_search' ) {
74 @
{$invoices} = GetInvoices
(
75 invoicenumber
=> $invoicenumber,
76 supplierid
=> $supplierid,
77 shipmentdatefrom
=> $shipmentdatefrom ? output_pref
( { str
=> $shipmentdatefrom, dateformat
=> 'iso' } ) : undef,
78 shipmentdateto
=> $shipmentdateto ? output_pref
( { str
=> $shipmentdateto, dateformat
=> 'iso' } ) : undef,
79 billingdatefrom
=> $billingdatefrom ? output_pref
( { str
=> $billingdatefrom, dateformat
=> 'iso' } ) : undef,
80 billingdateto
=> $billingdateto ? output_pref
( { str
=> $billingdateto, dateformat
=> 'iso' } ) : undef,
81 isbneanissn
=> $isbneanissn,
84 publisher
=> $publisher,
85 publicationyear
=> $publicationyear,
86 branchcode
=> $branch,
87 message_id
=> $message_id,
91 # Build suppliers list
92 my @suppliers = Koha
::Acquisition
::Booksellers
->search( undef, { order_by
=> { -asc
=> 'name' } } );
93 my $suppliers_loop = [];
95 foreach (@suppliers) {
97 if ($supplierid && $supplierid == $_->id ) {
99 $suppliername = $_->name;
101 push @
{$suppliers_loop},
103 suppliername
=> $_->name,
104 booksellerid
=> $_->id,
105 selected
=> $selected,
109 my $budgets = GetBudgets
();
111 foreach my $budget (@
$budgets) {
112 push @budgets_loop, $budget if CanUserUseBudget
( $loggedinuser, $budget, $flags );
115 $template->{'VARS'}->{'budgets_loop'} = \
@budgets_loop;
118 do_search
=> ( $op and $op eq 'do_search' ) ?
1 : 0,
119 invoices
=> $invoices,
120 invoicenumber
=> $invoicenumber,
121 booksellerid
=> $supplierid,
122 suppliername
=> $suppliername,
123 shipmentdatefrom
=> $shipmentdatefrom,
124 shipmentdateto
=> $shipmentdateto,
125 billingdatefrom
=> $billingdatefrom,
126 billingdateto
=> $billingdateto,
127 isbneanissn
=> $isbneanissn,
130 publisher
=> $publisher,
131 publicationyear
=> $publicationyear,
133 suppliers_loop
=> $suppliers_loop,
136 output_html_with_http_headers
$input, $cookie, $template->output;