[Koha-cvs] CVS: koha/C4 Catalogue.pm,1.36,1.37

MJ Ray slef at users.sourceforge.net
Wed Dec 17 02:28:33 CET 2003


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

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

Index: Catalogue.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Catalogue.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** Catalogue.pm	24 Nov 2003 16:24:24 -0000	1.36
--- Catalogue.pm	17 Dec 2003 01:28:31 -0000	1.37
***************
*** 99,123 ****
    my ($basketno,$supplier)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select *,biblio.title from aqorders,biblio,biblioitems
!   where basketno='$basketno'
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
    =aqorders.biblioitemnumber
    and (datecancellationprinted is NULL or datecancellationprinted =
!   '0000-00-00')";
!   if ($supplier ne ''){
!     $query.=" and aqorders.booksellerid='$supplier'";
    }
!   $query.=" group by aqorders.ordernumber";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
!   my @results;
! #  print $query;
!   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 99,121 ----
    my ($basketno,$supplier)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblio,biblioitems
!   where basketno=?
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
    =aqorders.biblioitemnumber
    and (datecancellationprinted is NULL or datecancellationprinted =
!   '0000-00-00')"
!   .(($supplier ne '')?" and aqorders.booksellerid=?":"")
!   ." group by aqorders.ordernumber");
!   if ($supplier ne '') {
!     $sth->execute($basketno,$supplier);
!   } else {
!     $sth->execute($basketno);
    }
!   my @results = ();
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 142,147 ****
  sub newbasket {
    my $dbh = C4::Context->dbh;
!   my $query="Select max(basketno) from aqorders";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
    my $data=$sth->fetchrow_arrayref;
--- 140,144 ----
  sub newbasket {
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select max(basketno) from aqorders");
    $sth->execute;
    my $data=$sth->fetchrow_arrayref;
***************
*** 226,235 ****
    my ($bibnum,$ordnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update aqorders set datecancellationprinted=now()
!   where biblionumber='$bibnum' and
!   ordernumber='$ordnum'";
!   my $sth=$dbh->prepare($query);
!   #print $query;
!   $sth->execute;
    $sth->finish;
    my $count=itemcount($bibnum);
--- 223,229 ----
    my ($bibnum,$ordnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update aqorders set datecancellationprinted=now()
!   where biblionumber=? and ordernumber=?");
!   $sth->execute($bibnum,$ordnum);
    $sth->finish;
    my $count=itemcount($bibnum);
***************
*** 259,274 ****
    my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update aqorders set title='$title',
!   quantity='$quantity',listprice='$listprice',basketno='$basketno',
!   rrp='$rrp',ecost='$ecost',unitprice='$cost',
!   booksellerinvoicenumber='$invoice'
    where
!   ordernumber=$ordnum and biblionumber=$bibnum";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
!   $query="update aqorderbreakdown set bookfundid=? where
!   ordernumber=?";
!   $sth=$dbh->prepare($query);
    $sth->execute($bookfund,$ordnum);
    $sth->finish;
--- 253,266 ----
    my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update aqorders set title=?,
!   quantity=?,listprice=?,basketno=?,
!   rrp=?,ecost=?,unitprice=?,
!   booksellerinvoicenumber=?
    where
!   ordernumber=? and biblionumber=?");
!   $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$invoice,$ordnum,$bibnum);
    $sth->finish;
!   $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
!   ordernumber=?");
    $sth->execute($bookfund,$ordnum);
    $sth->finish;
***************
*** 287,292 ****
  sub newordernum {
    my $dbh = C4::Context->dbh;
!   my $query="Select max(ordernumber) from aqorders";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
    my $data=$sth->fetchrow_arrayref;
--- 279,283 ----
  sub newordernum {
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select max(ordernumber) from aqorders");
    $sth->execute;
    my $data=$sth->fetchrow_arrayref;
***************
*** 317,329 ****
    my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
    										biblioitemnumber=?,unitprice=?,freight=?,rrp=?
!   						where biblionumber=? and ordernumber=?";
!   my $sth=$dbh->prepare($query);
    $sth->execute($quantrec,$invoiceno,$bibitemno,$cost,$freight,$rrp,$biblio,$ordnum);
    $sth->finish;
!   $query="update aqorderbreakdown set bookfundid=? where
!   ordernumber=?";
!   $sth=$dbh->prepare($query);
    $sth->execute($bookfund,$ordnum);
    $sth->finish;
--- 308,318 ----
    my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
    										biblioitemnumber=?,unitprice=?,freight=?,rrp=?
!   						where biblionumber=? and ordernumber=?");
    $sth->execute($quantrec,$invoiceno,$bibitemno,$cost,$freight,$rrp,$biblio,$ordnum);
    $sth->finish;
!   $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
!   ordernumber=?");
    $sth->execute($bookfund,$ordnum);
    $sth->finish;
***************
*** 347,363 ****
    my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update aqorders set
!   unitprice='$cost', rrp='$rrp'
!   where biblionumber=$biblio and ordernumber=$ordnum
!   ";
! #  print $query;
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
!   $query="update aqorderbreakdown set bookfundid=$bookfund where
!   ordernumber=$ordnum";
!   $sth=$dbh->prepare($query);
! #  print $query;
!   $sth->execute;
    $sth->finish;
  }
--- 336,347 ----
    my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update aqorders set
!   unitprice=?, rrp=?
!   where biblionumber=? and ordernumber=?
!   ");
!   $sth->execute($cost,$rrp,$biblio,$ordnum);
    $sth->finish;
!   $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where ordernumber=?");
!   $sth->execute($bookfund,$ordnum);
    $sth->finish;
  }
***************
*** 405,424 ****
    my ($supplierid)=@_;
    my $dbh = C4::Context->dbh;
!   my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
!   booksellerid='$supplierid' and (quantity > quantityreceived or
    quantityreceived is NULL)
!   and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')";
!   $query.=" group by basketno order by entrydate desc";
!   #print $query;
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
!   my @results;
!   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return ($i,\@results);
  }
  
--- 389,404 ----
    my ($supplierid)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select count(*),authorisedby,entrydate,basketno from aqorders where
!   booksellerid=? and (quantity > quantityreceived or
    quantityreceived is NULL)
!   and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')
!    group by basketno order by entrydate desc");
!   $sth->execute($supplierid);
!   my @results = ();
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return (scalar(@results),\@results);
  }
  
***************
*** 441,446 ****
    my ($bi,$bib)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?";
!   my $sth=$dbh->prepare($query);
    $sth->execute($bib,$bi);
    # FIXME - Use fetchrow_array(), since we're only interested in the one
--- 421,425 ----
    my ($bi,$bib)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?");
    $sth->execute($bib,$bi);
    # FIXME - Use fetchrow_array(), since we're only interested in the one
***************
*** 449,453 ****
    $sth->finish;
    my $order=getsingleorder($ordnum->{'ordernumber'});
- #  print $query;
    return ($order,$ordnum->{'ordernumber'});
  }
