From b9bc3a11f1d9398d8c44a2a80fdfa93a14285ebf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Nov 2020 11:14:45 +0100 Subject: [PATCH] Bug 24488: Simplify structure passed to the template Signed-off-by: Michal Denar Signed-off-by: Josef Moravec Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- circ/pendingreserves.pl | 36 ++++++----- .../prog/en/modules/circ/pendingreserves.tt | 64 ++++++++++--------- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 9cad99ab8f..69477bf6da 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -222,10 +222,11 @@ my $patrons_count = { } }; -# make final reserves hash and fill with info -my $reserves; +# make final holds_info array and fill with info +my @holds_info; foreach my $bibnum ( @biblionumbers ){ + my $hold_info; my $items = $all_items->{$bibnum}; # get available item types for each biblio @@ -240,39 +241,38 @@ foreach my $bibnum ( @biblionumbers ){ } )->get_column('itemtype'); } - $reserves->{$bibnum}->{itemtypes} = \@res_itemtypes; + $hold_info->{itemtypes} = \@res_itemtypes; # get available locations for each biblio - $reserves->{$bibnum}->{locations} = [ uniq map { defined $_->location ? $_->location : () } @$items ]; + $hold_info->{locations} = [ uniq map { defined $_->location ? $_->location : () } @$items ]; # get available callnumbers for each biblio - $reserves->{$bibnum}->{callnumbers} = [ uniq map { defined $_->itemcallnumber ? $_->itemcallnumber : () } @$items ]; + $hold_info->{callnumbers} = [ uniq map { defined $_->itemcallnumber ? $_->itemcallnumber : () } @$items ]; # get available enumchrons for each biblio - $reserves->{$bibnum}->{enumchrons} = [ uniq map { defined $_->enumchron ? $_->enumchron : () } @$items ]; + $hold_info->{enumchrons} = [ uniq map { defined $_->enumchron ? $_->enumchron : () } @$items ]; # get available copynumbers for each biblio - $reserves->{$bibnum}->{copynumbers} = [ uniq map { defined $_->copynumber ? $_->copynumber : () } @$items ]; + $hold_info->{copynumbers} = [ uniq map { defined $_->copynumber ? $_->copynumber : () } @$items ]; # get available barcodes for each biblio - $reserves->{$bibnum}->{barcodes} = [ uniq map { defined $_->barcode ? $_->barcode : () } @$items ]; + $hold_info->{barcodes} = [ uniq map { defined $_->barcode ? $_->barcode : () } @$items ]; # get available holding branches for each biblio - $reserves->{$bibnum}->{holdingbranches} = [ uniq map { defined $_->holdingbranch ? $_->holdingbranch : () } @$items ]; + $hold_info->{holdingbranches} = [ uniq map { defined $_->holdingbranch ? $_->holdingbranch : () } @$items ]; # items available my $items_count = scalar @$items; - $reserves->{$bibnum}->{items_count} = $items_count; + $hold_info->{items_count} = $items_count; # patrons with holds $hold_info->{patrons_count} = $patrons_count->{$bibnum}; my $pull_count = $items_count <= $patrons_count->{$bibnum} ? $items_count : $patrons_count->{$bibnum}; if ( $pull_count == 0 ) { - delete($reserves->{$bibnum}); next; } - $reserves->{$bibnum}->{pull_count} = $pull_count; + $hold_info->{pull_count} = $pull_count; # get other relevant information my $res_info = Koha::Holds->search( @@ -282,17 +282,19 @@ foreach my $bibnum ( @biblionumbers ){ alias => 'reserve' } )->next; # get first item in results - $reserves->{$bibnum}->{borrower} = $res_info->borrower; - $reserves->{$bibnum}->{item} = $res_info->item; - $reserves->{$bibnum}->{biblio} = $res_info->biblio; - $reserves->{$bibnum}->{reserve} = $res_info; + $hold_info->{patron} = $res_info->patron; + $hold_info->{item} = $res_info->item; + $hold_info->{biblio} = $res_info->biblio; + $hold_info->{hold} = $res_info; + + push @holds_info, $hold_info; } $template->param( todaysdate => $today, from => $startdate, to => $enddate, - reserves => $reserves, + holds_info => \@holds_info, "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, HoldsToPullStartDate => C4::Context->preference('HoldsToPullStartDate') || PULL_INTERVAL, HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds') || 0, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt index db0574044b..c4bdf7f901 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -47,7 +47,7 @@

Reported on [% todaysdate | $KohaDates %]

The following holds have not been filled. Please retrieve them and check them in.

