Code cleaned. GPL & POD added. Sub renamed.
[wip/koha-chris_n.git] / acqui / histsearch.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 # $Id$
19
20
21 =head1 NAME
22
23 histsearch.pl
24
25 =head1 DESCRIPTION
26 this script offer a interface to search among order.
27
28
29 =head1 CGI PARAMETERS
30
31 =over 4
32
33 =item title
34 if the script has to filter the results on title.
35
36 =item author
37 if the script has to filter the results on author.
38
39 =item name
40 if the script has to filter the results on supplier.
41
42 =item fromplacedon
43 to filter on started date.
44
45 =item toplacedon
46 to filter on ended date.
47
48 =back
49
50 =cut
51
52 use strict;
53 require Exporter;
54 use CGI;
55 use HTML::Template;
56
57 use C4::Auth;       # get_template_and_user
58 use C4::Interface::CGI::Output;
59 use C4::Acquisition;
60
61 my $input = new CGI;
62 my $title = $input->param('title');
63 my $author = $input->param('author');
64 my $name = $input->param('name');
65 my $from_placed_on = $input->param('fromplacedon');
66 my $to_placed_on = $input->param('toplacedon');
67
68 my $dbh = C4::Context->dbh;
69 my ($template, $loggedinuser, $cookie)
70     = get_template_and_user({template_name => "acqui/histsearch.tmpl",
71                              query => $input,
72                              type => "intranet",
73                              authnotrequired => 0,
74                              flagsrequired => {acquisition => 1},
75                              debug => 1,
76                              });
77 my ($order_loop,$total_qty,$total_price,$total_qtyreceived)= &GetHistory($title,$author,$name,$from_placed_on,$to_placed_on);
78 $template->param(suggestions_loop => $order_loop,
79                                 total_qty => $total_qty,
80                                 total_qtyreceived => $total_qtyreceived,
81                                 total_price => sprintf  ("%.2f",$total_price),
82                                 numresults => scalar(@$order_loop),
83                                 title => $title,
84                                 author => $author,
85                                 name => $name,
86                                 from_placed_on =>$from_placed_on,
87                                 to_placed_on =>$to_placed_on,
88                                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
89                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
90                 IntranetNav => C4::Context->preference("IntranetNav"),
91 );
92 output_html_with_http_headers $input, $cookie, $template->output;