--- 428,431 ----
***************
*** 471,481 ****
    my ($ordnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
!   where aqorders.ordernumber='$ordnum'
    and biblio.biblionumber=aqorders.biblionumber and
    biblioitems.biblioitemnumber=aqorders.biblioitemnumber and
!   aqorders.ordernumber=aqorderbreakdown.ordernumber";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $data=$sth->fetchrow_hashref;
    $sth->finish;
--- 449,458 ----
    my ($ordnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from biblio,biblioitems,aqorders,aqorderbreakdown
!   where aqorders.ordernumber=?
    and biblio.biblionumber=aqorders.biblionumber and
    biblioitems.biblioitemnumber=aqorders.biblioitemnumber and
!   aqorders.ordernumber=aqorderbreakdown.ordernumber");
!   $sth->execute($ordnum);
    my $data=$sth->fetchrow_hashref;
    $sth->finish;
***************
*** 502,506 ****
    my ($supid)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
    and (cancelledby is NULL or cancelledby = '')
    and (quantityreceived < quantity or quantityreceived is NULL)
--- 479,484 ----
    my ($supid)=@_;
    my $dbh = C4::Context->dbh;
!   my @results = ();
!   my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
    and (cancelledby is NULL or cancelledby = '')
    and (quantityreceived < quantity or quantityreceived is NULL)
***************
*** 509,523 ****
    group by aqorders.biblioitemnumber
    order by
!   biblio.title";
!   my $i=0;
!   my @results;
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 487,497 ----
    group by aqorders.biblioitemnumber
    order by
!   biblio.title");
!   $sth->execute($supid);
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 527,531 ****
    my ($supid)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
    and (cancelledby is NULL or cancelledby = '')
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
--- 501,506 ----
    my ($supid)=@_;
    my $dbh = C4::Context->dbh;
!   my @results= ();
!   my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
    and (cancelledby is NULL or cancelledby = '')
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
***************
*** 535,549 ****
    group by aqorders.biblioitemnumber
    order by
!   biblio.title";
!   my $i=0;
!   my @results;
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 510,520 ----
    group by aqorders.biblioitemnumber
    order by
!   biblio.title");
!   $sth->execute($supid);
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 586,613 ****
  	my ($search,$id,$biblio,$catview) = @_;
  	my $dbh   = C4::Context->dbh;
- 	my $query = "Select *,biblio.title from aqorders,biblioitems,biblio
- 							where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
- 									and aqorders.booksellerid = '$id'
- 									and biblio.biblionumber=aqorders.biblionumber
- 									and ((datecancellationprinted is NULL)
- 									or (datecancellationprinted = '0000-00-00'))
- 									and ((";
  	my @data  = split(' ',$search);
! 	my $count = @data;
! 	for (my $i = 0; $i < $count; $i++) {
! 		$query .= "(biblio.title like '$data[$i]%' or biblio.title like '% $data[$i]%') and ";
! 	}
! 	$query=~ s/ and $//;
! 			# FIXME - Redo this properly instead of hacking off the
! 			# trailing 'and'.
! 	$query.=" ) or biblioitems.isbn='$search' or (aqorders.ordernumber='$search' and aqorders.biblionumber='$biblio')) ";
! 	if ($catview ne 'yes'){
! 		$query.=" and (quantityreceived < quantity or quantityreceived is NULL)";
! 	}
! 	$query.=" group by aqorders.ordernumber";
! 	my $sth=$dbh->prepare($query);
! 	$sth->execute;
! 	my $i=0;
! 	my @results;
  	my $sth2=$dbh->prepare("Select * from biblio where biblionumber=?");
  	my $sth3=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
--- 557,577 ----
  	my ($search,$id,$biblio,$catview) = @_;
  	my $dbh   = C4::Context->dbh;
  	my @data  = split(' ',$search);
! 	my @searchterms = ($id);
! 	map { push(@searchterms,"$_%","% $_%") } @data;
! 	push(@searchterms,$search,$search,$biblio);
! 	my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblioitems,biblio
! 		where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
! 		and aqorders.booksellerid = ?
! 		and biblio.biblionumber=aqorders.biblionumber
! 		and ((datecancellationprinted is NULL)
! 		or (datecancellationprinted = '0000-00-00'))
! 		and (("
! 		.(join(" and ",map { "(biblio.title like ? or biblio.title like ?)" } @data))
! 		.") or biblioitems.isbn=? or (aqorders.ordernumber=? and aqorders.biblionumber=?)) "
! 		.(($catview ne 'yes')?" and (quantityreceived < quantity or quantityreceived is NULL)":"")
! 		." group by aqorders.ordernumber");
! 	$sth->execute(@searchterms);
! 	my @results = ();
  	my $sth2=$dbh->prepare("Select * from biblio where biblionumber=?");
  	my $sth3=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
***************
*** 621,631 ****
  		$data->{'branchcode'}=$data3->{'branchcode'};
  		$data->{'bookfundid'}=$data3->{'bookfundid'};
! 		$results[$i]=$data;
! 		$i++;
  	}
  	$sth->finish;
  	$sth2->finish;
  	$sth3->finish;
! 	return($i, at results);
  }
  
--- 585,594 ----
  		$data->{'branchcode'}=$data3->{'branchcode'};
  		$data->{'bookfundid'}=$data3->{'bookfundid'};
! 		push(@results,$data);
  	}
  	$sth->finish;
  	$sth2->finish;
  	$sth3->finish;
! 	return(scalar(@results), at results);
  }
  
***************
*** 651,668 ****
    my ($invoice)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqorders,biblio,biblioitems where
!   booksellerinvoicenumber='$invoice'
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
!   aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber";
!   my $i=0;
!   my @results;
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 614,628 ----
    my ($invoice)=@_;
    my $dbh = C4::Context->dbh;
!   my @results = ();
!   my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where
!   booksellerinvoicenumber=?
    and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
!   aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber");
!   $sth->execute($invoice);
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 682,698 ****
  sub bookfunds {
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
    =aqbudget.bookfundid
!   group by aqbookfund.bookfundid order by bookfundname";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
!   my @results;
!   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 642,655 ----
  sub bookfunds {
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
    =aqbudget.bookfundid
!   group by aqbookfund.bookfundid order by bookfundname");
    $sth->execute;
!   my @results = ();
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 702,712 ****
    my ($id)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
!   from aqorders,aqorderbreakdown where bookfundid='$id' and
    aqorders.ordernumber=aqorderbreakdown.ordernumber
    and (datecancellationprinted is NULL or
!   datecancellationprinted='0000-00-00')";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $comtd=0;
    my $spent=0;
--- 659,668 ----
    my ($id)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
!   from aqorders,aqorderbreakdown where bookfundid=? and
    aqorders.ordernumber=aqorderbreakdown.ordernumber
    and (datecancellationprinted is NULL or
!   datecancellationprinted='0000-00-00')");
!   $sth->execute($id);
    my $comtd=0;
    my $spent=0;
***************
*** 739,748 ****
    my ($currency,$price)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select rate from currency where currency='$currency'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
!   my $data=$sth->fetchrow_hashref;
    $sth->finish;
-   my $cur=$data->{'rate'};
    if ($cur==0){
      $cur=1;
--- 695,702 ----
    my ($currency,$price)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select rate from currency where currency=?");
!   $sth->execute($currency);
!   my $cur=($sth->fetchrow_array())[0];
    $sth->finish;
    if ($cur==0){
      $cur=1;
***************
*** 765,779 ****
  sub getcurrencies {
    my $dbh = C4::Context->dbh;
!   my $query="Select * from currency";
!   my $sth=$dbh->prepare($query);
    $sth->execute;
!   my @results;
!   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i,\@results);
  }
  
--- 719,730 ----
  sub getcurrencies {
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from currency");
    $sth->execute;
!   my @results = ();
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results),\@results);
  }
  
***************
*** 789,795 ****
    my ($currency,$rate)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update currency set rate=$rate where currency='$currency'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
  }
--- 740,745 ----
    my ($currency,$rate)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update currency set rate=? where currency=?");
!   $sth->execute($rate,$currency);
    $sth->finish;
  }
