Bug 17301 - Add callnumber to label-edit-batch.pl
[koha.git] / acqui / invoices.pl
blob7f0ed5d29cd260e6d496e9a73f9af232c04db979
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 strict;
30 use warnings;
32 use CGI qw ( -utf8 );
33 use C4::Auth;
34 use C4::Output;
36 use C4::Acquisition qw/GetInvoices/;
37 use C4::Budgets;
38 use Koha::DateUtils;
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 authnotrequired => 0,
47 flagsrequired => { 'acquisition' => '*' },
48 debug => 1,
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 ) };
72 my $invoices = [];
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,
82 title => $title,
83 author => $author,
84 publisher => $publisher,
85 publicationyear => $publicationyear,
86 branchcode => $branch,
87 message_id => $message_id,
91 # Build suppliers list
92 my @suppliers = Koha::Acquisition::Bookseller->search;
93 my $suppliers_loop = [];
94 my $suppliername;
95 foreach (@suppliers) {
96 my $selected = 0;
97 if ($supplierid && $supplierid == $_->{id} ) {
98 $selected = 1;
99 $suppliername = $_->{name};
101 push @{$suppliers_loop},
103 suppliername => $_->{name},
104 booksellerid => $_->{id},
105 selected => $selected,
109 my $budgets = GetBudgets();
110 my @budgets_loop;
111 foreach my $budget (@$budgets) {
112 push @budgets_loop, $budget if CanUserUseBudget( $loggedinuser, $budget, $flags );
115 $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
117 $template->param(
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,
128 title => $title,
129 author => $author,
130 publisher => $publisher,
131 publicationyear => $publicationyear,
132 branch => $branch,
133 suppliers_loop => $suppliers_loop,
136 output_html_with_http_headers $input, $cookie, $template->output;