- [% IF ( reserves ) %] + [% IF holds_info %] @@ -68,20 +68,24 @@ - [% FOREACH reserve IN reserves %] + [% FOREACH hold_info IN holds_info %] - [% IF ( reserve.value.borrower ) %] - - - - + [% SET patron = hold_info.patron %] + [% SET item = hold_info.item %] + [% SET hold = hold_info.hold %] + [% IF patron %] + [% SET biblio = hold_info.biblio %] + + + + [% ELSE %] @@ -91,24 +95,24 @@ [% END %]

[% reserve.value.pull_count | html %]

[% reserve.value.items_count | html %][% reserve.value.patrons_count | html %][% reserve.value.borrower.firstname | html %] [% reserve.value.borrower.surname | html %]

[% hold_info.pull_count | html %]

[% hold_info.items_count | html %][% hold_info.patrons_count | html %][% patron.firstname | html %] [% patron.surname | html %]

- [% INCLUDE 'biblio-title.inc' biblio=reserve.value.biblio link = 1 %] + [% INCLUDE 'biblio-title.inc' biblio=biblio link = 1 %]

- [% IF ( reserve.value.biblio.author ) %]

by [% reserve.value.biblio.author | html %]

[% END %] - [% IF ( reserve.value.biblio.biblioitem.editionstatement ) %]

[% reserve.value.biblio.biblioitem.editionstatement | html %]

[% END %] - [% IF ( reserve.value.biblio.biblioitem.publicationyear ) %]

[% reserve.value.biblio.biblioitem.publicationyear | html %]

[% END %] + [% IF ( biblio.author ) %]

by [% biblio.author | html %]

[% END %] + [% IF ( biblio.biblioitem.editionstatement ) %]

[% biblio.biblioitem.editionstatement | html %]

[% END %] + [% IF ( biblio.biblioitem.publicationyear ) %]

[% biblio.biblioitem.publicationyear | html %]

[% END %]
"" - [% IF ( reserve.value.holdingbranches.size ) %] + [% IF ( hold_info.holdingbranches.size ) %]
    - [% FOREACH holdingbranch IN reserve.value.holdingbranches %] + [% FOREACH holdingbranch IN hold_info.holdingbranches %]
  • [% Branches.GetName ( holdingbranch ) | html %]
  • [% END %]
[% END %]
- [% IF ( reserve.value.barcodes.size ) %] - [% SET barcode = reserve.value.barcodes.first %] - [% IF ( reserve.value.itemnumber ) %]Only [% barcode | html %][% ELSE %][% barcode | html %] or any available.[% END %] + [% IF ( hold_info.barcodes.size ) %] + [% SET barcode = hold_info.barcodes.first %] + [% IF ( hold_info.itemnumber ) %]Only [% barcode | html %][% ELSE %][% barcode | html %] or any available.[% END %] [% END %] - [% IF ( reserve.value.callnumbers.size ) %] + [% IF ( hold_info.callnumbers.size ) %]
    - [% FOREACH callnumber IN reserve.value.callnumbers %] + [% FOREACH callnumber IN hold_info.callnumbers %]
  • [% callnumber | html %]
  • @@ -117,9 +121,9 @@ [% END %]
- [% IF ( reserve.value.copynumbers.size ) %] + [% IF ( hold_info.copynumbers.size ) %]
    - [% FOREACH copyno IN reserve.value.copynumbers %] + [% FOREACH copyno IN hold_info.copynumbers %]
  • [% copyno | html %]
  • @@ -128,9 +132,9 @@ [% END %]
- [% IF ( reserve.value.enumchrons.size ) %] + [% IF ( hold_info.enumchrons.size ) %]
    - [% FOREACH enumchron IN reserve.value.enumchrons %] + [% FOREACH enumchron IN hold_info.enumchrons %]
  • [% enumchron | html %]
  • @@ -140,25 +144,25 @@
    - [% FOREACH type IN reserve.value.itemtypes %] + [% FOREACH type IN hold_info.itemtypes %]
  • [% ItemTypes.GetDescription( type ) | html %]
  • [% END %]
    - [% FOREACH loc IN reserve.value.locations %] + [% FOREACH loc IN hold_info.locations %]
  • [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => loc ) | html %]
  • [% END %]
- [% reserve.value.reserve.reservedate | $KohaDates %] in [% Branches.GetName ( reserve.value.reserve.branchcode ) | html %] + [% hold.reservedate | $KohaDates %] in [% Branches.GetName ( hold.branchcode ) | html %]
- + [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] [% IF hold_cancellation %] @@ -173,17 +177,17 @@ [% END %] - [% IF reserve.value.item.holdingbranch != reserve.value.item.homebranch %] - + [% IF item.holdingbranch != item.homebranch %] + [% ELSE %] [% END %]
[% IF Koha.Preference('CanMarkHoldsToPullAsLost') != 'do_not_allow' %] - [% IF reserve.value.reserve.itemnumber %] + [% IF hold.itemnumber %]
- + [% IF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow' %] -- 2.39.5