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 $isbn = $input->param('isbn');
65 my $name = $input->param( 'name' );
66 my $basket = $input->param( 'basket' );
67 my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
68 my $do_search = $input->param('do_search') || 0;
69 my $from_placed_on = C4
::Dates
->new($input->param('from'));
70 my $to_placed_on = C4
::Dates
->new($input->param('to'));
71 if ( not $input->param('from') ) {
72 # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ?
73 # We would use a function like Add_Delta_YM(-1, 0, 0);
74 $$from_placed_on{dmy_arrayref
}[5] -= 1;
77 my $dbh = C4
::Context
->dbh;
78 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
80 template_name
=> "acqui/histsearch.tmpl",
84 flagsrequired
=> { acquisition
=> 'group_manage', acquisition
=> 'order_manage', acquisition
=> 'order_receive' },
89 my ( $from_iso, $to_iso, $d );
90 if ( $d = $input->param('from') ) {
91 $from_iso = C4
::Dates
->new($d)->output('iso');
93 if ( $d = $input->param('iso') ) {
94 $to_iso = C4
::Dates
->new($d)->output('iso');
97 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived );
98 # If we're supplied any value then we do a search. Otherwise we don't.
100 ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory
(
105 from_placed_on
=> $from_iso,
106 to_placed_on
=> $to_iso,
108 booksellerinvoicenumber
=> $booksellerinvoicenumber,
112 my $from_date = $from_placed_on ?
$from_placed_on->output('syspref') : undef;
113 my $to_date = $to_placed_on ?
$to_placed_on->output('syspref') : undef;
116 suggestions_loop
=> $order_loop,
117 total_qty
=> $total_qty,
118 total_qtyreceived
=> $total_qtyreceived,
119 total_price
=> sprintf( "%.2f", $total_price ),
120 numresults
=> $order_loop ?
scalar(@
$order_loop) : undef,
126 booksellerinvoicenumber
=> $booksellerinvoicenumber,
127 from_placed_on
=> $from_date,
128 to_placed_on
=> $to_date,
129 DHTMLcalendar_dateformat
=> C4
::Dates
->DHTMLcalendar(),
130 dateformat
=> C4
::Dates
->new()->format(),
131 debug
=> $debug || $input->param('debug') || 0,
134 output_html_with_http_headers
$input, $cookie, $template->output;