From 98683262ca3b39c7c332b45e13c9d96827573900 Mon Sep 17 00:00:00 2001 From: Mason James Date: Wed, 31 Oct 2007 19:57:29 -0500 Subject: [PATCH] Modbookfund() now correctly updating all aqbudget.branchcode's linked to mod-ed bookfund Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Bookfund.pm | 53 +++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/C4/Bookfund.pm b/C4/Bookfund.pm index 50bd464fe7..553180a8f1 100644 --- a/C4/Bookfund.pm +++ b/C4/Bookfund.pm @@ -19,6 +19,7 @@ package C4::Bookfund; use strict; +use Smart::Comments; use vars qw($VERSION @ISA @EXPORT); @@ -321,50 +322,36 @@ on database. =cut + sub ModBookFund { my ($bookfundname,$bookfundid,$current_branch, $branchcode) = @_; my $dbh = C4::Context->dbh; -=c - my $query = " - UPDATE aqbookfund - SET bookfundname = ?, - branchcode = ? - WHERE bookfundid = ? - AND branchcode= ? - "; - warn "$bookfundname,$branchcode, $bookfundid,$current_branch"; - my $sth=$dbh->prepare($query); - $sth->execute($bookfundname,"$branchcode", $bookfundid,"$current_branch"); -=cut - - my $retval = $dbh->do(' + my $retval = $dbh->do(" UPDATE aqbookfund - SET bookfundname = $bookfundname, - branchcode = $branchcode - WHERE bookfundid = $bookfundid - AND branchcode= $current_branch - '); - - warn "$bookfundname,$branchcode, $bookfundid,$current_branch"; -### $retval - - - -# budgets depending on a bookfund must have the same branchcode -# if the bookfund branchcode is set - if (defined $branchcode) { - $query = " - UPDATE aqbudget + SET bookfundname = '$bookfundname', + branchcode = '$branchcode' + WHERE bookfundid = '$bookfundid' + AND branchcode = '$current_branch' + "); + + ### $retval + + # budgets depending on a bookfund must have the same branchcode + # if the bookfund branchcode is set + if (defined $branchcode && $retval > 0) { + my $query = "UPDATE aqbudget SET branchcode = ? - WHERE bookfundid = ? - "; - $sth=$dbh->prepare($query); + WHERE bookfundid = ? "; + + my $sth=$dbh->prepare($query); $sth->execute($branchcode, $bookfundid) ; } } + + #-------------------------------------------------------------# =head3 SearchBookFund -- 2.39.5