Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1ca98d42

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 1ca98d42a3b628007035e89bb3763fe327b05c39
  • Vorgänger 558c234e
  • Nachfolger 2a48b1f8

Belegvorlagen: Speichern bei Kreditorenbuchungen

Unterschiede anzeigen:

bin/mozilla/ap.pl
155 155
  update();
156 156
}
157 157

  
158
sub save_record_template {
159
  $::auth->assert('ap_transactions');
160

  
161
  my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new;
162
  my $js       = SL::ClientJS->new(controller => SL::Controller::Base->new);
163
  my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name});
164

  
165
  $js->dialog->close('#record_template_dialog');
166

  
167
  my @items = grep {
168
    $_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0)
169
  } map {
170
    +{ chart_id   => $::form->{"AP_amount_chart_id_${_}"},
171
       amount1    => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}),
172
       tax_id     => (split m{--}, $::form->{"taxchart_${_}"})[0],
173
       project_id => $::form->{"project_id_${_}"} || undef,
174
     }
175
  } (1..($::form->{rowcount} || 1));
176

  
177
  $template->assign_attributes(
178
    template_type  => 'ap_transaction',
179
    template_name  => $new_name,
180

  
181
    currency_id    => SL::DB::Manager::Currency->find_by(name => $::form->{currency})->id,
182
    ar_ap_chart_id => $::form->{AP_chart_id}      || undef,
183
    vendor_id      => $::form->{vendor_id}        || undef,
184
    department_id  => $::form->{department_id}    || undef,
185
    project_id     => $::form->{globalproject_id} || undef,
186
    taxincluded    => $::form->{taxincluded}  ? 1 : 0,
187
    direct_debit   => $::form->{direct_debit} ? 1 : 0,
188
    ordnumber      => $::form->{ordnumber},
189
    notes          => $::form->{notes},
190

  
191
    items          => \@items,
192
  );
193

  
194
  eval {
195
    $template->save;
196
    1;
197
  } or do {
198
    return $js
199
      ->flash('error', $::locale->text("Saving the record template '#1' failed.", $new_name))
200
      ->render;
201
  };
202

  
203
  return $js
204
    ->flash('info', $::locale->text("The record template '#1' has been saved.", $new_name))
205
    ->render;
206
}
207

  
158 208
sub add {
159 209
  $main::lxdebug->enter_sub();
160 210

  
......
380 430
  my $follow_up_vc         = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : '';
381 431
  my $follow_up_trans_info =  "$form->{invnumber} ($follow_up_vc)";
382 432

  
383
  $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js");
433
  $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js");
384 434
  my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
385 435
  my $first_taxchart;
386 436

  
templates/webpages/ap/form_footer.html
42 42
  [% END %]
43 43
[%- END %]
44 44

  
45
  [% L.button_tag("kivi.RecordTemplate.popup('ap_transaction')", LxERP.t8("Record templates")) %]
45 46
</form>
46 47

  
47 48
<script type="text/javascript">

Auch abrufbar als: Unified diff