summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-28 15:35:08 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-09-28 15:35:08 +0000
commit7a2786805e9f7e29050b82a3da03d0fefa7841e7 (patch)
tree00069dd81e7da3404ba5eeb7b382883375e7713e
parent4189e38298109e7e923970771a17c56b2973c79e (diff)
Moving loading of Perl Module CP to top of function.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@163 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xLedgerSMB/OE.pm26
1 files changed, 15 insertions, 11 deletions
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm
index 9e87055b..a008092a 100755
--- a/LedgerSMB/OE.pm
+++ b/LedgerSMB/OE.pm
@@ -247,7 +247,7 @@ sub save {
$form->db_prepare_vars("quonumber", "transdate", "vendor_id",
"customer_id", "reqdate", "taxincluded", "shippingpoint",
- "shipvia", "currency", "closed", "department_id",
+ "shipvia", "currency", "department_id",
"employee_id", "language_code", "ponumber", "terms");
# connect to database, turn off autocommit
my $dbh = $form->{dbh};
@@ -309,13 +309,18 @@ sub save {
$sth->execute($form->{id}) || $form->dberror($query);
} else { # id is not in the database
- $form->{id} = undef;
+ delete $form->{id};
}
}
my $did_insert = 0;
if (! $form->{id}) {
+ $query = qq|SELECT nextval('id')|;
+ $sth = $dbh->prepare($query);
+ $sth->execute || $form->dberror($query);
+ ($form->{id}) = $sth->fetchrow_array;
+ $sth->finish;
my $uid = localtime;
$uid .= "$$";
@@ -325,16 +330,20 @@ sub save {
if (!$form->{transdate}){
$form->{transdate} = "now";
}
-
+
+ if (($form->{closed} ne 't') and ($form->{closed} ne "1")){
+ $form->{closed} = 'f';
+ }
+ # $form->{id} is safe because it is only pulled *from* the db.
$query = qq|
INSERT INTO oe
- (ordnumber, quonumber, transdate, vendor_id,
+ (id, ordnumber, quonumber, transdate, vendor_id,
customer_id, reqdate, shippingpoint, shipvia,
notes, intnotes, curr, closed, department_id,
employee_id, language_code, ponumber, terms,
quotation)
VALUES
- (?, ?, ?, ?,
+ ($form->{id}, ?, ?, ?, ?,
?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?)|;
@@ -351,11 +360,6 @@ sub save {
$sth->execute(@queryargs) || $form->dberror($query);
$sth->finish;
- $query = qq|SELECT currval('id')|;
- $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
- ($form->{id}) = $sth->fetchrow_array;
- $sth->finish;
@queries = $form->get_custom_queries('oe', 'INSERT');
for (@queries){
@@ -1194,6 +1198,7 @@ sub exchangerate_defaults {
sub order_details {
+ use LedgerSMB::CP;
my ($self, $myconfig, $form) = @_;
# connect to database
@@ -1774,7 +1779,6 @@ sub order_details {
? $form->{ordtotal}
: $form->{ordtotal} + $tax;
- use LedgerSMB::CP;
my $c;
if ($form->{language_code} ne "") {
$c = new CP $form->{language_code};