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
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
27 this script offer a interface to search among order.
34 if the script has to filter the results on title.
37 if the script has to filter the results on author.
40 if the script has to filter the results on supplier.
43 to filter on started date.
46 to filter on ended date.
53 #use warnings; FIXME - Bug 2505
55 use C4::Auth; # get_template_and_user
62 my $title = $input->param( 'title');
63 my $author = $input->param('author');
64 my $name = $input->param( 'name' );
65 my $basket = $input->param( 'basket' );
66 my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
67 my $from_placed_on = C4::Dates->new($input->param('from')) if $input->param('from');
68 my $to_placed_on = C4::Dates->new($input->param( 'to')) if $input->param('to');
70 my $dbh = C4::Context->dbh;
71 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
73 template_name => "acqui/histsearch.tmpl",
77 flagsrequired => { acquisition => 1 },
82 my ( $from_iso, $to_iso, $d );
83 if ( $d = $input->param('from') ) {
84 $from_iso = C4::Dates->new($d)->output('iso');
86 if ( $d = $input->param('iso') ) {
87 $to_iso = C4::Dates->new($d)->output('iso');
90 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived );
91 # If we're supplied any value then we do a search. Otherwise we don't.
92 my $do_search = $title || $author || $name || $basket || $booksellerinvoicenumber ||
93 $from_placed_on || $to_placed_on;
95 ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory(
99 from_placed_on => $from_iso,
100 to_placed_on => $to_iso,
102 booksellerinvoicenumber => $booksellerinvoicenumber,
106 my $from_date = $from_placed_on->output('syspref') if $from_placed_on;
107 my $to_date = $to_placed_on->output('syspref') if $to_placed_on;
110 suggestions_loop => $order_loop,
111 total_qty => $total_qty,
112 total_qtyreceived => $total_qtyreceived,
113 total_price => sprintf( "%.2f", $total_price ),
114 numresults => $order_loop ? scalar(@$order_loop) : undef,
119 booksellerinvoicenumber => $booksellerinvoicenumber,
120 from_placed_on => $from_date,
121 to_placed_on => $to_date,
122 DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
123 dateformat => C4::Dates->new()->format(),
124 debug => $debug || $input->param('debug') || 0,
127 output_html_with_http_headers $input, $cookie, $template->output;