FIX for Date calculation
[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 =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::Output;
56 use C4::Acquisition;
57 use C4::Date;
58
59 my $input          = new CGI;
60 my $title          = $input->param('title');
61 my $author         = $input->param('author');
62 my $name           = $input->param('name');
63 my $from_placed_on = $input->param('fromplacedon');
64 my $to_placed_on   = format_date_in_iso($input->param('toplacedon'));
65
66 my $dbh = C4::Context->dbh;
67 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
68     {
69         template_name   => "acqui/histsearch.tmpl",
70         query           => $input,
71         type            => "intranet",
72         authnotrequired => 0,
73         flagsrequired   => { acquisition => 1 },
74         debug           => 1,
75     }
76 );
77
78 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
79   &GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
80   
81 $template->param(
82     suggestions_loop        => $order_loop,
83     total_qty               => $total_qty,
84     total_qtyreceived       => $total_qtyreceived,
85     total_price             => sprintf( "%.2f", $total_price ),
86     numresults              => scalar(@$order_loop),
87     title                   => $title,
88     author                  => $author,
89     name                    => $name,
90     from_placed_on          => $from_placed_on,
91     to_placed_on            => $to_placed_on,
92     intranetcolorstylesheet =>
93       C4::Context->preference("intranetcolorstylesheet"),
94     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
95     IntranetNav        => C4::Context->preference("IntranetNav"),
96     DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
97 );
98
99 output_html_with_http_headers $input, $cookie, $template->output;