142 |
142 |
update();
|
143 |
143 |
}
|
144 |
144 |
|
|
145 |
sub save_record_template {
|
|
146 |
$::auth->assert('gl_transactions');
|
|
147 |
|
|
148 |
my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new;
|
|
149 |
my $js = SL::ClientJS->new(controller => SL::Controller::Base->new);
|
|
150 |
my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name});
|
|
151 |
|
|
152 |
$js->dialog->close('#record_template_dialog');
|
|
153 |
|
|
154 |
my @items = grep {
|
|
155 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') && (($_->{amount1} != 0) || ($_->{amount2} != 0))
|
|
156 |
} map {
|
|
157 |
+{ chart_id => $::form->{"accno_id_${_}"},
|
|
158 |
amount1 => $::form->parse_amount(\%::myconfig, $::form->{"debit_${_}"}),
|
|
159 |
amount2 => $::form->parse_amount(\%::myconfig, $::form->{"credit_${_}"}),
|
|
160 |
tax_id => (split m{--}, $::form->{"taxchart_${_}"})[0],
|
|
161 |
project_id => $::form->{"project_id_${_}"} || undef,
|
|
162 |
source => $::form->{"source_${_}"},
|
|
163 |
memo => $::form->{"memo_${_}"},
|
|
164 |
}
|
|
165 |
} (1..($::form->{rowcount} || 1));
|
|
166 |
|
|
167 |
$template->assign_attributes(
|
|
168 |
template_type => 'gl_transaction',
|
|
169 |
template_name => $new_name,
|
|
170 |
|
|
171 |
currency_id => $::instance_conf->get_currency_id,
|
|
172 |
department_id => $::form->{department_id} || undef,
|
|
173 |
project_id => $::form->{globalproject_id} || undef,
|
|
174 |
taxincluded => $::form->{taxincluded} ? 1 : 0,
|
|
175 |
ob_transaction => $::form->{ob_transaction} ? 1 : 0,
|
|
176 |
cb_transaction => $::form->{cb_transaction} ? 1 : 0,
|
|
177 |
reference => $::form->{reference},
|
|
178 |
description => $::form->{description},
|
|
179 |
|
|
180 |
items => \@items,
|
|
181 |
);
|
|
182 |
|
|
183 |
eval {
|
|
184 |
$template->save;
|
|
185 |
1;
|
|
186 |
} or do {
|
|
187 |
return $js
|
|
188 |
->flash('error', $::locale->text("Saving the record template '#1' failed.", $new_name))
|
|
189 |
->render;
|
|
190 |
};
|
|
191 |
|
|
192 |
return $js
|
|
193 |
->flash('info', $::locale->text("The record template '#1' has been saved.", $new_name))
|
|
194 |
->render;
|
|
195 |
}
|
|
196 |
|
145 |
197 |
sub add {
|
146 |
198 |
$main::lxdebug->enter_sub();
|
147 |
199 |
|
... | ... | |
891 |
943 |
|
892 |
944 |
my ($init) = @_;
|
893 |
945 |
|
894 |
|
$::request->layout->add_javascripts("autocomplete_chart.js", "kivi.GL.js");
|
|
946 |
$::request->layout->add_javascripts("autocomplete_chart.js", "kivi.GL.js", "kivi.RecordTemplate.js");
|
895 |
947 |
|
896 |
948 |
my @old_project_ids = grep { $_ } map{ $::form->{"project_id_$_"} } 1..$::form->{rowcount};
|
897 |
949 |
|
Belegvorlagen: Speichern bei Dialogbuchungen