From a2ebbf3dcec62db23d2974c46e725b46ace5630b Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 15 Dec 2010 14:13:15 +0100 Subject: [PATCH] Bug 5873 : build_holds_queue.pl : patch to fixup with IssuingRules --- misc/cronjobs/holds/build_holds_queue.pl | 8 +++++--- opac/opac-ISBDdetail.pl | 13 +++++++++++-- opac/opac-MARCdetail.pl | 4 ++++ opac/opac-user.pl | 13 ++++++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index b02ab60..edbc4a7 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -21,6 +21,7 @@ use C4::Search; use C4::Items; use C4::Branch; use C4::Circulation; +use C4::IssuingRules; use C4::Members; use C4::Biblio; @@ -188,9 +189,10 @@ sub GetItemsAvailableToFillHoldRequestsForBib { $sth->execute(@params); my $items = $sth->fetchall_arrayref({}); - $items = [ grep { my @transfers = GetTransfers($_->{itemnumber}); $#transfers == -1; } @$items ]; - map { my $rule = GetBranchItemRule($_->{homebranch}, $_->{itype}); $_->{holdallowed} = $rule->{holdallowed}; $rule->{holdallowed} != 0 } @$items; - return [ grep { $_->{holdallowed} != 0 } @$items ]; + + my $branchfield = C4::Context->preference('HomeOrHoldingBranch'); + + return [ grep { my $rule = GetIssuingRule('*', $_->{itype}, $_->{$branchfield}); $_->{reservesallowed} = $rule->{reservesallowed}; $_->{reservesallowed} != 0 } @$items ]; } =head2 MapItemsToHoldRequests diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index e022497..02ed41e 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -53,6 +53,8 @@ use C4::Review; use C4::Serials; # uses getsubscriptionfrom biblionumber use C4::Koha; use C4::Members; # GetMember +use C4::Items; +use C4::Reserves; use C4::External::Amazon; my $query = CGI->new(); @@ -68,7 +70,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $biblionumber = $query->param('biblionumber'); -$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') ); $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); my $marcflavour = C4::Context->preference("marcflavour"); @@ -122,6 +123,15 @@ $template->param( ); my $norequests = 1; +## Check if an item Can be holds on shelf +$template->param(C4::Search::enabled_opac_search_views); +my @all_items = &GetItemsInfo( $biblionumber, 'opac' ); +my $allowonshelfholds = 0; +for my $item (@all_items){ + $allowonshelfholds = 1 if(CanHoldOnShelf($item->{itemnumber}) and not $allowonshelfholds); +} +$template->param( 'AllowOnShelfHolds' => $allowonshelfholds ); + my $res = GetISBDView($biblionumber, "opac"); my @items = &GetItemsInfo($biblionumber, 'opac'); @@ -148,7 +158,6 @@ foreach ( @$reviews ) { $template->param( RequestOnOpac => C4::Context->preference("RequestOnOpac"), - AllowOnShelfHolds => C4::Context->preference('AllowOnShelfHolds'), norequests => $norequests, ISBD => $res, biblionumber => $biblionumber, diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index fd909f5..bfd288f 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -49,6 +49,8 @@ use C4::Output; use CGI; use MARC::Record; use C4::Biblio; +use C4::Items; #qw/GetItemsInfo GetItemsCount/; +use C4::Reserves qw/CanHoldOnShelf/; use C4::Acquisition; use C4::Koha; @@ -82,6 +84,8 @@ $template->param( $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') ); $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); +$template->param( 'ItemsCount' => GetItemsCount( $biblionumber ) ); +$template->param(C4::Search::enabled_opac_search_views); # adding the $RequestOnOpac param my $RequestOnOpac; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 634b77a..7c2910e 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -24,7 +24,7 @@ use CGI; use C4::Auth; use C4::Koha; use C4::Circulation; -use C4::Reserves; +use C4::Reserves;# qw/GetMaxPickupDate GetReservesFromBorrowernumber/; use C4::Members; use C4::Output; use C4::Biblio; @@ -32,6 +32,7 @@ use C4::Items; use C4::Dates qw/format_date/; use C4::Letters; use C4::Branch; # GetBranches +use C4::Overdues qw/CheckBorrowerDebarred/; my $query = new CGI; @@ -64,7 +65,7 @@ for (qw(dateenrolled dateexpiry dateofbirth)) { } $borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); -if ( $borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { +if ( CheckBorrowerDebarred($borrowernumber) || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { $borr->{'flagged'} = 1; } @@ -183,6 +184,7 @@ $template->param( branchloop => \@branch_loop ); # now the reserved items.... my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); foreach my $res (@reserves) { + warn $res->{'waitingdate'}; $res->{'reservedate'} = format_date( $res->{'reservedate'} ); if ( $res->{'expirationdate'} ne '0000-00-00' ) { @@ -193,7 +195,12 @@ foreach my $res (@reserves) { my $publictype = $res->{'publictype'}; $res->{$publictype} = 1; - $res->{'waiting'} = 1 if $res->{'found'} eq 'W'; + if ($res->{'found'} eq 'W'){ + $res->{'waiting'} = 1; + my @maxpickupdate = $res->{'waitingdate'} ? GetMaxPickupDate( $res->{'waitingdate'}, $borrowernumber, $res ) : ''; + $res->{'maxpickupdate'} = sprintf("%d-%02d-%02d", @maxpickupdate); + $res->{'formattedwaitingdate'} = format_date($res->{'maxpickupdate'}); + } $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'}; my $biblioData = GetBiblioData($res->{'biblionumber'}); $res->{'reserves_title'} = $biblioData->{'title'}; -- 1.7.1