From 76653e8d1c729764f76c6dc366c55a6eebe4bcb0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 25 Nov 2019 12:58:24 +0100 Subject: [PATCH] Bug 10758: WIP Started working on this but then realised we do not have Koha::Old::Biblios classes. It is getting complicated and will put a spoke in bug 20271's wheel --- acqui/parcel.pl | 35 ++++++++++++------ .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 42 ++++++++++++---------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 9c16c9ccfe..4782454e84 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -69,6 +69,7 @@ use Koha::Acquisition::Baskets; use Koha::Acquisition::Bookseller; use Koha::Acquisition::Orders; use Koha::Biblios; +use Koha::Old::Biblios; use Koha::DateUtils; use Koha::Biblios; @@ -140,14 +141,22 @@ for my $order ( @orders ) { my %line = %{ $order }; $line{invoice} = $invoice->{invoicenumber}; - my @itemnumbers = $order_object->items->get_column('itemnumber'); + my $biblio = Koha::Biblios->find( $line{biblionumber} ); - $line{total_holds} = $biblio ? $biblio->holds->count : 0; - $line{item_holds} = $biblio ? $biblio->current_holds->search( - { - itemnumber => { -in => \@itemnumbers }, - } - )->count : 0; + if ( $biblio ) { + my @itemnumbers = $order_object->items->get_column('itemnumber'); + $line{total_holds} = $biblio->holds->count; + $line{item_holds} = $biblio->current_holds->search( + { + itemnumber => { -in => \@itemnumbers }, + } + )->count; + } else { + $biblio = Koha::Old::Biblios->find( $line{biblionumber} ); + $line{total_holds} = 0; + $line{item_holds} = 0; + } + $line{biblio} = $biblio; $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} ); $line{tax_value} = $line{tax_value_on_receiving}; @@ -244,11 +253,15 @@ unless( defined $invoice->{closedate} ) { my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $line{'ordernumber'}; my $order_object = Koha::Acquisition::Orders->find($ordernumber); - my $cnt_subscriptions = $biblio ? $biblio->subscriptions->count: 0; - my $itemcount = $biblio ? $biblio->items->count : 0; - my $holds_count = $biblio ? $biblio->holds->count : 0; my @itemnumbers = $order_object->items->get_column('itemnumber'); - my $itemholds = $biblio ? $biblio->holds->search({ itemnumber => { -in => \@itemnumbers } })->count : 0; + my ( $cnt_subscriptions, $itemcount, $holds_count, $itemholds ) = (0) x 4; + if ( $biblio ) { + $cnt_subscriptions = $biblio->subscriptions->count; + $itemcount = $biblio->items->count; + $holds_count = $biblio->holds->count; + $itemholds = $biblio->holds->search({ itemnumber => { -in => \@itemnumbers } })->count; + } + $order->{biblio} = $biblio; my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); $line{suggestionid} = $suggestion->{suggestionid}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 414844397c..bb894b1f95 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -140,13 +140,13 @@ [% loop_order.ordernumber | html %] - [% loop_order.title | html %] - [% IF ( loop_order.author ) %] by [% loop_order.author | html %][% END %] - [% IF ( loop_order.isbn ) %] – [% loop_order.isbn | html %][% END %] - [% IF ( loop_order.publishercode ) %] -
Publisher: [% loop_order.publishercode | html %] - [%- IF ( loop_order.publicationyear > 0) -%], [% loop_order.publicationyear | html %] - [%- ELSIF ( loop_order.copyrightdate > 0) -%] [% loop_order.copyrightdate | html %] + [% loop_order.biblio.title | html %] + [% IF ( loop_order.biblio.author ) %] by [% loop_order.biblio.author | html %][% END %] + [% IF ( loop_order.biblio.biblioitem ) %] – [% loop_order.biblio.biblioitem.isbn | html %][% END %] + [% IF ( loop_order.biblio.biblioitem.publishercode ) %] +
Publisher: [% loop_order.biblio.biblioitem.publishercode | html %] + [%- IF ( loop_order.biblio.biblioitem.publicationyear > 0) -%], [% loop_order.biblio.biblioitem.publicationyear | html %] + [%- ELSIF ( loop_order.biblio.copyrightdate > 0) -%] [% loop_order.biblio.copyrightdate | html %] [% END %] [% END %] [% IF ( loop_order.suggestionid ) %] @@ -167,8 +167,10 @@ [% tp('noun', 'Order') | html %]
- MARC
- Card + [% IF loop_order.biblionumber %] + MARC
+ Card + [% END %] [% loop_order.replacementprice | $Price %] [% loop_order.quantity | html %] @@ -303,13 +305,13 @@ 0 [% END %] - [% order.title | html %] - [% IF ( order.author ) %] / [% order.author | html %][% END %] - [% IF ( order.isbn ) %] - [% order.isbn | html %][% END %] - [% IF ( order.publishercode ) %] -
Publisher: [% order.publishercode | html %] - [%- IF ( order.publicationyear > 0) -%], [% order.publicationyear | html %] - [%- ELSIF ( order.copyrightdate > 0) -%] [% order.copyrightdate | html %] + [% order.biblio.title | html %] + [% IF ( order.biblio.author ) %] / [% order.biblio.author | html %][% END %] + [% IF ( order.biblio.biblioitem.isbn ) %] - [% order.biblio.biblioitem.isbn | html %][% END %] + [% IF ( order.biblio.biblioitem.publishercode ) %] +
Publisher: [% order.biblio.biblioitem.publishercode | html %] + [%- IF ( order.biblio.biblioitem.publicationyear > 0) -%], [% order.biblio.biblioitem.publicationyear | html %] + [%- ELSIF ( order.biblio.copyrightdate > 0) -%] [% order.biblio.copyrightdate | html %] [% END %] [% END %] [% IF ( order.suggestionid ) %] @@ -330,9 +332,11 @@ [% END %] - [% tp('noun', 'Order') | html %]
- MARC
- Card + [% tp('noun', 'Order') | html %]
+ [% IF order.biblionumber %] + MARC
+ Card + [% END %] [% order.replacementprice | $Price %] [% order.quantityreceived | html %] -- 2.11.0