map { $form->{$_} = $ref->{$_} } keys %{ $ref };
$query = <<SQL;
- SELECT b.*,
- ( EXISTS(SELECT i.bin_id FROM inventory i WHERE i.bin_id = b.id LIMIT 1)
- OR EXISTS(SELECT p.bin_id FROM parts p WHERE p.bin_id = b.id LIMIT 1))
- AS in_use
- FROM bin b
- WHERE b.warehouse_id = ?
+ SELECT b.*, use.in_use
+ FROM bin b
+ LEFT JOIN (
+ SELECT DISTINCT bin_id, TRUE AS in_use FROM inventory
+ UNION
+ SELECT DISTINCT bin_id, TRUE AS in_use FROM parts
+ ) use ON use.bin_id = b.id
+ WHERE b.warehouse_id = ?;
SQL
$form->{BINS} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id}));
$main::lxdebug->leave_sub();
}
+sub get_eur_categories {
+ my ($self, $myconfig, $form) = @_;
+
+ my $dbh = SL::DB->client->dbh;
+ my %eur_categories = selectall_as_map($form, $dbh, "select * from eur_categories order by id", 'id', 'description');
+
+ return \%eur_categories;
+}
+
+sub get_bwa_categories {
+ my ($self, $myconfig, $form) = @_;
+
+ my $dbh = SL::DB->client->dbh;
+ my %bwa_categories = selectall_as_map($form, $dbh, "select * from bwa_categories order by id", 'id', 'description');
+
+ return \%bwa_categories;
+}
+
1;