[Koha-cvs] CVS: koha/C4/Circulation Circ2.pm,1.26,1.27

Finlay Thompson finlayt at users.sourceforge.net
Thu Jun 6 04:48:55 CEST 2002


Update of /cvsroot/koha/koha/C4/Circulation
In directory usw-pr-cvs1:/tmp/cvs-serv14805/C4/Circulation

Modified Files:
	Circ2.pm 
Log Message:

Changed the issuebook routine to use the new methods from C4::Reserves2.pm


Index: Circ2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** Circ2.pm	29 May 2002 05:52:12 -0000	1.26
--- Circ2.pm	6 Jun 2002 02:48:53 -0000	1.27
***************
*** 290,296 ****
      my ($env, $patroninformation, $barcode, $responses, $date) = @_;
      my $dbh=&C4Connect;
!     my $iteminformation=getiteminformation($env, 0, $barcode);
      my ($datedue);
      my ($rejected,$question,$defaultanswer,$questionnumber, $noissue);
      SWITCH: {
  	if ($patroninformation->{'gonenoaddress'}) {
--- 290,297 ----
      my ($env, $patroninformation, $barcode, $responses, $date) = @_;
      my $dbh=&C4Connect;
!     my $iteminformation = getiteminformation($env, 0, $barcode);
      my ($datedue);
      my ($rejected,$question,$defaultanswer,$questionnumber, $noissue);
+     my $message;
      SWITCH: {
  	if ($patroninformation->{'gonenoaddress'}) {
***************
*** 307,320 ****
  	}
  	my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh,$date);
! 	if ($amount>5 && $patroninformation->{'categorycode'} ne 'L' &&
                           $patroninformation->{'categorycode'} ne 'W' &&
                           $patroninformation->{'categorycode'} ne 'I' && 
                           $patroninformation->{'categorycode'} ne 'B' &&
                           $patroninformation->{'categorycode'} ne 'P') {
! 	    $rejected=sprintf "Patron owes \$%.02f.", $amount;
  	    last SWITCH;
  	}
  	unless ($iteminformation) {
! 	    $rejected="$barcode is not a valid barcode.";
  	    last SWITCH;
  	}
--- 308,321 ----
  	}
  	my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh,$date);
! 	if ($amount > 5 && $patroninformation->{'categorycode'} ne 'L' &&
                           $patroninformation->{'categorycode'} ne 'W' &&
                           $patroninformation->{'categorycode'} ne 'I' && 
                           $patroninformation->{'categorycode'} ne 'B' &&
                           $patroninformation->{'categorycode'} ne 'P') {
! 	    $rejected = sprintf "Patron owes \$%.02f.", $amount;
  	    last SWITCH;
  	}
  	unless ($iteminformation) {
! 	    $rejected = "$barcode is not a valid barcode.";
  	    last SWITCH;
  	}
***************
*** 344,350 ****
  	    } else {
  		if ($responses->{4} eq '') {
! 		    $questionnumber=4;
! 		    $question="Book is issued to this borrower.\nRenew?";
! 		    $defaultanswer='Y';
  		    last SWITCH;
  		} elsif ($responses->{4} eq 'Y') {
--- 345,351 ----
  	    } else {
  		if ($responses->{4} eq '') {
! 		    $questionnumber = 4;
! 		    $question = "Book is issued to this borrower.\nRenew?";
! 		    $defaultanswer = 'Y';
  		    last SWITCH;
  		} elsif ($responses->{4} eq 'Y') {
***************
*** 352,356 ****
  		    if ($charge > 0) {
  			createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge);
! 			$iteminformation->{'charge'}=$charge;
  		    }
  		    &UpdateStats($env,$env->{'branchcode'},'renew',$charge,'',$iteminformation->{'itemnumber'},$iteminformation->{'itemtype'});
--- 353,357 ----
  		    if ($charge > 0) {
  			createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge);
! 			$iteminformation->{'charge'} = $charge;
  		    }
  		    &UpdateStats($env,$env->{'branchcode'},'renew',$charge,'',$iteminformation->{'itemnumber'},$iteminformation->{'itemtype'});
***************
*** 377,409 ****
  	}
  
