there is some old 2.2 code for more complete labels-searching, thats been commented out
ive logged a 'bug' for this - 2777 http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=2777 this fix... - enables the index-searching functionality - adds date-ranges - uses the numSearchResults syspref, not a hardcoded '20' - rewrote old 2.2 page-num code, (didnt work for 3.x) - some indent and whitepages tidys. - unused 2.2 search-code removed. Mason --- catalogue/search.pl | 16 + .../prog/en/modules/labels/result.tmpl | 44 ++- .../prog/en/modules/labels/search.tmpl | 81 ++++-- labels/label-item-search.pl | 309 +++++++++++--------- 4 files changed, 286 insertions(+), 164 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 13b137b..4c37fb9 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -529,6 +529,9 @@ for (my $i=0;$i<@servers;$i++) { } exit; } + + + if ($hits) { $template->param(total => $hits); my $limit_cgi_not_availablity = $limit_cgi; @@ -575,6 +578,9 @@ for (my $i=0;$i<@servers;$i++) { } } + + + # now, show twenty pages, with the current one smack in the middle else { for (my $i=$current_page_number; $i<=($current_page_number + 20 );$i++) { @@ -592,10 +598,20 @@ for (my $i=0;$i<@servers;$i++) { previous_page_offset => $previous_page_offset) unless $pages < 2; $template->param( next_page_offset => $next_page_offset) unless $pages eq $current_page_number; } + + + + + # no hits else { $template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc); } + + + + + } # end of the if local # asynchronously search the authority server diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl index 1dcb20e..3380992 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl @@ -2,7 +2,7 @@ <style type="text/css">#custom-doc { width:46.23em;*width:45.04em;min-width:610px; margin:auto;margin-top: .4em; text-align:left; }</style> <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.pack.js"></script> <script type="text/javascript"> -//<![CDATA[ +//<![CDATA[ $(document).ready(function(){ $("#CheckAll").click(function(){ $(".checkboxed").checkCheckboxes(); @@ -16,7 +16,7 @@ $(document).ready(function(){ function add_item(itemnum,batch_id,type_id){ var getstr=''; if (itemnum == 'checked') { - itms= new Array; + itms= new Array; if(document.resultform.i_itemnumber.length > 0) { for (var i=0; i < document.resultform.i_itemnumber.length; i++) { if (document.resultform.i_itemnumber[i].checked) { @@ -29,8 +29,8 @@ function add_item(itemnum,batch_id,type_id){ } } else { getstr = "itemnumber="+itemnum; -} - var myurl = "label-manager.pl?op=add&batch_id="+batch_id+ +} + var myurl = "label-manager.pl?op=add&batch_id="+batch_id+ // "&type="+type_id+ // The template variable NAME="TYPE" is RESERVED ('opac' or 'intranet'). "&"+getstr; window.opener.location.href = myurl; @@ -47,23 +47,27 @@ function add_item3(i_itemnumber){ <div id="custom-doc" class="yui-t7"> <div id="bd"> <h1>Search results</h1> + + <div class="results"> <!-- TMPL_IF EXPR="displayprev || displaynext" --><p> <!-- TMPL_IF NAME="displayprev" --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a> <!-- /TMPL_IF --> + <!-- TMPL_LOOP NAME="numbers" --> <!-- TMPL_IF NAME="highlight" --> <span class="current"><!-- TMPL_VAR NAME="number" --></span> <!-- TMPL_ELSE --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a> <!-- /TMPL_IF --> <!-- /TMPL_LOOP --> + <!-- TMPL_IF NAME="displaynext" --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a> <!-- /TMPL_IF --> </p><!-- /TMPL_IF --> - <p> + <!-- TMPL_IF name="result" --> <strong>Results <!-- TMPL_VAR name="from" --> through <!-- TMPL_VAR name="to" --> <!-- TMPL_IF NAME="total" --> of <!-- TMPL_VAR name="total" --><!-- /TMPL_IF --></strong> <!-- TMPL_ELSE --> @@ -71,9 +75,14 @@ function add_item3(i_itemnumber){ <!-- /TMPL_IF --> </p> </div> + + <div id="breadcrumbs"><a href="/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Search for Items for Batch <!-- TMPL_VAR NAME="batch_id" --></a> › Search results</div> <form name="resultform" class="checkboxed"><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',<!-- TMPL_VAR NAME="batch_id" -->,'<!-- TMPL_VAR NAME="type" -->'); return false" /> <input type="button" class="close" value="Done" /></div><div style="line-height: 2em; margin-left: .7em;"><a id="CheckAll" href="/cgi-bin/koha/labels/label-item-search.pl">Select All</a></span><span class="clearall"><a id="CheckNone" href="/cgi-bin/koha/labels/label-item-search.pl">Clear All</a></div> +<input type="hidden" name="ccl_query" value="<!-- TMPL_VAR name="ccl_query" -->" /> + + <!-- TMPL_LOOP name="result" --> <table width="610 pixels" frame="border" border="2" style="float: left; margin: .5em 0;"> <!-- TMPL_IF name="highlight" --> @@ -99,7 +108,7 @@ function add_item3(i_itemnumber){ <!-- TMPL_IF name="i_itemcallnumber" --><td align="center"><!-- TMPL_VAR name="i_itemcallnumber" --><br /></td><!-- /TMPL_IF --> <!-- TMPL_IF name="i_dateaccessioned" --><td align="center"><!-- TMPL_VAR name="i_dateaccessioned" --><br /></td><!-- /TMPL_IF --> <!-- TMPL_IF name="i_barcode" --><td align="center"><!-- TMPL_VAR name="i_barcode" --></td><!-- /TMPL_IF --> - <!-- TMPL_IF name="i_itemnumber2" --><td align="center"> + <!-- TMPL_IF name="i_itemnumber2" --><td align="center"> <a onclick="add_item('<!-- TMPL_VAR NAME="i_itemnumber2" -->',<!-- TMPL_VAR NAME="batch_id" -->, '<!-- TMPL_VAR NAME="type" -->'); return false" href="/cgi-bin/koha/barcodes/label-manager.pl?itemnumber=<!-- TMPL_VAR NAME="i_itemnumber2" -->&batch_id=<!-- TMPL_VAR name="batch_id" -->&op=add">Add</a></td> <!-- /TMPL_IF --> <!-- /NEW --> @@ -108,22 +117,27 @@ function add_item3(i_itemnumber){ </table> <!-- /TMPL_LOOP --> </form> + <div class="results"> - <p> + <!-- TMPL_IF EXPR="displayprev || displaynext" --><p> <!-- TMPL_IF NAME="displayprev" --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search>&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><<</a> <!-- /TMPL_IF --> + <!-- TMPL_LOOP NAME="numbers" --> <!-- TMPL_IF NAME="highlight" --> - <span class="current"><!-- TMPL_VAR NAME="number" --></span> + <span class="current"><!-- TMPL_VAR NAME="number" --></span> <!-- TMPL_ELSE --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfrom" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->"><!-- TMPL_VAR NAME="number" --></a> <!-- /TMPL_IF --> <!-- /TMPL_LOOP --> + <!-- TMPL_IF NAME="displaynext" --> - <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a> + <a href="label-item-search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&ccl_query=<!-- TMPL_VAR NAME="ccl_query" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&op=do_search&batch_id=<!-- TMPL_VAR NAME="batch_id" -->">>></a> <!-- /TMPL_IF --> - </p> + </p><!-- /TMPL_IF --> </div> + + <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" --> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tmpl index 0626f75..9abc5ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tmpl @@ -18,12 +18,55 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> <input type="hidden" name="op" value="do_search" /> <input type="hidden" name="batch_id" value="<!-- TMPL_VAR NAME="batch_id" -->" /> <input type="hidden" name="type" value="<!-- TMPL_VAR NAME="type" -->" /> + <fieldset class="rows"> <ol><li> - <select name="idx" disabled="disabled"><!-- FIXME: script does keyword search regardless --> - <option value="kw" selected="selected">Keyword</option> - </select> - <input type="text" size="30" id="marclist" name="marclist" class="focus" title="Enter search terms" value=""/> +<select name="idx" > <!-- FIXME: script does keyword search regardless --> + +<!-- TMPL_IF NAME="selected" --><option value="kw" selected="selected">Keyword</option> +<!-- TMPL_ELSE --><option value="kw">Keyword</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="au" selected="selected">Author</option> +<!-- TMPL_ELSE --><option value="au">Author</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="yr" selected="selected">Publication Date</option> +<!-- TMPL_ELSE --><option value="yr">Publication Date</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="sn" selected="selected">Standard Number</option> +<!-- TMPL_ELSE --><option value="sn">Standard Number</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="nb" selected="selected">ISBN</option> +<!-- TMPL_ELSE --><option value="nb">ISBN</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="ns" selected="selected">ISSN</option> +<!-- TMPL_ELSE --><option value="ns">ISSN</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="lcn,phr" selected="selected">Call Number</option> +<!-- TMPL_ELSE --><option value="lcn,phr">Call Number</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="su" selected="selected">Subject</option> +<!-- TMPL_ELSE --><option value="su">Subject</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --> + <option value="ti" selected="selected">Title</option> +<!-- TMPL_ELSE --> + <option value="ti" selected="selected">Title</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="ti,phr" selected="selected">Title Phrase</option> +<!-- TMPL_ELSE --><option value="ti,phr">Title Phrase</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="se" selected="selected">Series Title</option> +<!-- TMPL_ELSE --><option value="se">Series Title</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="bc" selected="selected">Barcode</option> +<!-- TMPL_ELSE --><option value="bc">Barcode</option><!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="selected" --><option value="acqdate" selected="selected">Acquisition Date</option> +<!-- TMPL_ELSE --><option value="acqdate">Acquisition Date</option><!-- /TMPL_IF --> +</select> + + <input type="text" size="30" id="ccl_textbox" name="ccl_textbox" class="focus" title="Enter search terms" value=""/> + </li><!-- FIXME: script does keyword search regardless<li> <select name="idx" disabled="disabled"> @@ -79,7 +122,7 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> <option value="">Field-weighted, Relevance Ranked</option> <!-- TMPL_ELSE --><!-- /TMPL_IF --> <!-- TMPL_LOOP NAME="sort_by_loop" --> - + <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="label" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="label" --></option><!-- /TMPL_IF --> <!-- TMPL_ELSE --><!-- /TMPL_IF --> @@ -89,17 +132,14 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> </fieldset><!-- /TMPL_IF --> - -<!--<fieldset class="rows"><table> + + +<fieldset class="rows"><table> <tr><th scope="row"> <label for="datefrom">Added on or after date</label> </th> <td> - <input type="hidden" name="marclist" value="items.dateaccessioned" /> - <input type="hidden" name="and_or" value="and" /> - <input type="hidden" name="excluding" value="" /> - <input type="hidden" name="operator" value=">=" /> - <input type="text" size="10" id="datefrom" name="value" value="" /> + <input type="text" size="10" id="datefrom" name="datefrom" value="" /> <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" border="0" id="openCalendarFrom" style="cursor: pointer;" valign="top" /> <script type="text/javascript"> @@ -110,6 +150,10 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> align : "Tl", singleClick : false }); + + + + </script> @@ -119,11 +163,7 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> <label for="dateto">Added on or before date</label> </th> <td> - <input type="hidden" name="marclist" value="items.dateaccessioned" /> - <input type="hidden" name="and_or" value="and" /> - <input type="hidden" name="excluding" value="" /> - <input type="hidden" name="operator" value="<=" /> - <input type="text" size="10" id="dateto" name="value" value="" /> + <input type="text" size="10" id="dateto" name="dateto" value="" /> <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" border="0" id="openCalendarTo" style="cursor: pointer;" valign="top" /> <script type="text/javascript"> @@ -134,7 +174,8 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> align : "Tl", }); </script> ---><!-- FIXME: script returns ALL type regardless + +<!-- FIXME: script returns ALL type regardless <tr><th scope="row">Document Type</th> <td colspan="2"> <select name="Filter" disabled="disabled"> @@ -152,6 +193,10 @@ to add to Batch <!-- TMPL_VAR NAME="batch_id" --> </td> </tr></table></fieldset>--> + + + + <fieldset class="action"><input type="submit" value="Search" class="submit" /> <a class="cancel close" href="#">Cancel</a></fieldset> </form> </div> diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index 9f97dfb..31b1d22 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -34,7 +34,10 @@ use C4::Dates; use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Debug; use List::Util qw( max min ); +use POSIX; + #use Smart::Comments; +#use Data::Dumper; BEGIN { $debug = $debug || $cgi_debug; @@ -49,148 +52,185 @@ BEGIN { # scrolling lists on the page !?!? That's why this function was written. my $query = new CGI; -my $type = $query->param('type'); -my $op = $query->param('op'); -my $batch_id = $query->param('batch_id'); -my $dateaccessioned = $query->param('dateaccessioned'); + +my $type = $query->param('type'); +my $op = $query->param('op'); +my $batch_id = $query->param('batch_id'); +my $ccl_query = $query->param('ccl_query'); my $dbh = C4::Context->dbh; -my $startfrom = $query->param('startfrom') || 0; +my $startfrom = $query->param('startfrom') || 1; my ( $template, $loggedinuser, $cookie ); -my $total_hits; -my (@marclist,@and_or,@excluding,@operator,@value,$orderby,@tags,$results,$total,$error,$marcresults); -# XXX should this be maxItemsInSearchResults or numSearchResults preference instead of 19? -my $resultsperpage = $query->param('resultsperpage') || 19; +my ($total_hits, $orderby, $results, $total, $error, $marcresults, $idx, $datefrom, $dateto, $ccl_textbox); + +my $resultsperpage = C4::Context->preference('numSearchResults') || '20'; my $show_results = 0; -if ( $op eq "do_search" ) { - @marclist = $query->param('marclist'); - @and_or = $query->param('and_or'); - @excluding = $query->param('excluding'); - @operator = $query->param('operator'); - @value = $query->param('value'); - $orderby = $query->param('orderby'); - if (scalar @marclist) { - #catalogsearch( $dbh, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], - # $startfrom * $resultsperpage, - # $resultsperpage, $orderby ); - ( $error, $marcresults, $total_hits ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage ); - if ($marcresults) { - $show_results = scalar @$marcresults; - } else { - warn "ERROR label-item-search: no results from SimpleSearch"; - # leave $show_results undef - } + +if ($op eq "do_search") { + $idx = $query->param('idx'); + $ccl_textbox = $query->param('ccl_textbox'); + if ($ccl_textbox && $idx) { + $ccl_query = "$idx=$ccl_textbox" ; + } + + $datefrom = $query->param('datefrom'); + $dateto = $query->param('dateto'); + + if ($datefrom) { + $datefrom = C4::Dates->new($datefrom); + $ccl_query .= ' and ' if $ccl_textbox; + $ccl_query .= "acqdate,st-date-normalized,ge=" . $datefrom->output("iso"); } -} -if ( $show_results ) { - ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "labels/result.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { catalogue => 1 }, - debug => 1, - } - ); + if ($dateto) { + $dateto = C4::Dates->new($dateto); + $ccl_query .= ' and ' if ($ccl_textbox || $datefrom) ; + $ccl_query .= "acqdate,st-date-normalized,le=". $dateto->output("iso"); + } + + my $offset = $startfrom > 1 ? $startfrom - 1 : 0; + ($error, $marcresults, $total_hits) = + SimpleSearch($ccl_query, $offset, $resultsperpage); + + if ($marcresults) { + $show_results = scalar @$marcresults; + } else { + warn "ERROR label-item-search: no results from SimpleSearch"; + + # leave $show_results undef + } +} +if ($show_results) { my $hits = $show_results; - my (@results, @items); - # This code needs to be refactored using these subs... - #my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' ); - #my $dat = &GetBiblioData( $biblio->{biblionumber} ); - for(my $i=0; $i<$hits; $i++) { - #DEBUG Notes: Decode the MARC record from each resulting MARC record... - my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]); - #DEBUG Notes: Transform it to Koha form... - my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,''); - # Begin building the hash for the template... - # I don't think we need this with the current template design, but I'm leaving it in place. -fbcit - #$biblio->{highlight} = ($i % 2)?(1):(0); - #DEBUG Notes: Stuff the bib into @results... - push @results, $biblio; - my $biblionumber = $biblio->{'biblionumber'}; - #DEBUG Notes: Grab the item numbers associated with this MARC record... - my $itemnums = get_itemnumbers_of($biblionumber); - #DEBUG Notes: Retrieve the item data for each number... - my $iii = $itemnums->{$biblionumber}; - if ($iii) { - my $item_results = GetItemInfosOf( @$iii ); - foreach my $item (keys %$item_results) { - #DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data... - if ($item_results->{$item}->{'biblionumber'} eq $results[$i]->{'biblionumber'}) { - # NOTE: The order of the elements in this array must be preserved or the table dependent on it will be incorrectly rendered. - # This is a real hack, but I can't think of a better way right now. -fbcit - # It is conceivable that itemcallnumber and/or barcode fields might be empty so the trinaries cover this possibility. - push @{$results[$i]->{'item'}}, { i_itemnumber1 => $item_results->{$item}->{'itemnumber'} }; - push @{$results[$i]->{'item'}}, { i_itemcallnumber => ($item_results->{$item}->{'itemcallnumber'} ? $item_results->{$item}->{'itemcallnumber'} : 'NA') }; - push @{$results[$i]->{'item'}}, { i_dateaccessioned => $item_results->{$item}->{'dateaccessioned'} }; - push @{$results[$i]->{'item'}}, { i_barcode => ($item_results->{$item}->{'barcode'} ? $item_results->{$item}->{'barcode'} : 'NA')}; - push @{$results[$i]->{'item'}}, { i_itemnumber2 => $item_results->{$item}->{'itemnumber'} }; - } - } - } - } - $debug and warn "[EMAIL PROTECTED]"; - $debug and warn Dumper(@results); - - my @field_data = (); - - # FIXME: this relies on symmetric order of CGI params that IS NOT GUARANTEED by spec. - - for ( my $i = 0 ; $i <= $#marclist ; $i++ ) { - push @field_data, { term => "marclist", val => $marclist[$i] }; - push @field_data, { term => "and_or", val => $and_or[$i] }; - push @field_data, { term => "excluding", val => $excluding[$i] }; - push @field_data, { term => "operator", val => $operator[$i] }; - push @field_data, { term => "value", val => $value[$i] }; - } + my (@results, @items); - my @numbers = (); - $total = $total_hits; - if ( $total > $resultsperpage ) { - for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) { - if ( $i < 16 ) { - my $highlight = 0; - ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 ); - push @numbers, - { - number => $i, - highlight => $highlight, - searchdata => [EMAIL PROTECTED], - startfrom => ( $i - 1 ) - }; - } - } - } + # This code needs to be refactored using these subs... + #my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' ); + #my $dat = &GetBiblioData( $biblio->{biblionumber} ); + for (my $i = 0 ; $i < $hits ; $i++) { - # multi page display gestion - my $displaynext = 0; - my $displayprev = $startfrom; - # XXX Kludge. We show the "next" link if we retrieved the max number of results. There could be 0 more. - if ( scalar @results == $resultsperpage ) { - $displaynext = 1; - } + #DEBUG Notes: Decode the MARC record from each resulting MARC record... + my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]); - $template->param( - result => [EMAIL PROTECTED], - startfrom => $startfrom, - displaynext => $displaynext, - displayprev => $displayprev, - resultsperpage => $resultsperpage, - startfromnext => $startfrom + min( $resultsperpage, scalar @results ), - startfromprev => max( $startfrom - $resultsperpage, 0 ), - searchdata => [EMAIL PROTECTED], - total => $total_hits, - from => $startfrom + 1, - to => $startfrom + min( $resultsperpage, scalar @results ), - numbers => [EMAIL PROTECTED], - batch_id => $batch_id, - type => $type, - ); + #DEBUG Notes: Transform it to Koha form... + my $biblio = TransformMarcToKoha(C4::Context->dbh, $marcrecord, ''); + +# Begin building the hash for the template... +# I don't think we need this with the current template design, but I'm leaving it in place. -fbcit +#$biblio->{highlight} = ($i % 2)?(1):(0); +#DEBUG Notes: Stuff the bib into @results... + push @results, $biblio; + my $biblionumber = $biblio->{'biblionumber'}; + + #DEBUG Notes: Grab the item numbers associated with this MARC record... + my $itemnums = get_itemnumbers_of($biblionumber); + + #DEBUG Notes: Retrieve the item data for each number... + my $iii = $itemnums->{$biblionumber}; + if ($iii) { + my $item_results = GetItemInfosOf(@$iii); + foreach my $item (keys %$item_results) { + +#DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data... + if ($item_results->{$item}->{'biblionumber'} eq + $results[$i]->{'biblionumber'}) { + +# NOTE: The order of the elements in this array must be preserved or the table dependent on it will be incorrectly rendered. +# This is a real hack, but I can't think of a better way right now. -fbcit +# It is conceivable that itemcallnumber and/or barcode fields might be empty so the trinaries cover this possibility. + push @{ $results[$i]->{'item'} }, { i_itemnumber1 => + $item_results->{$item}->{'itemnumber'} }; + push @{ $results[$i]->{'item'} }, + { i_itemcallnumber => ( + $item_results->{$item}->{'itemcallnumber'} + ? $item_results->{$item}->{'itemcallnumber'} : 'NA' + ) + }; + push @{ $results[$i]->{'item'} }, { i_dateaccessioned => + $item_results->{$item}->{'dateaccessioned'} }; + push @{ $results[$i]->{'item'} }, + { i_barcode => ( + $item_results->{$item}->{'barcode'} + ? $item_results->{$item}->{'barcode'} : 'NA' + ) + }; + push @{ $results[$i]->{'item'} }, { i_itemnumber2 => + $item_results->{$item}->{'itemnumber'} }; + } + } + } + } + $debug and warn "[EMAIL PROTECTED]"; + $debug and warn Dumper(@results); + + ($template, $loggedinuser, $cookie) = get_template_and_user( + { template_name => "labels/result.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1 }, + flagsrequired => { catalogue => 1 }, + debug => 1, + } + ); + + # build page nav stuff. + my (@field_data, @numbers); + $total = $total_hits; + + my ($from, $to, $startfromnext, $startfromprev, $displaynext, $displayprev); + + if ($total > $resultsperpage) { + my $num_of_pages = ceil($total / $resultsperpage + 1); + for (my $page = 1 ; $page < $num_of_pages ; $page++) { + my $startfrm = (($page - 1) * $resultsperpage) + 1; + push @numbers, + { number => $page, + startfrom => $startfrm + }; + } + + $from = $startfrom; + $startfromprev = $startfrom - $resultsperpage; + $startfromnext = $startfrom + $resultsperpage; + + $to = + $startfrom + $resultsperpage > $total + ? $total + : $startfrom + $resultsperpage - 1; + + # multi page display + my $displaynext = 0; + my $displayprev = $startfrom; + + $displaynext = 1 if (scalar @results == $resultsperpage); + + $template->param( + + total => $total_hits, + from => $from, + to => $to, + startfromnext => $startfromnext, + startfromprev => $startfromprev, + startfrom => $startfrom, + displaynext => $displaynext, + displayprev => $displayprev, + resultsperpage => $resultsperpage, + numbers => [EMAIL PROTECTED], + + ); + } + + $template->param( + result => [EMAIL PROTECTED], + batch_id => $batch_id, + type => $type, + idx => $idx, + ccl_query => $ccl_query, + ); } # @@ -213,9 +253,9 @@ else { foreach my $thisitemtype (keys %$itemtypes) { my %row =(value => $thisitemtype, description => $itemtypes->{$thisitemtype}->{'description'}, - ); + ); push @itemtypeloop, \%row; - } + } $template->param( itemtypeloop =>[EMAIL PROTECTED], batch_id => $batch_id, @@ -232,3 +272,10 @@ output_html_with_http_headers $query, $cookie, $template->output; # Local Variables: # tab-width: 4 # End: + + + + + + + -- 1.5.6.3 _______________________________________________ Koha-patches mailing list [email protected] http://lists.koha.org/mailman/listinfo/koha-patches
