Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c6bf6a01

Von Werner Hahn vor mehr als 1 Jahr hinzugefügt

  • ID c6bf6a018cf9ad3bbc7a46ec7f3ab92bcf464f19
  • Vorgänger 5e9fd0ac
  • Nachfolger 9e2964fa

Dispositionsmanager: Artikel aus der artikelmaske dem Einkaufswarenkorb
hinzufügen

Unterschiede anzeigen:

SL/Controller/Part.pm
20 20
use SL::DB::Part;
21 21
use SL::DB::PartsGroup;
22 22
use SL::DB::PriceRuleItem;
23
use SL::DB::PurchaseBasketItem;
23 24
use SL::DB::Shop;
24 25
use SL::Helper::Flash;
25 26
use SL::JSON;
......
257 258
  $self->render_form;
258 259
}
259 260

  
261
sub action_add_to_basket {
262
  my ( $self ) = @_;
263

  
264
  if ( !$self->_is_in_purchase_basket && scalar @{$self->part->makemodels}) {
265
    my $basket_part = SL::DB::PurchaseBasketItem->new(
266
      parts_id    => $self->part->id,
267
      qty         => $self->part->ordersize || 1, # was ist wenn order_size < (rop-onhand) ist? sollte dann nicht (rop-onhand) genommen werden?
268
    )->save;
269

  
270
    $self->js->flash('info', t8('Part added to purchasebasket'))->render;
271
  } else {
272
    $self->js->flash('error', t8('Part already in purchasebasket or has no vendor'))->render;
273
  }
274
  return 1;
275
}
276

  
260 277
sub render_form {
261 278
  my ($self, %params) = @_;
262 279

  
......
942 959

  
943 960
  my $position = 0;
944 961
  my $makemodels = delete($::form->{makemodels}) || [];
945
$main::lxdebug->dump(0, 'WH:MMFORM ', $makemodels);
946 962
  foreach my $makemodel ( @{$makemodels} ) {
947 963
    next unless $makemodel->{make};
948 964
    $position++;
......
1102 1118
  my $position = 0;
1103 1119
  my @makemodel_array = ();
1104 1120
  my $makemodels = delete($::form->{makemodels}) || [];
1105
$main::lxdebug->dump(0, 'WH:MM ', $makemodels);
1106 1121

  
1107 1122
  foreach my $makemodel ( @{$makemodels} ) {
1108 1123
    next unless $makemodel->{make};
......
1461 1476
  return \@item_objects;
1462 1477
}
1463 1478

  
1479
sub _is_in_purchase_basket {
1480
  my ( $self ) = @_;
1481

  
1482
  return SL::DB::Manager::PurchaseBasketItem->get_all_count( query => [ parts_id => $self->part->id ] );
1483
}
1484

  
1464 1485
sub _setup_form_action_bar {
1465 1486
  my ($self) = @_;
1466 1487

  
......
1533 1554
                  :                          undef,
1534 1555
      ],
1535 1556

  
1557
      action => [
1558
        t8('Add to basket'),
1559
        call     => [ 'kivi.Part.add_to_basket' ],
1560
        disabled => $self->_is_in_purchase_basket ? t8('Part already in purchasebasket')
1561
                  : !scalar @{$self->part->makemodels} ? t8('No vendors to add to purchasebasket')
1562
                  : undef,
1563
      ],
1564

  
1536 1565
      'separator',
1537 1566

  
1538 1567
      action => [
js/kivi.Part.js
798 798
    ns.reinit_widgets();
799 799
  };
800 800

  
801
  ns.add_to_basket = function() {
802
    var data = $('#ic').serializeArray();
803
    data.push({ name: 'action', value: 'Part/add_to_basket' });
804

  
805
    $.post("controller.pl", data, kivi.eval_json_result);
806
  };
807

  
801 808
  $(function(){
802 809
    $('#ic').on('focusout', '.reformat_number', function(event) {
803 810
      ns.reformat_number(event);

Auch abrufbar als: Unified diff