X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/94e11003809e9090514026a733e58e72e636a6bb..06211d74ea81c20cd935a9f35df45a6f76590692:/SL/DO.pm diff --git a/SL/DO.pm b/SL/DO.pm index 3f623ec6d..50905ec01 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -142,12 +142,13 @@ sub transactions { "transaction_description" => "dord.transaction_description" ); - my $sortoder = "dord.id"; + my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; + my $sortorder = "dord.id"; if ($form->{sort} && grep($form->{sort}, keys(%allowed_sort_columns))) { $sortorder = $allowed_sort_columns{$form->{sort}}; } - $query .= qq| ORDER by | . $sortorder; + $query .= qq| ORDER by | . $sortorder . " $sortdir"; $form->{DO} = selectall_hashref_query($form, $dbh, $query, @values); @@ -388,13 +389,11 @@ sub mark_orders_if_delivered { my ($oe_id) = $links[0]->{from_id} if (scalar @links); - $main::lxdebug->message(0, "oe_id $oe_id"); - return $main::lxdebug->leave_sub() if (!$oe_id); my $all_units = AM->retrieve_all_units(); - $query = qq|SELECT oi.parts_id, oi.qty, oi.unit, p.unit AS partunit + my $query = qq|SELECT oi.parts_id, oi.qty, oi.unit, p.unit AS partunit FROM orderitems oi LEFT JOIN parts p ON (oi.parts_id = p.id) WHERE (oi.trans_id = ?)|; @@ -404,8 +403,6 @@ sub mark_orders_if_delivered { 'oe_id' => $oe_id,); my %ordered = (); - do_statement($form, $sth, $query, $oe_id); - while (my $ref = $sth->fetchrow_hashref()) { $ref->{baseqty} = $ref->{qty} * $all_units->{$ref->{unit}}->{factor} / $all_units->{$ref->{partunit}}->{factor}; @@ -899,10 +896,10 @@ sub get_item_availability { LEFT JOIN warehouse w ON (i.warehouse_id = w.id) LEFT JOIN bin b ON (i.bin_id = b.id) WHERE (i.parts_id IN (| . join(', ', ('?') x scalar(@parts_ids)) . qq|)) - AND qty > 0 GROUP BY i.warehouse_id, i.bin_id, i.chargenumber, i.parts_id, w.description, b.description - ORDER BY LOWER(w.description), LOWER(b.description), LOWER(i.chargenumber)|; - + HAVING SUM(qty) > 0 + ORDER BY LOWER(w.description), LOWER(b.description), LOWER(i.chargenumber) +|; my $contents = selectall_hashref_query($form, $form->get_standard_dbh($myconfig), $query, @parts_ids); $main::lxdebug->leave_sub();