From 5f8935a896c3e844b2b23934a19f279be728c76e Mon Sep 17 00:00:00 2001
From: Devinim <kohadevinim@devinim.com.tr>
Date: Thu, 3 Oct 2019 15:59:37 +0000
Subject: [PATCH] Bug 22773: Message appearing if any invoice selected

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 .../intranet-tmpl/prog/en/modules/acqui/invoices.tt    | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
index f19370f0a6..7c1b3cb96d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
@@ -118,10 +118,10 @@
               [% IF tab == 'closed' %]
                 <a class="submit" id="open_sel" href="#reopen_selected" data-op="reopen" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-refresh"></i> Reopen selected invoices</a>
               [% ELSE  %]
-                <a class="submit" id="close_sel" href="#close_selected" data-op="close" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close selected nvoices</a>
+                <a class="submit" id="close_sel" href="#close_selected" data-op="close" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close selected invoices</a>
               [% END %]
 
-              [% END %] <!-- invoices_table -->
+          [% END %] <!-- invoices_table -->
               <div id="invoicestabs" class="toptabs" style="clear:both;">
                   <ul class="ui-tabs-nav">
                       <li><a href="#opened">Open invoices ([% openedinvoices.size || 0 | html %])</a></li>
@@ -384,11 +384,15 @@
                 var referer = $(this).attr("data-referer");
                 var op = $(this).attr("data-op");
                 var invoice_link = "invoice.pl?op="+op;
-                $('.select-invoice:checked').each(function () {
-                    var row = $(this).parents('tr');
-                    invoice_link = invoice_link + "&amp;invoiceid="+$(row).attr('data-invoiceid');
-                });
-                window.location.href =invoice_link +"&amp;"+referer;
+                if ($('.select-invoice:checked').length) {
+                    $('.select-invoice:checked').each(function () {
+                            var row = $(this).parents('tr');
+                            invoice_link = invoice_link + "&amp;invoiceid="+$(row).attr('data-invoiceid');
+                    });
+                    window.location.href =invoice_link +"&amp;"+referer;
+                } else {
+                    alert ("Please select at least one invoice." );
+                }
             });
 
             $('.merge').click(function (ev) {
-- 
2.11.0