[Koha-cvs] CVS: koha/C4/Circulation Circ2.pm,1.78,1.79

doXulting doxulting at users.sourceforge.net
Tue Jun 29 15:02:38 CEST 2004


Update of /cvsroot/koha/koha/C4/Circulation
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11664/koha/C4/Circulation

Modified Files:
	Circ2.pm 
Log Message:
Debugged issuing rules n01

Index: Circ2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -r1.78 -r1.79
*** Circ2.pm	17 Jun 2004 08:17:39 -0000	1.78
--- Circ2.pm	29 Jun 2004 13:02:34 -0000	1.79
***************
*** 599,639 ****
  # returns an array with errors if any
  
! sub HowManyIssues ($){
      my $borrower = shift;
      my $dbh = C4::Context->dbh;
      
-     my $sth = $dbh->prepare('select COUNT(borrowernumber) from issues where borrowernumber = ?
- 			    and returndate is null');
-     $sth->execute($borrower->{'borrowernumber'});
-     my $data = $sth->fetchrow;
-     return $data;
- }
- 
- sub NumberIssuesOk(@)
- {
-     (my $biblionumber, my $cat) = @_;
-     my $dbh = C4::Context->dbh;
  
      my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?');
!     $sth->execute($biblionumber);
!     my $data = $sth->fetchrow;
!     $sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ?');
!     $sth->execute($cat, $data);
!     my $value = $sth->fetchrow_hashref;
!     return $value->{'maxissueqty'}, $value->{'issuelength'} 
!     if (defined($value));   
!     $sth->execute("*", $data);
!     $value = $sth->fetchrow_hashref;
!     return $value->{'maxissueqty'}, $value->{'issuelength'}
!     if (defined($value));
!     $sth->execute($cat, "*");
!     $value = $sth->fetchrow_hashref;
!     return $value->{'maxissueqty'}, $value->{'issuelength'}
!     if (defined($value));
!     $sth->execute("*", "*");
!     $value = $sth->fetchrow_hashref;
!     return $value->{'maxissueqty'}, $value->{'issuelength'};
  }
  
  sub canbookbeissued {
  	my ($env,$borrower,$barcode,$year,$month,$day) = @_;
--- 599,686 ----
  # returns an array with errors if any
  
! sub TooMany ($$){
      my $borrower = shift;
+     my $iteminformation = shift;
+     my $cat_borrower = $borrower->{'categorycode'};
+     my $branch_borrower = $borrower->{'branchcode'};
      my $dbh = C4::Context->dbh;
      
  
      my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?');
!     $sth->execute($iteminformation->{'biblionumber'});
!     my $type = $sth->fetchrow;
! 
!     $sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?');
!     my $sth2 = $dbh->prepare("select COUNT(i.borrowernumber) from issues i, biblioitems s where i.borrowernumber = ? and i.returndate is null and i.itemnumber = s.biblioitemnumber and s.itemtype like ?");
!     my $sth3 = $dbh->prepare('select COUNT(borrowernumber) from issues where borrowernumber = ? and returndate is null');
!     
!     $sth->execute($cat_borrower, $type, $branch_borrower);
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
! 	return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
!     }
! 
!     $sth->execute($cat_borrower, $type, "*");
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
! 	return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
!     }
! 
!     $sth->execute($cat_borrower, "*", $branch_borrower);
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth3->execute($borrower->{'borrowernumber'});
! 	return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
!     }
! 
!     $sth->execute("*", $type, $branch_borrower);
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
! 	return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
!     }
! 
!     $sth->execute("*", "*", $branch_borrower);
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth3->execute($borrower->{'borrowernumber'});
! 	return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
!     }
! 
!     $sth->execute("*", $type, "*");
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
! 	return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
!     }
! 
!     $sth->execute($cat_borrower, "*", "*");
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth2->execute($borrower->{'borrowernumber'}, "%$type%");
! 	return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow);
!     }
! 
!     $sth->execute("*", "*", "*");
!     my $result = $sth->fetchrow_hashref;
!     if (defined($result))
!     {
! 	$sth3->execute($borrower->{'borrowernumber'});
! 	return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow);
!     }
! 
!     return (1);
  }
  
+ 
  sub canbookbeissued {
  	my ($env,$borrower,$barcode,$year,$month,$day) = @_;
***************
*** 676,684 ****
  #
  	
- 	(my $maxissueqty, my $issuelength) = 
- 	    NumberIssuesOk($iteminformation->{'biblionumber'}, 
- 			   $borrower->{'categorycode'});
  	$needsconfirmation{TOO_MANY} = 1 
! 	    if (HowManyIssues($borrower) > $maxissueqty);
  
  #
--- 723,729 ----
  #
  	
  	$needsconfirmation{TOO_MANY} = 1 
! 	    if (!TooMany($borrower, $iteminformation));
! 
  
  #





More information about the Koha-cvs mailing list