diff options
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/AM.pm | 24 |
1 files changed, 22 insertions, 2 deletions
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='$_';")}; + + } + } } |