From 4d139b1d980478b340e5d1bbb738e2fff8da0881 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Oct 2018 15:19:28 -0300 Subject: [PATCH] Bug 21467: Display a summary line per parent_ordernumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help to keep track of the different orders for a given subscription. Signed-off-by: Séverine QUEUNE --- .../prog/en/modules/serials/subscription-detail.tt | 48 ++++++++++++++++------ serials/subscription-detail.pl | 18 +++++++- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index 3dfc172..50174ac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -333,7 +333,7 @@ - [% IF orders %] + [% IF orders_grouped %]

Acquisition details

@@ -360,12 +360,39 @@ - [% FOR order IN orders %] - [% IF order.parent_ordernumber != order.ordernumber %] - - [% ELSE %] - - [% END %] + [% FOR ordernumber IN orders_grouped.keys %] + [% SET parent_tree_id = loop.count %] + [% SET parent_order = orders_grouped.$ordernumber %] + + [%# invoice %] + + [%# ordernumber %] + + + + [%# internalnote %] + [%# vendornote %] + [%# fund %] + + + + + [% FOR order IN parent_order.orders %] + - + [%# basket %] @@ -409,6 +432,7 @@ [% END %] + [% END %] [% END %]
+ [% IF CAN_user_acquisition_order_manage %] + [% parent_order.basket.basketname | html %] ([% parent_order.basket.basketno | html %]) + [% ELSE %] + [% parent_order.basket.basketname | html %] ([% parent_order.basket.basketno | html %]) + [% END %] + [% parent_order.basket.creationdate | $KohaDates %][% parent_order.datereceived | $KohaDates %] + [% SWITCH parent_order.orderstatus %] + [% CASE 'new' %]New + [% CASE 'ordered' %]Ordered + [% CASE 'partial' %]Partial + [% CASE 'complete' %]Complete + [% CASE 'cancelled' %]Cancelled + [% END %] + [% parent_order.quantity | html %][% parent_order.ecost_tax_excluded | $Price %] / [% parent_order.ecost_tax_included | $Price %][% parent_order.unitprice_tax_excluded | $Price %] / [% parent_order.unitprice_tax_included | $Price %]
[% IF order.invoice %] [% IF CAN_user_acquisition %] @@ -376,11 +403,7 @@ [% END %] [% END %] [% IF CAN_user_acquisition_order_manage %] - [% order.basket.basketname | html %] ([% order.basketno | html %]) - [% ELSE %] - [% order.basket.basketname | html %] ([% order.basketno | html %]) - [% END %][% order.ordernumber | html %] [% order.basket.creationdate | $KohaDates%] [% IF order.datereceived %][% order.datereceived | $KohaDates %][% END %]
diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 9c64af6..69aa799 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -125,7 +125,21 @@ for my $field ( @$additional_fields ) { $template->param( additional_fields_for_subscription => $additional_fields ); # FIXME Do we want to hide canceled orders? -my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => { -desc => 'parent_ordernumber' } } ); +my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => [ { -desc => 'timestamp' }, \[ "field(orderstatus, 'ordered', 'partial', 'complete')" ] ] } ); +my $orders_grouped; +while ( my $o = $orders->next ) { + if ( $o->ordernumber == $o->parent_ordernumber ) { + $orders_grouped->{$o->parent_ordernumber}->{datereceived} = $o->datereceived; + $orders_grouped->{$o->parent_ordernumber}->{orderstatus} = $o->orderstatus; + $orders_grouped->{$o->parent_ordernumber}->{basket} = $o->basket; + } + $orders_grouped->{$o->parent_ordernumber}->{quantity} += $o->quantity; + $orders_grouped->{$o->parent_ordernumber}->{ecost_tax_excluded} += sprintf('%.2f', $o->ecost_tax_excluded * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{ecost_tax_included} += sprintf('%.2f', $o->ecost_tax_included * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{unitprice_tax_excluded} += sprintf('%.2f', $o->unitprice_tax_excluded * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{unitprice_tax_included} += sprintf('%.2f', $o->unitprice_tax_included * $o->quantity); + push @{$orders_grouped->{$o->parent_ordernumber}->{orders}}, $o; +} $template->param( subscriptionid => $subscriptionid, @@ -143,7 +157,7 @@ $template->param( intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'), irregular_issues => scalar @irregular_issues, default_bib_view => $default_bib_view, - orders => $orders, + orders_grouped => $orders_grouped, (uc(C4::Context->preference("marcflavour"))) => 1, ); -- 2.1.4