From c2461cf1719a46d8a293167955940daf11ad6f8e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Mar 2014 11:17:18 +0100 Subject: [PATCH] Bug 7288: (follow-up) set a boolean if the invoice if linked to subscriptions If an invoice is linked to subscription, we need to set a boolean to true in order to filter them in the interface. Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 7 +++++++ koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt | 5 ++--- t/db_dependent/Acquisition/Invoices.t | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index c7d0951e06..a5979371b0 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2587,6 +2587,13 @@ sub GetInvoices { NULL ) ) AS receivedbiblios, + COUNT( + DISTINCT IF( + aqorders.subscriptionid IS NOT NULL, + aqorders.subscriptionid, + NULL + ) + ) AS is_linked_to_subscriptions, SUM(aqorders.quantityreceived) AS receiveditems FROM aqinvoices LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid 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 21625a5a21..8f0c21d873 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -12,7 +12,6 @@ $(document).ready(function() { var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, { sDom: "t", bPaginate: false, - bFilter: false, bInfo: false, "aoColumns": [ null,null,null,{ "sType": "title-string" },null,null,null,null @@ -27,7 +26,7 @@ $(document).ready(function() { $("#show_only_subscription").click(function(){ if ( $(this).attr("checked") ) { - resultst.fnFilter( "[0-9]+", 0, true ); + resultst.fnFilter( "1", 0, true ); } else { resultst.fnFilter( '', 0 ); } @@ -121,7 +120,7 @@ $(document).ready(function() { [% FOREACH invoice IN invoices %] - [% invoice.subscriptionid %] + [% invoice.is_linked_to_subscriptions %] [% invoice.invoicenumber %] [% invoice.suppliername %] diff --git a/t/db_dependent/Acquisition/Invoices.t b/t/db_dependent/Acquisition/Invoices.t index 3b86a545ba..3862926724 100644 --- a/t/db_dependent/Acquisition/Invoices.t +++ b/t/db_dependent/Acquisition/Invoices.t @@ -179,6 +179,13 @@ DelInvoice($invoiceid3); is(scalar @invoices, $invoicecount - 1, 'DelInvoice deletes invoice'); is(GetInvoice($invoiceid3), undef, 'DelInvoice deleted correct invoice'); +my @invoices_linked_to_subscriptions = map{ + $_->{linked_to_subscriptions} + ? $_ + : () +} @invoices; +is_deeply( \@invoices_linked_to_subscriptions, [], "GetInvoices return linked_to_subscriptions: there is no invoices linked to subscriptions yet" ) + END { $dbh and $dbh->rollback; } -- 2.39.5