From ba5890bd2f14e916e47f17a79af49392487dbeb0 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 10 Oct 2008 15:35:29 +0000 Subject: merging in fix for OE generation git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2361 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/AM.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/AM.pm b/LedgerSMB/AM.pm index d502bc20..b6834e53 100644 --- a/LedgerSMB/AM.pm +++ b/LedgerSMB/AM.pm @@ -1828,8 +1828,28 @@ sub save_defaults { || $form->dberror("Saving $_"); } else { - $sth_plain->execute( $val, $_ ) - || $form->dberror("Saving $_"); + my $found=0; + my $sth_defcheck=$dbh->prepare("select count(*) from defaults where setting_key='$_';") || $form->dberror("Select defaults $_"); + $sth_defcheck->execute() || $form->dberror("execute defaults $_"); + while(my $found1=$sth_defcheck->fetchrow()){$found=$found1;} + + if($val ne '') + { + if($found) + { + $dbh->do("update defaults set value=" . $dbh->quote($val) . " where setting_key='$_';"); + } + else + { + $dbh->do("insert into defaults(value,setting_key) values( " . $dbh->quote($val) . ",'$_');"); + } + } + else + { + if($found){$dbh->do("delete from defaults where setting_key='$_';")}; + + } + } } -- cgit v1.2.3