close(TEMPLATE);
}
- $content = Encode::decode('utf-8-strict', $content) if $::locale->is_utf8;
+ $content = Encode::decode('utf-8-strict', $content);
$main::lxdebug->leave_sub();
my $error = "";
if (open(TEMPLATE, ">", $filename)) {
- $content = Encode::encode('utf-8-strict', $content) if $::locale->is_utf8;
+ $content = Encode::encode('utf-8-strict', $content);
$content =~ s/\r\n/\n/g;
print(TEMPLATE $content);
close(TEMPLATE);
$form->{description}, $form->{invalid} ? 't' : 'f', conv_i($form->{id}));
if (0 < $form->{number_of_new_bins}) {
+ my ($num_existing_bins) = selectfirst_array_query($form, $dbh, qq|SELECT COUNT(*) FROM bin WHERE warehouse_id = ?|, $form->{id});
$query = qq|INSERT INTO bin (warehouse_id, description) VALUES (?, ?)|;
$sth = prepare_query($form, $dbh, $query);
foreach my $i (1..$form->{number_of_new_bins}) {
- do_statement($form, $sth, $query, conv_i($form->{id}), "$form->{prefix}${i}");
+ do_statement($form, $sth, $query, conv_i($form->{id}), "$form->{prefix}" . ($i + $num_existing_bins));
}
$sth->finish();
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
- $query = qq|SELECT b.*, EXISTS
- (SELECT i.warehouse_id, p.warehouse_id
- FROM inventory i, parts p
- WHERE i.bin_id = b.id
- OR p.bin_id = b.id
- LIMIT 1)
- AS in_use
- FROM bin b
- WHERE b.warehouse_id = ?|;
+ $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 = ?
+SQL
$form->{BINS} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id}));