[Koha-cvs] CVS: koha/C4/Circulation Main.pm,1.7,1.8

MJ Ray slef at users.sourceforge.net
Mon Dec 8 15:33:05 CET 2003


Update of /cvsroot/koha/koha/C4/Circulation
In directory sc8-pr-cvs1:/tmp/cvs-serv15212/C4/Circulation

Modified Files:
	Main.pm 
Log Message:
DBI call fix for bug 662

Index: Main.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Main.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Main.pm	13 Oct 2002 06:21:20 -0000	1.7
--- Main.pm	8 Dec 2003 14:33:03 -0000	1.8
***************
*** 79,84 ****
    my ($env) = @_;
    my $dbh = C4::Context->dbh;
!   my $query = "select * from branches order by branchcode";
!   my $sth = $dbh->prepare($query);
    $sth->execute;
    if ($sth->rows>1) {
--- 79,83 ----
    my ($env) = @_;
    my $dbh = C4::Context->dbh;
!   my $sth = $dbh->prepare("select * from branches order by branchcode");
    $sth->execute;
    if ($sth->rows>1) {
***************
*** 92,99 ****
        $env->{'branchcode'}=$data->{'branchcode'};
    }
!   my $query = "select * from branches
!     where branchcode = '$env->{'branchcode'}'";
!   $sth = $dbh->prepare($query);
!   $sth->execute;
    my $data = $sth->fetchrow_hashref;
    $env->{'brdata'} = $data;
--- 91,97 ----
        $env->{'branchcode'}=$data->{'branchcode'};
    }
!   $sth = $dbh->prepare("select * from branches
!     where branchcode = ?");
!   $sth->execute($env->{'branchcode'});
    my $data = $sth->fetchrow_hashref;
    $env->{'brdata'} = $data;
***************
*** 109,114 ****
    my ($env) = @_;
    my $dbh = C4::Context->dbh;
!   my $query = "select * from printers order by printername";
!   my $sth = $dbh->prepare($query);
    $sth->execute;
    if ($sth->rows>1) {
--- 107,111 ----
    my ($env) = @_;
    my $dbh = C4::Context->dbh;
!   my $sth = $dbh->prepare("select * from printers order by printername");
    $sth->execute;
    if ($sth->rows>1) {
***************
*** 135,142 ****
    #Get list of all items borrower has currently on issue
    my ($env,$bornum,$dbh)=@_;
!   my $query1 = "select * from issues  where (borrowernumber=$bornum)
!     and (returndate is null) order by date_due";
!   my $sth=$dbh->prepare($query1);
!   $sth->execute;
    my $i=0;
    my @items;
--- 132,138 ----
    #Get list of all items borrower has currently on issue
    my ($env,$bornum,$dbh)=@_;
!   my $sth=$dbh->prepare("select * from issues  where (borrowernumber=?)
!     and (returndate is null) order by date_due");
!   $sth->execute($bornum);
    my $i=0;
    my @items;
***************
*** 172,185 ****
    # FIXME - Use C4::Context->dbh instead of getting $dbh as an argument
    my ($env,$bornum,$dbh)=@_;
!   # FIXME - This is what POSIX::strftime is for.
!   my @datearr = localtime;
!   my $today = ($datearr[5] + 1900)."-".($datearr[4]+1)."-".$datearr[3];
!   # FIXME - MySQL can figure out what today is, so there's no need
!   # to calculate that separately. Just use
!   #	... date_due < curdate()
!   my $query = "Select count(*) from issues where borrowernumber=$bornum and
!         returndate is NULL and date_due < '$today'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $data = $sth->fetchrow_hashref;
    $sth->finish;
--- 168,174 ----
    # FIXME - Use C4::Context->dbh instead of getting $dbh as an argument
    my ($env,$bornum,$dbh)=@_;
!   my $sth=$dbh->prepare("Select count(*) from issues where borrowernumber=? and
!         returndate is NULL and date_due < curdate()");
!   $sth->execute($bornum);
    my $data = $sth->fetchrow_hashref;
    $sth->finish;
***************
*** 273,285 ****
    # Apparently reserves.found=='W' means "Waiting".
    # FIXME - Is it necessary to get every field from both tables?
!   my $query = "select * from reserves,items
!     where (items.itemnumber = '$itemnum')
      and (reserves.cancellationdate is NULL)
      and (items.biblionumber = reserves.biblionumber)
      and ((reserves.found = 'W')
      or (reserves.found is null))
!     order by priority";
!   my $sth = $dbh->prepare($query);
!   $sth->execute();
    my $resrec;
    if (my $data=$sth->fetchrow_hashref) {
--- 262,273 ----
    # Apparently reserves.found=='W' means "Waiting".
    # FIXME - Is it necessary to get every field from both tables?
!   my $sth = $dbh->prepare("select * from reserves,items
!     where (items.itemnumber = ?)
      and (reserves.cancellationdate is NULL)
      and (items.biblionumber = reserves.biblionumber)
      and ((reserves.found = 'W')
      or (reserves.found is null))
!     order by priority");
!   $sth->execute($itemnum);
    my $resrec;
    if (my $data=$sth->fetchrow_hashref) {
***************
*** 290,301 ****
      } else {
        my $found = 0;
!       my $cquery = "select * from reserveconstraints,items
!          where (borrowernumber='$data->{'borrowernumber'}')
!          and reservedate='$data->{'reservedate'}'
! 	 and reserveconstraints.biblionumber='$data->{'biblionumber'}'
! 	 and (items.itemnumber=$itemnum and
! 	 items.biblioitemnumber = reserveconstraints.biblioitemnumber)";
!       my $csth = $dbh->prepare($cquery);
!       $csth->execute;
        if (my $cdata=$csth->fetchrow_hashref) {$found = 1;}
        if ($const eq 'o') {		# FIXME - What does 'o' mean?
--- 278,288 ----
      } else {
        my $found = 0;
!       my $csth = $dbh->prepare("select * from reserveconstraints,items
!          where (borrowernumber=?)
!          and reservedate=?
! 	 and reserveconstraints.biblionumber=?
! 	 and (items.itemnumber=? and
! 	 items.biblioitemnumber = reserveconstraints.biblioitemnumber)");
!       $csth->execute($data->{'borrowernumber'},$data->{'reservedate'},$data->{'biblionumber'},$itemnum);
        if (my $cdata=$csth->fetchrow_hashref) {$found = 1;}
        if ($const eq 'o') {		# FIXME - What does 'o' mean?
***************
*** 318,326 ****
    my ($env,$dbh,$bornum)=@_;
    my @itemswaiting;
!   my $query = "select * from reserves
!     where (borrowernumber = '$bornum')
!     and (reserves.found='W') and cancellationdate is NULL";
!   my $sth = $dbh->prepare($query);
!   $sth->execute();
    my $cnt=0;
    if (my $data=$sth->fetchrow_hashref) {
--- 305,312 ----
    my ($env,$dbh,$bornum)=@_;
    my @itemswaiting;
!   my $sth = $dbh->prepare("select * from reserves
!     where (borrowernumber = ?)
!     and (reserves.found='W') and cancellationdate is NULL");
!   $sth->execute($bornum);
    my $cnt=0;
    if (my $data=$sth->fetchrow_hashref) {





More information about the Koha-cvs mailing list