From 788b59b5c54def0a49aaa182526f813f57303c31 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 | 60 +++++++++++++++++++ .../prog/en/modules/catalogue/results.tt | 4 ++ .../prog/js/acquisitions-menu.js | 8 ++- 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 6430c6ab91d..ecbf334e501 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 c815cadc757..f10b7a0d1de 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,50 @@ [% END # /UNLESS ( closedate ) %] + + + [% END # /IF ( delete_confirmed ) %] [% END # /IF ( NO_BOOKSELLER ) %] [% ELSE %] @@ -1106,6 +1152,20 @@ $(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"); + $(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 91db336895a..5d10b8fa67a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -590,7 +590,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