Bug 7309 - Add NORMARCslim2intranetDetail.xsl for detail view in intranet
[koha.git] / acqui / histsearch.pl
blobff68599f45a877e118e5d2a6de3631ee92dec326
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Parts copyright 2011 Catalyst IT Ltd.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 =head1 NAME
23 histsearch.pl
25 =head1 DESCRIPTION
27 this script offer a interface to search among order.
29 =head1 CGI PARAMETERS
31 =over 4
33 =item title
34 if the script has to filter the results on title.
36 =item author
37 if the script has to filter the results on author.
39 =item name
40 if the script has to filter the results on supplier.
42 =item fromplacedon
43 to filter on started date.
45 =item toplacedon
46 to filter on ended date.
48 =back
50 =cut
52 use strict;
53 #use warnings; FIXME - Bug 2505
54 use CGI;
55 use C4::Auth; # get_template_and_user
56 use C4::Output;
57 use C4::Acquisition;
58 use C4::Dates;
59 use C4::Debug;
61 my $input = new CGI;
62 my $title = $input->param( 'title');
63 my $author = $input->param('author');
64 my $isbn = $input->param('isbn');
65 my $name = $input->param( 'name' );
66 my $basket = $input->param( 'basket' );
67 my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
68 my $from_placed_on = $input->param('from');
69 $from_placed_on = C4::Dates->new($from_placed_on) if $from_placed_on;
70 my $to_placed_on = $input->param('to');
71 $to_placed_on = C4::Dates->new($to_placed_on) if $to_placed_on;
73 my $dbh = C4::Context->dbh;
74 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
76 template_name => "acqui/histsearch.tmpl",
77 query => $input,
78 type => "intranet",
79 authnotrequired => 0,
80 flagsrequired => { acquisition => 1 },
81 debug => 1,
85 my ( $from_iso, $to_iso, $d );
86 if ( $d = $input->param('from') ) {
87 $from_iso = C4::Dates->new($d)->output('iso');
89 if ( $d = $input->param('iso') ) {
90 $to_iso = C4::Dates->new($d)->output('iso');
93 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived );
94 # If we're supplied any value then we do a search. Otherwise we don't.
95 my $do_search = $title || $author || $isbn || $name || $basket || $booksellerinvoicenumber ||
96 $from_placed_on || $to_placed_on;
97 if ($do_search) {
98 ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory(
99 title => $title,
100 author => $author,
101 isbn => $isbn,
102 name => $name,
103 from_placed_on => $from_iso,
104 to_placed_on => $to_iso,
105 basket => $basket,
106 booksellerinvoicenumber => $booksellerinvoicenumber,
110 my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef;
111 my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef;
113 $template->param(
114 suggestions_loop => $order_loop,
115 total_qty => $total_qty,
116 total_qtyreceived => $total_qtyreceived,
117 total_price => sprintf( "%.2f", $total_price ),
118 numresults => $order_loop ? scalar(@$order_loop) : undef,
119 title => $title,
120 author => $author,
121 isbn => $isbn,
122 name => $name,
123 basket => $basket,
124 booksellerinvoicenumber => $booksellerinvoicenumber,
125 from_placed_on => $from_date,
126 to_placed_on => $to_date,
127 DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
128 dateformat => C4::Dates->new()->format(),
129 debug => $debug || $input->param('debug') || 0,
132 output_html_with_http_headers $input, $cookie, $template->output;