[Koha-cvs] koha cataloguing/addbooks.pl koha-tmpl/intranet... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Fri Nov 3 09:47:12 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/11/03 08:47:12

Modified files:
	cataloguing    : addbooks.pl 
	koha-tmpl/intranet-tmpl/prog/en/cataloguing: addbooks.tmpl 

Log message:
	addbooks now use zebra to search an existing biblio.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbooks.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2&r2=1.2.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbooks.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=1.1.2.2

Patches:
Index: cataloguing/addbooks.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbooks.pl,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- cataloguing/addbooks.pl	19 Jan 2006 12:48:00 -0000	1.2
+++ cataloguing/addbooks.pl	3 Nov 2006 08:47:12 -0000	1.2.2.1
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: addbooks.pl,v 1.2 2006/01/19 12:48:00 tipaul Exp $
+# $Id: addbooks.pl,v 1.2.2.1 2006/11/03 08:47:12 toins Exp $
 
 #
 # Modified saas at users.sf.net 12:00 01 April 2001
@@ -35,21 +35,23 @@
 use strict;
 use CGI;
 use C4::Auth;
-# use C4::Catalogue;
 use C4::Biblio;
 use C4::Output;
 use C4::Interface::CGI::Output;
 use HTML::Template;
 use C4::Koha;
+use C4::Search;
 
-my $query = new CGI;
+my $input = new CGI;
+
+my $error   = $input->param('error');
+my $success = $input->param('biblioitem');
+my $query   = $input->param('q');
 
-my $error   = $query->param('error');
-my $success = $query->param('biblioitem');
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "cataloguing/addbooks.tmpl",
-        query           => $query,
+        query           => $input,
         type            => "intranet",
         authnotrequired => 0,
         flagsrequired   => { editcatalogue => 1 },
@@ -57,6 +59,45 @@
     }
 );
 
+# Searching the catalog.
+my ($error, $marcresults) = SimpleSearch($query);
+
+if (defined $error) {
+    $template->param(query_error => $error);
+    warn "error: ".$error;
+    output_html_with_http_headers $input, $cookie, $template->output;
+    exit;
+}
+
+my $total = scalar @$marcresults;
+my @results;
+
+for(my $i=0;$i<$total;$i++) {
+    my %resultsloop;
+    my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
+    my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+    
+    #hilight the result
+    $biblio->{'title'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    $biblio->{'subtitle'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    $biblio->{'biblionumber'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    $biblio->{'author'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    $biblio->{'publishercode'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    $biblio->{'publicationyear'} =~ s/$query/<span class=term>$&<\/span>/gi;
+    
+    #build the hash for the template.
+    $resultsloop{highlight}       = ($i % 2)?(1):(0);
+    $resultsloop{title}           = $biblio->{'title'};
+    $resultsloop{subtitle}        = $biblio->{'subtitle'};
+    $resultsloop{biblionumber}    = $biblio->{'biblionumber'};
+    $resultsloop{author}          = $biblio->{'author'};
+    $resultsloop{publishercode}   = $biblio->{'publishercode'};
+    $resultsloop{publicationyear} = $biblio->{'publicationyear'};
+
+    push @results, \%resultsloop;
+}
+
+
 # get framework list
 my $frameworks = getframeworks;
 my @frameworkcodeloop;
@@ -69,6 +110,10 @@
 
 my $marc_p = C4::Context->boolean_preference("marc");
 $template->param( NOTMARC => !$marc_p,
-				frameworkcodeloop => \@frameworkcodeloop );
+				  frameworkcodeloop => \@frameworkcodeloop,
+				  total => $total,
+				  query => $query,
+				  resultsloop => \@results,
+				   );
 
-output_html_with_http_headers $query, $cookie, $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;

Index: koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbooks.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbooks.tmpl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbooks.tmpl	2 Nov 2006 17:33:42 -0000	1.1.2.1
+++ koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbooks.tmpl	3 Nov 2006 08:47:12 -0000	1.1.2.2
@@ -10,29 +10,10 @@
 	
 <h2>Search Existing Records</h2>
 <div id="addbooks_search">
-	<form action="isbnsearch.pl">
-		<p>
-			<label for="title">Title</label>
-			<input type="hidden" name="marclist" value="biblio.title" />
-			<input type="hidden" name="and_or" value="and" />
-			<input type="hidden" name="excluding" value="" />
-			<input type="hidden" name="operator" value="contains" />
-			<input type="text" name="value" id="title"size="35" />
-		</p>
-		<p>
-			<label for="isbn">ISBN</label>
-			<input type="hidden" name="marclist" value="biblioitems.isbn" />
-			<input type="hidden" name="and_or" value="and" />
-			<input type="hidden" name="excluding" value="" />
-			<input type="hidden" name="operator" value="start" />
-			<input type="text" name="value" id="isbn"size="35" />
-		</p>
-		<p><input type="submit" value="Search" /></p>
-		<ul>
-			<li>If the ISBN is found into the database, that record will be retrieved and can be modified.</li>
-			<li>If the ISBN is found in the reservoir, it will be retrieved and a full record added.</li>
-			<li>Otherwise, a record can be added from scratch.</li>
-		</ul>
+	<form action="addbooks.pl">
+        <label for="q">Search the catalog: </label>
+        <input id="q" type="text"  size="25"   name="q" />
+        <input type="submit" value="search">
 	</form>
 </div>
 <div id="addbooks_add_without_search">
@@ -58,4 +39,42 @@
 		</form>
 			<!-- /TMPL_IF -->
 </div>
+
+
+<!-- display the search results -->
+
+<!-- TMPL_IF NAME="total"-->
+<!-- TMPL_VAR NAME="total"--> Results found.
+<div class="searchresults">
+    <table>
+    <tr>
+       <th>Title</th>
+       <th>Author</th>
+       <th>publisher</th>
+       <th>Publication year</th>
+    </tr>
+    <!-- TMPL_LOOP NAME="resultsloop" -->
+        <tr>
+            <td>
+                <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">
+                    <!-- TMPL_VAR NAME="title" -->
+                </a>
+                <br />
+                <small><!-- TMPL_VAR NAME="subtitle" --></small>
+            </td>
+            <td>
+                <!-- TMPL_VAR NAME="author" -->
+            </td>
+            <td>
+                <!-- TMPL_VAR NAME="publishercode" -->
+            </td>
+            <td>
+                <!-- TMPL_VAR NAME="publicationyear" -->
+            </td>
+        </tr>
+    <!-- /TMPL_LOOP -->
+    </table>
+</div>
+<!-- /TMPL_IF -->
+
 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->





More information about the Koha-cvs mailing list