[Koha-patches] [PATCH] Bug 3804 Add search by Purchase Order number To Acq Screens

Colin Campbell colin.campbell at ptfs-europe.com
Mon Nov 23 12:49:40 CET 2009


Allows searching by purchase order number in acq screens
Add PO Number to histsearch results display for consistency

This feature sponsored by UN-FAO
---
 C4/Acquisition.pm                                  |   29 +++++++
 acqui/posearch.pl                                  |   56 ++++++++++++++
 .../en/includes/acquisitions-history-search.inc    |    8 ++
 .../prog/en/includes/acquisitions-search.inc       |    8 ++
 .../prog/en/modules/acqui/histsearch.tmpl          |    4 +-
 .../prog/en/modules/acqui/posearch.tmpl            |   80 ++++++++++++++++++++
 6 files changed, 184 insertions(+), 1 deletions(-)
 create mode 100755 acqui/posearch.pl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/posearch.tmpl

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 3ad4cd9..8a07e3c 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -40,6 +40,7 @@ BEGIN {
 		&SearchOrder &GetHistory &GetRecentAcqui
 		&ModOrder &ModReceiveOrder &ModOrderBiblioNumber
 		&GetParcels &GetParcel
+        GetOrdersByPO 
 	);
 }
 
@@ -275,6 +276,33 @@ sub GetOrders {
     return @{ $order_rows };
 }
 
+=head3 GetOrdersByPO
+
+=over 4
+
+$orders_arrayref = GetOrdersByPO($purchaseordernumber);
+
+Retrieves orders by (possibly truncated) purchase order number
+
+return :
+An arrayref of matching orders (incl basket level info)
+
+=back
+
+=cut
+
+sub GetOrdersByPO {
+    my $ponumber = shift;
+    $ponumber .= '%';
+        my $sql = 'SELECT aqorders.*, aqbasket.booksellerid, aqbasket.creationdate, aqbooksellers.name from aqorders '
+        . 'LEFT JOIN aqbasket on aqorders.basketno = aqbasket.basketno '
+        . 'LEFT JOIN aqbooksellers on aqbasket.booksellerid = aqbooksellers.id WHERE purchaseordernumber like ? '
+        . 'order by purchaseordernumber';
+    my $dbh = C4::Context->dbh;
+    my $rows = $dbh->selectall_arrayref( $sql, { Slice => {} }, $ponumber); 
+
+    return $rows;
+}
 #------------------------------------------------------------#
 
 =head3 GetOrderNumber
