From 5cbc894e7d03dab98fd5b9345fa25d9f0e95fc69 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 11 Jun 2024 04:53:05 +0000 Subject: [PATCH] Bug 27063: Add modal for linking a basket order to a different record --- catalogue/search.pl | 7 ++- .../prog/en/modules/acqui/basket.tt | 61 +++++++++++++++++++ .../prog/en/modules/catalogue/results.tt | 4 ++ .../prog/js/acquisitions-menu.js | 8 ++- 4 files changed, 75 insertions(+), 5 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index ebb78bcfb6e..bcd72a5fe41 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -223,10 +223,11 @@ if($cgi->cookie("holdforclub")){ } if($cgi->cookie("searchToOrder")){ - my ( $basketno, $vendorid ) = split( /\//, $cgi->cookie("searchToOrder") ); + my ( $basketno, $vendorid, $ordernumber ) = split( /\//, $cgi->cookie("searchToOrder") ); $template->param( - searchtoorder_basketno => $basketno, - searchtoorder_vendorid => $vendorid + searchtoorder_basketno => $basketno, + searchtoorder_vendorid => $vendorid, + searchtoorder_ordernumber => $ordernumber, ); } 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 f5e2004eefc..05e7f5aa577 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -723,6 +723,8 @@ Modify
Transfer +
+ Link to different record [% END %] [% END %] @@ -885,6 +887,47 @@ [% END # /UNLESS ( closedate ) %] + + + [% END # /IF ( delete_confirmed ) %] [% END # /IF ( NO_BOOKSELLER ) %] [% ELSE %] @@ -1106,6 +1149,24 @@ $(this).find("legend").html(legend); $(this).find("input:text").focus(); }); + + $(".relink_order").click(function(){ + var basket = $(this).data("basketname"); + var ordernumber = $(this).data("ordernumber"); + var legend = _("Relink order no. %s in basket %s").format(ordernumber, basket); + $("#relinkOrder").find("h4").text( legend ); + $("#relinkOrder").find("legend").html(legend); + $("#relinkOrder").find("input:text").focus(); + $("#relinkOrder").find("input[id='searchtoorder']").attr("data-ordernumber", ordernumber); + $("#relinkOrder a").each(function() { + var link = $(this).attr("href"); + if ( link.indexOf("duplicate_orders") >= 0 ) { + $(this).attr("href", link + "&linking_ordernumber=" + ordernumber); + } else { + $(this).attr("href", link + "&ordernumber=" + ordernumber); + } + }); + }); }); 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 17765ebe5d8..4766b946486 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -591,7 +591,11 @@ [% IF ( CAN_user_acquisition_order_manage ) %] [% IF ( searchtoorder_basketno && searchtoorder_vendorid ) %] + [% IF searchtoorder_ordernumber %] + | Relink to order + [% ELSE %] | Add order + [% END %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js b/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js index 313ae0f5ef9..a1f5ca400cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/acquisitions-menu.js @@ -1,8 +1,11 @@ -function searchToOrder( basketno, vendorid ){ +function searchToOrder( basketno, vendorid, ordernumber ){ var date = new Date(); var cookieData = ""; date.setTime(date.getTime() + (10 * 60 * 1000)); cookieData += basketno + "/" + vendorid; + if ( ordernumber ) { + cookieData += "/" + ordernumber; + } Cookies.set("searchToOrder", cookieData, { path: "/", expires: date, sameSite: 'Lax' }); } @@ -15,6 +18,7 @@ $(document).ready(function() { $("body").on("click", "#searchtoorder", function(){ var vendorid = $(this).data("booksellerid"); var basketno = $(this).data("basketno"); - searchToOrder( basketno, vendorid ); + var ordernumber = $(this).data("ordernumber"); + searchToOrder( basketno, vendorid, ordernumber ); }); }); -- 2.39.2