From 11a0146df2408195dcdf0f2e012359e705c18638 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Sun, 14 Sep 2014 12:28:15 +0300 Subject: [PATCH 4/6] Bug 12353 - Displaying the last pickup date in OPAC and staff client and waitingholds.pl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TEST PLAN: 1. Create a reservation for a Borrower with pickup branch 2. Check-in the corresponding Item in the pickup branch and confirm the hold for the Borrower 3. Go to circ/circulation.pl for the Borrower and verify that the reservation is "Waiting for pickup" 4. In the Home › Circulation › Checkouts -tab (circ/circulation.pl) and in the Home › Patrons › Patron details -tab and in the OPAC your summary and in the circ/waitingreserves.pl When looking at reserves, you will find a last pickup date -column added which has a value if the reservation is waiting for pickup. --- circ/waitingreserves.pl | 19 +++++++------------ koha-tmpl/intranet-tmpl/prog/en/js/holds.js | 1 + .../prog/en/modules/circ/circulation.tt | 1 + .../prog/en/modules/circ/waitingreserves.tt | 4 ++++ .../prog/en/modules/members/moremember.tt | 1 + .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 7 +++++++ opac/opac-user.pl | 4 ++++ svc/holds | 18 +++++++++++++++--- 8 files changed, 40 insertions(+), 15 deletions(-) diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index fb7a3d1..f4a93f0 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -31,11 +31,8 @@ use C4::Members; use C4::Biblio; use C4::Items; -use Date::Calc qw( - Today - Add_Delta_Days - Date_to_Days -); +use DateTime; + use C4::Reserves; use C4::Koha; @@ -86,7 +83,7 @@ my ($reservcount, $overcount); my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch($default); # get reserves for the branch we are logged into, or for all branches -my $today = Date_to_Days(&Today); +my $today = DateTime->now(); foreach my $num (@getreserves) { next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); @@ -106,13 +103,11 @@ foreach my $num (@getreserves) { my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'}); my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype $getreserv{'waitingdate'} = $num->{'waitingdate'}; - my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'}); - ( $waiting_year, $waiting_month, $waiting_day ) = - Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, - C4::Context->preference('ReservesMaxPickUpDelay')); - my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day ); + + my $lastpickupdate = C4::Reserves::_reserve_last_pickup_date( $num ); $getreserv{'itemtype'} = $itemtypeinfo->{'description'}; + $getreserv{'lastpickupdate'} = C4::Dates->new($lastpickupdate->ymd(), 'iso')->output(); $getreserv{'title'} = $gettitle->{'title'}; $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; $getreserv{'barcode'} = $gettitle->{'barcode'}; @@ -132,7 +127,7 @@ foreach my $num (@getreserves) { $getreserv{'borrowermail'} = $getborrower->{'emailaddress'}; } - if ($today > $calcDate) { + if ( DateTime->compare( $today,$lastpickupdate ) == 1 ) { #If today is bigger than lastpickupdate, pickup time has expired if ($cancelall) { my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); push @cancel_result, $res if $res; diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js index 73807ea..c78e3ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js @@ -10,6 +10,7 @@ $(document).ready(function() { { "mDataProp": "reservedate_formatted" }, + { "mDataProp": "lastpickupdate_formatted" }, { "mDataProp": function ( oObj ) { title = " @@ -138,6 +140,7 @@ + @@ -148,6 +151,7 @@ [% FOREACH overloo IN overloop %] + + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index ec3de30..485cefb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -493,6 +493,7 @@ + [% IF ( showpriority ) %] @@ -530,6 +531,12 @@ [% RESERVE.reservedate | $KohaDates %] +
Available sinceLast pickup date Title Patron Location

[% overloo.waitingdate | $KohaDates %]

[% overloo.lastpickupdate | $KohaDates %] [% INCLUDE 'biblio-default-view.inc' biblionumber = overloo.biblionumber %][% overloo.title |html %] [% overloo.subtitle |html %] [% UNLESS ( item_level_itypes ) %][% IF ( overloo.itemtype ) %]  ([% overloo.itemtype %])[% END %][% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index d6b95f8..6a0cde0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -506,6 +506,7 @@ function validate1(date) {
Hold dateLast pickup date Title Call number Barcode
Title Placed onLast pickup date Expires on Pick up location + + Last pickup date: + [% RESERVE.lastpickupdate | $KohaDates %] + + [% IF ( RESERVE.expirationdate ) %] diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 667ac3d..9bf9d4e 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -321,6 +321,10 @@ foreach my $res (@reserves) { } # set found to 1 if reserve is waiting for patron pickup $res->{'found'} = 1 if $res->{'found'} eq 'W'; + + my $lastpickupdate = C4::Reserves::_reserve_last_pickup_date( $res ); + $res->{'lastpickupdate'} = $lastpickupdate if $lastpickupdate; + } else { my ($transfertwhen, $transfertfrom, $transfertto) = GetTransfers( $res->{'itemnumber'} ); if ($transfertwhen) { diff --git a/svc/holds b/svc/holds index 3ff704f..a3c4a03 100755 --- a/svc/holds +++ b/svc/holds @@ -31,6 +31,7 @@ use C4::Context; use Koha::Database; use Koha::DateUtils; +use Koha::Reserves; my $input = new CGI; @@ -53,8 +54,8 @@ my $borrowernumber = $input->param('borrowernumber'); my $offset = $input->param('iDisplayStart'); my $results_per_page = $input->param('iDisplayLength'); my $sorting_direction = $input->param('sSortDir_0') || 'desc'; -my $sorting_column = $sort_columns[ $input->param('iSortCol_0') ] - || 'reservedate'; +my $sorting_column = ( $input->param('iSortCol_0') ) ? + $sort_columns[ $input->param('iSortCol_0') ] : 'reservedate'; binmode STDOUT, ":encoding(UTF-8)"; print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); @@ -106,7 +107,18 @@ while ( my $h = $holds_rs->next() ) { ) : q{}, }; - + + #Calculate the last pickup date for reservations that are waiting for pickup. + if ($hold->{waiting}) { + my $lastpickupdate = Koha::Reserves::GetLastpickupdate( $h ); + $hold->{lastpickupdate} = $lastpickupdate->ymd(); + $hold->{lastpickupdate_formatted} = C4::Dates->new($lastpickupdate->ymd(), 'iso')->output(); + } + else {#These values need to be initialized anyway for DataTables to not complain. + $hold->{lastpickupdate} = ''; + $hold->{lastpickupdate_formatted} = ''; + } + $hold->{transfered} = 0; $hold->{not_transfered} = 0; -- 1.7.9.5