From 5ef593682d4ab0f1cab2473870d23a10e605a0b9 Mon Sep 17 00:00:00 2001 From: rangi Date: Wed, 7 Jun 2006 00:39:22 +0000 Subject: [PATCH] Merging katipo changes Last of the changes for Acquisitions.pm, bookfundbreakdowns --- C4/Acquisition.pm | 54 ++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 484df98cc7..156873796e 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1051,18 +1051,18 @@ sub bookfunds { my $branch = $userenv->{branch}; my $strsth; - if ( !( $branch eq '' ) ) { - $strsth = "Select * from aqbookfund,aqbudget where aqbookfund.bookfundid - =aqbudget.bookfundid and startdatenow() and (aqbookfund.branchcode is null or aqbookfund.branchcode='' or aqbookfund.branchcode= ? ) - group by aqbookfund.bookfundid order by bookfundname"; + if ( $branch ne '' ) { + $strsth = "SELECT * FROM aqbookfund,aqbudget WHERE aqbookfund.bookfundid + =aqbudget.bookfundid AND startdatenow() AND (aqbookfund.branchcode is null or aqbookfund.branchcode='' or aqbookfund.branchcode= ? ) + GROUP BY aqbookfund.bookfundid ORDER BY bookfundname"; } else { - $strsth = "Select * from aqbookfund,aqbudget where aqbookfund.bookfundid - =aqbudget.bookfundid and startdatenow() - group by aqbookfund.bookfundid order by bookfundname"; + $strsth = "SELECT * FROM aqbookfund,aqbudget WHERE aqbookfund.bookfundid + =aqbudget.bookfundid AND startdatenow() + GROUP BY aqbookfund.bookfundid ORDER BY bookfundname"; } my $sth = $dbh->prepare($strsth); - if ( !( $branch eq '' ) ) { + if ( $branch ne '' ) { $sth->execute($branch); } else { @@ -1088,21 +1088,31 @@ sub bookfundbreakdown { my ( $id, $year ) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( -"SELECT startdate, enddate, quantity, datereceived, freight, unitprice, listprice, ecost, quantityreceived, subscription -FROM aqorders, aqorderbreakdown, aqbudget, aqbasket -WHERE aqorderbreakdown.bookfundid = ? -AND aqorders.ordernumber = aqorderbreakdown.ordernumber -AND ( -datecancellationprinted IS NULL -OR datecancellationprinted = '0000-00-00' -) -AND aqbudget.bookfundid = aqorderbreakdown.bookfundid -AND aqbasket.basketno = aqorders.basketno -AND aqbasket.creationdate >= startdate -AND enddate >= aqbasket.creationdate -and startdate<=now() and enddate>=now()" + "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); + if ($start) { + $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') + AND ((datereceived >= ? AND datereceived < ?) OR + (budgetdate >= ? AND budgetdate < ?))" + ); + $sth->execute( $id, $start, $end, $start, $end ); + } + else { + $sth->execute($id); + } + my $comtd = 0; my $spent = 0; while ( my $data = $sth->fetchrow_hashref ) { -- 2.39.5