Revision 5f67a255
Von Sven Schöling vor fast 7 Jahren hinzugefügt
- ID 5f67a2554b91e838408f6d2c2876e5790e72127b
- Vorgänger 69d4e8e8
bin/mozilla/io.pl | ||
---|---|---|
236 | 236 |
|
237 | 237 |
_update_part_information(); |
238 | 238 |
_update_ship() if ($is_s_p_order); |
239 |
_update_custom_variables(); |
|
240 | 239 |
|
241 | 240 |
my $totalweight = 0; |
242 | 241 |
|
... | ... | |
248 | 247 |
my %column_data = (); |
249 | 248 |
|
250 | 249 |
my $record_item = $record->id && $record->items ? $record->items->[$i-1] : _make_record_item($i); |
250 |
_update_custom_variables($record_item, $i); |
|
251 | 251 |
|
252 | 252 |
# undo formatting |
253 | 253 |
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } |
... | ... | |
488 | 488 |
|
489 | 489 |
$form->{invsubtotal} += $linetotal; |
490 | 490 |
|
491 |
# Benutzerdefinierte Variablen für Waren/Dienstleistungen/Erzeugnisse |
|
492 |
_render_custom_variables_inputs(ROW2 => \@ROW2, row => $i, part_id => $form->{"id_$i"}); |
|
493 |
|
|
494 | 491 |
my $colspan = scalar @ROW1; |
495 |
push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, error => $form->{"row_error_$i"}, obj => $record_item }; |
|
492 |
push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, error => $form->{"row_error_$i"}, obj => $record_item, i => $i };
|
|
496 | 493 |
} |
497 | 494 |
|
498 | 495 |
$form->{totalweight} = $totalweight; |
... | ... | |
1698 | 1695 |
} |
1699 | 1696 |
|
1700 | 1697 |
sub _update_custom_variables { |
1701 |
$main::lxdebug->enter_sub(); |
|
1702 |
|
|
1703 |
my $form = $main::form; |
|
1704 |
|
|
1705 |
$form->{CVAR_CONFIGS} = { } unless ref $form->{CVAR_CONFIGS} eq 'HASH'; |
|
1706 |
$form->{CVAR_CONFIGS}->{IC} ||= CVar->get_configs(module => 'IC'); |
|
1707 |
|
|
1708 |
$main::lxdebug->leave_sub(); |
|
1709 |
} |
|
1710 |
|
|
1711 |
sub _render_custom_variables_inputs { |
|
1712 |
$main::lxdebug->enter_sub(2); |
|
1713 |
|
|
1714 |
my $form = $main::form; |
|
1715 |
|
|
1716 |
my %params = @_; |
|
1717 |
|
|
1718 |
if (!$form->{CVAR_CONFIGS}->{IC}) { |
|
1719 |
$main::lxdebug->leave_sub(); |
|
1720 |
return; |
|
1721 |
} |
|
1722 |
|
|
1723 |
my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id}); |
|
1724 |
|
|
1725 |
# get partsgroup_id from part |
|
1726 |
my $partsgroup_id; |
|
1727 |
if ($params{part_id}) { |
|
1728 |
$partsgroup_id = SL::DB::Part->new(id => $params{part_id})->load->partsgroup_id; |
|
1729 |
} |
|
1730 |
|
|
1731 |
my $num_visible_cvars = 0; |
|
1732 |
foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { |
|
1733 |
$cvar->{valid} = $params{part_id} && $valid->($cvar->{id}); |
|
1698 |
my ($record_item, $index) = @_; |
|
1734 | 1699 |
|
1735 |
# set partsgroup filter |
|
1736 |
my $partsgroup_filtered = 0; |
|
1737 |
if ($cvar->{flag_partsgroup_filter}) { |
|
1738 |
if (!$partsgroup_id || (!grep {$partsgroup_id == $_} @{ $cvar->{partsgroups} })) { |
|
1739 |
$partsgroup_filtered = 1; |
|
1740 |
} |
|
1741 |
} |
|
1742 |
|
|
1743 |
my $hide_non_editable = 1; |
|
1744 |
|
|
1745 |
my $show = 0; |
|
1746 |
my $description = ''; |
|
1747 |
if (( ($cvar->{flag_editable} || !$hide_non_editable) && $cvar->{valid}) && !$partsgroup_filtered) { |
|
1748 |
$num_visible_cvars++; |
|
1749 |
$description = $cvar->{description} . ' '; |
|
1750 |
$show = 1; |
|
1751 |
} |
|
1752 |
|
|
1753 |
my $form_key = "ic_cvar_" . $cvar->{name} . "_$params{row}"; |
|
1754 |
|
|
1755 |
push @{ $params{ROW2} }, { |
|
1756 |
line_break => $show && !(($num_visible_cvars - 1) % ($::myconfig{form_cvars_nr_cols}*1 || 3)), |
|
1757 |
description => $description, |
|
1758 |
cvar => 1, |
|
1759 |
render_options => { |
|
1760 |
hide_non_editable => $hide_non_editable, |
|
1761 |
var => $cvar, |
|
1762 |
name_prefix => 'ic_', |
|
1763 |
name_postfix => "_$params{row}", |
|
1764 |
valid => $cvar->{valid}, |
|
1765 |
value => CVar->parse($::form->{$form_key}, $cvar), |
|
1766 |
partsgroup_filtered => $partsgroup_filtered, |
|
1767 |
} |
|
1768 |
}; |
|
1769 |
} |
|
1700 |
return unless $record_item; |
|
1770 | 1701 |
|
1771 |
$main::lxdebug->leave_sub(2); |
|
1702 |
my $cvars = $record_item->cvars_by_config; |
|
1703 |
$_->value($::form->{"ic_cvar_" . $_->config->name . "_$index"}) for @$cvars; |
|
1704 |
$record_item->{custom_variables} = $cvars; |
|
1772 | 1705 |
} |
1773 | 1706 |
|
1774 | 1707 |
sub _remove_billed_or_delivered_rows { |
templates/webpages/amcvar/render_inputs_block.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE HTML %] |
|
3 |
[%- USE L %] |
|
4 |
[%- USE P %] |
|
5 |
[%- USE LxERP %][%- USE P -%] |
|
6 |
[%- BLOCK cvar_inputs %] |
|
7 |
[%- SET render_cvar_tag_options = {}; |
|
8 |
render_cvar_tag_options.import(cvar_tag_options) IF cvar_tag_options; |
|
9 |
SET cvar_tag_name = HTML.escape(cvar.name_prefix) _ "cvar_" _ HTML.escape(cvar.var.name) _ HTML.escape(cvar.name_postfix); |
|
10 |
IF !render_cvar_tag_options.id && (cvar.var.type != 'select'); |
|
11 |
SET render_cvar_tag_options.no_id = 1; |
|
12 |
END; |
|
13 |
%] |
|
14 |
|
|
15 |
[%- IF (!cvar.hide_non_editable || cvar.var.flag_editable) && !cvar.partsgroup_filtered %] |
|
16 |
|
|
17 |
[%- IF !cvar.valid %] |
|
18 |
[%- IF show_disabled_message %] |
|
19 |
<i>[% 'Element disabled' | $T8 %]</i> |
|
20 |
[%- END %] |
|
21 |
|
|
22 |
[%- ELSIF cvar.var.type == 'bool' %] |
|
23 |
[%- render_cvar_tag_options.import(checked=cvar.value, value=1); |
|
24 |
L.checkbox_tag(cvar_tag_name, render_cvar_tag_options) %] |
|
25 |
|
|
26 |
[%- ELSIF cvar.var.type == 'textfield' %] |
|
27 |
[% render_cvar_tag_options.import(cols=cvar.var.width, rows=cvar.var.height); |
|
28 |
L.textarea_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
29 |
|
|
30 |
[%- ELSIF cvar.var.type == 'date' %] |
|
31 |
[%- L.date_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
32 |
|
|
33 |
[%- ELSIF cvar.var.type == 'timestamp' %] |
|
34 |
[%- L.input_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
35 |
|
|
36 |
[%- ELSIF cvar.var.type == 'select' %] |
|
37 |
[%- render_cvar_tag_options.name=cvar_tag_name %] |
|
38 |
<select [% P.stringify_attributes(render_cvar_tag_options) %]> |
|
39 |
[%- IF LxERP.is_rdbo(cvar.var, 'CustomVariableConfig') %] |
|
40 |
[%- FOREACH option = cvar.var.processed_options %] |
|
41 |
[%- SET render_cvar_opts = { |
|
42 |
value = option |
|
43 |
}; |
|
44 |
render_cvar_opts.selected = 'selected' IF option == cvar.value; |
|
45 |
L.html_tag('option', option, render_cvar_opts) %] |
|
46 |
[%- END %] |
|
47 |
[%- ELSE %] |
|
48 |
[%- FOREACH option = cvar.var.OPTIONS %] |
|
49 |
[%- SET render_cvar_opts = { |
|
50 |
value = option.value |
|
51 |
}; |
|
52 |
render_cvar_opts.selected = 'selected' IF option.value == cvar.value; |
|
53 |
L.html_tag('option', option.value, render_cvar_opts) %] |
|
54 |
[%- END %] |
|
55 |
[%- END %] |
|
56 |
</select> |
|
57 |
|
|
58 |
[%- ELSIF cvar.var.type == 'customer' %] |
|
59 |
[%- render_cvar_tag_options.type = 'customer' %] |
|
60 |
[%- P.customer_vendor.picker(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
61 |
|
|
62 |
[%- ELSIF cvar.var.type == 'vendor' %] |
|
63 |
[%- render_cvar_tag_options.type = 'vendor' %] |
|
64 |
[%- P.customer_vendor.picker(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
65 |
|
|
66 |
[%- ELSIF cvar.var.type == 'part' %] |
|
67 |
[% P.part.picker(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
68 |
|
|
69 |
[%- ELSIF cvar.var.type == 'number' %] |
|
70 |
[%- L.input_tag(cvar_tag_name, LxERP.format_amount(cvar.value, -2), render_cvar_tag_options) %] |
|
71 |
|
|
72 |
[%- ELSE %] |
|
73 |
[% render_cvar_tag_options.maxlength=cvar.var.maxlength IF cvar.var.maxlength; |
|
74 |
L.input_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
|
75 |
[%- END %] |
|
76 |
|
|
77 |
[%- END %] |
|
78 |
|
|
79 |
[%- END %] |
templates/webpages/oe/sales_order.html | ||
---|---|---|
2 | 2 |
[%- USE HTML %] |
3 | 3 |
[%- USE L %] |
4 | 4 |
[%- USE LxERP %] |
5 |
[%- PROCESS 'amcvar/render_inputs_block.html' %] |
|
6 | 5 |
<tr> |
7 | 6 |
<td> |
8 | 7 |
<input type="button" id="cb_show_details" name="show_details_button" value='[% 'Show details' | $T8 %]'[% IF show_details %] style="display:none"[% END %]> |
... | ... | |
48 | 47 |
[%- END %] |
49 | 48 |
[%- END %] |
50 | 49 |
|
51 |
[%# process editable cvars %] |
|
52 |
<table class='row2-cvars-table'> |
|
53 |
<tr> |
|
54 |
[%- FOREACH row2 = row.ROW2 %] |
|
55 |
[%- SET show = ((row2.render_options.var.flag_editable || !row2.render_options.hide_non_editable ) && row2.render_options.valid && !row2.render_options.partsgroup_filtered) %] |
|
56 |
[%- IF row2.cvar && show %] |
|
57 |
[%- IF row2.line_break %] |
|
58 |
</tr><tr> |
|
59 |
[%- END %] |
|
60 |
<th> |
|
61 |
[% row2.description %] |
|
62 |
</th> |
|
63 |
<td> |
|
64 |
[% PROCESS cvar_inputs cvar = row2.render_options %] |
|
65 |
</td> |
|
66 |
[%- END %] |
|
67 |
[%- END %] |
|
68 |
</tr> |
|
69 |
</table> |
|
70 |
|
|
71 |
[%# process non editable cvars extra to not disturb the table layout (this will be hidden inputs) %] |
|
72 |
[%- FOREACH row2 = row.ROW2 %] |
|
73 |
[%- SET hide = (!row2.render_options.var.flag_editable && row2.render_options.hide_non_editable) %] |
|
74 |
[%- IF row2.cvar && hide %] |
|
75 |
[% PROCESS cvar_inputs cvar = row2.render_options %] |
|
76 |
[%- END %] |
|
77 |
[%- END %] |
|
50 |
[% P.record_item.cvar_inputs_as_block(row.obj, hide_non_editable=1, table=1) %] |
|
78 | 51 |
|
79 | 52 |
</td> |
80 | 53 |
</tr> |
Auch abrufbar als: Unified diff
CVars in Belegen mit Presenter rendern, nicht mehr mit Template