rel_3_0 moved to HEAD
[koha.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 =head1 NAME
21
22 histsearch.pl
23
24 =head1 DESCRIPTION
25
26 this script offer a interface to search among order.
27
28 =head1 CGI PARAMETERS
29
30 =over 4
31
32 =item title
33 if the script has to filter the results on title.
34
35 =item author
36 if the script has to filter the results on author.
37
38 =item name
39 if the script has to filter the results on supplier.
40
41 =item fromplacedon
42 to filter on started date.
43
44 =item toplacedon
45 to filter on ended date.
46
47 =back
48
49 =cut
50
51 use strict;
52 require Exporter;
53 use CGI;
54 use C4::Auth;    # get_template_and_user
55 use C4::Interface::CGI::Output;
56 use C4::Acquisition;
57
58 my $input          = new CGI;
59 my $title          = $input->param('title');
60 my $author         = $input->param('author');
61 my $name           = $input->param('name');
62 my $from_placed_on = $input->param('fromplacedon');
63 my $to_placed_on   = $input->param('toplacedon');
64
65 my $dbh = C4::Context->dbh;
66 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
67     {
68         template_name   => "acqui/histsearch.tmpl",
69         query           => $input,
70         type            => "intranet",
71         authnotrequired => 0,
72         flagsrequired   => { acquisition => 1 },
73         debug           => 1,
74     }
75 );
76
77 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
78   &GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
79   
80 $template->param(
81     suggestions_loop        => $order_loop,
82     total_qty               => $total_qty,
83     total_qtyreceived       => $total_qtyreceived,
84     total_price             => sprintf( "%.2f", $total_price ),
85     numresults              => scalar(@$order_loop),
86     title                   => $title,
87     author                  => $author,
88     name                    => $name,
89     from_placed_on          => $from_placed_on,
90     to_placed_on            => $to_placed_on,
91     intranetcolorstylesheet =>
92       C4::Context->preference("intranetcolorstylesheet"),
93     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
94     IntranetNav        => C4::Context->preference("IntranetNav"),
95 );
96
97 output_html_with_http_headers $input, $cookie, $template->output;