From: Bernd Bleßmann Date: Tue, 27 Jan 2015 14:05:59 +0000 (+0100) Subject: Rechnungen: Nicht editierbare CVars nicht rendern, aber richtig speichern bzw. drucken. X-Git-Tag: release-3.2.0beta~21 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d557935a1484e5ebbb15f0eabe107d74e192ff0b;p=kivitendo-erp.git Rechnungen: Nicht editierbare CVars nicht rendern, aber richtig speichern bzw. drucken. Die Änderung für Rechnungen (u. Gutschriften) fehlte noch im commit 6b4a71ff376e8337b708127f9f6c63c1d70d0af3 (Nicht editierbare CVars nicht rendern, aber richtig speichern und drucken.) --- diff --git a/SL/IR.pm b/SL/IR.pm index 7a7f57c4b..dd042488b 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -369,6 +369,7 @@ sub post_invoice { next if $payments_only; + my $cvars; if (!$form->{"invoice_id_$i"}) { # there is no persistent id, therefore create one with all necessary constraints my $q_invoice_id = qq|SELECT nextval('invoiceid')|; @@ -379,7 +380,22 @@ sub post_invoice { do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); $h_invoice_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 => 'invoice', + trans_id => $form->{"invoice_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 }; # save detail record in invoice table $query = <finish; } + my $cvars; + if (! $form->{"invoice_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 => 'invoice', + trans_id => $form->{"invoice_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 }; @@ -749,6 +767,7 @@ sub post_invoice { $pricegroup_id *= 1; $pricegroup_id = undef if !$pricegroup_id; + my $cvars; if (!$form->{"invoice_id_$i"}) { # there is no persistent id, therefore create one with all necessary constraints my $q_invoice_id = qq|SELECT nextval('invoiceid')|; @@ -759,7 +778,22 @@ sub post_invoice { do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); $h_invoice_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 => 'invoice', + trans_id => $form->{"invoice_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 }; # save detail record in invoice table $query = <