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 | |
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')
-rwxr-xr-x | LedgerSMB/AA.pm | 43 | ||||
-rwxr-xr-x | LedgerSMB/Form.pm | 17 | ||||
-rwxr-xr-x | LedgerSMB/IS.pm | 20 | ||||
-rwxr-xr-x | LedgerSMB/OE.pm | 40 |
4 files changed, 92 insertions, 28 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index a3e2d49e..f5b8a470 100755 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -250,25 +250,36 @@ sub post_transaction { $form->{invnumber} = $form->update_defaults($myconfig, $invnumber) unless $form->{invnumber}; - $query = qq|UPDATE $table SET invnumber = |.$dbh->quote($form->{invnumber}).qq|, - ordnumber = |.$dbh->quote($form->{ordnumber}).qq|, - transdate = '$form->{transdate}', - $form->{vc}_id = $form->{"$form->{vc}_id"}, - taxincluded = '$form->{taxincluded}', - amount = $invamount, - duedate = '$form->{duedate}', - paid = $paid, - datepaid = $datepaid, - netamount = $invnetamount, - curr = '$form->{currency}', - notes = |.$dbh->quote($form->{notes}).qq|, - department_id = $form->{department_id}, - employee_id = $form->{employee_id}, - ponumber = |.$dbh->quote($form->{ponumber}).qq| - WHERE id = $form->{id}|; + $query = qq| + UPDATE $table + SET invnumber = |.$dbh->quote($form->{invnumber}).qq|, + ordnumber = |.$dbh->quote($form->{ordnumber}).qq|, + transdate = '$form->{transdate}', + $form->{vc}_id = $form->{"$form->{vc}_id"}, + taxincluded = '$form->{taxincluded}', + amount = $invamount, + duedate = '$form->{duedate}', + paid = $paid, + datepaid = $datepaid, + netamount = $invnetamount, + curr = '$form->{currency}', + notes = |.$dbh->quote($form->{notes}).qq|, + department_id = $form->{department_id}, + employee_id = $form->{employee_id}, + ponumber = |.$dbh->quote($form->{ponumber}).qq| + WHERE id = $form->{id} + |; $dbh->do($query) || $form->dberror($query); + @queries = $form->get_custom_queries($table, '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; + } # update exchangerate my $buy = $form->{exchangerate}; my $sell = 0; diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 7a578448..2e0f6b4b 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1304,6 +1304,7 @@ sub get_custom_queries { } for (keys %temphash){ my @data; + my $ins_values; $query = "$query_type "; if ($query_type eq 'UPDATE'){ $query .= " $_ SET "; @@ -1316,21 +1317,25 @@ sub get_custom_queries { if ($query_type eq 'UPDATE'){ $query .= '= ?'; } - my $ins_values .= "?, "; - if ($first == 0){ - $query .= ", "; - } + $ins_values .= "?, "; + $query .= ", "; $first = 0; - if ($query_type eq 'UPDATE' or $query_type eq 'INERT'){ - push @data, $form->{$_ . $linenum}; + if ($query_type eq 'UPDATE' or $query_type eq 'INSERT'){ + push @data, $self->{"$_$linenum"}; } } + if ($query_type ne 'INSERT'){ + $query =~ s/, $//; + } if ($query_type eq 'SELECT'){ $query .= " FROM $_"; } if ($query_type eq 'SELECT' or $query_type eq 'UPDATE'){ $query .= " WHERE field_id = ?"; } + if ($query_type eq 'INSERT'){ + $query .= " field_id) VALUES ($ins_values ?)"; + } if ($query_type eq 'SELECT'){ push @rc, [ $query ]; } else { diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index bda4d5b6..1e4714fa 100755 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -633,6 +633,15 @@ sub post_invoice { ($form->{id}) = $sth->fetchrow_array; $sth->finish; + + @queries = $form->get_custom_queries('ar', '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; + } } @@ -1421,6 +1430,17 @@ sub retrieve_invoice { my $rc = $dbh->commit; $dbh->disconnect; + @queries = $form->get_custom_queries('ar', '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; $rc; } 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 |