Revision 289450df
Von Sven Schöling vor mehr als 1 Jahr hinzugefügt
SL/DB/Manager/PriceRuleItem.pm | ||
---|---|---|
13 | 13 |
__PACKAGE__->make_manager_methods; |
14 | 14 |
|
15 | 15 |
use SL::Locale::String qw(t8); |
16 |
use List::Util qw(first); |
|
17 |
|
|
18 |
use SL::DB::CustomVariableConfig; |
|
16 | 19 |
|
17 | 20 |
my %ops = ( |
18 | 21 |
'num' => { eq => '=', le => '<=', ge => '>=' }, |
... | ... | |
80 | 83 |
# we only generate cvar types for cvar price_rules that are actually used to keep the query smaller |
81 | 84 |
# these are cached per request |
82 | 85 |
sub generate_cvar_types { |
83 |
my $cvar_configs = SL::DB::Manager::CustomVariableConfig->get_all(query => [ id => \"(select distinct custom_variable_configs_id from price_rule_items where custom_variable_configs_id is not null)" ]); |
|
86 |
my $cvar_configs = SL::DB::Manager::CustomVariableConfig->get_all(query => [ |
|
87 |
id => [ \"(select distinct custom_variable_configs_id from price_rule_items where custom_variable_configs_id is not null)" ] |
|
88 |
]); |
|
84 | 89 |
|
85 | 90 |
my @types; |
86 | 91 |
|
87 | 92 |
for my $config (@$cvar_configs) { |
88 | 93 |
|
89 |
# NOTE! this only works for non-editable selects. |
|
90 |
# if the cvar is editable, it needs to be pulled from the record itself |
|
91 |
push @types, { |
|
92 |
type => "cvar_" . $config->id, |
|
93 |
description => $config->description, |
|
94 |
customer => 1, |
|
95 |
vendor => 1, |
|
96 |
data_type => 'text', |
|
97 |
data => sub { $_[1]->part->cvar_by_name($config->name)->value }, |
|
98 |
exclude_nulls => 1, |
|
99 |
cvar_config => $config->id, |
|
100 |
} if $config->module eq 'IC' && !$config->processed_flags->{editable} && $config->type eq 'select'; |
|
101 |
|
|
102 |
# NOTE! this only works for editable selects. |
|
103 |
# if the cvar is editable, it needs to be pulled from the record itself |
|
104 | 94 |
push @types, { |
105 | 95 |
type => "cvar_" . $config->id, |
106 | 96 |
description => $config->description, |
107 | 97 |
customer => 1, |
108 | 98 |
vendor => 1, |
109 | 99 |
data_type => 'text', |
110 |
data => sub { $_[1]->cvar_by_name($config->name)->value }, |
|
100 |
data => sub { |
|
101 |
$config->processed_flags->{editable} |
|
102 |
? $_[1]->cvar_by_name($config->name)->value |
|
103 |
: $_[1]->part->cvar_by_name($config->name)->value |
|
104 |
}, |
|
111 | 105 |
exclude_nulls => 1, |
112 | 106 |
cvar_config => $config->id, |
113 |
} if $config->module eq 'IC' && $config->processed_flags->{editable} && $config->type eq 'select';
|
|
107 |
} if $config->module eq 'IC' && $config->type eq 'select'; |
|
114 | 108 |
|
115 | 109 |
} |
116 | 110 |
|
Auch abrufbar als: Unified diff
PriceRule: cvar editable Behandlung gefixt