+ if ($self->{printer_id}) {
+
+ my $dbh = $self->dbconnect($myconfig);
+
+
+ my $query = qq|SELECT p.template_code,p.printer_command FROM printers p
+ WHERE p.id = $self->{printer_id}|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ ($template_code, $self->{printer_command}) = $sth->fetchrow_array;
+ $sth->finish;
+ $dbh->disconnect;
+ }
+
+ $main::lxdebug->leave_sub();
+
+ return $template_code;
+}
+
+sub get_shipto {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig) = @_;
+
+ my $template_code = "";
+
+ if ($self->{shipto_id}) {
+
+ my $dbh = $self->dbconnect($myconfig);
+
+
+ my $query = qq|SELECT s.* FROM shipto s
+ WHERE s.shipto_id = $self->{shipto_id}|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+ $ref = $sth->fetchrow_hashref(NAME_lc);
+ map { $self->{$_} = $ref->{$_} } keys %$ref;
+ $sth->finish;
+ $dbh->disconnect;
+ }
+
+ $main::lxdebug->leave_sub();
+
+}
+
+sub add_shipto {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $dbh, $id, $module) = @_;
+##LINET
+ my $shipto;
+ foreach my $item (
+ qw(name department_1 department_2 street zipcode city country contact phone fax email)
+ ) {
+ if ($self->{"shipto$item"}) {
+ $shipto = 1 if ($self->{$item} ne $self->{"shipto$item"});
+ }
+ $self->{"shipto$item"} =~ s/\'/\'\'/g;
+ }
+ if ($shipto) {
+ if ($self->{shipto_id}) {
+ my $query = qq| UPDATE shipto set
+ shiptoname = '$self->{shiptoname}',
+ shiptodepartment_1 = '$self->{shiptodepartment_1}',
+ shiptodepartment_2 = '$self->{shiptodepartment_2}',
+ shiptostreet = '$self->{shiptostreet}',
+ shiptozipcode = '$self->{shiptozipcode}',
+ shiptocity = '$self->{shiptocity}',
+ shiptocountry = '$self->{shiptocountry}',
+ shiptocontact = '$self->{shiptocontact}',
+ shiptophone = '$self->{shiptophone}',
+ shiptofax = '$self->{shiptofax}',
+ shiptoemail = '$self->{shiptoemail}'
+ WHERE shipto_id = $self->{shipto_id}|;
+ $dbh->do($query) || $self->dberror($query);
+ } else {
+ my $query =
+ qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, shiptodepartment_2, shiptostreet,
+ shiptozipcode, shiptocity, shiptocountry, shiptocontact,
+ shiptophone, shiptofax, shiptoemail, module) VALUES ($id,
+ '$self->{shiptoname}', '$self->{shiptodepartment_1}', '$self->{shiptodepartment_2}', '$self->{shiptostreet}',
+ '$self->{shiptozipcode}', '$self->{shiptocity}',
+ '$self->{shiptocountry}', '$self->{shiptocontact}',
+ '$self->{shiptophone}', '$self->{shiptofax}',
+ '$self->{shiptoemail}', '$module')|;
+ $dbh->do($query) || $self->dberror($query);
+ }
+ }
+##/LINET
+ $main::lxdebug->leave_sub();
+}
+
+sub get_employee {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $dbh) = @_;
+
+ my $query = qq|SELECT e.id, e.name FROM employee e
+ WHERE e.login = '$self->{login}'|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ ($self->{employee_id}, $self->{employee}) = $sth->fetchrow_array;