Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7f1f5efe

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 7f1f5efedc0b738f8e8faaeca52f649150448e32
  • Vorgänger c2cf302a
  • Nachfolger f5594740

Speichern, Laden, Löschen von Importprofilen implementiert

Unterschiede anzeigen:

SL/DB/CsvImportProfile.pm
24 24
# public functions
25 25
#
26 26

  
27
sub new_with_default {
28
  my ($class, $type) = @_;
29

  
30
  return $class->new(type => $type)->set_defaults;
31
}
32

  
33
sub set_defaults {
34
  my ($self) = @_;
35

  
36
  $self->_set_defaults(sep_char     => ',',
37
                       quote_char   => '"',
38
                       escape_char  => '"',
39
                       charset      => 'CP850',
40
                       numberformat => $::myconfig{numberformat},
41
                      );
42

  
43
  if ($self->type eq 'parts') {
44
    my $bugru = SL::DB::Manager::Buchungsgruppe->find_by(name => { like => 'Standard%19%' });
45

  
46
    $self->_set_defaults(sellprice_places          => 2,
47
                         sellprice_adjustment      => 0,
48
                         sellprice_adjustment_type => 'percent',
49
                         article_number_policy     => 'update_price',
50
                         price_group_sep_char      => '!',
51
                         shoparticle_if_missing    => 0,
52
                         parts_type                => 'part',
53
                         default_buchungsgruppe    => ($bugru ? $bugru->name : undef),
54
                        );
55
  } else {
56
    $self->_set_defaults(table => 'customer');
57
  }
58

  
59
  return $self;
60
}
61

  
27 62
sub set {
28 63
  my ($self, %params) = @_;
29 64

  
......
32 67

  
33 68
    if (!$setting) {
34 69
      $setting = SL::DB::CsvImportProfileSetting->new(key => $key);
35
      $self->add_settings($setting);
70
      $self->settings(@{ $self->settings || [] }, $setting);
36 71
    }
37 72

  
38 73
    $setting->value($value);
......
48 83
  return $setting ? $setting->value : $default;
49 84
}
50 85

  
86
sub _set_defaults {
87
  my ($self, %params) = @_;
88

  
89
  while (my ($key, $value) = each %params) {
90
    $self->settings(@{ $self->settings || [] }, { key => $key, value => $value }) if !$self->_get_setting($key);
91
  }
92

  
93
  return $self;
94
}
95

  
51 96
#
52 97
# hooks
53 98
#
......
70 115

  
71 116
sub _get_setting {
72 117
  my ($self, $key) = @_;
73
  return first { $_->key eq $key } @{ $self->settings };
118
  return first { $_->key eq $key } @{ $self->settings || [] };
74 119
}
75 120

  
76 121
1;

Auch abrufbar als: Unified diff