my $position = $i;
+ my $cvars;
if (!$form->{"delivery_order_items_id_$i"}) {
# there is no persistent id, therefore create one with all necessary constraints
my $q_item_id = qq|SELECT nextval('delivery_order_items_id')|;
do_query($form, $dbh, $query, conv_i($form->{"delivery_order_items_id_$i"}),
conv_i($form->{"id"}), conv_i($position), conv_i($form->{"id_$i"}));
$h_item_id->finish();
+
+ # get values for CVars from master data for new items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ trans_id => $form->{"id_$i"},
+ );
+ } else {
+ # get values for CVars from custom_variables for existing items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => 'delivery_order_items',
+ trans_id => $form->{"delivery_order_items_id_$i"},
+ );
}
+ # map only non-editable CVars to form (editable ones are already there)
+ map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars };
+
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
my $item_unit = $part_unit_map{$form->{"id_$i"}};
}
}
+ my $cvars;
+ if (! $form->{"delivery_order_items_id_$i"}) {
+ # get values for CVars from master data for new items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ trans_id => $form->{"id_$i"},
+ );
+ } else {
+ # get values for CVars from custom_variables for existing items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => 'delivery_order_items',
+ trans_id => $form->{"delivery_order_items_id_$i"},
+ );
+ }
+ # map only non-editable CVars to form (editable ones are already there)
+ map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars };
+
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} },
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_)
for @{ $ic_cvar_configs };
my $position = $i;
# save detail record in orderitems table
+ my $cvars;
if (! $form->{"orderitems_id_$i"}) {
$query = qq|SELECT nextval('orderitemsid')|;
($form->{"orderitems_id_$i"}) = selectrow_query($form, $dbh, $query);
$query = qq|INSERT INTO orderitems (id, position) VALUES (?, ?)|;
do_query($form, $dbh, $query, $form->{"orderitems_id_$i"}, conv_i($position));
+
+ # get values for CVars from master data for new items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ trans_id => $form->{"id_$i"},
+ );
+ } else {
+ # get values for CVars from custom_variables for existing items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => 'orderitems',
+ trans_id => $form->{"orderitems_id_$i"},
+ );
}
+ # map only non-editable CVars to form (editable ones are already there)
+ map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars };
+
my $orderitems_id = $form->{"orderitems_id_$i"};
push @processed_orderitems, $orderitems_id;
$sth->finish;
}
+ my $cvars;
+ if (! $form->{"orderitems_id_$i"}) {
+ # get values for CVars from master data for new items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ trans_id => $form->{"id_$i"},
+ );
+ } else {
+ # get values for CVars from custom_variables for existing items
+ $cvars = CVar->get_custom_variables(dbh => $dbh,
+ module => 'IC',
+ sub_module => 'orderitems',
+ trans_id => $form->{"orderitems_id_$i"},
+ );
+ }
+ # map only non-editable CVars to form (editable ones are already there)
+ map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars };
+
push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} },
CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_)
for @{ $ic_cvar_configs };
SET render_cvar_tag_options.no_id = 1;
END;
%]
-[%- IF (cvar.hide_non_editable && !cvar.var.flag_editable) || cvar.partsgroup_filtered %]
-[%- L.hidden_tag(cvar_tag_name, cvar.var.value, render_cvar_tag_options) %]
-[%- ELSIF !cvar.valid %]
+
+[%- IF (!cvar.hide_non_editable || cvar.var.flag_editable) && !cvar.partsgroup_filtered %]
+
+[%- IF !cvar.valid %]
[%- IF show_disabled_message %]
<i>[% 'Element disabled' | $T8 %]</i>
[%- END %]
[% render_cvar_tag_options.maxlength=cvar.var.maxlength IF cvar.var.maxlength;
L.input_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %]
[%- END %]
+
+[%- END %]
+
[%- END %]