@@ -1118,6 +1146,7 @@ sub GetHistory {
                 aqorders.ordernumber,
                 aqorders.booksellerinvoicenumber as invoicenumber,
                 aqbooksellers.id as id,
+                aqorders.purchaseordernumber,
                 aqorders.biblionumber
             FROM aqorders 
             LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno 
diff --git a/acqui/posearch.pl b/acqui/posearch.pl
new file mode 100755
index 0000000..d49c056
--- /dev/null
+++ b/acqui/posearch.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+#
+# Copyright 2009 PTFS-Europe Ltd.
+#
+# 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
+
+use strict;
+use warnings;
+
+use CGI;
+
+use C4::Auth;
+use C4::Output;
+use C4::Acquisition;
+
+my $query = CGI->new();
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => 'acqui/posearch.tmpl',
+        query           => $query,
+        type            => 'intranet',
+        authnotrequired => 0,
+        flagsrequired   => { acquisition => 1 },
+        debug           => 1,
+    }
+);
+my $result_set = [];
+my $ponumber   = $query->param('ponumber');
+
+if ($ponumber) {
+    $result_set = GetOrdersByPO($ponumber);
+}
+
+my $set_size = @{$result_set};
+$template->param(
+    searchstring    => $ponumber,
+    orders_loop     => $result_set,
+    orders_returned => $set_size,
+
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-history-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-history-search.inc
index 8e895dc..39ad36f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-history-search.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-history-search.inc
@@ -16,9 +16,17 @@
 	<input value="Submit" class="submit" type="submit" /> <a href="/cgi-bin/koha/acqui/histsearch.pl">Advanced Search</a>
 	</form>
 	</div>	
+    <div id="porders_search" class="residentsearch">
+        <p class="tip">Search PO Number:</p>
+        <form action="/cgi-bin/koha/acqui/posearch.pl" method="post">
+            <input type="text" size="30" name="ponumber" id="ponumber" class="focus" />
+            <input type="submit" class="submit" value="Submit" />
+        </form>
+    </div>
 			<ul>
 			<li><a href="/cgi-bin/koha/acqui/booksellers.pl#supplier_search">Vendor Search</a></li>
 			<li class="ui-tabs-selected"><a href="/cgi-bin/koha/acqui/histsearch.pl#orders_search">Orders Search</a></li>
+			<li><a href="/cgi-bin/koha/acqui/posearch.pl#porders_search">PO Number Search</a></li>
 			</ul>	
 </div>
 <!-- End Acquisitions Resident Search Box -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-search.inc
index 72d4e65..d7308a8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-search.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-search.inc
@@ -15,9 +15,17 @@
 	<input value="Submit" class="submit" type="submit" /> <a href="/cgi-bin/koha/acqui/histsearch.pl">Advanced Search</a>
 	</form>
 	</div>	
+    <div id="porders_search" class="residentsearch">
+        <p class="tip">Search PO Number:</p>
+        <form action="/cgi-bin/koha/acqui/posearch.pl" method="post">
+            <input type="text" size="30" name="ponumber" id="ponumber" class="focus" />
+            <input type="submit" class="submit" value="Submit" />
+        </form>
+    </div>
 			<ul>
 			<li><a href="/cgi-bin/koha/acqui/booksellers.pl#supplier_search">Vendor Search</a></li>
 			<li><a href="/cgi-bin/koha/acqui/histsearch.pl#orders_search">Orders Search</a></li>
+			<li><a href="/cgi-bin/koha/acqui/posearch.pl#porders_search">PO Number Search</a></li>
 			</ul>	
 </div>
 <!-- End Acquisitions Resident Search Box -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tmpl
index 3b29414..17c43ed 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tmpl
@@ -58,18 +58,20 @@
 		<table>
 			<tr>
 				<th>Basket</th>
+                <th>PO Number</th>
 				<th>Invoice Number</th>
 				<th>Summary</th>
 				<th>Vendor</th>
 				<th>Placed on</th>
 				<th>Received on</th>
-				<th>Quantity ordered</th>
+				<th>Qty ordered</th>
 				<th>Unit cost</th>
 			</tr>
 			
 			<!-- TMPL_LOOP NAME="suggestions_loop" -->
 				<tr>
                     <td><a href="basket.pl?basketno=<!-- TMPL_VAR name="basketno" -->"><!-- TMPL_VAR name="basketno" --></a></td>
+                    <td><!-- TMPL_VAR name="purchaseordernumber" --></td>
 					<td><!-- TMPL_IF NAME="invoicenumber" -->
 					        <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=<!-- TMPL_VAR NAME="invoicenumber"-->&amp;supplierid=<!-- TMPL_VAR NAME="id"-->&amp;datereceived=<!-- TMPL_VAR NAME="datereceived" -->"><!-- TMPL_VAR NAME="invoicenumber"--></a>
 					    <!-- TMPL_ELSE -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/posearch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/posearch.tmpl
new file mode 100644
index 0000000..c89d9a2
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/posearch.tmpl
@@ -0,0 +1,80 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Search by Purchase Order Number <!-- TMPL_VAR NAME="ponumber" --></title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="acquisitions-search.inc" -->
+
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; 
+    <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; 
+    Search for Purchase Order <em><!-- TMPL_VAR name="ponumber" --></em>
+</div>
+
+<div id="doc3" class="yui-t2">
+
+    <div id="bd">
+        <div id="yui-main">`
+            <div class="yui-b">
+            <!-- TMPL_INCLUDE NAME="acquisitions-toolbar.inc" -->
+            <h1>You searched on <b>purchase order number <!-- TMPL_VAR NAME="searchstring" -->,</b> 
+                <!-- TMPL_VAR name="orders_returned" --> results found</h1>
+                <div id="order_list">
+                    <table>
+                    <tr>
+                        <th>Purchase Order No</th>
+                        <th>Basket</th>
+                        <th>Invoice Number</th>
+                        <th>Summary</th>
+                        <th>Vendor</th>
+                        <th>Placed on</th>
+                        <th>Received On</th>
+                        <th>Qty ordered</th>
+                        <th>Unit cost</th>
+                    </tr>
+                    <!-- TMPL_LOOP name="orders_loop" -->
+                            <!-- TMPL_UNLESS name="__odd__" -->
+                                <tr class="highlight">
+                            <!-- TMPL_ELSE -->
+                                <tr>
+                            <!-- /TMPL_UNLESS -->
+                                <td>
+                                    <!-- TMPL_VAR NAME="purchaseordernumber" -->
+                                </td>
+                                <td>
+                        <a href="basket.pl?basketno=<!-- TMPL_VAR name="basketno" -->"><!-- TMPL_VAR name="basketno" --></a>
+                                </td>
+					            <td>
+                                <!-- TMPL_IF  NAME="booksellerinvoicenumber" -->
+					        <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=<!-- TMPL_VAR NAME="booksellerinvoicenumber"-->&amp;supplierid=<!-- TMPL_VAR NAME="booksellerid"-->&amp;datereceived=<!-- TMPL_VAR NAME="datereceived" -->"><!-- TMPL_VAR NAME="booksellerinvoicenumber"--></a>
+					            <!-- TMPL_ELSE -->
+					                &nbsp;
+					            <!-- /TMPL_IF -->
+					            </td>
+					            <td>
+<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">
+<!-- TMPL_VAR NAME="title" escape="html" --></a>
+                                    <br /><!-- TMPL_VAR NAME="author" -->
+                                </td>
+					            <td>
+                <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR name="booksellerid" -->"><!-- TMPL_VAR NAME="name" --></a>
+                                </td>
+					            <td>
+                                    <!-- TMPL_VAR name="creationdate" -->
+                                </td>
+					            <td><!-- TMPL_VAR name="datereceived" --></td>
+					            <td><!-- TMPL_VAR name="quantity" --></td>
+					            <td><!-- TMPL_VAR name="ecost" --></td>
+                                </tr>
+                    <!-- /TMPL_LOOP -->
+                    </table>
+                </div>
+            </div>
+        </div>
+        <div class="yui-b">
+<!-- TMPL_INCLUDE NAME="acquisitions-menu.inc" -->
+        </div>
+    </div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
+
-- 
1.6.5.2




More information about the Koha-patches mailing list