# get shipto address
- $query = qq|SELECT id, shiptoname
+ $query = qq|SELECT shipto_id, shiptoname, shiptodepartment_1
FROM shipto WHERE trans_id=$form->{id}|;
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
}
# add shipto
- $form->add_shipto($dbh, $form->{id});
+ $form->add_shipto($dbh, $form->{id}, "CT");
$rc = $dbh->disconnect;
my $dbh = $form->dbconnect($myconfig);
my $query = qq|SELECT s.*
FROM shipto s
- WHERE s.id = $form->{shipto_id} order by s.id limit 1|;
+ WHERE s.shipto_id = $form->{shipto_id}|;
+ #WHERE s.shipto_id = $form->{shipto_id} order by s.shipto_id limit 1|;
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
$where .= "AND ar.transdate <= '$form->{to}' ";
}
- my $query = qq|select shiptoname, adr_code, ar.transdate, ar.invnumber, ar.ordnumber, invoice.description, qty, invoice.unit FROM ar LEFT join shipto ON (ar.shipto_id=shipto.id) LEFT join invoice on (ar.id=invoice.trans_id) LEFT join parts ON (parts.id=invoice.parts_id) LEFT join adr ON (parts.adr_id=adr.id) $where ORDER BY ar.transdate DESC LIMIT 15|;
+ my $query = qq|select shiptoname, adr_code, ar.transdate, ar.invnumber, ar.ordnumber, invoice.description, qty, invoice.unit FROM ar LEFT join shipto ON (ar.shipto_id=shipto.shipto_id) LEFT join invoice on (ar.id=invoice.trans_id) LEFT join parts ON (parts.id=invoice.parts_id) LEFT join adr ON (parts.adr_id=adr.id) $where ORDER BY ar.transdate DESC LIMIT 15|;
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
my $query = qq|SELECT s.* FROM shipto s
- WHERE s.id = $self->{shipto_id}|;
+ WHERE s.shipto_id = $self->{shipto_id}|;
my $sth = $dbh->prepare($query);
$sth->execute || $self->dberror($query);
$ref = $sth->fetchrow_hashref(NAME_lc);
}
$self->{"shipto$item"} =~ s/\'/\'\'/g;
}
-
if ($shipto) {
if ($self->{shipto_id}) {
my $query = qq| UPDATE shipto set
shiptophone = '$self->{shiptophone}',
shiptofax = '$self->{shiptofax}',
shiptoemail = '$self->{shiptoemail}'
- WHERE id = $self->{shipto_id}|;
+ WHERE shipto_id = $self->{shipto_id}|;
$dbh->do($query) || $self->dberror($query);
} else {
my $query =
$sth->finish;
# get shipping addresses
- $query = qq|SELECT s.id,s.shiptoname
+ $query = qq|SELECT s.shipto_id,s.shiptoname,s.shiptodepartment_1
FROM shipto s
WHERE s.trans_id = $form->{customer_id}|;
$sth = $dbh->prepare($query);