Circulation borrower name autocompletion
authorFrederic Demians <f.demians@tamil.fr>
Fri, 19 Oct 2007 19:32:18 +0000 (14:32 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Sat, 20 Oct 2007 21:17:08 +0000 (16:17 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
admin/systempreferences.pl
circ/circulation.pl
circ/ysearch.pl [new file with mode: 0755]
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css [changed mode: 0644->0755]
koha-tmpl/intranet-tmpl/prog/en/includes/circ-search-autocompl.inc [new file with mode: 0755]
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl [changed mode: 0644->0755]

index f8afbbb..b96137b 100755 (executable)
@@ -109,6 +109,7 @@ my %tabsysprefs;
     $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
     $tabsysprefs{useDaysMode}="Circulation";
     $tabsysprefs{ReservesNeedReturns}="Circulation";
+    $tabsysprefs{CircAutocompl}="Circulation";
 
 # Intranet
     $tabsysprefs{TemplateEncoding}="Intranet";
index 169427e..813eaa2 100755 (executable)
@@ -653,4 +653,5 @@ if ($stickyduedate) {
 $template->param(
     SpecifyDueDate     => C4::Context->preference("SpecifyDueDate")
 );
+$template->param( CircAutocompl => C4::Context->preference("CircAutocompl") );
 output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/circ/ysearch.pl b/circ/ysearch.pl
new file mode 100755 (executable)
index 0000000..9b42a57
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
+
+# Copyright 2007 Tamil s.a.r.l.
+#
+# 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 ysearch.pl
+
+
+=cut
+
+use strict;
+use CGI;
+use C4::Context;
+
+my $input   = new CGI;
+my $query   = $input->param('query');
+
+# FIXME: charset should be UTF-8 but borrowers table is still ISO-8859-1
+print $input->header(-type => 'text/plain', -charset => 'ISO-8859-1');
+
+my $dbh = C4::Context->dbh;
+my $query = "SELECT surname, firstname, cardnumber, address, city, zipcode ".
+            "FROM borrowers " .
+            "WHERE surname LIKE '". $query . "%' " .
+            "OR firstname LIKE '" . $query . "%' " .
+            #"OR cardnumber LIKE '" . $query . "%' " .
+            "ORDER BY surname, firstname ";
+my $sth = $dbh->prepare( $query );
+$sth->execute();
+while ( my $rec = $sth->fetchrow_hashref ) {
+    print $rec->{surname} . ", " . $rec->{firstname} . "\t" .
+          $rec->{cardnumber} . "\t" .
+          $rec->{address} . "\t" .
+          $rec->{city} . "\t" .
+          $rec->{zip} .
+          "\n";
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-search-autocompl.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-search-autocompl.inc
new file mode 100755 (executable)
index 0000000..3244f9c
--- /dev/null
@@ -0,0 +1,162 @@
+<!-- Begin Circulation Resident Search Box -->
+
+
+
+<script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/utilities/utilities.js"></script>
+<script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/autocomplete/autocomplete-min.js"></script>
+<script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/yahoo-dom-event/yahoo-dom-event-min.js"></script>
+<script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/element/element-beta-min.js"></script>
+
+
+
+<style type="text/css">
+.yui-skin-sam .yui-ac {
+    position:relative;
+    font-size:100%;
+}
+.yui-skin-sam .yui-ac-input { 
+    position:absolute;
+    width:100%;}
+.yui-skin-sam .yui-ac-container { 
+    position:absolute;
+    top:1.6em;
+    width:100%;
+}
+.yui-skin-sam .yui-ac-content {
+    position:absolute;
+    width:100%;
+    border:1px solid #808080;
+    background:#fff;
+    overflow:hidden;
+    z-index:9050;
+}
+.yui-skin-sam .yui-ac-shadow {
+    position:absolute;
+    margin:.3em;
+    width:100%;
+    background:#000;
+    -moz-opacity:0.10;
+    opacity:.10;
+    filter:alpha(opacity=10);
+    z-index:9049;
+}
+.yui-skin-sam .yui-ac-content ul {
+    margin:0;
+    padding:0;
+    width:100%;
+}
+.yui-skin-sam .yui-ac-content li {
+    margin:0;
+    padding:2px 5px;
+    cursor:default;
+    white-space:nowrap;
+}
+.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight {
+    background:#B3D4FF;
+}
+.yui-skin-sam .yui-ac-content li.yui-ac-highlight {
+    background:#426FD9;
+    color:#FFF;
+}
+
+
+
+#borrowerautocomplete { width: 405px; text-align:left;} /* z-index needed on top instances for ie & sf absolute inside relative issue */
+.autocomplete { width:130px; }/* set width of widget here*/
+.autocomplete .yui-ac-highlight ,
+.autocomplete .yui-ac-highlight .sample-result,
+.autocomplete .yui-ac-highlight .sample-query { color:#FFF; }
+.autocomplete .sample-result { color: black; }
+.autocomplete .sample-query { color:#000; }
+#findborrower { position:static; width:335px; }  */
+#yborrowercontainer { text-align:left;width:300px; }
+</style>
+
+
+<div id="header_search">
+
+<div id="circ_search" class="residentsearch">
+    <p class="tip">Enter patron card number or partial name:</p>
+    <form action="/cgi-bin/koha/circ/circulation.pl" method="post">
+        <div class="yui-skin-sam">
+            <div id="borrowerautocomplete" class="autocomplete">
+                <input id="findborrower" name="findborrower" class="focus" type="text" />
+                <div id="yborrowercontainer"></div>
+                <input id="ysearchsubmit" type="submit" value="Submit">
+                <input name="branch" value="<!-- TMPL_VAR name="branch" -->" type="hidden" />
+                <input name="printer" value="" type="hidden" />
+            </div>
+        </div>
+    </form>
+</div> 
+
+<div id="checkin_search" class="residentsearch">
+    <p class="tip">Scan a barcode to check in:</p>
+    <form method="post" action="/cgi-bin/koha/circ/returns.pl">
+        <input name="barcode" id="ret_barcode" size="40" maxlength="14" />
+        <input value="Submit" type="submit" />
+    </form>
+</div>
+
+<div id="catalog_search" class="residentsearch">
+    <p class="tip">Enter search keywords:</p>
+    <form action="/cgi-bin/koha/catalogue/search.pl"  method="get" id="cat-search-block">
+        <input type="text" name="q" id="search-form" size="40" />
+        <input type="submit" name="op" id="opac-submit" value="Submit"  class="form-submit" />
+    </form>
+</div>
+
+<ul>
+    <li><a href="/cgi-bin/koha/circ/circulation.pl#circ_search">Check Out</a></li>
+    <li><a href="/cgi-bin/koha/circ/returns.pl#checkin_search">Check In</a></li>
+    <li><a href="/cgi-bin/koha/catalogue/advsearch.pl#catalog_search">Search the Catalog</a></li>
+</ul>   
+
+</div>
+
+
+<script type="text/javascript">
+YAHOO.bsearch.ACFlatData = new function() {
+    // Define a custom formatter function
+    this.fnCustomFormatter = function(oResultItem, sQuery) {
+        var name        = oResultItem[0];
+        var cardnumber  = oResultItem[1];
+        var address     = oResultItem[2];
+        var city        = oResultItem[3];
+        var zip         = oResultItem[4];
+        var aMarkup = [
+            "<div class='sample-result'>",
+            name,
+            " (",
+            cardnumber,
+            ")<small> -- ",
+            address,
+            ", ",
+            city,
+            "</small>",
+            "</div>"];
+        return (aMarkup.join(""));
+    };
+
+    // Instantiate one XHR DataSource and define schema as an array:
+    //     ["Record Delimiter",
+    //     "Field Delimiter"]
+    this.oACDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/circ/ysearch.pl", ["\n", "\t"]);
+    this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
+    this.oACDS.maxCacheEntries = 60;
+    this.oACDS.queryMatchSubset = true;
+
+    // Instantiate first AutoComplete
+    var myInput = document.getElementById('findborrower');
+    var myContainer = document.getElementById('yborrowercontainer');
+    this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.oACDS);
+    //this.oAutoComp.delimChar = ";";
+    //this.oAutoComp.queryDelay = 1;
+    this.oAutoComp.formatResult = this.fnCustomFormatter;
+}
+
+
+
+</script>
+
+<!-- End Circulation Resident Search Box -->
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index cb535b6..ae77649
 <body>
 
 <!-- TMPL_INCLUDE NAME="header.inc" -->
+
+<!-- TMPL_IF NAME="CircAutocompl" -->
+<!-- TMPL_INCLUDE NAME="circ-search-autocompl.inc" -->
+<!-- TMPL_ELSE -->
 <!-- TMPL_INCLUDE NAME="circ-search.inc" -->
+<!-- /TMPL_IF -->
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo;<!-- TMPL_IF NAME="borrowernumber" --> <a href="/cgi-bin/koha/circ/circulation.pl">Checkouts</a> &rsaquo; <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --><!-- TMPL_ELSE --> <strong>Checkouts</strong><!-- /TMPL_IF --></div>