[Koha-patches] [PATCH] add autofill title search to checkin and checkout

Scott Hepler scott.hepler at gmail.com
Mon Aug 24 04:08:14 CEST 2009


---
 circ/ybiblio_search.pl                             |   70 ++++++++++++++++++++
 .../intranet-tmpl/prog/en/css/staff-global.css     |    9 +++
 .../en/includes/circ-checkin-biblio-search.inc     |   35 ++++++++++
 .../en/includes/circ-checkout-biblio-search.inc    |   31 +++++++++
 .../prog/en/modules/circ/circulation.tmpl          |    2 +
 .../prog/en/modules/circ/returns.tmpl              |    8 ++-
 6 files changed, 152 insertions(+), 3 deletions(-)
 create mode 100755 circ/ybiblio_search.pl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkin-biblio-search.inc
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkout-biblio-search.inc

diff --git a/circ/ybiblio_search.pl b/circ/ybiblio_search.pl
new file mode 100755
index 0000000..70e4134
--- /dev/null
+++ b/circ/ybiblio_search.pl
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+=head1 ycust_search.pl
+
+
+=cut
+
+use strict;
+use lib ('/usr/share/koha/lib/');
+
+use CGI;
+use C4::Context;
+use C4::Auth qw/check_cookie_auth/;
+# use C4::Output;
+use C4::Search;
+use C4::Languages qw(getAllLanguages);
+use C4::Koha;
+use C4::Biblio;
+
+my $input   = new CGI;
+my $query   = $input->param('query');
+
+$query .= '*' if (substr($query,-1) ne ' ');
+$query = "title = \"$query\"";
+
+binmode STDOUT, ":utf8";
+print $input->header(-type => 'text/plain', -charset => 'UTF-8');
+
+#my ($auth_status, $sessionID) = check_cookie_auth($input->cookie('CGISESSID'), { circulate => '*' });
+#if ($auth_status ne "ok") {
+#    exit 0;
+#}
+
+my ($error, $marcresults) = SimpleSearch($query);
+
+if (defined $error) {
+    print "query_error => $error\n";
+    exit;
+}
+
+my $hits = scalar @$marcresults;
+
+my @results;
+
+for(my $i=0;$i<$hits;$i++) {
+
+    my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
+    my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
+
+    print $biblio->{'barcode'} . "\t" .
+			$biblio->{'author'} . "\t" .
+			$biblio->{'title'} . $biblio->{'subtitle'} . "\n" ;
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index 41ba3e9..37f09ca 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -1242,6 +1242,13 @@ h1#logo a {
 
 .barcode {
 	font-size :  200%;
+	position: static;
+	width: 335px;
+}
+
+#ret_barcode {
+	position: static;
+	width: 335px;
 }
 
 li.email a {
@@ -1669,6 +1676,8 @@ span.permissiondesc {
 .autocomplete .sample-query { color:#000; }
 #findborrower { position:static; width:auto; }
 #yborrowercontainer { text-align:left;width:335px; }
+#ybibliocontainer { text-align:left; position:static; }
+#ybibliocontainer .yui-ac-content { width:450px; }
 
 /* patron attribues autocomplete for overdues report (pattrodue) */
 .pattrodue-autocomplete .pattrodue-result { color: black; }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkin-biblio-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkin-biblio-search.inc
new file mode 100644
index 0000000..0567a6a
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkin-biblio-search.inc
@@ -0,0 +1,35 @@
+<script type="text/javascript">
+//<![CDATA[
+	YAHOO.util.Event.onContentReady('ret_barcode', function() {
+		new function() {
+			// Define a custom formatter function
+			this.fnCustomBiblioFormatter = function(oResultItem, sQuery) {
+				var bcode  = oResultItem[0];
+				var author = oResultItem[1];
+				var title  = oResultItem[2];
+				var aMarkup = [
+					"<div class=\"sample-result\"><i>",
+					title,
+					"</i>, ",
+					author,
+					" -- ",
+					bcode,
+					"</div>"];
+				return (aMarkup.join(""));
+			};
+
+			// Instantiate one XHR DataSource and define schema as an array:
+			//     ["Record Delimiter", "Field Delimiter"]
+			this.oACDS_biblio = new YAHOO.widget.DS_XHR("/cgi-bin/koha/circ/ybiblio_search.pl", ["\n", "\t"]);
+			this.oACDS_biblio.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
+			this.oACDS_biblio.maxCacheEntries = 40;
+			this.oACDS_biblio.queryMatchSubset = false;
+
+			this.oAutoComp_biblio = new YAHOO.widget.AutoComplete('ret_barcode','ybiblioCIContainer',this.oACDS_biblio);
+			this.oAutoComp_biblio.queryDelay = 1;
+			this.oAutoComp_biblio.formatResult = this.fnCustomBiblioFormatter;
+		}
+	});    
+	//]]>
+</script>
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkout-biblio-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkout-biblio-search.inc
new file mode 100644
index 0000000..5397361
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-checkout-biblio-search.inc
@@ -0,0 +1,31 @@
+<script type="text/javascript">
+//<![CDATA[
+	YAHOO.util.Event.onContentReady('barcode', function() {
+		new function() {
+			this.fnCustomBiblioFormatter = function(oResultItem, sQuery) {
+				var bcode  = oResultItem[0];
+				var author = oResultItem[1];
+				var title  = oResultItem[2];
+				var aMarkup = [
+					"<div class=\"sample-result\"><i>",
+					title,
+					"</i>, ",
+					author,
+					" -- ",
+					bcode,
+					"</div>"];
+				return (aMarkup.join(""));
+			};
+
+			this.oACDS_biblio = new YAHOO.widget.DS_XHR("/cgi-bin/koha/circ/ybiblio_search.pl", ["\n", "\t"]);
+			this.oACDS_biblio.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
+			this.oACDS_biblio.maxCacheEntries = 40;
+			this.oACDS_biblio.queryMatchSubset = false;
+
+			this.oAutoComp_biblio = new YAHOO.widget.AutoComplete('barcode','ybibliocontainer',this.oACDS_biblio);
+			this.oAutoComp_biblio.queryDelay = 1;
+			this.oAutoComp_biblio.formatResult = this.fnCustomBiblioFormatter;
+		}
+	});    
+	//]]>
+</script>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
index 013a303..8ffdce5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -51,6 +51,7 @@ $.tablesorter.addParser({
 	 });
 //]]>
 </script>
+<!-- TMPL_INCLUDE NAME="circ-checkout-biblio-search.inc" -->
 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
 </head>
 <body>
@@ -269,6 +270,7 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
 	<div class="hint">Enter item barcode:</div>
 
 	<input type="text" name="barcode" id="barcode" class="barcode focus" size="14" /> <input type="submit" value="Check Out" />
+	<div id="ybibliocontainer"></div>
 
     <!-- TMPL_IF NAME="SpecifyDueDate" --><div class="date-select">
         <div class="hint">Specify Due Date:</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
index 12b372c..9925dcb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
@@ -43,6 +43,7 @@ function Dopop(link) {
 	 });
 //]]>
 </script>
+<!-- TMPL_INCLUDE NAME="circ-checkout-biblio-search.inc" -->
 </head>
 <body>
 <!-- TMPL_INCLUDE NAME="header.inc" -->
@@ -294,12 +295,13 @@ function Dopop(link) {
 	<legend>Check In</legend>
             <label for="barcode">Enter item barcode: </label>
 			<!-- TMPL_IF NAME="exemptfine" -->
-			<input name="barcode" id="barcode" size="14" class="focus alert"/>
+			<input name="barcode" id="barcode" size="14" class="barcode focus alert"/>
 			<!-- TMPL_ELSIF NAME="dropboxmode"-->
-			<input name="barcode" id="barcode" size="14" class="focus alert"/>
+			<input name="barcode" id="barcode" size="14" class="barcode focus alert"/>
 			<!-- TMPL_ELSE -->
-			<input name="barcode" id="barcode" size="14" class="focus"/>
+			<input name="barcode" id="barcode" size="14" class="barcode focus"/>
 			<!-- /TMPL_IF -->
+			<div id="ybibliocontainer"></div>
             <input type="submit" class="submit" value="Submit" />
             <!-- TMPL_LOOP Name="inputloop" -->
                 <input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
-- 
1.6.0.4




More information about the Koha-patches mailing list