@@ -, +, @@ with rental fees --- C4/Circulation.pm | 458 ++++++++++---------- installer/data/mysql/sysprefs.sql | 2 +- .../prog/en/modules/circ/circulation.tt | 4 +- 3 files changed, 231 insertions(+), 233 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -61,56 +61,56 @@ use Date::Calc qw( use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); BEGIN { - require Exporter; - $VERSION = 3.07.00.049; # for version checking - @ISA = qw(Exporter); + require Exporter; + $VERSION = 3.07.00.049; # for version checking + @ISA = qw(Exporter); - # FIXME subs that should probably be elsewhere - push @EXPORT, qw( - &barcodedecode + # FIXME subs that should probably be elsewhere + push @EXPORT, qw( + &barcodedecode &LostItem &ReturnLostItem - ); - - # subs to deal with issuing a book - push @EXPORT, qw( - &CanBookBeIssued - &CanBookBeRenewed - &AddIssue - &AddRenewal - &GetRenewCount + ); + + # subs to deal with issuing a book + push @EXPORT, qw( + &CanBookBeIssued + &CanBookBeRenewed + &AddIssue + &AddRenewal + &GetRenewCount &GetSoonestRenewDate - &GetItemIssue - &GetItemIssues - &GetIssuingCharges - &GetIssuingRule + &GetItemIssue + &GetItemIssues + &GetIssuingCharges + &GetIssuingRule &GetBranchBorrowerCircRule &GetBranchItemRule - &GetBiblioIssues - &GetOpenIssue - &AnonymiseIssueHistory + &GetBiblioIssues + &GetOpenIssue + &AnonymiseIssueHistory &CheckIfIssuedToPatron &IsItemIssued - ); + ); - # subs to deal with returns - push @EXPORT, qw( - &AddReturn + # subs to deal with returns + push @EXPORT, qw( + &AddReturn &MarkIssueReturned - ); - - # subs to deal with transfers - push @EXPORT, qw( - &transferbook - &GetTransfers - &GetTransfersFromTo - &updateWrongTransfer - &DeleteTransfer + ); + + # subs to deal with transfers + push @EXPORT, qw( + &transferbook + &GetTransfers + &GetTransfersFromTo + &updateWrongTransfer + &DeleteTransfer &IsBranchTransferAllowed &CreateBranchTransferLimit &DeleteBranchTransferLimits &TransferSlip - ); + ); # subs to deal with offline circulation push @EXPORT, qw( @@ -146,11 +146,11 @@ Generic filter function for barcode string. Called on every circ if the System Pref itemBarcodeInputFilter is set. Will do some manipulation of the barcode for systems that deliver a barcode to circulation.pl that differs from the barcode stored for the item. -For proper functioning of this filter, calling the function on the +For proper functioning of this filter, calling the function on the correct barcode string (items.barcode) should return an unaltered barcode. -The optional $filter argument is to allow for testing or explicit -behavior that ignores the System Pref. Valid values are the same as the +The optional $filter argument is to allow for testing or explicit +behavior that ignores the System Pref. Valid values are the same as the System Pref options. =cut @@ -163,30 +163,30 @@ sub barcodedecode { my $branch = C4::Branch::mybranch(); $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter; $filter or return $barcode; # ensure filter is defined, else return untouched barcode - if ($filter eq 'whitespace') { - $barcode =~ s/\s//g; - } elsif ($filter eq 'cuecat') { - chomp($barcode); - my @fields = split( /\./, $barcode ); - my @results = map( decode($_), @fields[ 1 .. $#fields ] ); - ($#results == 2) and return $results[2]; - } elsif ($filter eq 'T-prefix') { - if ($barcode =~ /^[Tt](\d)/) { - (defined($1) and $1 eq '0') and return $barcode; + if ($filter eq 'whitespace') { + $barcode =~ s/\s//g; + } elsif ($filter eq 'cuecat') { + chomp($barcode); + my @fields = split( /\./, $barcode ); + my @results = map( decode($_), @fields[ 1 .. $#fields ] ); + ($#results == 2) and return $results[2]; + } elsif ($filter eq 'T-prefix') { + if ($barcode =~ /^[Tt](\d)/) { + (defined($1) and $1 eq '0') and return $barcode; $barcode = substr($barcode, 2) + 0; # FIXME: probably should be substr($barcode, 1) - } + } return sprintf("T%07d", $barcode); # FIXME: $barcode could be "T1", causing warning: substr outside of string # Why drop the nonzero digit after the T? # Why pass non-digits (or empty string) to "T%07d"? - } elsif ($filter eq 'libsuite8') { - unless($barcode =~ m/^($branch)-/i){ #if barcode starts with branch code its in Koha style. Skip it. - if($barcode =~ m/^(\d)/i){ #Some barcodes even start with 0's & numbers and are assumed to have b as the item type in the libsuite8 software + } elsif ($filter eq 'libsuite8') { + unless($barcode =~ m/^($branch)-/i){ #if barcode starts with branch code its in Koha style. Skip it. + if($barcode =~ m/^(\d)/i){ #Some barcodes even start with 0's & numbers and are assumed to have b as the item type in the libsuite8 software $barcode =~ s/^[0]*(\d+)$/$branch-b-$1/i; }else{ - $barcode =~ s/^(\D+)[0]*(\d+)$/$branch-$1-$2/i; - } - } + $barcode =~ s/^(\D+)[0]*(\d+)$/$branch-$1-$2/i; + } + } } elsif ($filter eq 'EAN13') { my $ean = CheckDigits('ean'); if ( $ean->is_valid($barcode) ) { @@ -195,7 +195,7 @@ sub barcodedecode { } else { warn "# [$barcode] not valid EAN-13/UPC-A\n"; } - } + } return $barcode; # return barcode, modified or not } @@ -240,7 +240,7 @@ sub decode { =head2 transferbook - ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, + ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, $barcode, $ignore_reserves); Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer. @@ -256,7 +256,7 @@ Returns three values: =over -=item $dotransfer +=item $dotransfer is true if the transfer was successful. @@ -325,7 +325,7 @@ sub transferbook { } elsif ( ! IsBranchTransferAllowed( $tbr, $fbr, $biblio->{ C4::Context->preference("BranchTransferLimitsType") } ) ) { $messages->{'NotAllowed'} = $tbr . "::" . $biblio->{ C4::Context->preference("BranchTransferLimitsType") }; $dotransfer = 0; - } + } } # if is permanent... @@ -373,16 +373,16 @@ sub transferbook { sub TooMany { my $borrower = shift; my $biblionumber = shift; - my $item = shift; + my $item = shift; my $cat_borrower = $borrower->{'categorycode'}; my $dbh = C4::Context->dbh; - my $branch; - # Get which branchcode we need - $branch = _GetCircControlBranch($item,$borrower); - my $type = (C4::Context->preference('item-level_itypes')) - ? $item->{'itype'} # item-level - : $item->{'itemtype'}; # biblio-level - + my $branch; + # Get which branchcode we need + $branch = _GetCircControlBranch($item,$borrower); + my $type = (C4::Context->preference('item-level_itypes')) + ? $item->{'itype'} # item-level + : $item->{'itemtype'}; # biblio-level + # given branch, patron category, and item type, determine # applicable issuing rule my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch); @@ -407,8 +407,8 @@ sub TooMany { AND (categorycode = ? OR categorycode = ?) AND itemtype <> '*' ) "; - } else { - $count_query .= " JOIN biblioitems USING (biblionumber) + } else { + $count_query .= " JOIN biblioitems USING (biblionumber) WHERE biblioitems.itemtype NOT IN ( SELECT itemtype FROM issuingrules WHERE branchcode = ? @@ -424,8 +424,8 @@ sub TooMany { # specific item type if (C4::Context->preference('item-level_itypes')) { $count_query .= " WHERE items.itype = ? "; - } else { - $count_query .= " JOIN biblioitems USING (biblionumber) + } else { + $count_query .= " JOIN biblioitems USING (biblionumber) WHERE biblioitems.itemtype= ? "; } push @bind_params, $type; @@ -598,7 +598,7 @@ sub itemissues { =head2 CanBookBeIssued - ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, + ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode, $duedatespec, $inprocess, $ignore_reserves ); Check if a book can be issued. @@ -627,7 +627,7 @@ Possible values are : =back -=head3 INVALID_DATE +=head3 INVALID_DATE sticky due date is invalid @@ -659,7 +659,7 @@ item withdrawn. item is restricted (set by ??) -C<$needsconfirmation> a reference to a hash. It contains reasons why the loan +C<$needsconfirmation> a reference to a hash. It contains reasons why the loan could be prevented, but ones that can be overriden by the operator. Possible values are : @@ -698,15 +698,15 @@ sub CanBookBeIssued { my $item = GetItem(GetItemnumberFromBarcode( $barcode )); my $issue = GetItemIssue($item->{itemnumber}); - my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); - $item->{'itemtype'}=$item->{'itype'}; + my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); + $item->{'itemtype'}=$item->{'itype'}; my $dbh = C4::Context->dbh; # MANDATORY CHECKS - unless item exists, nothing else matters unless ( $item->{barcode} ) { $issuingimpossible{UNKNOWN_BARCODE} = 1; } - return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; + return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; # # DUE DATE is OK ? -- should already have checked. @@ -738,8 +738,8 @@ sub CanBookBeIssued { # # BORROWER STATUS # - if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { - # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . + if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { + # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}, undef, $item->{'ccode'}); ModDateLastSeen( $item->{'itemnumber'} ); return( { STATS => 1 }, {}); @@ -809,12 +809,12 @@ sub CanBookBeIssued { my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'}); if ($blocktype == -1) { ## patron has outstanding overdue loans - if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ - $issuingimpossible{USERBLOCKEDOVERDUE} = $count; - } - elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ - $needsconfirmation{USERBLOCKEDOVERDUE} = $count; - } + if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ + $issuingimpossible{USERBLOCKEDOVERDUE} = $count; + } + elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ + $needsconfirmation{USERBLOCKEDOVERDUE} = $count; + } } elsif($blocktype == 1) { # patron has accrued fine days $issuingimpossible{USERBLOCKEDREMAINING} = $count; @@ -823,7 +823,7 @@ sub CanBookBeIssued { # # JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS # - my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item ); + my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item ); # if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book if (defined $max_loans_allowed && $max_loans_allowed == 0) { $needsconfirmation{PATRON_CANT} = 1; @@ -906,17 +906,15 @@ sub CanBookBeIssued { if ( $borrower->{'branchcode'} ne $userenv->{branch} ); } } - + # # CHECK IF THERE IS RENTAL CHARGES. RENTAL MUST BE CONFIRMED BY THE BORROWER - my $sth = $dbh->prepare("SELECT rentalcharge FROM itemtypes WHERE itemtype = ?"); - $sth->execute( $item->{'itemtype'} ); - my $rentalCharge = $sth->fetchrow(); + # + my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); - if ( $rentalCharge && $rentalConfirmation ) + if ( $rentalConfirmation && $rentalCharge != 0 ) { - $rentalCharge = sprintf("%.02f \$", $rentalCharge); - $rentalCharge =~ s/\./,/; + $rentalCharge = sprintf("%.02f", $rentalCharge); $needsconfirmation{RENTALCHARGE} = $rentalCharge; } @@ -1191,7 +1189,7 @@ AddIssue does the following things : sub AddIssue { my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; my $dbh = C4::Context->dbh; - my $barcodecheck=CheckValidBarcode($barcode); + my $barcodecheck=CheckValidBarcode($barcode); if ($datedue && ref $datedue ne 'DateTime') { $datedue = dt_from_string($datedue); } @@ -1205,48 +1203,48 @@ sub AddIssue { } } - if ($borrower and $barcode and $barcodecheck ne '0'){#??? wtf - # find which item we issue - my $item = GetItem('', $barcode) or return; # if we don't get an Item, abort. - my $branch = _GetCircControlBranch($item,$borrower); - - # get actual issuing if there is one - my $actualissue = GetItemIssue( $item->{itemnumber}); - - # get biblioinformation for this item - my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); - - # - # check if we just renew the issue. - # - if ($actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}) { - $datedue = AddRenewal( - $borrower->{'borrowernumber'}, - $item->{'itemnumber'}, - $branch, - $datedue, - $issuedate, # here interpreted as the renewal date - ); - } - else { + if ($borrower and $barcode and $barcodecheck ne '0'){#??? wtf + # find which item we issue + my $item = GetItem('', $barcode) or return; # if we don't get an Item, abort. + my $branch = _GetCircControlBranch($item,$borrower); + + # get actual issuing if there is one + my $actualissue = GetItemIssue( $item->{itemnumber}); + + # get biblioinformation for this item + my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); + + # + # check if we just renew the issue. + # + if ($actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}) { + $datedue = AddRenewal( + $borrower->{'borrowernumber'}, + $item->{'itemnumber'}, + $branch, + $datedue, + $issuedate, # here interpreted as the renewal date + ); + } + else { # it's NOT a renewal - if ( $actualissue->{borrowernumber}) { - # This book is currently on loan, but not to the person - # who wants to borrow it now. mark it returned before issuing to the new borrower - AddReturn( - $item->{'barcode'}, - C4::Context->userenv->{'branch'} - ); - } + if ( $actualissue->{borrowernumber}) { + # This book is currently on loan, but not to the person + # who wants to borrow it now. mark it returned before issuing to the new borrower + AddReturn( + $item->{'barcode'}, + C4::Context->userenv->{'branch'} + ); + } MoveReserve( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $cancelreserve ); - # Starting process for transfer job (checking transfert and validate it if we have one) + # Starting process for transfer job (checking transfert and validate it if we have one) my ($datesent) = GetTransfers($item->{'itemnumber'}); if ($datesent) { - # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) + # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) my $sth = $dbh->prepare( - "UPDATE branchtransfers + "UPDATE branchtransfers SET datearrived = now(), tobranch = ?, comments = 'Forced branchtransfer' @@ -1340,7 +1338,7 @@ sub AddIssue { logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'itemnumber'}) if C4::Context->preference("IssueLog"); } - return ($datedue); # not necessarily the same as when it came in! + return ($datedue); # not necessarily the same as when it came in! } =head2 GetLoanLength @@ -1443,7 +1441,7 @@ sub GetHardDueDate { my $irule = &GetIssuingRule($borrowertype,$itemtype,branchcode) FIXME - This is a copy-paste of GetLoanLength -as a stop-gap. Do not wish to change API for GetLoanLength +as a stop-gap. Do not wish to change API for GetLoanLength this close to release. Get the issuing rule for an itemtype, a borrower type and a branch @@ -1457,7 +1455,7 @@ sub GetIssuingRule { my $sth = $dbh->prepare( "select * from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" ); my $irule; - $sth->execute( $borrowertype, $itemtype, $branchcode ); + $sth->execute( $borrowertype, $itemtype, $branchcode ); $irule = $sth->fetchrow_hashref; return $irule if defined($irule) ; @@ -1498,7 +1496,7 @@ sub GetIssuingRule { my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); Retrieves circulation rule attributes that apply to the given -branch and patron category, regardless of item type. +branch and patron category, regardless of item type. The return value is a hashref containing the following key: maxissueqty - maximum number of loans that a @@ -1506,11 +1504,11 @@ patron of the given category can have at the given branch. If the value is undef, no limit. This will first check for a specific branch and -category match from branch_borrower_circ_rules. +category match from branch_borrower_circ_rules. If no rule is found, it will then check default_branch_circ_rules (same branch, default category). If no rule is found, -it will then check default_borrower_circ_rules (default +it will then check default_borrower_circ_rules (default branch, same category), then failing that, default_circ_rules (default branch, default category). @@ -1560,7 +1558,7 @@ sub GetBranchBorrowerCircRule { if ($result = $sth->fetchrow_hashref()) { return $result; } - + # try default branch, default borrower category my $default_query = "SELECT maxissueqty FROM default_circ_rules"; @@ -1569,7 +1567,7 @@ sub GetBranchBorrowerCircRule { if ($result = $sth->fetchrow_hashref()) { return $result; } - + # built-in default circulation rule return { maxissueqty => undef, @@ -1636,7 +1634,7 @@ sub GetBranchItemRule { $result->{'holdallowed'} = $search_result->{'holdallowed'} unless ( defined $result->{'holdallowed'} ); $result->{'returnbranch'} = $search_result->{'returnbranch'} unless ( defined $result->{'returnbranch'} ); } - + # built-in default circulation rule $result->{'holdallowed'} = 2 unless ( defined $result->{'holdallowed'} ); $result->{'returnbranch'} = 'homebranch' unless ( defined $result->{'returnbranch'} ); @@ -1734,7 +1732,7 @@ sub AddReturn { my $biblio; my $doreturn = 1; my $validTransfert = 0; - my $stat_type = 'return'; + my $stat_type = 'return'; # get information on item my $itemnumber = GetItemnumberFromBarcode( $barcode ); @@ -1818,7 +1816,7 @@ sub AddReturn { if ($doreturn) { my $datedue = $issue->{date_due}; $borrower or warn "AddReturn without current borrower"; - my $circControlBranch; + my $circControlBranch; if ($dropbox) { # define circControlBranch only if dropbox mode is set # don't allow dropbox mode to create an invalid entry in issues (issuedate > today) @@ -1920,7 +1918,7 @@ sub AddReturn { if ($borrowernumber) { my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined - + if ( $issue->{overdue} && $issue->{date_due} ) { # fix fine days my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today ); @@ -1975,10 +1973,10 @@ sub AddReturn { branch => $branch, }); } - + logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) if C4::Context->preference("ReturnLog"); - + # Remove any OVERDUES related debarment if the borrower has no overdues if ( $borrowernumber && $borrower->{'debarred'} @@ -2017,7 +2015,7 @@ Unconditionally marks an issue as being returned by moving the C row to C and setting C to the current date, or the last non-holiday date of the branccode specified in -C . Assumes you've already checked that +C . Assumes you've already checked that it's safe to do this, i.e. last non-holiday > issuedate. if C<$returndate> is specified (in iso format), it is used as the date @@ -2027,7 +2025,7 @@ C<$privacy> contains the privacy parameter. If the patron has set privacy to 2, the old_issue is immediately anonymised Ideally, this function would be internal to C, -not exported, but it is currently needed by one +not exported, but it is currently needed by one routine in C. =cut @@ -2157,7 +2155,7 @@ C<$brn> borrowernumber C<$itm> itemnumber -C<$exemptfine> BOOL -- remove overdue charge associated with this issue. +C<$exemptfine> BOOL -- remove overdue charge associated with this issue. C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue. Internal function, called only by AddReturn @@ -2304,7 +2302,7 @@ sub _FixAccountForLostAndReturned { my $circ_control_branch = _GetCircControlBranch($iteminfos, $borrower); -Internal function : +Internal function : Return the library code to be used to determine which circulation policy applies to a transaction. Looks up the CircControl and @@ -2389,7 +2387,7 @@ Returns a hashref sub GetOpenIssue { my ( $itemnumber ) = @_; return unless $itemnumber; - my $dbh = C4::Context->dbh; + my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" ); $sth->execute( $itemnumber ); return $sth->fetchrow_hashref(); @@ -2479,7 +2477,7 @@ Returns reference to an array of hashes sub GetItemIssues { my ( $itemnumber, $history ) = @_; - + my $today = DateTime->now( time_zome => C4::Context->tz); # get today date $today->truncate( to => 'minute' ); my $sql = "SELECT * FROM issues @@ -2568,7 +2566,7 @@ sub GetUpcomingDueIssues { my $statement = <= 0 AND days_until_due <= ? END_SQL my @bind_parameters = ( $params->{'days_in_advance'} ); - + my $sth = $dbh->prepare( $statement ); $sth->execute( @bind_parameters ); my $upcoming_dues = $sth->fetchall_arrayref({}); @@ -2728,7 +2726,7 @@ sub AddRenewal { # of how many times it has been renewed. my $renews = $issuedata->{'renewals'} + 1; $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? - WHERE borrowernumber=? + WHERE borrowernumber=? AND itemnumber=?" ); @@ -2744,7 +2742,7 @@ sub AddRenewal { my $accountno = getnextacctno( $borrowernumber ); my $item = GetBiblioFromItemNumber($itemnumber); my $manager_id = 0; - $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; + $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; $sth = $dbh->prepare( "INSERT INTO accountlines (date, borrowernumber, accountno, amount, manager_id, @@ -2758,22 +2756,22 @@ sub AddRenewal { # Send a renewal slip according to checkout alert preferencei if ( C4::Context->preference('RenewalSendNotice') eq '1') { - my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); - my $circulation_alert = 'C4::ItemCirculationAlertPreference'; - my %conditions = ( - branchcode => $branch, - categorycode => $borrower->{categorycode}, - item_type => $item->{itype}, - notification => 'CHECKOUT', - ); - if ($circulation_alert->is_enabled_for(\%conditions)) { - SendCirculationAlert({ - type => 'RENEWAL', - item => $item, - borrower => $borrower, - branch => $branch, - }); - } + my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); + my $circulation_alert = 'C4::ItemCirculationAlertPreference'; + my %conditions = ( + branchcode => $branch, + categorycode => $borrower->{categorycode}, + item_type => $item->{itype}, + notification => 'CHECKOUT', + ); + if ($circulation_alert->is_enabled_for(\%conditions)) { + SendCirculationAlert({ + type => 'RENEWAL', + item => $item, + borrower => $borrower, + branch => $branch, + }); + } } # Remove any OVERDUES related debarment if the borrower has no overdues @@ -2788,7 +2786,7 @@ sub AddRenewal { # Log the renewal UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'}); - return $datedue; + return $datedue; } sub GetRenewCount { @@ -2800,7 +2798,7 @@ sub GetRenewCount { my $renewsleft = 0; my $borrower = C4::Members::GetMember( borrowernumber => $bornum); - my $item = GetItem($itemno); + my $item = GetItem($itemno); # Look in the issues table for this item, lent to this borrower, # and not yet returned. @@ -2816,9 +2814,9 @@ sub GetRenewCount { $renewcount = $data->{'renewals'} if $data->{'renewals'}; # $item and $borrower should be calculated my $branchcode = _GetCircControlBranch($item, $borrower); - + my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); - + $renewsallowed = $issuingrule->{'renewalsallowed'}; $renewsleft = $renewsallowed - $renewcount; if($renewsleft < 0){ $renewsleft = 0; } @@ -3151,7 +3149,7 @@ sub SendCirculationAlert { my %message_name = ( CHECKIN => 'Item_Check_in', CHECKOUT => 'Item_Checkout', - RENEWAL => 'Item_Checkout', + RENEWAL => 'Item_Checkout', ); my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $borrower->{borrowernumber}, @@ -3194,25 +3192,25 @@ sub SendCirculationAlert { $items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary); -This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation +This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation =cut sub updateWrongTransfer { - my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_; - my $dbh = C4::Context->dbh; + my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_; + my $dbh = C4::Context->dbh; # first step validate the actual line of transfert . - my $sth = - $dbh->prepare( - "update branchtransfers set datearrived = now(),tobranch=?,comments='wrongtransfer' where itemnumber= ? AND datearrived IS NULL" - ); - $sth->execute($FromLibrary,$itemNumber); + my $sth = + $dbh->prepare( + "update branchtransfers set datearrived = now(),tobranch=?,comments='wrongtransfer' where itemnumber= ? AND datearrived IS NULL" + ); + $sth->execute($FromLibrary,$itemNumber); # second step create a new line of branchtransfer to the right location . - ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary); + ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary); #third step changing holdingbranch of item - UpdateHoldingbranch($FromLibrary,$itemNumber); + UpdateHoldingbranch($FromLibrary,$itemNumber); } =head2 UpdateHoldingbranch @@ -3224,7 +3222,7 @@ Simple methode for updating hodlingbranch in items BDD line =cut sub UpdateHoldingbranch { - my ( $branch,$itemnumber ) = @_; + my ( $branch,$itemnumber ) = @_; ModItem({ holdingbranch => $branch }, undef, $itemnumber); } @@ -3336,17 +3334,17 @@ This function checks if the date due is a repeatable holiday C<$date_due> = returndate calculate with no day check C<$itemnumber> = itemnumber -C<$branchcode> = localisation of issue +C<$branchcode> = localisation of issue =cut sub CheckRepeatableHolidays{ my($itemnumber,$week_day,$branchcode)=@_; my $dbh = C4::Context->dbh; -my $query = qq|SELECT count(*) - FROM repeatable_holidays - WHERE branchcode=? - AND weekday=?|; +my $query = qq|SELECT count(*) + FROM repeatable_holidays + WHERE branchcode=? + AND weekday=?|; my $sth = $dbh->prepare($query); $sth->execute($branchcode,$week_day); my $result=$sth->fetchrow; @@ -3364,20 +3362,20 @@ C<$years> = the years of datedue C<$month> = the month of datedue C<$day> = the day of datedue C<$itemnumber> = itemnumber -C<$branchcode> = localisation of issue +C<$branchcode> = localisation of issue =cut sub CheckSpecialHolidays{ my ($years,$month,$day,$itemnumber,$branchcode) = @_; my $dbh = C4::Context->dbh; -my $query=qq|SELECT count(*) - FROM `special_holidays` - WHERE year=? - AND month=? - AND day=? +my $query=qq|SELECT count(*) + FROM `special_holidays` + WHERE year=? + AND month=? + AND day=? AND branchcode=? - |; + |; my $sth = $dbh->prepare($query); $sth->execute($years,$month,$day,$branchcode); my $countspecial=$sth->fetchrow ; @@ -3393,19 +3391,19 @@ This function check if the date is a repeatble special holidays C<$month> = the month of datedue C<$day> = the day of datedue C<$itemnumber> = itemnumber -C<$branchcode> = localisation of issue +C<$branchcode> = localisation of issue =cut sub CheckRepeatableSpecialHolidays{ my ($month,$day,$itemnumber,$branchcode) = @_; my $dbh = C4::Context->dbh; -my $query=qq|SELECT count(*) - FROM `repeatable_holidays` - WHERE month=? - AND day=? +my $query=qq|SELECT count(*) + FROM `repeatable_holidays` + WHERE month=? + AND day=? AND branchcode=? - |; + |; my $sth = $dbh->prepare($query); $sth->execute($month,$day,$branchcode); my $countspecial=$sth->fetchrow ; @@ -3417,10 +3415,10 @@ return $countspecial; sub CheckValidBarcode{ my ($barcode) = @_; my $dbh = C4::Context->dbh; -my $query=qq|SELECT count(*) - FROM items +my $query=qq|SELECT count(*) + FROM items WHERE barcode=? - |; + |; my $sth = $dbh->prepare($query); $sth->execute($barcode); my $exist=$sth->fetchrow ; @@ -3436,24 +3434,24 @@ Code is either an itemtype or collection doe depending on the pref BranchTransfe =cut sub IsBranchTransferAllowed { - my ( $toBranch, $fromBranch, $code ) = @_; - - if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed. - - my $limitType = C4::Context->preference("BranchTransferLimitsType"); - my $dbh = C4::Context->dbh; - - my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?"); - $sth->execute( $toBranch, $fromBranch, $code ); - my $limit = $sth->fetchrow_hashref(); - - ## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed* - if ( $limit->{'limitId'} ) { - return 0; - } else { - return 1; - } -} + my ( $toBranch, $fromBranch, $code ) = @_; + + if ( $toBranch eq $fromBranch ) { return 1; } ## Short circuit for speed. + + my $limitType = C4::Context->preference("BranchTransferLimitsType"); + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare("SELECT * FROM branch_transfer_limits WHERE toBranch = ? AND fromBranch = ? AND $limitType = ?"); + $sth->execute( $toBranch, $fromBranch, $code ); + my $limit = $sth->fetchrow_hashref(); + + ## If a row is found, then that combination is not allowed, if no matching row is found, then the combination *is allowed* + if ( $limit->{'limitId'} ) { + return 0; + } else { + return 1; + } +} =head2 CreateBranchTransferLimit @@ -3467,9 +3465,9 @@ 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 ( ?, ?, ? )"); return $sth->execute( $code, $toBranch, $fromBranch ); } @@ -3510,9 +3508,9 @@ sub LostItem{ my ($itemnumber, $mark_returned) = @_; my $dbh = C4::Context->dbh(); - my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title - FROM issues - JOIN items USING (itemnumber) + my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title + FROM issues + JOIN items USING (itemnumber) JOIN biblio USING (biblionumber) WHERE issues.itemnumber=?"); $sth->execute($itemnumber); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -332,7 +332,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'), ('RenewalSendNotice','0','',NULL,'YesNo'), ('RenewSerialAddsSuggestion','0',NULL,'If ON, adds a new suggestion at serial subscription renewal','YesNo'), -('RentalFeesCheckoutConfirmation', '1', NULL , 'Allow user to confirme when checking out an item with rental fees.', 'YesNo'), +('RentalFeesCheckoutConfirmation', '0', NULL , 'Allow user to confirme when checking out an item with rental fees.', 'YesNo'), ('RentalsInNoissuesCharge','1',NULL,'Rental charges block checkouts (added to noissuescharge).','YesNo'), ('RequestOnOpac','1',NULL,'If ON, globally enables patron holds on OPAC','YesNo'), ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -203,11 +203,11 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% END %] [% IF ( DEBT ) %] -
  • The patron has a debt of [% DEBT %]
  • +
  • The patron has a debt of [% DEBT %].
  • [% END %] [% IF ( RENTALCHARGE ) %] -
  • Rental charge for this item : [% RENTALCHARGE %]
  • +
  • Rental charge for this item: [% RENTALCHARGE %]
  • [% END %] [% IF ( RENEW_ISSUE ) %] --