Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6f1da6d4

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 6f1da6d45bd0b3142876e2bb46acba757ad4e716
  • Vorgänger c4f90397
  • Nachfolger ff424b75

ActionBar: Prüfung auf Transportkostenartikel in JavaScript implementiert

Unterschiede anzeigen:

bin/mozilla/oe.pl
308 308
      && $params{obj}->periodic_invoices_config->get_previous_billed_period_start_date;
309 309
  }
310 310

  
311
  my $allow_invoice  = $params{is_req_quo}
312
                    || $params{is_pur_ord}
313
                    || ($params{is_sales_quo} && $::instance_conf->get_allow_sales_invoice_from_sales_quotation)
314
                    || ($params{is_sales_ord} && $::instance_conf->get_allow_sales_invoice_from_sales_order);
315
  my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
316
  my @warn_p_invoice = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice) x!!$has_active_periodic_invoice;
317

  
318
  my $tpca_remainder = 0;
311
  my $allow_invoice      = $params{is_req_quo}
312
                        || $params{is_pur_ord}
313
                        || ($params{is_sales_quo} && $::instance_conf->get_allow_sales_invoice_from_sales_quotation)
314
                        || ($params{is_sales_ord} && $::instance_conf->get_allow_sales_invoice_from_sales_order);
315
  my @req_trans_desc     = qw(kivi.SalesPurchase.check_transaction_description)         x!!$::instance_conf->get_require_transaction_description_ps;
316
  my @req_trans_cost_art = qw(kivi.SalesPurchase.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id;
317
  my @warn_p_invoice     = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice)  x!!$has_active_periodic_invoice;
319 318

  
320 319
  for my $bar ($::request->layout->get('actionbar')) {
321 320
    $bar->add_actions([ t8('Update'),
......
327 326
    $bar->add_actions("combobox");
328 327
    $bar->actions->[-1]->add_actions([ t8('Save'),
329 328
      submit  => [ '#form', { action_save => 1 } ],
330
      checks  => [ @req_trans_desc, @warn_p_invoice ],
331
      confirm => t8('Missing transport cost: #1  Are you sure?', $tpca_remainder),
329
      checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
332 330
    ]);
333 331
    $bar->actions->[-1]->add_actions([ t8('Save as new'),
334 332
      submit   => [ '#form', { action_save_as_new => 1 } ],
335
      checks   => [ @req_trans_desc ],
333
      checks   => [ @req_trans_desc, @req_trans_cost_art ],
336 334
      disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
337 335
    ]);
338 336
     $bar->actions->[-1]->add_actions([ t8('Save and Close'),
339 337
      submit  => [ '#form', { action_save_and_close => 1 } ],
340
      checks  => [ @req_trans_desc, @warn_p_invoice ],
341
      confirm => t8('Missing transport cost: #1  Are you sure?', $tpca_remainder),
338
      checks  => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
342 339
    ]);
343 340
    $bar->add_actions([ t8('Delete'),
344 341
      submit   => [ '#form', { action_delete => 1 } ],
......
574 571

  
575 572
  $TMPL_VAR{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ];
576 573

  
574
  if ($type_check_vars{is_sales} && $::instance_conf->get_transport_cost_reminder_article_number_id) {
575
    $TMPL_VAR{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load;
576
  }
577

  
577 578
  print $form->parse_html_template("oe/form_header", { %TMPL_VAR });
578 579

  
579 580
  $main::lxdebug->leave_sub();
......
645 646

  
646 647
  $TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
647 648

  
648
  my $tpca_reminder;
649
  $tpca_reminder = check_transport_cost_reminder_article_number() if $::instance_conf->get_transport_cost_reminder_article_number_id;
650 649
  print $form->parse_html_template("oe/form_footer", {
651 650
     %TMPL_VAR,
652
     tpca_reminder   => $tpca_reminder,
653 651
     print_options   => print_options(inline => 1),
654 652
     is_sales        => scalar ($form->{type} =~ /^sales_/),              # these vars are exported, so that the template
655 653
     is_order        => scalar ($form->{type} =~ /_order$/),              # may determine what to show
......
2198 2196
  _remove_billed_or_delivered_rows(quantities => \%handled_base_qtys);
2199 2197
}
2200 2198

  
2201
# iterate all positions and match articlenumber
2202
sub check_transport_cost_reminder_article_number {
2203
  $main::lxdebug->enter_sub();
2204

  
2205
  my $form     = $main::form;
2206

  
2207
  check_oe_access();
2208

  
2209
  my $transport_article_id = $::instance_conf->get_transport_cost_reminder_article_number_id;
2210
  for my $i (1 .. $form->{rowcount}) {
2211
    return if $form->{"id_${i}"} eq $transport_article_id;
2212
  }
2213

  
2214
  # simply return the name of the part
2215
  return SL::DB::Part->new(id => $transport_article_id)->load()->partnumber;
2216

  
2217
  $main::lxdebug->leave_sub();
2218
}
2219 2199
sub dispatcher {
2220 2200
  foreach my $action (qw(delete delivery_order e_mail invoice print purchase_order quotation
2221 2201
                         request_for_quotation sales_order save save_and_close save_as_new ship_to update)) {
js/kivi.SalesPurchase.js
88 88
    return false;
89 89
  };
90 90

  
91
  this.check_transport_cost_article_presence = function() {
92
    var $form          = $('#form');
93
    var wanted_part_id = $form.data('transport-cost-reminder-article-id');
94

  
95
    if (!wanted_part_id)
96
      return true;
97

  
98
    var rowcount = $('#rowcount').val() * 1;
99
    for (var row = 1; row <= rowcount; row++)
100
      if (   (($('#id_'         + row).val() * 1)   === wanted_part_id)
101
          && (($('#partnumber_' + row).val() || '') !== ''))
102
        return true;
103

  
104
    var description = $form.data('transport-cost-reminder-article-description');
105
    return confirm(kivi.t8("The transport cost article '#1' is missing. Do you want to continue anyway?", [ description ]));
106
  };
107

  
91 108
  this.on_submit_checks = function() {
92 109
    var $button = $(this);
93 110
    if (($button.data('check-transfer-qty') == 1) && !kivi.SalesPurchase.delivery_order_check_transfer_qty())
templates/webpages/oe/form_footer.html
135 135

  
136 136
<input type="hidden" name="action" value="dispatcher">
137 137
<input type="hidden" name="saved_xyznumber" value="[% HTML.escape(saved_xyznumber) %]">
138
<input type="hidden" name="rowcount" value="[% HTML.escape(rowcount) %]">
138
[% L.hidden_tag("rowcount", rowcount) %]
139 139
<input type="hidden" name="callback" value="[% callback | html %]">
140 140
[% IF vc == 'customer' %]
141 141
  <input type="hidden" name="customer_discount" value="[% HTML.escape(customer_discount) %]">
templates/webpages/oe/form_header.html
3 3
[%- USE LxERP %]
4 4
[%- USE L %][%- USE P -%]
5 5

  
6
  <form method="post" id='form' name="oe" action="[% script %]">
6
  <form method="post" id='form' name="oe" action="[% script %]"
7
        data-transport-cost-reminder-article-id="[% HTML.escape(transport_cost_reminder_article.id) %]"
8
        data-transport-cost-reminder-article-description="[% HTML.escape(transport_cost_reminder_article.displayable_name) %]"
9
        >
7 10

  
8 11
    <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
9 12
    <script type="text/javascript" src="js/calculate_qty.js"></script>

Auch abrufbar als: Unified diff