Bug 12533: (follow-up) Add CSS to preview display of authority MARC
[koha.git] / acqui / invoices.pl
blob076e26733b8c6c2196c7b65d1a81eca77f0d1327
1 #!/usr/bin/perl
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>.
19 =head1 NAME
21 invoices.pl
23 =head1 DESCRIPTION
25 Search for invoices
27 =cut
29 use Modern::Perl;
31 use CGI qw ( -utf8 );
32 use C4::Auth;
33 use C4::Output;
35 use C4::Acquisition qw/GetInvoices/;
36 use C4::Budgets;
37 use Koha::DateUtils;
38 use Koha::Acquisition::Booksellers;
40 my $input = CGI->new;
41 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
43 template_name => 'acqui/invoices.tt',
44 query => $input,
45 type => 'intranet',
46 flagsrequired => { 'acquisition' => '*' },
47 debug => 1,
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 ) };
71 my $invoices = [];
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,
81 title => $title,
82 author => $author,
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 = [];
93 my $suppliername;
94 foreach (@suppliers) {
95 my $selected = 0;
96 if ($supplierid && $supplierid == $_->id ) {
97 $selected = 1;
98 $suppliername = $_->name;
100 push @{$suppliers_loop},
102 suppliername => $_->name,
103 booksellerid => $_->id,
104 selected => $selected,
108 my $budgets = GetBudgets();
109 my @budgets_loop;
110 foreach my $budget (@$budgets) {
111 push @budgets_loop, $budget if CanUserUseBudget( $loggedinuser, $budget, $flags );
114 $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
116 $template->param(
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,
127 title => $title,
128 author => $author,
129 publisher => $publisher,
130 publicationyear => $publicationyear,
131 branch => $branch,
132 suppliers_loop => $suppliers_loop,
135 output_html_with_http_headers $input, $cookie, $template->output;