+# this function closes multiple orders given in $form->{ordnumber_#}.
+# use this for multiple orders that don't have to be saved back
+# single orders should use OE::save instead.
+sub close_orders {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ for my $i (1 .. $form->{rowcount}) {
+
+ map {
+ $form->{"${_}_$i"} =
+ $form->parse_amount($myconfig, $form->{"${_}_$i"})
+ } qw(qty ship);
+ if ($delete_oe_id) {
+ $form->{"orderitems_id_$i"} = "";
+ }
+
+ if ($form->{"qty_$i"}) {
+
+ # set values to 0 if nothing entered
+ $form->{"discount_$i"} =
+ $form->parse_amount($myconfig, $form->{"discount_$i"});
+
+ $form->{"sellprice_$i"} =
+ $form->parse_amount($myconfig, $form->{"sellprice_$i"});
+ }
+ }
+
+ # get ids from $form
+ map { push @ids, $form->{"ordnumber_$_"} if $form->{"ordnumber_$_"} }
+ (1 .. $form->{rowcount});
+
+ my $dbh = $form->dbconnect($myconfig);
+ $query = qq|UPDATE oe SET
+ closed = TRUE
+ WHERE ordnumber IN (|
+ . join(', ', map { $dbh->quote($_) } @ids) . qq|)|;
+ $dbh->do($query) || $form->dberror($query);
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
+sub close_order {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ $main::lxdebug->leave_sub() unless ($form->{"id"});
+
+ my $dbh = $form->dbconnect($myconfig);
+ do_query($form, $dbh, qq|UPDATE oe SET closed = TRUE where id = ?|,
+ $form->{"id"});
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+