***************
*** 799,806 ****
    my($price,$rrp,$itemnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="update items set price='$price',replacementprice='$rrp'
!   where itemnumber=$itemnum";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    $sth->finish;
  }
--- 749,754 ----
    my($price,$rrp,$itemnum)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("update items set price=?,replacementprice=? where itemnumber=?");
!   $sth->execute($price,$rrp,$itemnum);
    $sth->finish;
  }
***************
*** 828,843 ****
    my ($searchstring)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqbooksellers where name like '$searchstring%' or
!   id = '$searchstring'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my @results;
-   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i, at results);
  }
  
--- 776,787 ----
    my ($searchstring)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from aqbooksellers where name like ? or id = ?");
!   $sth->execute("$searchstring%",$searchstring);
    my @results;
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results), at results);
  }
  
***************
*** 857,871 ****
    my ($id)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from aqorderbreakdown where ordernumber='$id'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
!   my @results;
!   my $i=0;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
!   return($i,\@results);
  }
  
--- 801,812 ----
    my ($id)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
!   $sth->execute($id);
!   my @results = ();
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
!   return(scalar(@results),\@results);
  }
  
***************
*** 884,900 ****
  sub branches {
      my $dbh   = C4::Context->dbh;
!     my $query = "Select * from branches order by branchname";
!     my $sth   = $dbh->prepare($query);
!     my $i     = 0;
!     my @results;
  
!     $sth->execute;
      while (my $data = $sth->fetchrow_hashref) {
!         $results[$i] = $data;
!     	$i++;
      } # while
  
      $sth->finish;
!     return($i, @results);
  } # sub branches
  