! 	my ($resbor, $resrec) = checkreserve($env, $dbh, $iteminformation->{'itemnumber'});
! 
! 	if ($resbor eq $patroninformation->{'borrowernumber'}) {
! 	     my $rquery = "update reserves set found = 'F' where reservedate = '$resrec->{'reservedate'}' and borrowernumber = '$resrec->{'borrowernumber'}' and biblionumber = '$resrec->{'biblionumber'}'";
! 	     my $rsth = $dbh->prepare($rquery);
! 	     $rsth->execute;
! 	     $rsth->finish;
! 	} elsif ($resbor ne "") {
! 	    my ($resborrower, $flags)=getpatroninformation($env, $resbor,0);
! 	    if ($responses->{2} eq '') {
! 		$questionnumber=2;
! 		$question="Reserved for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'}) since $resrec->{'reservedate'}\nAllow issue?";
! 		$defaultanswer='N';
! 		last SWITCH;
! 	    } elsif ($responses->{2} eq 'N') {
! 		#printreserve($env, $resrec, $resborrower, $iteminformation);
! 		$rejected=-1;
! 		last SWITCH;
! 	    } else {
! 		if ($responses->{3} eq '') {
! 		    $questionnumber=3;
! 		    $question="Cancel reserve for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'})?";
  		    $defaultanswer='N';
  		    last SWITCH;
! 		} elsif ($responses->{3} eq 'Y') {
! 		    my $rquery = "update reserves set found = 'F' where reservedate = '$resrec->{'reservedate'}' and borrowernumber = '$resrec->{'borrowernumber'}' and biblionumber = '$resrec->{'biblionumber'}'";
! 		    my $rsth = $dbh->prepare($rquery);
! 		    $rsth->execute;
! 		    $rsth->finish;
  		}
  	    }
--- 378,438 ----
  	}
  
! 	my ($restype, $res) = CheckReserves($iteminformation->{'itemnumber'});
! 	if ($restype) {
! 	    my $resbor = $res->{'borrowernumber'};
! 	    if ($resbor eq $patroninformation->{'borrowernumber'}) {
! 		FillReserve($res);
! 	    } elsif ($restype eq "Waiting") {
! 		my ($resborrower, $flags)=getpatroninformation($env, $resbor,0);
! 		my $branches = getbranches();
! 		my $branchname = $branches->{$res->{'branchcode'}}->{'branchname'};
! 		if ($responses->{2} eq '') {
! 		    $questionnumber=2;
! 		    $question="Waiting for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'}) at $branchname \nAllow issue?";
! 		    $defaultanswer='N';
! 		    last SWITCH;
! 		} elsif ($responses->{2} eq 'N') {
! 		    $rejected=-1;
! 		    last SWITCH;
! 		} else {
! 		    if ($responses->{3} eq '') {
! 			$questionnumber=3;
! 			$question="Cancel reserve for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'})?";
! 			$defaultanswer='N';
! 			last SWITCH;
! 		    } elsif ($responses->{3} eq 'Y') {
! 			CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'});
! 		    }
! 		}
! 	    } elsif ($restype eq "Reserved") {
! 		my ($resborrower, $flags)=getpatroninformation($env, $resbor,0);
! 		my $branches = getbranches();
! 		my $branchname = $branches->{$res->{'branchcode'}}->{'branchname'};
! 		if ($responses->{5} eq '') {
! 		    $questionnumber=5;
! 		    $question="Reserved for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'}) since $res->{'reservedate'} \nAllow issue?";
  		    $defaultanswer='N';
  		    last SWITCH;
! 		} elsif ($responses->{5} eq 'N') {
! 		    if ($responses->{6} eq '') {
! 			$questionnumber=6;
! 			$question="Set reserve for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'}) to waiting and transfer to $branchname?";
! 			$defaultanswer='N';
! 		    } elsif ($responses->{6} eq 'Y') {
! 			my $tobrcd = ReserveWaiting($res->{'itemnumber'}, $res->{'borrowernumber'});
! 			transferbook($tobrcd, $barcode, 1);
! 			$message = "Item should now be waiting at $branchname";
! 		    }
! 		    $rejected=-1;
! 		    last SWITCH;
! 		} else {
! 		    if ($responses->{7} eq '') {
! 			$questionnumber=7;
! 			$question="Cancel reserve for $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'})?";
! 			$defaultanswer='N';
! 			last SWITCH;
! 		    } elsif ($responses->{7} eq 'Y') {
! 			CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'});
! 		    }
  		}
  	    }
***************
*** 438,442 ****
  	&UpdateStats($env,$env->{'branchcode'},'issue',$charge,'',$iteminformation->{'itemnumber'},$iteminformation->{'itemtype'});
      }
