From f4027c6e99ece3a7127ad2759e9193e635263cd2 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Mon, 6 Jan 2020 01:45:21 +0000
Subject: [PATCH] Bug 24347: Add a 'search to order' option similar to 'search
to hold'
This patch modifes the process of searching for an existing record
to add to a basket. Now the search is performed as a keyword search in
the regular catalog rather than via a custom search script. Options are
added to the search results and detail pages to add results to an order.
This process follows the same pattern as the "Search to hold" feature:
When the search is initiated, a cookie is set with the requisite
information--in this case vendor id and basket number.
If the search results or bibliographic detail pages detect that a
"searchToOrder" cookie is present, the correct "Add order" link will be
shown. Like with the "search to hold" feature, the cookie expires in 10
minutes.
To test, apply the patch and log into the staff client as a user who has
permission to add to a basket in acquisitions.
- Go to Acquisitions -> Vendor -> Basket -> Add to basket.
- Using the "From an existing record" option, perform a search.
- On the search results page, test the "Add order" link which appears
with each result. Clicking the link should take you to the "New
order" page for the correct vendor and basket. The catalog
details section of the form should include the correct information.
- From the search results page view the bibliographic details page for
any record. There should be a new toolbar button, "Add order." Verify
that it works correctly.
- Test the same thing from all bibliographic detail pages: Normal,
MARC, Labeled MARC, ISBD, as well as the items page
(moredetail.pl).
- Test this process for both the locations in acquisitions where one
can add to an existing basket: Vendor search results and the basket
detail page
- Test the cookie timeout: Wait 10 minutes and perform another catalog
search. The "Add order" link should no longer be present.
Signed-off-by: David Nind <david@davidnind.com>
---
catalogue/ISBDdetail.pl | 8 ++++++++
catalogue/MARCdetail.pl | 8 ++++++++
catalogue/detail.pl | 8 ++++++++
catalogue/imageviewer.pl | 8 ++++++++
catalogue/labeledMARCdetail.pl | 8 ++++++++
catalogue/moredetail.pl | 8 ++++++++
catalogue/search.pl | 8 ++++++++
.../prog/en/includes/acquisitions-add-to-basket.inc | 14 ++++++--------
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc | 8 ++++++++
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt | 1 +
.../intranet-tmpl/prog/en/modules/acqui/booksellers.tt | 1 +
.../intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt | 1 +
.../intranet-tmpl/prog/en/modules/catalogue/results.tt | 6 ++++++
koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js | 14 ++++++++++++++
14 files changed, 93 insertions(+), 8 deletions(-)
diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl
index aade9c90be..eb96fff1fd 100755
--- a/catalogue/ISBDdetail.pl
+++ b/catalogue/ISBDdetail.pl
@@ -118,6 +118,14 @@ if($query->cookie("holdfor")){
);
}
+if( $query->cookie("searchToOrder") ){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
# count of item linked with biblio
my $itemcount = $biblio->items->count;
$template->param( count => $itemcount);
diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl
index ab44ef76d4..adfe24c192 100755
--- a/catalogue/MARCdetail.pl
+++ b/catalogue/MARCdetail.pl
@@ -113,6 +113,14 @@ if($query->cookie("holdfor")){
);
}
+if( $query->cookie("searchToOrder") ){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
$template->param( ocoins => $biblio_object->get_coins );
#count of item linked
diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index 249a7417cb..8e9163a26d 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -126,6 +126,14 @@ if($query->cookie("holdfor")){
);
}
+if($query->cookie("searchToOrder")){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
my $fw = GetFrameworkCode($biblionumber);
my $showallitems = $query->param('showallitems');
my $marcflavour = C4::Context->preference("marcflavour");
diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl
index 009b82ecf1..8b734a4ce4 100755
--- a/catalogue/imageviewer.pl
+++ b/catalogue/imageviewer.pl
@@ -67,6 +67,14 @@ if ( $query->cookie("holdfor") ) {
);
}
+if( $query->cookie("searchToOrder") ){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
if ( C4::Context->preference("LocalCoverImages") ) {
my @images = ListImagesForBiblio($biblionumber);
$template->{VARS}->{'LocalCoverImages'} = 1;
diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl
index 7c3b77bc9a..90543f6794 100755
--- a/catalogue/labeledMARCdetail.pl
+++ b/catalogue/labeledMARCdetail.pl
@@ -79,6 +79,14 @@ if($query->cookie("holdfor")){
);
}
+if( $query->cookie("searchToOrder") ){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
#count of item linked
my $itemcount = $biblio_object->items->count;
$template->param( count => $itemcount,
diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl
index f74bc85aa0..ccff8276a4 100755
--- a/catalogue/moredetail.pl
+++ b/catalogue/moredetail.pl
@@ -60,6 +60,14 @@ if($query->cookie("holdfor")){
);
}
+if( $query->cookie("searchToOrder") ){
+ my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
# get variables
my $biblionumber=$query->param('biblionumber');
diff --git a/catalogue/search.pl b/catalogue/search.pl
index 89a5211b5c..882a9eb052 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -211,6 +211,14 @@ if($cgi->cookie("holdforclub")){
);
}
+if($cgi->cookie("searchToOrder")){
+ my ( $basketno, $vendorid ) = split( /\//, $cgi->cookie("searchToOrder") );
+ $template->param(
+ searchtoorder_basketno => $basketno,
+ searchtoorder_vendorid => $vendorid
+ );
+}
+
# get biblionumbers stored in the cart
my @cart_list;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
index 6e5698f08c..b4f37edb19 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
@@ -3,14 +3,12 @@
[% IF has_budgets %]
<ul>
<li>
- <form action="/cgi-bin/koha/acqui/neworderbiblio.pl" method="post">
- <label>From an existing record:
- <input type="text" size="25" name="q" required="required"/>
- </label>
- <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
- <input type="hidden" name="basketno" value="[% basketno | html %]" />
- <input type="submit" class="submit" value="Search" />
- </form>
+ <form action="/cgi-bin/koha/catalogue/search.pl" method="get">
+ <label>From an existing record:
+ <input type="text" name="q" size="25" />
+ </label>
+ <input type="submit" class="submit" id="searchtoorder" data-booksellerid="[% booksellerid | html %]" data-basketno="[% basketno | html %]" value="Submit" />
+ </form>
</li>
<li><a href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]">From a suggestion</a></li>
<li><a href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]">From a subscription</a></li>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
index 7ab50f59b6..12b903d039 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
@@ -139,6 +139,14 @@ CAN_user_serials_create_subscription ) %]
<div class="btn-group"><a id="placehold" class="btn btn-default" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber | html %]"><i class="fa fa-file-text-o"></i> Request article</a></div>
[% END %]
+[% IF ( CAN_user_acquisition_order_manage ) %]
+ [% IF ( searchtoorder_basketno && searchtoorder_vendorid ) %]
+ <div class="btn-group">
+ <a class="btn btn-default" href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% searchtoorder_vendorid | uri %]&basketno=[% searchtoorder_basketno | uri %]&biblionumber=[% biblionumber | uri %]"><i class="fa fa-shopping-basket"></i> Add order</a>
+ </div>
+ [% END %]
+[% END %]
+
[% FOREACH p IN plugins %]
[% p.intranet_catalog_biblio_enhancements_toolbar_button | $raw %]
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
index 8bbfe08ecc..c4d4d178dd 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
@@ -783,6 +783,7 @@
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
[% Asset.js("lib/hc-sticky.js") | $raw %]
+ [% Asset.js("js/acq.js") | $raw %]
<script>
function updateColumnsVisibility(visible) {
if ( visible ) {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
index 512eed7015..4f6165704c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
@@ -201,6 +201,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/acquisitions-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
+ [% Asset.js("js/acq.js") | $raw %]
<script>
$(document).ready(function() {
$("table.baskets").dataTable($.extend(true, {}, dataTablesDefaults, {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt
index bc0ea58ad9..eff4367183 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt
@@ -109,6 +109,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/acquisitions-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
+ [% Asset.js("js/acq.js") | $raw %]
<script>
$(document).ready(function() {
var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
index e0da564ccf..6ae7863f06 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
@@ -473,6 +473,12 @@
| <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a>
[% END %]
+ [% IF ( CAN_user_acquisition_order_manage ) %]
+ [% IF ( searchtoorder_basketno && searchtoorder_vendorid ) %]
+ | <a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% searchtoorder_vendorid | uri %]&basketno=[% searchtoorder_basketno | uri %]&biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Add order</a>
+ [% END %]
+ [% END %]
+
[% IF ( OPACBaseURL ) %]
<span class="view-in-opac">
| <a href="[% Koha.Preference('OPACBaseURL') | url %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" target="_blank">OPAC view</a>
diff --git a/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js b/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js
index 30c0567630..97597dd4d9 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js
@@ -1,6 +1,20 @@
+function searchToOrder( basketno, vendorid ){
+ var date = new Date();
+ var cookieData = "";
+ date.setTime(date.getTime() + (10 * 60 * 1000));
+ cookieData += basketno + "/" + vendorid;
+ Cookies.set("searchToOrder", cookieData, { path: "/", expires: date });
+}
+
$(document).ready(function() {
var path = location.pathname.substring(1);
if (path.indexOf("invoice") >= 0) {
$('#navmenulist a[href$="/cgi-bin/koha/acqui/invoices.pl"]').addClass("current");
}
+
+ $("body").on("click", "#searchtoorder", function(){
+ var vendorid = $(this).data("booksellerid");
+ var basketno = $(this).data("basketno");
+ searchToOrder( basketno, vendorid );
+ });
});
--
2.11.0