--- 825,838 ----
  sub branches {
      my $dbh   = C4::Context->dbh;
!     my $sth   = $dbh->prepare("Select * from branches order by branchname");
!     my @results = ();
  
!     $sth->execute();
      while (my $data = $sth->fetchrow_hashref) {
!         push(@results,$data);
      } # while
  
      $sth->finish;
!     return(scalar(@results), @results);
  } # sub branches
  
***************
*** 903,918 ****
    my ($biblionumber)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from biblioitems,items,itemtypes where
!   biblioitems.biblionumber=$biblionumber
    and biblioitems.biblioitemnumber=items.biblioitemnumber and
    itemtypes.itemtype=biblioitems.itemtype
!   order by items.biblioitemnumber";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my @results;
-   my $i;
    while (my $data=$sth->fetchrow_hashref){
!     $results[$i]=$data;
!     $i++;
    }
    $sth->finish;
--- 841,853 ----
    my ($biblionumber)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from biblioitems,items,itemtypes where
!   biblioitems.biblionumber=?
    and biblioitems.biblioitemnumber=items.biblioitemnumber and
    itemtypes.itemtype=biblioitems.itemtype
!   order by items.biblioitemnumber");
!   $sth->execute($biblionumber);
    my @results;
    while (my $data=$sth->fetchrow_hashref){
!     push(@results,$data);
    }
    $sth->finish;