-     my $message='';
      if ($iteminformation->{'charge'}) {
  	$message=sprintf "Rental charge of \$%.02f applies.", $iteminformation->{'charge'};
--- 467,470 ----
***************
*** 680,684 ****
  	$flags{'NOTES'} = \%flaginfo;
      }
!     my ($odues, $itemsoverdue) = checkoverdues($env, $patroninformation->{'borrowernumber'}, $dbh);
      if ($odues > 0) {
  	my %flaginfo;
--- 708,713 ----
  	$flags{'NOTES'} = \%flaginfo;
      }
!     my ($odues, $itemsoverdue) 
!                   = checkoverdues($env, $patroninformation->{'borrowernumber'}, $dbh);
      if ($odues > 0) {
  	my %flaginfo;
***************
*** 690,699 ****
  	$flags{'ODUES'} = \%flaginfo;
      }
!     my ($nowaiting, $itemswaiting) = checkwaiting($env, $dbh, $patroninformation->{'borrowernumber'});
      if ($nowaiting > 0) {
  	my %flaginfo;
  	$flaginfo{'message'} = "Reserved items available";
  	$flaginfo{'itemlist'} = $itemswaiting;
- 	$flaginfo{'itemfields'} = ['barcode', 'title', 'author', 'dewey', 'subclass', 'holdingbranch'];
  	$flags{'WAITING'} = \%flaginfo;
      }
--- 719,728 ----
  	$flags{'ODUES'} = \%flaginfo;
      }
!     my ($nowaiting, $itemswaiting) 
!                   = CheckWaiting($patroninformation->{'borrowernumber'});
      if ($nowaiting > 0) {
  	my %flaginfo;
  	$flaginfo{'message'} = "Reserved items available";
  	$flaginfo{'itemlist'} = $itemswaiting;
  	$flags{'WAITING'} = \%flaginfo;
      }
***************
*** 705,715 ****
  # From Main.pm, modified to return a list of overdueitems, in addition to a count
    #checks whether a borrower has overdue items
!   my ($env,$bornum,$dbh)=@_;
    my @datearr = localtime;
    my $today = ($datearr[5] + 1900)."-".($datearr[4]+1)."-".$datearr[3];
    my @overdueitems;
!   my $count=0;
!   my $query = "Select * from issues,biblio,biblioitems,items where items.biblioitemnumber=biblioitems.biblioitemnumber and items.biblionumber=biblio.biblionumber and issues.itemnumber=items.itemnumber and borrowernumber=$bornum and returndate is NULL and date_due < '$today'";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
    while (my $data = $sth->fetchrow_hashref) {
--- 734,750 ----
  # From Main.pm, modified to return a list of overdueitems, in addition to a count
    #checks whether a borrower has overdue items
!   my ($env, $bornum, $dbh)=@_;
    my @datearr = localtime;
    my $today = ($datearr[5] + 1900)."-".($datearr[4]+1)."-".$datearr[3];
    my @overdueitems;
!   my $count = 0;
!   my $query = "SELECT * FROM issues,biblio,biblioitems,items 
!                        WHERE items.biblioitemnumber = biblioitems.biblioitemnumber 
!                          AND items.biblionumber     = biblio.biblionumber 
!                          AND issues.itemnumber      = items.itemnumber 
!                          AND issues.borrowernumber  = $bornum 
!                          AND issues.returndate is NULL 
!                          AND issues.date_due < '$today'";
!   my $sth = $dbh->prepare($query);
    $sth->execute;
    while (my $data = $sth->fetchrow_hashref) {





More information about the Koha-cvs mailing list