diff options
-rw-r--r-- | LedgerSMB/AM.pm | 24 | ||||
-rw-r--r-- | bin/pe.pl | 2 | ||||
-rw-r--r-- | sql/modules/Account.sql | 2 |
3 files changed, 24 insertions, 4 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='$_';")}; + + } + } } @@ -2891,8 +2891,8 @@ sub generate_sales_orders { } $order = new Form; - $order->{dbh} = $form->{dbh}; for ( keys %{ $form->{order} } ) { + $order->{dbh} = $form->{dbh}; for (qw(type vc defaultcurrency login)) { $order->{$_} = $form->{$_} } for ( split / /, $form->{taxaccounts} ) { diff --git a/sql/modules/Account.sql b/sql/modules/Account.sql index 36275744..2265508a 100644 --- a/sql/modules/Account.sql +++ b/sql/modules/Account.sql @@ -13,7 +13,7 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION account_is_orphaned (in_id int) RETURNS bool AS $$ BEGIN - SELECT trans_id FROM acc_trans WHERE chart_id = in_id LIMIT 1; + PERFORM trans_id FROM acc_trans WHERE chart_id = in_id LIMIT 1; IF FOUND THEN RETURN true; ELSE |