Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8a721ec3

Von Bernd Bleßmann vor etwa 1 Jahr hinzugefügt

  • ID 8a721ec3ad3d11a8d0a59234a6945b46ec0a9c99
  • Vorgänger 06c506bc
  • Nachfolger 192c2ae9

Erweiterung für Artikelnummern nach Kunden-/Lieferanten-Typ (business).

Suche im Bericht und Import sind (noch) nicht implementiert.

Unterschiede anzeigen:

SL/Controller/Part.pm
15 15

  
16 16
use SL::CVar;
17 17
use SL::Controller::Helper::GetModels;
18
use SL::DB::Business;
19
use SL::DB::BusinessModel;
18 20
use SL::DB::Helper::ValidateAssembly qw(validate_assembly);
19 21
use SL::DB::History;
20 22
use SL::DB::Part;
......
31 33

  
32 34
use Rose::Object::MakeMethods::Generic (
33 35
  'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models
34
                                  makemodels shops_not_assigned
36
                                  makemodels businessmodels shops_not_assigned
35 37
                                  customerprices
36 38
                                  orphaned
37 39
                                  assortment assortment_items assembly assembly_items
38 40
                                  all_pricegroups all_translations all_partsgroups all_units
39 41
                                  all_buchungsgruppen all_payment_terms all_warehouses
40 42
                                  parts_classification_filter
41
                                  all_languages all_units all_price_factors) ],
43
                                  all_languages all_units all_price_factors
44
                                  all_businesses) ],
42 45
  'scalar'                => [ qw(warehouse bin stock_amounts journal) ],
43 46
);
44 47

  
......
525 528
    ->render;
526 529
}
527 530

  
531
sub action_add_businessmodel_row {
532
  my ($self) = @_;
533

  
534
  my $business_id = $::form->{add_businessmodel};
535

  
536
  my $business = SL::DB::Manager::Business->find_by(id => $business_id) or
537
    return $self->js->error(t8("No business selected or found!"))->render;
538

  
539
  if ( grep { $business_id == $_->business_id } @{ $self->businessmodels } ) {
540
    $self->js->flash('info', t8("This business has already been added."));
541
  };
542

  
543
  my $bm = SL::DB::BusinessModel->new(#parts_id             => $::form->{part}->{id},
544
                                      business             => $business,
545
                                      model                => '',
546
                                      part_description     => '',
547
                                      part_longdescription => '',
548
  ) or die "Can't create BusinessModel object";
549

  
550
  my $row_as_html = $self->p->render('part/_businessmodel_row',
551
                                     businessmodel => $bm);
552

  
553
  # after selection focus on the model field in the row that was just added
554
  $self->js
555
    ->append('#businessmodel_rows', $row_as_html)  # append in tbody
556
    ->val('#add_businessmodel', '')
557
    ->run('kivi.Part.focus_last_businessmodel_input')
558
    ->render;
559
}
560

  
528 561
sub action_add_customerprice_row {
529 562
  my ($self) = @_;
530 563

  
......
906 939

  
907 940
  $self->parse_form_customerprices;
908 941
  $self->parse_form_makemodels;
942
  $self->parse_form_businessmodels;
909 943
}
910 944

  
911 945
sub parse_form_prices {
......
977 1011
  };
978 1012
}
979 1013

  
1014
sub parse_form_businessmodels {
1015
  my ($self) = @_;
1016

  
1017
  my $make_key = sub { return $_[0]->parts_id . '+' . $_[0]->business_id; };
1018

  
1019
  my $businessmodels_map;
1020
  if ( $self->part->businessmodels ) { # check for new parts or parts without businessmodels
1021
    $businessmodels_map = { map { $make_key->($_) => Rose::DB::Object::Helpers::clone($_) } @{$self->part->businessmodels} };
1022
  };
1023

  
1024
  $self->part->businessmodels([]);
1025

  
1026
  my $businessmodels = delete($::form->{businessmodels}) || [];
1027
  foreach my $businessmodel ( @{$businessmodels} ) {
1028
    next unless $businessmodel->{business_id};
1029

  
1030
    my $bm = SL::DB::BusinessModel->new( #parts_id            => $self->part->id,            # will be assigned by row add_businessmodels
1031
                                         business_id          => $businessmodel->{business_id},
1032
                                         model                => $businessmodel->{model} || '',
1033
                                         part_description     => $businessmodel->{part_description} || '',
1034
                                         part_longdescription => $businessmodel->{part_longdescription} || '',
1035
    );
1036

  
1037
    $self->part->add_businessmodels($bm);
1038
  };
1039
}
1040

  
980 1041
sub parse_form_customerprices {
981 1042
  my ($self) = @_;
982 1043

  
......
1044 1105
  # used by edit, save, delete and add
1045 1106

  
1046 1107
  if ( $::form->{part}{id} ) {
1047
    return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels customerprices prices translations partsgroup shop_parts shop_parts.shop) ]);
1108
    return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels businessmodels customerprices prices translations partsgroup shop_parts shop_parts.shop) ]);
1048 1109
  } elsif ( $::form->{id} ) {
1049 1110
    return SL::DB::Part->new(id => $::form->{id})->load; # used by inventory tab
1050 1111
  } else {
......
1127 1188
  return \@makemodel_array;
1128 1189
}
1129 1190

  
1191
sub init_businessmodels {
1192
  my ($self) = @_;
1193

  
1194
  my @businessmodel_array = ();
1195
  my $businessmodels = delete($::form->{businessmodels}) || [];
1196

  
1197
  foreach my $businessmodel ( @{$businessmodels} ) {
1198
    next unless $businessmodel->{business_id};
1199

  
1200
    my $bm = SL::DB::BusinessModel->new(#parts_id            => $self->part->id,             # will be assigned by row add_businessmodels
1201
                                        business_id          => $businessmodel->{business_id},
1202
                                        model                => $businessmodel->{model} || '',
1203
                                        part_description     => $businessmodel->{part_description} || '',
1204
                                        part_longdescription => $businessmodel->{part_longdescription} || '',
1205
                                  ) or die "Can't create bm";
1206

  
1207
    push(@businessmodel_array, $bm);
1208
  };
1209

  
1210
  return \@businessmodel_array;
1211
}
1212

  
1130 1213
sub init_customerprices {
1131 1214
  my ($self) = @_;
1132 1215

  
......
1235 1318
  SL::DB::Manager::Pricegroup->get_all_sorted(query => [ obsolete => 0 ]);
1236 1319
}
1237 1320

  
1321
sub init_all_businesses {
1322
  SL::DB::Manager::Business->get_all_sorted;
1323
}
1324

  
1238 1325
# model used to filter/display the parts in the multi-items dialog
1239 1326
sub init_multi_items_models {
1240 1327
  SL::Controller::Helper::GetModels->new(

Auch abrufbar als: Unified diff