3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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
25 use HTML::Template::Pro;
35 use C4::Koha; # XXX subfield_is_koha_internal_p
37 use List::Util qw( max min );
44 $debug = $debug || $cgi_debug;
47 import Data::Dumper qw(Dumper);
51 # Creates a scrolling list with the associated default value.
52 # Using more than one scrolling list in a CGI assigns the same default value to all the
53 # scrolling lists on the page !?!? That's why this function was written.
57 my $type = $query->param('type');
58 my $op = $query->param('op') || '';
59 my $batch_id = $query->param('batch_id');
60 my $ccl_query = $query->param('ccl_query');
62 my $dbh = C4::Context->dbh;
64 my $startfrom = $query->param('startfrom') || 1;
65 my ( $template, $loggedinuser, $cookie );
67 $total_hits, $orderby, $results, $total, $error,
68 $marcresults, $idx, $datefrom, $dateto, $ccl_textbox
71 my $resultsperpage = C4::Context->preference('numSearchResults') || '20';
75 if ( $op eq "do_search" ) {
76 $idx = $query->param('idx');
77 $ccl_textbox = $query->param('ccl_textbox');
78 if ( $ccl_textbox && $idx ) {
79 $ccl_query = "$idx=$ccl_textbox";
82 $datefrom = $query->param('datefrom');
83 $dateto = $query->param('dateto');
85 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
87 template_name => "labels/search.tmpl",
91 flagsrequired => { catalogue => 1 },
97 $datefrom = C4::Dates->new($datefrom);
98 $ccl_query .= ' and ' if $ccl_textbox;
100 "acqdate,st-date-normalized,ge=" . $datefrom->output("iso");
104 $dateto = C4::Dates->new($dateto);
105 $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
106 $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto->output("iso");
109 my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
110 ( $error, $marcresults, $total_hits ) =
111 SimpleSearch( $ccl_query, $offset, $resultsperpage );
114 $show_results = scalar @$marcresults;
117 $debug and warn "ERROR label-item-search: no results from SimpleSearch";
119 # leave $show_results undef
124 $template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), );
125 output_html_with_http_headers $query, $cookie, $template->output;