X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=926098188f923d54b2e0f4418cf59a6d9107dde1;hb=6b935d522a38e1a20802c25ed51a15e0cd292c1d;hp=6ab92cff078798676983fd19aa209ce5fad4ee7d;hpb=a0a30f41301f5f52c26febd9366182be858e54bb;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 6ab92cff0..926098188 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -151,7 +151,7 @@ sub display_row { { id => 'serialnr', width => 10, value => $locale->text('Serial No.'), display => 0, }, { id => 'projectnr', width => 10, value => $locale->text('Project'), display => 0, }, { id => 'sellprice', width => 15, value => $locale->text('Price'), display => !$is_delivery_order, }, - { id => 'sellprice_pg', width => 8, value => $locale->text('Pricegroup'), display => ($form->{type} =~ /^(sales_|invoice)/) && !$is_delivery_order, }, + { id => 'sellprice_pg', width => 8, value => $locale->text('Pricegroup'), display => !$is_delivery_order && !$is_purchase, }, { id => 'discount', width => 5, value => $locale->text('Discount'), display => !$is_delivery_order, }, { id => 'linetotal', width => 10, value => $locale->text('Extended'), display => !$is_delivery_order, }, { id => 'bin', width => 10, value => $locale->text('Bin'), display => 0, }, @@ -159,6 +159,7 @@ sub display_row { ); my @column_index = map { $_->{id} } grep { $_->{display} } @HEADER; + # cache units my $all_units = AM->retrieve_units(\%myconfig, $form); @@ -209,7 +210,9 @@ sub display_row { my %column_data = (); # undo formatting - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty discount sellprice price_new price_old) unless ($form->{simple_save}); + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } + qw(qty discount sellprice lastcost price_new price_old) + unless ($form->{simple_save}); # unit begin $form->{"unit_old_$i"} ||= $form->{"unit_$i"}; @@ -226,7 +229,6 @@ sub display_row { } my $this_unit = $form->{"unit_$i"}; $this_unit = $form->{"selected_unit_$i"} if AM->convert_unit($this_unit, $form->{"selected_unit_$i"}, $all_units); - $this_unit ||= "kg"; if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); @@ -245,8 +247,7 @@ sub display_row { $column_data{"unit"} = AM->unit_select_html($all_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef); # / unit ending - $form->{"sellprice_$i"} =~ /\.(\d+)/; - my $decimalplaces = max 2, length $1; + my $decimalplaces = ($form->{"sellprice_$i"} =~ /\.(\d+)/) ? max 2, length $1 : 2; my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1; my $discount = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100 / $price_factor, 2); @@ -260,8 +261,7 @@ sub display_row { : $cgi->textfield(-name => "description_$i", -size => 30, -value => $form->{"description_$i"})) . $cgi->button(-value => $locale->text('L'), -onClick => "set_longdescription_window('longdescription_$i')"); - $form->{"qty_$i"} =~ /\.(\d+)/; - my $qty_dec = length $1; + my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; $column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)); $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)", -value => $locale->text('*/')) @@ -296,6 +296,7 @@ sub display_row { } $column_data{sellprice} = $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces)); + } $column_data{discount} = $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"})); $column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2); @@ -319,28 +320,31 @@ sub display_row { $locale->text('Subtotal'), $form->{"subtotal_$i"} ? 'checked' : '' }; # begin marge calculations - my $marge_color; - my $real_sellprice = ($form->{"sellprice_$i"} - $discount) / $price_factor; - my $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1; - - $form->{"lastcost_$i"} *= 1; + $form->{"lastcost_$i"} *= 1; $form->{"marge_percent_$i"} = 0; - if ($real_sellprice && ($form->{"qty_$i"} * 1)) { - $form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice; - $myconfig{marge_percent_warn} ||= 15; - $marge_color = 'color="#ff0000"' if $form->{"id_$i"} && ($form->{"marge_percent_$i"} < (1 * $myconfig{marge_percent_warn})); + my $marge_color; + my $real_sellprice = $linetotal; + my $real_lastcost = $form->{"lastcost_$i"} * $form->{"qty_$i"} / ( $form->{"marge_price_factor_$i"} || 1 ); + my $marge_percent_warn = $myconfig{marge_percent_warn} * 1 || 15; + my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; + + if ($real_sellprice * 1 && ($form->{"qty_$i"} * 1)) { + $form->{"marge_percent_$i"} = ($real_sellprice - $real_lastcost) * 100 / $real_sellprice; + $marge_color = 'color="#ff0000"' if $form->{"id_$i"} && $form->{"marge_percent_$i"} < $marge_percent_warn; } - my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; - $form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note; + $form->{"marge_absolut_$i"} = ($real_sellprice - $real_lastcost) * $marge_adjust_credit_note; $form->{"marge_total"} += $form->{"marge_absolut_$i"}; - $form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor; - $form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"}; + $form->{"lastcost_total"} += $real_lastcost; + $form->{"sellprice_total"} += $real_sellprice; map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); - push @ROW2, { value => sprintf qq|%s %s  %s%%  %s %s  %s %s|, + push @ROW2, { value => sprintf qq| + %s %s  %s%% +  %s %s +  %s |, $marge_color, $locale->text('Ertrag'),$form->{"marge_absolut_$i"}, $form->{"marge_percent_$i"}, $locale->text('LP'), $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2), $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) } @@ -363,8 +367,8 @@ sub display_row { my @hidden_vars; if ($is_delivery_order) { - map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount); - push @hidden_vars, qw(sellprice discount price_factor_id); + map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost); + push @hidden_vars, qw(sellprice discount price_factor_id lastcost); push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}"; } @@ -374,7 +378,7 @@ sub display_row { map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" } (qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber - longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost), @hidden_vars) + longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars) ); map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"})); @@ -670,7 +674,7 @@ sub item_selected { map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) - } qw(sellprice listprice) if $form->{item} ne 'assembly'; + } qw(sellprice listprice lastcost) if $form->{item} ne 'assembly'; # get pricegroups for parts IS->get_pricegroups_for_parts(\%myconfig, \%$form); @@ -752,7 +756,7 @@ sub check_form { #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; # fuer assemblies auskommentiert. siehe oben - # $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"} / ($form->{"price_factor_$i"} || 1)); + # $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"} / ($form->{"price_factor_$i"} || 1)); $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"} / ($form->{"price_factor_$i"} || 1)); $count++; } @@ -767,44 +771,9 @@ sub check_form { map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost); } else { - my @flds = qw(id partnumber description qty ship sellprice unit - discount inventory_accno income_accno expense_accno listprice - taxaccounts bin assembly weight projectnumber project_id - oldprojectnumber runningnumber serialnumber partsgroup payment_id - not_discountable shop ve gv buchungsgruppen_id language_values - sellprice_pg pricegroup_old price_old price_new unit_old ordnumber - transdate longdescription basefactor marge_total marge_percent - marge_price_factor lastcost price_factor_id partnotes - stock_out stock_in has_sernumber); - - my $ic_cvar_configs = CVar->get_configs(module => 'IC'); - push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; - - # this section applies to invoices and orders - # remove any empty numbers - if ($form->{rowcount}) { - for my $i (1 .. $form->{rowcount} - 1) { - if ($form->{"partnumber_$i"}) { - push @a, {}; - my $j = $#a; - - map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; - $count++; - if ($main::lizenzen) { - if ($form->{"licensenumber_$i"} == -1) { - &new_license($i); - exit; - } - } - } - } - - $form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); - $form->{rowcount} = $count; + remove_emptied_rows(1); - $form->{creditremaining} -= &invoicetotal; - - } + $form->{creditremaining} -= &invoicetotal; } #sk @@ -827,6 +796,37 @@ sub check_form { $main::lxdebug->leave_sub(); } +sub remove_emptied_rows { + my $dont_add_empty = shift; + my $form = $::form; + + return unless $form->{rowcount}; + + my @flds = qw(id partnumber description qty ship sellprice unit + discount inventory_accno income_accno expense_accno listprice + taxaccounts bin assembly weight projectnumber project_id + oldprojectnumber runningnumber serialnumber partsgroup payment_id + not_discountable shop ve gv buchungsgruppen_id language_values + sellprice_pg pricegroup_old price_old price_new unit_old ordnumber + transdate longdescription basefactor marge_total marge_percent + marge_price_factor lastcost price_factor_id partnotes + stock_out stock_in has_sernumber reqdate); + + my $ic_cvar_configs = CVar->get_configs(module => 'IC'); + push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; + + my @new_rows; + for my $i (1 .. $form->{rowcount} - 1) { + next unless $form->{"partnumber_$i"}; + + push @new_rows, { map { $_ => $form->{"${_}_$i" } } @flds }; + } + + my $new_rowcount = scalar @new_rows; + $form->redo_rows(\@flds, \@new_rows, $new_rowcount, $form->{rowcount}); + $form->{rowcount} = $new_rowcount + ($dont_add_empty ? 0 : 1); +} + sub invoicetotal { $main::lxdebug->enter_sub(); @@ -881,7 +881,7 @@ sub validate_items { # check if items are valid if ($form->{rowcount} == 1) { &update; - exit; + ::end_of_request(); } for my $i (1 .. $form->{rowcount} - 1) { @@ -1040,9 +1040,9 @@ sub edit_e_mail { $form->{email} = $form->{shiptoemail} if $form->{shiptoemail} && $form->{formname} =~ /(pick|packing|bin)_list/; - if ($form->{"cp_id"} && !$form->{"email"}) { + if ($form->{"cp_id"}) { CT->get_contact(\%myconfig, $form); - $form->{"email"} = $form->{"cp_email"}; + $form->{"email"} = $form->{"cp_email"} if $form->{"cp_email"}; } my $title = $locale->text('E-mail') . " " . $form->get_formname_translation(); @@ -1151,7 +1151,6 @@ sub print_options { ) : undef, ($form->{type} eq 'invoice' && $form->{storno}) ? ( opthash("storno_invoice", $form->{PD}{storno_invoice}, $locale->text('Storno Invoice')), - opthash("storno_packing_list", $form->{PD}{storno_packing_list}, $locale->text('Storno Packing List')) ) : undef, ($form->{type} =~ /_delivery_order$/) ? ( opthash($form->{type}, $form->{PD}{$form->{type}}, $locale->text('Delivery Order')), @@ -1165,7 +1164,7 @@ sub print_options { push @MEDIA, grep $_, opthash("screen", $form->{OP}{screen}, $locale->text('Screen')), - (scalar @{ $form->{printers} } && $main::latex_templates) ? + ($form->{printers} && scalar @{ $form->{printers} } && $main::latex_templates) ? opthash("printer", $form->{OP}{printer}, $locale->text('Printer')) : undef, ($main::latex_templates && !$options{no_queue}) ? opthash("queue", $form->{OP}{queue}, $locale->text('Queue')) : undef @@ -1183,7 +1182,9 @@ sub print_options { (!$options{no_html}) ? opthash("html", $form->{DF}{html}, "HTML") : undef, ($main::opendocument_templates && !$options{no_opendocument}) ? - opthash("opendocument", $form->{DF}{opendocument}, $locale->text("OpenDocument/OASIS")) : undef; + opthash("opendocument", $form->{DF}{opendocument}, $locale->text("OpenDocument/OASIS")) : undef, + ($main::excel_templates && !$options{no_excel}) ? + opthash("excel", $form->{DF}{excel}, $locale->text("Excel")) : undef; push @LANGUAGE_ID, map { opthash($_->{id}, ($_->{id} eq $form->{language_id} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{languages} } @@ -1210,7 +1211,7 @@ sub print_options { ); my %template_vars = ( - display_copies => scalar @{ $form->{printers} } && $main::latex_templates && $form->{media} ne 'email', + display_copies => scalar @{ $form->{printers} || [] } && $main::latex_templates && $form->{media} ne 'email', display_remove_draft => (!$form->{id} && $form->{draft_id}), display_groupitems => !$dont_display_groupitems{$form->{type}}, groupitems_checked => $form->{groupitems} ? "checked" : '', @@ -1262,7 +1263,8 @@ sub print { &save(); $form->{formname} = $formname; &edit(); - exit; + $::lxdebug->leave_sub(); + ::end_of_request(); } &print_form($old_form); @@ -1295,11 +1297,6 @@ sub print_form { if ($form->{formname} eq "invoice") { $form->{label} = $locale->text('Invoice'); } - if ($form->{formname} eq "packing_list") { - - # this is from an invoice - $form->{label} = $locale->text('Packing List'); - } if ($form->{formname} eq 'sales_order') { $inv = "ord"; $due = "req"; @@ -1329,17 +1326,6 @@ sub print_form { $order = 1; } - if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') { - - # we use the same packing list as from an invoice - $inv = "ord"; - $due = "req"; - $form->{invdate} = $form->{"${inv}date"} = $form->{transdate}; - $form->{label} = $locale->text('Packing List'); - $order = 1; - # set invnumber for template packing_list - $form->{invnumber} = $form->{ordnumber}; - } if ($form->{formname} eq 'purchase_order') { $inv = "ord"; $due = "req"; @@ -1400,8 +1386,6 @@ sub print_form { # $locale->text('Invoice Number missing!') # $locale->text('Invoice Date missing!') - # $locale->text('Packing List Number missing!') - # $locale->text('Packing List Date missing!') # $locale->text('Order Number missing!') # $locale->text('Order Date missing!') # $locale->text('Quotation Number missing!') @@ -1423,13 +1407,13 @@ sub print_form { call_sub($display_form); # saving the history - if(!exists $form->{addition}) { + if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; - $form->{addition} = "PRINTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->{addition} = "PRINTED"; + $form->save_history; } # /saving the history - exit; + ::end_of_request(); } } @@ -1591,6 +1575,9 @@ sub print_form { } elsif ($form->{"format"} =~ /opendocument/) { $form->{opendocument} = 1; $extension = 'odt'; + } elsif ($form->{"format"} =~ /excel/) { + $form->{excel} = 1; + $extension = 'xls'; } my $email_extension = '_email' if (($form->{media} eq 'email') && (-f "$myconfig{templates}/$form->{formname}_email$form->{language}${printer_code}.${extension}")); @@ -1643,18 +1630,18 @@ sub print_form { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; if($form->{media} =~ /printer/) { - $form->{addition} = "PRINTED"; + $form->{addition} = "PRINTED"; } elsif($form->{media} =~ /email/) { - $form->{addition} = "MAILED"; + $form->{addition} = "MAILED"; } elsif($form->{media} =~ /queue/) { - $form->{addition} = "QUEUED"; + $form->{addition} = "QUEUED"; } elsif($form->{media} =~ /screen/) { - $form->{addition} = "SCREENED"; + $form->{addition} = "SCREENED"; } - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history @@ -1699,7 +1686,7 @@ sub print_form { } call_sub($display_form); - exit; + ::end_of_request(); } my $msg = @@ -1710,7 +1697,7 @@ sub print_form { } if ($form->{printing}) { call_sub($display_form); - exit; + ::end_of_request(); } $main::lxdebug->leave_sub(); @@ -1775,7 +1762,7 @@ sub ship_to { my @shipto_vars = qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry - shiptocontact shiptophone shiptofax shiptoemail + shiptocontact shiptocp_gender shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2); my @addr_vars = @@ -1790,6 +1777,19 @@ sub ship_to { ? $locale->text('Customer Number') : $locale->text('Vendor Number'); + # sieht nicht nett aus, funktioniert aber + # das vorausgewählte select-feld wird über shiptocp_gender + # entsprechend vorbelegt + my $selected_m=''; + my $selected_f=''; + if ($form->{shiptocp_gender} eq 'm') { + $selected_m='selected'; + $selected_f=''; + } elsif ($form->{shiptocp_gender} eq 'f') { + $selected_m=''; + $selected_f='selected'; + } + # get pricegroups for parts IS->get_pricegroups_for_parts(\%myconfig, \%$form); @@ -1811,72 +1811,81 @@ sub ship_to { - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
| +
| . $locale->text('Billing Address') . qq|| + | . $locale->text('Shipping Address') . qq|
$number$form->{"$form->{vc}number"}
| . $locale->text('Company Name') . qq|$form->{name}
| . $locale->text('Department') . qq|$form->{department_1}
 $form->{department_2}
| . $locale->text('Street') . qq|$form->{street}
| . $locale->text('Zipcode') . qq|$form->{zipcode}
| . $locale->text('City') . qq|$form->{city}
| . $locale->text('Country') . qq|$form->{country}
| . $locale->text('Contact') . qq|$form->{contact}
| . $locale->text('Phone') . qq|$form->{phone}
| . $locale->text('Fax') . qq|$form->{fax}
| . $locale->text('E-mail') . qq|$form->{email}
$number$form->{"$form->{vc}number"}
| . $locale->text('Company Name') . qq|$form->{name}
| . $locale->text('Department') . qq|$form->{department_1}
 $form->{department_2}
| . $locale->text('Street') . qq|$form->{street}
| . $locale->text('Zipcode') . qq|$form->{zipcode}
| . $locale->text('City') . qq|$form->{city}
| . $locale->text('Country') . qq|$form->{country}
| . $locale->text('Contact') . qq|$form->{contact}
| . $locale->text('Gender') . qq| +
| . $locale->text('Phone') . qq|$form->{phone}
| . $locale->text('Fax') . qq|$form->{fax}
| . $locale->text('E-mail') . qq|$form->{email}
@@ -1887,7 +1896,7 @@ sub ship_to { # delete shipto - map({ delete $form->{$_} } (@shipto_vars, qw(header))); + map({ delete $form->{$_} } (@shipto_vars, qw(header shipto_id))); $form->{title} = $title; foreach my $key (keys %$form) { @@ -1946,13 +1955,11 @@ sub new_license { $form->{script} = "licenses.pl"; - our $name; - map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description); map { $form->{$_} = $form->escape($form->{$_}, 1) } qw(partnumber description); $form->{callback} = - qq|$form->{script}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|; + qq|$form->{script}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$form->{name}&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|; $form->redirect; $main::lxdebug->leave_sub(); @@ -1973,11 +1980,7 @@ sub relink_accounts { } $form->{"taxaccounts"} = ""; - for (my $i = 1; $i <= $form->{"rowcount"}; $i++) { - if ($form->{"id_$i"}) { - IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1); - } - } + IC->retrieve_accounts(\%myconfig, $form, map { $_ => $form->{"id_$_"} } 1 .. $form->{rowcount}); $main::lxdebug->leave_sub(); } @@ -2072,14 +2075,14 @@ sub _update_custom_variables { my $form = $main::form; - $form->{CVAR_CONFIGS} ||= { }; - $form->{CVAR_CONFIGS}->{IC} = CVar->get_configs(module => 'IC'); + $form->{CVAR_CONFIGS} = { } unless ref $form->{CVAR_CONFIGS} eq 'HASH'; + $form->{CVAR_CONFIGS}->{IC} ||= CVar->get_configs(module => 'IC'); $main::lxdebug->leave_sub(); } sub _render_custom_variables_inputs { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my $form = $main::form; @@ -2090,31 +2093,32 @@ sub _render_custom_variables_inputs { return; } - foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { - $cvar->{valid} = $params{part_id} - ? CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id}) - : 0; - - $cvar->{value} = $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"}; - } - - CVar->render_inputs(hide_non_editable => 1, - variables => $form->{CVAR_CONFIGS}->{IC}, - name_prefix => 'ic_', - name_postfix => "_$params{row}"); + my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id}); my $num_visible_cvars = 0; foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { + $cvar->{valid} = $params{part_id} && $valid->($cvar->{id}); + my $description = ''; if ($cvar->{flag_editable} && $cvar->{valid}) { $num_visible_cvars++; $description = $cvar->{description} . ' '; } - push @{ $params{ROW2} }, { line_break => $num_visible_cvars == 1, - value => $description . $cvar->{HTML_CODE}, - }; + push @{ $params{ROW2} }, { + line_break => $num_visible_cvars == 1, + description => $description, + cvar => 1, + render_options => { + hide_non_editable => 1, + var => $cvar, + name_prefix => 'ic_', + name_postfix => "_$params{row}", + valid => $cvar->{valid}, + value => $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"}, + } + }; } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); }