From: Nahuel ANGELINETTI Date: Mon, 1 Feb 2010 11:31:35 +0000 (+0100) Subject: [3.0.x](bug #4084) fix offline circ X-Git-Tag: v3.00.06~69 X-Git-Url: http://git.rot13.org/?p=koha.git;a=commitdiff_plain;h=5af80ab9abe609fbd354b70c05ed920a97de63bc [3.0.x](bug #4084) fix offline circ this add the function C4::Circulation::GetOpenIssue and delete \r chars when processing koc files. --- diff --git a/C4/Circulation.pm b/C4/Circulation.pm index cfa1519bb2..6fce6dc6b0 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -73,6 +73,7 @@ BEGIN { &GetBranchBorrowerCircRule &GetBranchItemRule &GetBiblioIssues + &GetOpenIssue &AnonymiseIssueHistory ); @@ -879,7 +880,6 @@ sub AddIssue { my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; my $dbh = C4::Context->dbh; my $barcodecheck=CheckValidBarcode($barcode); - # $issuedate defaults to today. if ( ! defined $issuedate ) { $issuedate = strftime( "%Y-%m-%d", localtime ); @@ -1793,6 +1793,28 @@ sub GetItemIssue { return ($data); } +=head2 GetOpenIssue + +$issue = GetOpenIssue( $itemnumber ); + +Returns the row from the issues table if the item is currently issued, undef if the item is not currently issued + +C<$itemnumber> is the item's itemnumber + +Returns a hashref + +=cut + +sub GetOpenIssue { + my ( $itemnumber ) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( "SELECT * FROM issues WHERE itemnumber = ? AND returndate IS NULL" ); + $sth->execute( $itemnumber ); + my $issue = $sth->fetchrow_hashref(); + return $issue; +} + =head2 GetItemIssues $issues = &GetItemIssues($itemnumber, $history); diff --git a/offline_circ/process_koc.pl b/offline_circ/process_koc.pl index 87ae5c16e4..d3d910520e 100755 --- a/offline_circ/process_koc.pl +++ b/offline_circ/process_koc.pl @@ -189,7 +189,8 @@ sub parse_header_line { sub parse_command_line { my $command_line = shift; chomp($command_line); - + $command_line =~ s/\r//g; + my ( $timestamp, $command, @args ) = split( /\t/, $command_line ); my ( $date, $time, $id ) = split( /\s/, $timestamp ); @@ -248,11 +249,11 @@ sub kocIssueItem { my ( $year, $month, $day ) = split( /-/, $circ->{'date'} ); ( $year, $month, $day ) = Add_Delta_Days( $year, $month, $day, $issuelength ); my $date_due = sprintf("%04d-%02d-%02d", $year, $month, $day); - + if ( $issue->{ 'date_due' } ) { ## Item is currently checked out to another person. #warn "Item Currently Issued."; my $issue = GetOpenIssue( $item->{'itemnumber'} ); - + if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it. #warn "Item issued to this member already, renewing.";