diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-24 06:22:23 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-24 06:22:23 +0000 |
commit | 0303f21d687059f314eaeef17e40eba99d22001f (patch) | |
tree | 5bff8e21de4eac7fd7fed585aa6041e325f5c49a /LedgerSMB/OE.pm | |
parent | 7598b08d170810570ff60d77fdb991673601e6b6 (diff) |
Added support for custom fields to IS, OE, and corrected API bugs in Form.
Also AA now partially supports the custom fields.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@139 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/OE.pm')
-rwxr-xr-x | LedgerSMB/OE.pm | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm index ae4cd635..2fcaec9b 100755 --- a/LedgerSMB/OE.pm +++ b/LedgerSMB/OE.pm @@ -261,6 +261,7 @@ sub save { } } + my $did_insert = 0; if (! $form->{id}) { my $uid = localtime; @@ -276,7 +277,15 @@ sub save { $sth->execute || $form->dberror($query); ($form->{id}) = $sth->fetchrow_array; $sth->finish; - + @queries = $form->get_custom_queries('oe', 'INSERT'); + + for (@queries){ + $query = shift (@{$_}); + $sth = $dbh->prepare($query) || $form->db_error($query); + $sth->execute(@{$_}, $form->{id})|| $form->dberror($query);; + $sth->finish; + $did_insert = 1; + } } my $amount; @@ -451,6 +460,18 @@ sub save { WHERE id = $form->{id}|; $dbh->do($query) || $form->dberror($query); + if (!$did_insert){ + @queries = $form->get_custom_queries('oe', 'UPDATE'); + for (@queries){ + my $query = shift @{$_}; + $sth = $dbh->prepare($query); + $sth->execute (@{$_}, $form->{id}); + $sth->finish; + } + } + + + $form->{ordtotal} = $amount; # add shipto @@ -644,10 +665,6 @@ sub retrieve { $sth->finish; for (qw(printed emailed queued)) { $form->{$_} =~ s/ +$//g } - my %oid = ( 'Pg' => 'id', - 'Oracle' => 'rowid', - 'DB2' => '1=1' - ); # retrieve individual items $query = qq|SELECT o.id AS orderitems_id, @@ -665,7 +682,7 @@ sub retrieve { LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) LEFT JOIN translation t ON (t.trans_id = p.partsgroup_id AND t.language_code = '$form->{language_code}') WHERE o.trans_id = $form->{id} - ORDER BY o.$oid{$myconfig->{dbdriver}}|; + ORDER BY o.id|; $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); @@ -727,6 +744,17 @@ sub retrieve { # get recurring transaction $form->get_recurring($dbh); + @queries = $form->get_custom_queries('oe', 'SELECT'); + for (@queries){ + $query = shift @{$_}; + $sth = $form->{dbh}->prepare($query); + $sth->execute($form->{id}); + $ref = $sth->fetchrow_hashref(NAME_lc); + for (keys %{$ref}){ + $form->{$_} = $ref->{$_}; + } + } + $form->{dbh}->commit; } else { # get last name used |