+
+my ( $from_iso, $to_iso, $d );
+if ( $d = $input->param('from') ) {
+ $from_iso = C4::Dates->new($d)->output('iso');
+}
+if ( $d = $input->param('iso') ) {
+ $to_iso = C4::Dates->new($d)->output('iso');
+}
+
+my ( $order_loop, $total_qty, $total_price, $total_qtyreceived );
+# If we're supplied any value then we do a search. Otherwise we don't.
+my $do_search = $title || $author || $isbn || $name || $basket || $booksellerinvoicenumber ||
+ $from_placed_on || $to_placed_on;
+if ($do_search) {
+ ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory(
+ title => $title,
+ author => $author,
+ isbn => $isbn,
+ name => $name,
+ from_placed_on => $from_iso,
+ to_placed_on => $to_iso,
+ basket => $basket,
+ booksellerinvoicenumber => $booksellerinvoicenumber,
+ );
+}
+
+my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef;
+my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef;
+
+$template->param(
+ suggestions_loop => $order_loop,
+ total_qty => $total_qty,
+ total_qtyreceived => $total_qtyreceived,
+ total_price => sprintf( "%.2f", $total_price ),
+ numresults => $order_loop ? scalar(@$order_loop) : undef,
+ title => $title,
+ author => $author,
+ isbn => $isbn,
+ name => $name,
+ basket => $basket,
+ booksellerinvoicenumber => $booksellerinvoicenumber,
+ from_placed_on => $from_date,
+ to_placed_on => $to_date,
+ DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
+ dateformat => C4::Dates->new()->format(),
+ debug => $debug || $input->param('debug') || 0,
+);
+