From 4a3cfe64119e127ac78662c8af233dd0e7136e73 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 22 Oct 2018 15:20:45 +0000 Subject: [PATCH] Bug 21628: Simplify holds awating pickup report To test: 1 - Place a number of holds 2 - Check in the items and confirm the holds 3 - Visit /cgi-bin/koha/circ/waitingreserves.pl 4 - View the report 5 - Apply patch 6 - Confirm that the report looks the same 7 - Confirm cancelling holds works as before --- circ/waitingreserves.pl | 58 ++---------- .../prog/en/includes/waiting_holds.inc | 51 ++++++++++ .../prog/en/modules/circ/waitingreserves.tt | 104 +-------------------- 3 files changed, 64 insertions(+), 149 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index aae9cbe..c78884f 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -81,69 +81,30 @@ if ( C4::Context->preference('IndependentBranches') ) { } $template->param( all_branches => 1 ) if $all_branches; -my (@reservloop, @overloop); -my ($reservcount, $overcount); +my (@reserve_loop, @over_loop); # FIXME - Is priority => 0 useful? If yes it must be moved to waiting, otherwise we need to remove it from here. my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] }); + # get reserves for the branch we are logged into, or for all branches my $today = Date_to_Days(&Today); -my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); while ( my $hold = $holds->next ) { next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); - my $item = $hold->item; - my $patron = $hold->borrower; - my $biblio = $item->biblio; - my $holdingbranch = $item->holdingbranch; - my $homebranch = $item->homebranch; - - my %getreserv = ( - title => $biblio->title, - itemnumber => $item->itemnumber, - waitingdate => $hold->waitingdate, - reservedate => $hold->reservedate, - borrowernum => $patron->borrowernumber, - biblionumber => $biblio->biblionumber, - barcode => $item->barcode, - homebranch => $homebranch, - holdingbranch => $item->holdingbranch, - itemcallnumber => $item->itemcallnumber, - enumchron => $item->enumchron, - copynumber => $item->copynumber, - borrowername => $patron->surname, # FIXME Let's send $patron to the template - borrowerfirstname => $patron->firstname, - borrowerphone => $patron->phone, - ); - - my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ); - $getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? - $getreserv{'subtitle'} = GetRecordValue( - 'subtitle', - GetMarcBiblio({ biblionumber => $biblio->biblionumber }), - $biblio->frameworkcode); - if ( $homebranch ne $holdingbranch ) { - $getreserv{'dotransfer'} = 1; - } - - $getreserv{patron} = $patron; - if ($today > $calcDate) { if ($cancelall) { - my $res = cancel( $item->itemnumber, $patron->borrowernumber, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); + my $res = cancel( $hold->item->itemnumber, $hold->borrowernumber, $hold->item->holdingbranch, $hold->item->homebranch, !$transfer_when_cancel_all ); push @cancel_result, $res if $res; next; } else { - push @overloop, \%getreserv; - $overcount++; + push @over_loop, $hold; } }else{ - push @reservloop, \%getreserv; - $reservcount++; + push @reserve_loop, $hold; } } @@ -151,12 +112,11 @@ while ( my $hold = $holds->next ) { $template->param(cancel_result => \@cancel_result) if @cancel_result; $template->param( - reserveloop => \@reservloop, - reservecount => $reservcount, - overloop => \@overloop, - overcount => $overcount, + reserveloop => \@reserve_loop, + reservecount => scalar @reserve_loop, + overloop => \@over_loop, + overcount => scalar @over_loop, show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), - ReservesMaxPickUpDelay => $max_pickup_delay, tab => $tab, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc new file mode 100644 index 0000000..15274f5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc @@ -0,0 +1,51 @@ +[% USE ItemTypes %] + + + + + + + + + + + + + +[% FOREACH reserveloo IN reserveloop %] + + + + + + + + + + + + +[% END %] +
Waiting sinceDate hold placedTitlePatronHome branchCurrent locationCall numberCopy numberEnumerationAction
[% reserveloo.waitingdate | $KohaDates %][% reserveloo.reservedate | $KohaDates %][% INCLUDE 'biblio-default-view.inc' biblionumber = reserveloo.biblionumber %] + [% reserveloo.biblio.title | html %] [% FOREACH subtitl IN reserveloo.biblio.subtitles %] [% subtitl.subfield | html %][% END %] + + [% UNLESS ( item_level_itypes ) %][% IF ( ItemTypes.GetDescription(reserveloo.item.effective_itemtype) ) %]  ([% ItemTypes.GetDescription(reserveloo.item.effective_itemtype) | html %])[% END %][% END %] +
Barcode: [% reserveloo.item.barcode | html %] +
[% reserveloo.borrower.surname | html %], [% reserveloo.borrower.firstname | html %] + [% IF ( reserveloo.borrower.phone ) %]
[% reserveloo.borrower.phone | html %][% END %] + [% IF ( reserveloo.borrower.first_valid_email_address ) %]
+ [% reserveloo.borrower.first_valid_email_address | html %][% END %] +
[% Branches.GetName( reserveloo.item.homebranch ) | html %][% Branches.GetName( reserveloo.item.holdingbranch ) | html %][% reserveloo.item.itemcallnumber | html %][% reserveloo.item.copynumber | html %][% reserveloo.item.enumchron | html %] +
+ + + + + + [% IF ( reserveloo.item.homebranch != reserveloo.item.holdingbranch ) %] + + [% ELSE %] + + [% END %] +
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt index 8c44294..35a167e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -63,62 +63,13 @@
  • Holds waiting: [% reservecount | html %]
  • - Holds waiting over [% ReservesMaxPickUpDelay | html %] days: [% overcount | html %] + Holds waiting over [% Koha.Preference('ReservesMaxPickUpDelay') | html %] days: [% overcount | html %]
  • - [% IF ( reserveloop ) %] - - - - - - - - - - - - - - [% FOREACH reserveloo IN reserveloop %] - - - - - - - - - - - - - [% END %] -
    Waiting sinceDate hold placedTitlePatronHome branchCurrent locationCall numberCopy numberEnumerationAction
    [% reserveloo.waitingdate | $KohaDates %][% reserveloo.reservedate | $KohaDates %][% INCLUDE 'biblio-default-view.inc' biblionumber = reserveloo.biblionumber %] - [% reserveloo.title | html %] [% FOREACH subtitl IN reserveloo.subtitle %] [% subtitl.subfield | html %][% END %] - - [% UNLESS ( item_level_itypes ) %][% IF ( reserveloo.itemtype ) %]  ([% reserveloo.itemtype | html %])[% END %][% END %] -
    Barcode: [% reserveloo.barcode | html %] -
    [% reserveloo.patron.surname | html %], [% reserveloo.patron.firstname | html %] - [% IF ( reserveloo.patron.phone ) %]
    [% reserveloo.patron.phone | html %][% END %] - [% IF ( reserveloo.patron.first_valid_email_address ) %]
    - [% reserveloo.patron.first_valid_email_address | html %][% END %] -
    [% Branches.GetName( reserveloo.homebranch ) | html %][% Branches.GetName( reserveloo.holdingbranch ) | html %][% reserveloo.itemcallnumber | html %][% reserveloo.copynumber | html %][% reserveloo.enumchron | html %] -
    - - - - - - [% IF ( reserveloo.dotransfer ) %] - - [% ELSE %] - - [% END %] -
    -
    + [% IF ( reserveloop ) %] + [% INCLUDE waiting_holds.inc table_name='holdst' reserveloop=reserveloop %] [% ELSE %]
    No holds found.
    [% END %] @@ -140,54 +91,7 @@ Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds sypref) [% END %] - - - - - - - - - - - - - - [% FOREACH overloo IN overloop %] - - - - - - - - - - - - - [% END %] -
    Waiting sinceDate hold placedTitlePatronHome branchCurrent locationCall numberCopy numberEnumerationAction
    [% overloo.waitingdate | $KohaDates %][% overloo.reservedate | $KohaDates %][% INCLUDE 'biblio-default-view.inc' biblionumber = overloo.biblionumber %][% overloo.title | html %] - [% FOREACH subtitl IN overloo.subtitle %] [% subtitl.subfield | html %][% END %] - - [% UNLESS ( item_level_itypes ) %][% IF ( overloo.itemtype ) %]  ([% overloo.itemtype | html %])[% END %][% END %] -
    Barcode: [% overloo.barcode | html %] -
    [% overloo.patron.surname | html %], [% overloo.patron.firstname | html %]
    [% overloo.patron.phone | html %]
    - [% IF ( overloo.patron.first_valid_email_address ) %] - [% overloo.patron.first_valid_email_address | html %][% END %] -
    [% Branches.GetName( overloo.homebranch ) | html %][% Branches.GetName( overloo.holdingbranch ) | html %][% overloo.itemcallnumber | html %][% overloo.copynumber | html %][% overloo.enumchron | html %]
    - - - - - - [% IF ( overloo.dotransfer ) %] - - [% ELSE %] - - [% END %] -
    -
    + [% INCLUDE waiting_holds.inc table_name='holdso' reserveloop=overloop %] [% ELSE %]
    No holds found.
    [% END %] -- 2.1.4