delete($ref->{id});
map { $form->{$_} = $ref->{$_} } keys %$ref;
$sth->finish;
- my $transdate = "current_date";
- if($form->{invdate}) {
- $transdate = "'$form->{invdate}'";
- }
+
+ my $transdate =
+ $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
if(!$form->{taxzone_id}) {
$form->{taxzone_id} = 0;
my ($self, $myconfig, $form) = @_;
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
my $i = $form->{rowcount};
# don't include assemblies or obsolete parts
my $transdate = "";
if ($form->{type} eq "invoice") {
- $transdate = "'$form->{invdate}'";
- } elsif ($form->{type} eq "purchase_order") {
- $transdate = "'$form->{transdate}'";
- } elsif ($form->{type} eq "request_quotation") {
- $transdate = "'$form->{transdate}'";
- }
-
- if ($transdate eq "") {
- $transdate = "current_date";
+ $transdate =
+ $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
+ } else {
+ $transdate =
+ $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
}
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
my $query = qq|SELECT p.id, p.partnumber, p.description, p.sellprice,
p.listprice, p.inventory_accno_id,
c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from as inventory_valid,
$sth->finish;
map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
- my $transdate = "current_date";
- if($form->{invdate}) {
- $transdate = "'$form->{invdate}'";
- }
+ my $transdate =
+ $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) :
+ $form->{invdate} ? $dbh->quote($form->{invdate}) :
+ "current_date";
- if(!$form->{taxzone_id}) {
+ if (!$form->{taxzone_id}) {
$form->{taxzone_id} = 0;
}
# retrieve individual items
my ($self, $myconfig, $form) = @_;
+ # connect to database
+ my $dbh = $form->dbconnect($myconfig);
+
my $i = $form->{rowcount};
my $where = "NOT p.obsolete = '1'";
$where .= " ORDER BY p.partnumber";
}
- my $transdate = "";
+ my $transdate;
if ($form->{type} eq "invoice") {
- $transdate = "'$form->{invdate}'";
- } elsif ($form->{type} eq "sales_order") {
- $transdate = "'$form->{transdate}'";
- } elsif ($form->{type} eq "sales_quotation") {
- $transdate = "'$form->{transdate}'";
- }
-
- if ($transdate eq "") {
- $transdate = "current_date";
+ $transdate =
+ $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) :
+ $form->{invdate} ? $dbh->quote($form->{invdate}) :
+ "current_date";
+ } else {
+ $transdate =
+ $form->{transdate} ? $dbh->quote($form->{transdate}) :
+ "current_date";
}
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
my $query = qq|SELECT p.id, p.partnumber, p.description, p.sellprice,
p.listprice, p.inventory_accno_id,
c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from as inventory_valid,
my %oid = ('Pg' => 'oid',
'Oracle' => 'rowid');
- my $transdate = "'$form->{transdate}'";
- if (!$transdate) {
- $transdate = "current_date";
- }
+ my $transdate =
+ $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
+
if(!$form->{taxzone_id}) {
$form->{taxzone_id} = 0;
}