***************
*** 924,931 ****
    my ($bibitemnum,$itemtype)=@_;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
!   and itemtype='$itemtype'";
!   my $sth=$dbh->prepare($query);
!   $sth->execute;
    my $result=0;
    if (my $data=$sth->fetchrow_hashref){
--- 859,865 ----
    my ($bibitemnum,$itemtype)=@_;
    my $dbh = C4::Context->dbh;
!   my $sth=$dbh->prepare("Select * from biblioitems where biblioitemnumber=?
!   and itemtype=?");
!   $sth->execute($bibitemnum,$itemtype);
    my $result=0;
    if (my $data=$sth->fetchrow_hashref){
***************
*** 954,958 ****
     my ($data)=@_;
     my $dbh = C4::Context->dbh;
!    my $query="Update aqbooksellers set
     name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
     phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
--- 888,892 ----
     my ($data)=@_;
     my $dbh = C4::Context->dbh;
!    my $sth=$dbh->prepare("Update aqbooksellers set
     name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
     phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
***************
*** 961,966 ****
     invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
     nocalc=?
!    where id=?";
!    my $sth=$dbh->prepare($query);
     $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
     $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
--- 895,899 ----
     invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
     nocalc=?
!    where id=?");
     $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
     $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
***************
*** 996,1001 ****
    $sth->finish;
    $data2->{'max(id)'}++;
!   $sth=$dbh->prepare("Insert into aqbooksellers (id) values ($data2->{'max(id)'})");
!   $sth->execute;
    $sth->finish;
    $data->{'id'}=$data2->{'max(id)'};
--- 929,934 ----
    $sth->finish;
    $data2->{'max(id)'}++;
!   $sth=$dbh->prepare("Insert into aqbooksellers (id) values (?)");
!   $sth->execute($data2->{'max(id)'});
    $sth->finish;
    $data->{'id'}=$data2->{'max(id)'};
***************
*** 1023,1063 ****
      my ($keywordlist) = @_;
      my $dbh   = C4::Context->dbh;
-     my $query = "Select distinct biblio.* from biblio, biblioitems where
- biblio.biblionumber = biblioitems.biblionumber and (";
-     my $count = 0;
      my $sth;
!     my @results;
      my @keywords = split(/ +/, $keywordlist);
-     my $keyword = shift(@keywords);
  
!     # FIXME - Can use
!     #	$query .= join(" and ",
!     #		apply { url like "%$_%" } @keywords
! 
!     $keyword =~ s/%/\\%/g;
!     $keyword =~ s/_/\\_/;
!     $keyword = "%" . $keyword . "%";
!     $keyword = $dbh->quote($keyword);
!     $query  .= " (url like $keyword)";
! 
!     foreach $keyword (@keywords) {
!         $keyword =~ s/%/\\%/;
! 	$keyword =~ s/_/\\_/;
! 	$keyword = "%" . $keyword . "%";
!         $keyword = $dbh->quote($keyword);
! 	$query  .= " or (url like $keyword)";
!     } # foreach
! 
!     $query .= ")";
!     $sth    = $dbh->prepare($query);
!     $sth->execute;
  
      while (my $data = $sth->fetchrow_hashref) {
!         $results[$count] = $data;
! 	$count++;
      } # while
  
      $sth->finish;
!     return($count, @results);
  } # sub websitesearch
  
--- 956,974 ----
      my ($keywordlist) = @_;
      my $dbh   = C4::Context->dbh;
      my $sth;
!     my @results = ();
      my @keywords = split(/ +/, $keywordlist);
  
! 	$sth    = $dbh->prepare("Select distinct biblio.* from biblio, biblioitems where
!     	biblio.biblionumber = biblioitems.biblionumber and ("
! 		.(join(") or (",map { "url like ?" } @keywords)).")");
!     $sth->execute(map { s/([%_])/\\\1/g; "%$_%" } @keywords);
  
      while (my $data = $sth->fetchrow_hashref) {
!         push(@results,$data);
      } # while
  
      $sth->finish;
!     return(scalar(@results), @results);
  } # sub websitesearch
  





More information about the Koha-cvs mailing list