Revision 86b6ff8a
Von Bernd Bleßmann vor mehr als 10 Jahren hinzugefügt
SL/Controller/CustomVariableConfig.pm | ||
---|---|---|
7 | 7 |
use List::Util qw(first); |
8 | 8 |
|
9 | 9 |
use SL::DB::CustomVariableConfig; |
10 |
use SL::DB::CustomVariableValidity; |
|
10 | 11 |
use SL::Helper::Flash; |
11 | 12 |
use SL::Locale::String; |
12 | 13 |
use Data::Dumper; |
... | ... | |
103 | 104 |
|
104 | 105 |
SL::DB::CustomVariableConfig->reorder_list(@{ $::form->{cvarcfg_id} || [] }); |
105 | 106 |
|
106 |
$self->render(\'', { type => 'json' }); |
|
107 |
$self->render(\'', { type => 'json' }); # ' make emacs happy
|
|
107 | 108 |
} |
108 | 109 |
|
109 | 110 |
# |
... | ... | |
179 | 180 |
return; |
180 | 181 |
} |
181 | 182 |
|
183 |
my $dbh = $self->config->db; |
|
184 |
$dbh->begin_work; |
|
185 |
|
|
182 | 186 |
$self->config->save; |
187 |
$self->_set_cvar_validity() if $is_new; |
|
188 |
|
|
189 |
$dbh->commit; |
|
183 | 190 |
|
184 | 191 |
flash_later('info', $is_new ? t8('The custom variable has been created.') : t8('The custom variable has been saved.')); |
185 | 192 |
$self->redirect_to(action => 'list', module => $self->module); |
186 | 193 |
} |
187 | 194 |
|
195 |
sub _set_cvar_validity { |
|
196 |
my ($self) = @_; |
|
197 |
|
|
198 |
my $flags = { |
|
199 |
map { split m/=/, $_, 2 } |
|
200 |
split m/:/, ($self->config->flags || '') |
|
201 |
}; |
|
202 |
|
|
203 |
# nothing to do to set valid |
|
204 |
return if !$flags->{defaults_to_invalid}; |
|
205 |
|
|
206 |
my $all_parts = SL::DB::Manager::Part->get_all(where => [ or => [ obsolete => 0, obsolete => undef ] ]); |
|
207 |
foreach my $part (@{ $all_parts }) { |
|
208 |
SL::DB::CustomVariableValidity->new(config_id => $self->config->id, trans_id => $part->id)->save; |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
188 | 212 |
1; |
Auch abrufbar als: Unified diff
Benutzerdef. Variablen f. Waren per Voreinstellung für Belege aktivieren/deaktivieren.