X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FCirculation.pm;h=1dc7a45e7515a93abdfb5df7a4b107249f379cb9;hb=ac11a5d9ff982d89ed1f00ca585e1ecb9e0195eb;hp=93bf8e1610225cfb1e12961606c1a5ca3b26af1d;hpb=fc61bd30186b0305579c5dee0a14f9d2733cd5db;p=koha.git diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 93bf8e1610..1dc7a45e75 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -826,9 +826,15 @@ sub CanBookBeIssued { $needsconfirmation{PATRON_CANT} = 1; } else { if($max_loans_allowed){ - $needsconfirmation{TOO_MANY} = 1; - $needsconfirmation{current_loan_count} = $current_loan_count; - $needsconfirmation{max_loans_allowed} = $max_loans_allowed; + if ( C4::Context->preference("AllowTooManyOverride") ) { + $needsconfirmation{TOO_MANY} = 1; + $needsconfirmation{current_loan_count} = $current_loan_count; + $needsconfirmation{max_loans_allowed} = $max_loans_allowed; + } else { + $issuingimpossible{TOO_MANY} = 1; + $issuingimpossible{current_loan_count} = $current_loan_count; + $issuingimpossible{max_loans_allowed} = $max_loans_allowed; + } } } @@ -890,8 +896,10 @@ sub CanBookBeIssued { if ( C4::Context->preference("IndependentBranches") ) { my $userenv = C4::Context->userenv; if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { - $issuingimpossible{ITEMNOTSAMEBRANCH} = 1 - if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ); + if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){ + $issuingimpossible{ITEMNOTSAMEBRANCH} = 1; + $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")}; + } $needsconfirmation{BORRNOTSAMEBRANCH} = GetBranchName( $borrower->{'branchcode'} ) if ( $borrower->{'branchcode'} ne $userenv->{branch} ); } @@ -1785,21 +1793,36 @@ sub AddReturn { } if ($borrowernumber) { - if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){ + if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){ # we only need to calculate and change the fines if we want to do that on return # Should be on for hourly loans - my ( $amount, $type, $unitcounttotal ) = C4::Overdues::CalcFine( $item, $borrower->{categorycode},$branch, $datedue, $today ); + my $control = C4::Context->preference('CircControl'); + my $control_branchcode = + ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} + : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} + : $issue->{branchcode}; + + my ( $amount, $type, $unitcounttotal ) = + C4::Overdues::CalcFine( $item, $borrower->{categorycode}, + $control_branchcode, $datedue, $today ); + $type ||= q{}; - if ( $amount > 0 && ( C4::Context->preference('finesMode') eq 'production' )) { - C4::Overdues::UpdateFine( - $issue->{itemnumber}, - $issue->{borrowernumber}, - $amount, $type, output_pref($datedue) - ); - } + + if ( $amount > 0 + && C4::Context->preference('finesMode') eq 'production' ) + { + C4::Overdues::UpdateFine( $issue->{itemnumber}, + $issue->{borrowernumber}, + $amount, $type, output_pref($datedue) ); + } } - MarkIssueReturned($borrowernumber, $item->{'itemnumber'}, $circControlBranch, '', $borrower->{'privacy'}); - $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? This could be the borrower hash. + + MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, + $circControlBranch, '', $borrower->{'privacy'} ); + + # FIXME is the "= 1" right? This could be the borrower hash. + $messages->{'WasReturned'} = 1; + } ModItem({ onloan => undef }, $issue->{'biblionumber'}, $item->{'itemnumber'}); @@ -2404,8 +2427,8 @@ SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )- FROM issues LEFT JOIN items USING (itemnumber) LEFT OUTER JOIN branches USING (branchcode) -WhERE returndate is NULL -AND ( TO_DAYS( NOW() )-TO_DAYS( date_due ) ) < ? +WHERE returndate is NULL +HAVING days_until_due > 0 AND days_until_due < ? END_SQL my @bind_parameters = ( $params->{'days_in_advance'} ); @@ -2463,8 +2486,9 @@ sub CanBookBeRenewed { $error = "too_many"; } - my $resstatus = C4::Reserves::GetReserveStatus($itemnumber); - if ( $resstatus eq "Waiting" or $resstatus eq "Reserved" ) { + my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber ); + + if ( $resfound ) { # '' when no hold was found $renewokay = 0; $error = "on_reserve"; } @@ -3227,28 +3251,31 @@ $code is either itemtype or collection code depending on what the pref BranchTra sub CreateBranchTransferLimit { my ( $toBranch, $fromBranch, $code ) = @_; - + return unless defined($toBranch) && defined($fromBranch); my $limitType = C4::Context->preference("BranchTransferLimitsType"); my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("INSERT INTO branch_transfer_limits ( $limitType, toBranch, fromBranch ) VALUES ( ?, ?, ? )"); - $sth->execute( $code, $toBranch, $fromBranch ); + return $sth->execute( $code, $toBranch, $fromBranch ); } =head2 DeleteBranchTransferLimits -DeleteBranchTransferLimits($frombranch); + my $result = DeleteBranchTransferLimits($frombranch); -Deletes all the branch transfer limits for one branch +Deletes all the library transfer limits for one library. Returns the +number of limits deleted, 0e0 if no limits were deleted, or undef if +no arguments are supplied. =cut sub DeleteBranchTransferLimits { my $branch = shift; + return unless defined $branch; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("DELETE FROM branch_transfer_limits WHERE fromBranch = ?"); - $sth->execute($branch); + return $sth->execute($branch); } sub ReturnLostItem{