$main::lxdebug->leave_sub();
}
+##########################
+# Get data for the submitted order id
+# from database
+#
+sub get_order_data {
+
+ $main::lxdebug->enter_sub();
+
+ my $self = shift;
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $dbh = $form->get_standard_dbh();
+
+ my @values = (conv_i($form->{ordnumber}));
+
+ # We query the database for the fields we need using the submitted "ordnumber"
+ my $query = <<SQL;
+ SELECT o.payment_id, o.salesman_id, o.transdate AS orddate, o.taxzone_id, o.quonumber
+ FROM oe o
+ WHERE o.ordnumber = ?;
+SQL
+
+ # Do the actual query and return the results for later processing by our "frontend"
+ my ($result) = selectfirst_hashref_query($form, $dbh, $query, @values);
+
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+
+ return $result;
+}
+
##########################
# get pricegroups from database
# build up selected pricegroup
$ref->{name} = $form->quote($ref->{name});
}
+ # Load data for a specific order and update form fields
+ my $order_data = IS->get_order_data();
+
+ # Copy the fields we need to %form
+ for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) {
+ $form->{$key} = $order_data->{$key};
+ }
+
$form->restore_vars(qw(id));
IS->retrieve_invoice(\%myconfig, \%$form);
$form->restore_vars(qw(taxincluded)) if $form->{id};
$form->restore_vars(qw(salesman_id)) if $main::editing;
+
# build vendor/customer drop down comatibility... don't ask
if (@{ $form->{"all_customer"} }) {
$form->{"selectcustomer"} = 1;