Revision 4b8e5682
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
- ID 4b8e56821eac8b83856dca20e2ca8371081c13f5
- Vorgänger 72b80f91
SL/IC.pm | ||
---|---|---|
103 | 103 |
my $query = |
104 | 104 |
qq|SELECT p.id, p.partnumber, p.description, p.sellprice, |
105 | 105 |
p.classification_id, |
106 |
p.weight, p.onhand, p.unit, pg.partsgroup, p.lastcost,
|
|
106 |
p.weight, stocks.onhand, p.unit, pg.partsgroup, p.lastcost,
|
|
107 | 107 |
p.price_factor_id, pfac.factor AS price_factor, p.notes as longdescription |
108 | 108 |
FROM parts p |
109 | 109 |
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) |
110 | 110 |
LEFT JOIN price_factors pfac ON pfac.id = p.price_factor_id |
111 |
LEFT JOIN stocks ON (stocks.part_id = p.id) |
|
111 | 112 |
WHERE $where|; |
112 | 113 |
$form->{item_list} = selectall_hashref_query($form, SL::DB->client->dbh, $query, @values); |
113 | 114 |
|
... | ... | |
248 | 249 |
cv => 'cv.', |
249 | 250 |
"ioi.id" => ' ', |
250 | 251 |
"ioi.ioi" => ' ', |
252 |
onhand => 'stocks.', |
|
251 | 253 |
); |
252 | 254 |
|
253 | 255 |
# if the join condition in these blocks are met, the column |
... | ... | |
391 | 393 |
(SELECT DISTINCT parts_id FROM invoice UNION |
392 | 394 |
SELECT DISTINCT parts_id FROM assembly UNION |
393 | 395 |
SELECT DISTINCT parts_id FROM orderitems)' if /orphaned/; |
394 |
push @where_tokens, 'p.onhand = 0' if /orphaned/;
|
|
396 |
push @where_tokens, 'stocks.onhand = 0' if /orphaned/;
|
|
395 | 397 |
push @where_tokens, 'NOT p.obsolete' if /active/; |
396 | 398 |
push @where_tokens, ' p.obsolete', if /obsolete/; |
397 |
push @where_tokens, 'p.onhand > 0', if /onhand/;
|
|
398 |
push @where_tokens, 'p.onhand < p.rop', if /short/;
|
|
399 |
push @where_tokens, 'stocks.onhand > 0', if /onhand/;
|
|
400 |
push @where_tokens, 'stocks.onhand < p.rop', if /short/;
|
|
399 | 401 |
} |
400 | 402 |
|
401 | 403 |
my $q_assembly_lastcost = |
... | ... | |
549 | 551 |
my $query = <<" SQL"; |
550 | 552 |
SELECT DISTINCT $select_clause |
551 | 553 |
FROM parts p |
554 |
LEFT JOIN stocks ON (stocks.part_id = p.id) |
|
552 | 555 |
$join_clause |
553 | 556 |
WHERE $where_clause |
554 | 557 |
$group_clause |
... | ... | |
846 | 849 |
|
847 | 850 |
my $dbh = $form->get_standard_dbh($myconfig); |
848 | 851 |
|
849 |
my $query = qq|SELECT * FROM parts WHERE id IN (| . join(', ', ('?') x scalar(@ids)) . qq|)|;
|
|
852 |
my $query = qq|SELECT p.* stocks.onhand FROM parts p LEFT JOIN stocks ON (stocks.part_id = p.id) WHERE p.id IN (| . join(', ', ('?') x scalar(@ids)) . qq|)|;
|
|
850 | 853 |
|
851 | 854 |
my $info = selectall_hashref_query($form, $dbh, $query, map { conv_i($_) } @ids); |
852 | 855 |
|
Auch abrufbar als: Unified diff
Separate Tabelle für onhand (stocks) für Artikel