Revision 0a798196
Von Sven Schöling vor fast 2 Jahren hinzugefügt
SL/Controller/PriceRule.pm | ||
---|---|---|
17 | 17 |
|
18 | 18 |
use Rose::Object::MakeMethods::Generic |
19 | 19 |
( |
20 |
'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses cvar) ], |
|
20 |
'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses cvar_configs) ],
|
|
21 | 21 |
); |
22 | 22 |
|
23 | 23 |
# __PACKAGE__->run_before('check_auth'); |
... | ... | |
80 | 80 |
sub action_add_item_row { |
81 | 81 |
my ($self, %params) = @_; |
82 | 82 |
|
83 |
my $item = SL::DB::PriceRuleItem->new(type => $::form->{type}); |
|
83 |
my $item = $::form->{type} =~ m{cvar/(\d+)} |
|
84 |
? SL::DB::PriceRuleItem->new(type => 'cvar', custom_variable_configs_id => $1) |
|
85 |
: SL::DB::PriceRuleItem->new(type => $::form->{type}); |
|
84 | 86 |
|
85 | 87 |
my $html = $self->render('price_rule/item', { output => 0 }, item => $item); |
86 | 88 |
|
... | ... | |
235 | 237 |
} |
236 | 238 |
|
237 | 239 |
sub all_price_rule_item_types { |
238 |
SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->vc || $_[0]->price_rule->type); |
|
240 |
my $item_types = SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->vc || $_[0]->price_rule->type); |
|
241 |
my @cvar_types = map [ "cvar/" . $_->id, $_->presenter->description_with_module ], @{$_[0]->cvar_configs }; |
|
242 |
|
|
243 |
[ @$item_types, @cvar_types ]; |
|
239 | 244 |
} |
240 | 245 |
|
241 | 246 |
sub add_javascripts { |
... | ... | |
255 | 260 |
|
256 | 261 |
my @items; |
257 | 262 |
for my $raw_item (@$items) { |
258 |
my $item = $raw_item->{id} ? $old_items{ $raw_item->{id} } || SL::DB::PriceRuleItem->new(id => $raw_item->{id})->load : SL::DB::PriceRuleItem->new; |
|
263 |
my $item = $raw_item->{id} |
|
264 |
? $old_items{ $raw_item->{id} } || SL::DB::PriceRuleItem->new(id => $raw_item->{id})->load |
|
265 |
: SL::DB::PriceRuleItem->new; |
|
259 | 266 |
$item->assign_attributes(%$raw_item); |
260 | 267 |
push @items, $item; |
261 | 268 |
} |
... | ... | |
281 | 288 |
SL::DB::Manager::PartsGroup->get_all; |
282 | 289 |
} |
283 | 290 |
|
284 |
sub init_cvar { |
|
285 |
# SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'IC' ]); |
|
286 |
# proof of concept: hard coded for articlegroup |
|
287 |
SL::DB::Manager::CustomVariableConfig->get_first(where => [ module => 'IC', name => 'articlegroup' ]) ; |
|
291 |
sub init_cvar_configs { |
|
292 |
# eligible cvars for this are all that are reachable from a record or recorditem (all modules but requirement spec) |
|
293 |
# and of a type that price rules support (currently: id-based with picker, numeric or date) and by special request select |
|
294 |
SL::DB::Manager::CustomVariableConfig->get_all(where => [ |
|
295 |
"!module" => 'RequirementSpecs', |
|
296 |
type => [ qw(timestamp date number integer customer vendor part select) ], |
|
297 |
]) ; |
|
288 | 298 |
} |
289 | 299 |
|
290 | 300 |
|
Auch abrufbar als: Unified diff
CVar + PriceRule: anlegen/editieren/speichern im Preisregel Controller
Im Moment erlaubt sind alle CVar configs, die:
- irgendwie im Beleg erreichbar sind (alle module ausser Pflichtenhefte)
- und von einem Typ sind die mit dem bestehenden Preisregelsystem
abgebildet werden können. d.h.: