@@ -, +, @@ --- C4/Circulation.pm | 42 ++++++++------- catalogue/detail.pl | 2 +- circ/returns.pl | 59 ++++++++++++---------- .../atomicupdate/bug_19532_-_add_recalls_table.sql | 2 +- installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/circ/recalls_waiting.tt | 6 +-- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 12 +++-- .../opac-tmpl/bootstrap/en/modules/opac-recall.tt | 6 ++- .../opac-tmpl/bootstrap/en/modules/opac-recalls.tt | 4 +- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 4 +- opac/opac-detail.pl | 5 +- opac/opac-recall.pl | 24 ++++++--- opac/opac-user.pl | 2 +- 13 files changed, 100 insertions(+), 70 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -346,19 +346,8 @@ sub transferbook { $messages->{'WasReturned'} = $issue->borrowernumber; } - # find reserves..... - # That'll save a database query. - my ( $resfound, $resrec, undef ) = - CheckReserves( $itemnumber ); - if ( $resfound and not $ignoreRs ) { - $resrec->{'ResFound'} = $resfound; - - # $messages->{'ResFound'} = $resrec; - $dotransfer = 1; - } - # check if item has been recalled. do a transfer if the recall branch is different to the item holding branch, otherwise don't do a transfer - my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, status => 'R' }); + my $recall = Koha::Recalls->find({ itemnumber => $item->itemnumber, old => undef }); if (defined $recall){ if ($recall->branchcode eq $fbr){ $dotransfer = 0; @@ -366,6 +355,14 @@ sub transferbook { } else { $dotransfer = 1; } + } else { #recalls take priority over holds, only check holds if no recalls + # find reserves..... + my ( $resfound, $resrec, undef ) = CheckReserves( $itemnumber ); + if ( $resfound and not $ignoreRs ) { + $resrec->{'ResFound'} = $resfound; + # $messages->{'ResFound'} = $resrec; + $dotransfer = 1; + } } #actually do the transfer.... @@ -1380,7 +1377,7 @@ sub AddIssue { # Check if a recall if ( C4::Context->preference('UseRecalls') ) { - my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'} }); + my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, borrowernumber => $borrower->{'borrowernumber'}, old => undef }); if (defined $recall) { $recall->update({ status => "F", old => 1 }); } @@ -2034,21 +2031,22 @@ sub AddReturn { } } - # find reserves..... - # if we don't have a reserve with the status W, we launch the Checkreserves routine my ($resfound, $resrec); - my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds - ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); - if ($resfound) { - $resrec->{'ResFound'} = $resfound; - $messages->{'ResFound'} = $resrec; - } # find recalls..... - my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} }); + my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'}, old => undef }); if (defined $recall){ $messages->{'RecallFound'} = 1; $messages->{'Recall'} = $recall; + } else { + # find reserves..... + # if we don't have a reserve with the status W, we launch the Checkreserves routine + my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds + ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); + if ($resfound) { + $resrec->{'ResFound'} = $resfound; + $messages->{'ResFound'} = $resrec; + } } # Record the fact that this book was returned. --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -334,7 +334,7 @@ foreach my $item (@items) { } } - my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber} }); + my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef }); if (defined $recall){ $item->{recalled} = 1; $item->{recall} = $recall; --- a/circ/returns.pl +++ a/circ/returns.pl @@ -190,29 +190,35 @@ if ( $query->param('reserve_id') ) { } if ( $query->param('recall_id') ){ - my $recall = Koha::Recalls->find(scalar $query->param('recall_id')); + my $recall = Koha::Recalls->find( $query->param('recall_id') ); my $recall_borrower = $recall->patron; my $item = Koha::Items->find($recall->itemnumber); my $biblio = Koha::Biblios->find($item->biblionumber); - my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch }); - my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay'); - my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time ); - $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate }); - - # send notice to user who requested recall to pick up item - my $letter = C4::Letters::GetPreparedLetter ( - module => 'circulation', - letter_code => 'PICKUP_RECALLED_ITEM', - branchcode => $recall->branchcode, - tables => { - 'biblio', $biblio->biblionumber, - 'borrowers', $recall_borrower->borrowernumber, - 'items', $item->itemnumber, - 'recalls', $recall->recall_id, - }, - ); - C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email'); + if( $query->param("transfer_recall") ){ + $recall->update({ status => 'T', waitingdate => undef, expirationdate => undef }); + } else { + my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch }); + my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay'); + my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time ); + $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate }); + # send notice to user who requested recall to pick up item + my $letter = C4::Letters::GetPreparedLetter ( + module => 'circulation', + letter_code => 'PICKUP_RECALLED_ITEM', + branchcode => $recall->branchcode, + tables => { + 'biblio', + $biblio->biblionumber, + 'borrowers', + $recall_borrower->borrowernumber, + 'items', $item->itemnumber, + 'recalls', + $recall->recall_id, + }, + ); + C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email'); + } } my $borrower; @@ -513,13 +519,14 @@ if ( $messages->{'RecallFound'} ){ found => 1, recalled => 1, recall => $recall, - address => $patron->address, - address2 => $patron->address2, - streetnumber => $patron->streetnumber, - city => $patron->city, - zipcode => $patron->zipcode, - state => $patron->state, - country => $patron->country, + transfer_recall => ($userenv_branch eq $recall->branchcode ? 1 : 0 ) +# address => $patron->address, +# address2 => $patron->address2, +# streetnumber => $patron->streetnumber, +# city => $patron->city, +# zipcode => $patron->zipcode, +# state => $patron->state, +# country => $patron->country, ); } --- a/installer/data/mysql/atomicupdate/bug_19532_-_add_recalls_table.sql +++ a/installer/data/mysql/atomicupdate/bug_19532_-_add_recalls_table.sql @@ -9,7 +9,7 @@ CREATE TABLE `recalls` ( -- information related to recalls in Koha `cancellationdate` date default NULL, -- the date this recall was cancelled `recallnotes` mediumtext, -- notes related to this recall `priority` smallint(6) default NULL, -- where in the queue the patron sits - `status` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, C=cancelled, F=finished/completed + `status` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, C=cancelled, F=finished/completed, T=transferring `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1883,7 +1883,7 @@ CREATE TABLE `recalls` ( -- information related to recalls in Koha `cancellationdate` date default NULL, -- the date this recall was cancelled `recallnotes` mediumtext, -- notes related to this recall `priority` smallint(6) default NULL, -- where in the queue the patron sits - `found` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, E=expired, F=finished/completed + `found` varchar(1) default NULL, -- a one letter code defining what the status is of the recall is after it has been requested. R=requested, O=overdue, W=awaiting pickup, T=transferring, E=expired, F=finished/completed `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this recall was last updated `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the recall request was placed on `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt @@ -45,8 +45,8 @@
Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') %] days.
[% END %]