Bug 14585: Fixing up online help on main page
[koha.git] / acqui / invoices.pl
blobf7318591077880987fb96bd8d2b5c585aa4a7c32
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;
33 use C4::Auth;
34 use C4::Output;
36 use C4::Acquisition qw/GetInvoices/;
37 use C4::Bookseller qw/GetBookSeller/;
38 use C4::Branch qw/GetBranches/;
39 use C4::Budgets;
41 my $input = CGI->new;
42 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
44 template_name => 'acqui/invoices.tt',
45 query => $input,
46 type => 'intranet',
47 authnotrequired => 0,
48 flagsrequired => { 'acquisition' => '*' },
49 debug => 1,
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');
67 my $invoices = [];
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,
81 title => $title,
82 author => $author,
83 publisher => $publisher,
84 publicationyear => $publicationyear,
85 branchcode => $branch
89 # Build suppliers list
90 my @suppliers = GetBookSeller(undef);
91 my $suppliers_loop = [];
92 my $suppliername;
93 foreach (@suppliers) {
94 my $selected = 0;
95 if ($supplierid && $supplierid == $_->{id} ) {
96 $selected = 1;
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 = [];
110 my $branchname;
111 foreach ( sort keys %$branches ) {
112 my $selected = 0;
113 if ( $branch && $branch eq $_ ) {
114 $selected = 1;
115 $branchname = $branches->{$_}->{'branchname'};
117 push @{$branches_loop},
119 branchcode => $_,
120 branchname => $branches->{$_}->{branchname},
121 selected => $selected,
125 my $budgets = GetBudgets();
126 my @budgets_loop;
127 foreach my $budget (@$budgets) {
128 push @budgets_loop, $budget if CanUserUseBudget( $loggedinuser, $budget, $flags );
131 $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
133 $template->param(
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,
142 title => $title,
143 author => $author,
144 publisher => $publisher,
145 publicationyear => $publicationyear,
146 branch => $branch,
147 branchname => $branchname,
148 suppliers_loop => $suppliers_loop,
149 branches_loop => $branches_loop,
152 output_html_with_http_headers $input, $cookie, $template->output;