$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
return $value;
}
+##########################
+# Get data for the submitted order id
+# from database
+#
+sub get_order_data_by_ordnumber {
+ $main::lxdebug->enter_sub();
+
+ my $self = shift;
+ my %params = @_;
+
+ Common::check_params(\%params, qw(ordnumber));
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $dbh = $form->get_standard_dbh();
+
+ my @values = ($params{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);
+
+ $main::lxdebug->leave_sub();
+
+ return $result;
+}
+
1;
use SL::FU;
use SL::IS;
use SL::PE;
+use SL::OE;
use Data::Dumper;
use List::Util qw(max sum);
}
# Load data for a specific order and update form fields
- my $order_data = IS->get_order_data();
+ my $order_data = OE->get_order_data_by_ordnumber(%$form);
# Copy the fields we need to %form
for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) {