Bug 24347: Add a 'search to order' option similar to 'search to hold'
authorOwen Leonard <oleonard@myacpl.org>
Mon, 6 Jan 2020 01:45:21 +0000 (01:45 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 30 Jan 2020 10:58:03 +0000 (10:58 +0000)
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>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

14 files changed:
catalogue/ISBDdetail.pl
catalogue/MARCdetail.pl
catalogue/detail.pl
catalogue/imageviewer.pl
catalogue/labeledMARCdetail.pl
catalogue/moredetail.pl
catalogue/search.pl
koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js

index aade9c9..eb96fff 100755 (executable)
@@ -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);
index ab44ef7..adfe24c 100755 (executable)
@@ -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
index 249a741..8e9163a 100755 (executable)
@@ -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");
index 009b82e..8b734a4 100755 (executable)
@@ -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;
index 7c3b77b..90543f6 100755 (executable)
@@ -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,
index f74bc85..ccff827 100755 (executable)
@@ -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');
index 89a5211..882a9eb 100755 (executable)
@@ -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;
 
index 6e5698f..b4f37ed 100644 (file)
@@ -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 %]&amp;basketno=[% basketno | uri %]">From a suggestion</a></li>
         <li><a href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">From a subscription</a></li>
index 7ab50f5..12b903d 100644 (file)
@@ -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 %]&amp;basketno=[% searchtoorder_basketno | uri %]&amp;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 %]
index 8bbfe08..c4d4d17 100644 (file)
     [% 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 ) {
index 512eed7..4f61657 100644 (file)
 [% 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, {
index bc0ea58..eff4367 100644 (file)
 [% 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, {
index 6429d90..e618d73 100644 (file)
                                                         | <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 %]&amp;basketno=[% searchtoorder_basketno | uri %]&amp;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>
index 30c0567..97597dd 100644 (file)
@@ -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 );
+    });
 });