use SL::DB::Default;
use SL::DB::Employee;
use SL::DB::Chart;
+use SL::DB::Customer;
+use SL::DB::Part;
+use SL::DB::Vendor;
use SL::DB;
use SL::GenericTranslations;
}
# get new accounts (Folgekonto). Find all charts with the same link
- $form->{NEWACCOUNT} = $chart_obj->db->dbh->selectall_arrayref('select id, accno,description from chart where link = ? order by accno', {Slice => {}}, $chart_obj->link);
+ $form->{NEWACCOUNT} = $chart_obj->db->dbh->selectall_arrayref('select id, accno,description from chart where link = ? and id != ? order by accno', {Slice => {}}, $chart_obj->link, $form->{id});
} else { # set to orphaned for new charts, so chart_type can be changed (needed by $AccountIsPosted)
$form->{orphaned} = 1;
return $error;
}
+sub displayable_name_specs_by_module {
+ +{
+ 'SL::DB::Customer' => {
+ specs => SL::DB::Customer->displayable_name_specs,
+ prefs => SL::DB::Customer->displayable_name_prefs,
+ },
+ 'SL::DB::Vendor' => {
+ specs => SL::DB::Vendor->displayable_name_specs,
+ prefs => SL::DB::Vendor->displayable_name_prefs,
+ },
+ 'SL::DB::Part' => {
+ specs => SL::DB::Part->displayable_name_specs,
+ prefs => SL::DB::Part->displayable_name_prefs,
+ },
+ };
+}
+
sub save_preferences {
$main::lxdebug->enter_sub();
map { ($_ => $form->{$_}) } SL::DB::AuthUser::CONFIG_VARS(),
});
+ # Displayable name preferences
+ my $displayable_name_specs_by_module = displayable_name_specs_by_module();
+ foreach my $specs (@{ $form->{displayable_name_specs} }) {
+ if (!$specs->{value} || $specs->{value} eq $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->get_default()) {
+ $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->delete($specs->{value});
+ } else {
+ $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->store_value($specs->{value});
+ }
+ }
+
$main::lxdebug->leave_sub();
return 1;
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;