X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FCirculation.pm;h=864794326560d2010ef007a86f88b3643dcc01e4;hb=7d55969329761f2eadf9c14f493b07f0a3b5503d;hp=a7e7389c978641035009f044a340ab6076c5e176;hpb=9d4e241adadc9a3c62d94a2d487a738e9490925a;p=koha_fer diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a7e7389c97..8647943265 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -38,6 +38,8 @@ use C4::Branch; # GetBranches use C4::Log; # logaction use C4::Koha qw(GetAuthorisedValueByCode); use C4::Overdues qw(CalcFine UpdateFine); +use Algorithm::CheckDigits; + use Data::Dumper; use Koha::DateUtils; use Koha::Calendar; @@ -169,6 +171,14 @@ sub barcodedecode { $barcode =~ s/^(\D+)[0]*(\d+)$/$branch-$1-$2/i; } } + } elsif ($filter eq 'EAN13') { + my $ean = CheckDigits('ean'); + if ( $ean->is_valid($barcode) ) { + #$barcode = sprintf('%013d',$barcode); # this doesn't work on 32-bit systems + $barcode = '0' x ( 13 - length($barcode) ) . $barcode; + } else { + warn "# [$barcode] not valid EAN-13/UPC-A\n"; + } } return $barcode; # return barcode, modified or not } @@ -1063,6 +1073,9 @@ sub AddIssue { CartToShelf( $item->{'itemnumber'} ); } $item->{'issues'}++; + if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { + UpdateTotalIssues($item->{'biblionumber'}, 1); + } ## If item was lost, it has now been found, reverse any list item charges if neccessary. if ( $item->{'itemlost'} ) { @@ -1199,53 +1212,16 @@ Get the Hard Due Date and it's comparison for an itemtype, a borrower type and a sub GetHardDueDate { my ( $borrowertype, $itemtype, $branchcode ) = @_; - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare( -"select hardduedate, hardduedatecompare from issuingrules where categorycode=? and itemtype=? and branchcode=?" - ); - $sth->execute( $borrowertype, $itemtype, $branchcode ); - my $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - $sth->execute( $borrowertype, "*", $branchcode ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - $sth->execute( "*", $itemtype, $branchcode ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - $sth->execute( "*", "*", $branchcode ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - $sth->execute( $borrowertype, $itemtype, "*" ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - $sth->execute( $borrowertype, "*", "*" ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - $sth->execute( "*", $itemtype, "*" ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; + my $rule = GetIssuingRule( $borrowertype, $itemtype, $branchcode ); - $sth->execute( "*", "*", "*" ); - $results = $sth->fetchrow_hashref; - return (dt_from_string($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) - if defined($results) && $results->{hardduedate}; - - # if no rule is set => return undefined - return (undef, undef); + if ( defined( $rule ) ) { + if ( $rule->{hardduedate} ) { + return (dt_from_string($rule->{hardduedate}, 'iso'),$rule->{hardduedatecompare}); + } else { + return (undef, undef); + } + } } =head2 GetIssuingRule @@ -1620,7 +1596,7 @@ sub AddReturn { if ($borrowernumber) { if($issue->{'overdue'}){ - my ( $amount, $type, $daycounttotal ) = C4::Overdues::CalcFine( $item, $borrower->{categorycode},$branch, $datedue, $today ); + my ( $amount, $type, $unitcounttotal ) = C4::Overdues::CalcFine( $item, $borrower->{categorycode},$branch, $datedue, $today ); $type ||= q{}; if ( $amount > 0 && ( C4::Context->preference('finesMode') eq 'production' )) { C4::Overdues::UpdateFine( @@ -1656,12 +1632,15 @@ sub AddReturn { ); $sth->execute( $item->{'itemnumber'} ); # if we have a reservation with valid transfer, we can set it's status to 'W' + ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W'); } else { $messages->{'WrongTransfer'} = $tobranch; $messages->{'WrongTransferItem'} = $item->{'itemnumber'}; } $validTransfert = 1; + } else { + ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); } # fix up the accounts..... @@ -2744,11 +2723,14 @@ sub SendCirculationAlert { borrowernumber => $borrower->{borrowernumber}, message_name => $message_name{$type}, }); + my $issues_table = ( $type eq 'CHECKOUT' ) ? 'issues' : 'old_issues'; my $letter = C4::Letters::GetPreparedLetter ( module => 'circulation', letter_code => $type, branchcode => $branch, tables => { + $issues_table => $item->{itemnumber}, + 'items' => $item->{itemnumber}, 'biblio' => $item->{biblionumber}, 'biblioitems' => $item->{biblionumber}, 'borrowers' => $borrower, @@ -3082,10 +3064,12 @@ sub ReturnLostItem{ MarkIssueReturned( $borrowernumber, $itemnum ); my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber ); + my $item = C4::Items::GetItem( $itemnum ); + my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{}; my @datearr = localtime(time); my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}"; - ModItem({ paidfor => "Paid for by $bor $date" }, undef, $itemnum); + ModItem({ paidfor => $old_note."Paid for by $bor $date" }, undef, $itemnum); }