Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3e0f8f25

Von Sven Schöling vor etwa 1 Jahr hinzugefügt

  • ID 3e0f8f25955425f4c387ac902179359934fc765c
  • Vorgänger 8a33e1f2
  • Nachfolger f1f7ec19

DeliveryOrder: TypeData jetzt über proxy eingebunden

Macht den Controller proxy unnötig. reqdate default werden jetzt anders
behandelt

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
32 32
use SL::DB::ValidityToken;
33 33
use SL::DB::Warehouse;
34 34
use SL::DB::Helper::RecordLink qw(set_record_link_conversions);
35
use SL::DB::Helper::TypeDataProxy;
36
use SL::DB::DeliveryOrder;
37
use SL::DB::DeliveryOrder::TypeData qw(:types);
35 38
use SL::Model::Record;
36 39

  
37 40
use SL::Helper::CreatePDF qw(:all);
......
42 45
use SL::Helper::UserPreferences::UpdatePositions;
43 46

  
44 47
use SL::Controller::Helper::GetModels;
45
use SL::Controller::DeliveryOrder::TypeData qw(:types);
46 48

  
47 49
use List::Util qw(first sum0);
48 50
use List::UtilsBy qw(sort_by uniq_by);
......
98 100
  # this interfers with init_order
99 101
  $self->{converted_from_oe_id} = delete $::form->{id};
100 102

  
101
  $self->type_data->validate($::form->{type});
103
  $self->type_data->validate;
102 104

  
103 105
  my $order = SL::DB::Order->new(id => $self->{converted_from_oe_id})->load;
104 106

  
......
190 192
sub action_delete {
191 193
  my ($self) = @_;
192 194

  
193
  my $number_type = $self->type_data;
194 195
  my %history = (snumbers => $self->type . '_' . $self->order->number);
195 196
  my %params = (history => \%history);
196 197
  SL::Model::Record->delete($self->order,%params);
......
436 437
                                  email_form  => $email_form,
437 438
                                  show_bcc    => $::auth->assert('email_bcc', 'may fail'),
438 439
                                  FILES       => \%files,
439
                                  is_customer => $self->type_data->is_customer,
440
                                  is_customer => $self->type_data->properties("is_customer"),
440 441
                                  ALL_EMPLOYEES => $self->{all_employees},
441 442
  );
442 443

  
......
699 700
                                     ITEM => $item,
700 701
                                     ID   => $item_id,
701 702
                                     SELF => $self,
702
                                     in_out => $self->type_data->transfer,
703
                                     in_out => $self->type_data->properties("transfer"),
703 704
  );
704 705

  
705 706
  if ($::form->{insert_before_item_id}) {
......
787 788
                                       ITEM => $item,
788 789
                                       ID   => $item_id,
789 790
                                       SELF => $self,
790
                                       in_out => $self->type_data->transfer,
791
                                       in_out => $self->type_data->properties("transfer"),
791 792
    );
792 793

  
793 794
    if ($::form->{insert_before_item_id}) {
......
930 931
  my $item_id = $::form->{item_id};
931 932
  my $qty     = _parse_number($::form->{qty_as_number});
932 933

  
933
  my $inout = $self->type_data->transfer;
934
  my $inout = $self->type_data->properties("transfer");
934 935

  
935 936
  my @contents   = DO->get_item_availability(parts_id => $part->id);
936 937
  my $stock_info = DO->unpack_stock_information(packed => $stock);
......
1261 1262
sub init_cv {
1262 1263
  my ($self) = @_;
1263 1264

  
1264
  return $self->type_data->customervendor;
1265
  return $self->type_data->properties("customervendor");
1265 1266
}
1266 1267

  
1267 1268
sub init_search_cvpartnumber {
......
1302 1303
sub check_auth {
1303 1304
  my ($self) = @_;
1304 1305

  
1305
  $::auth->assert($self->type_data->access('view') || 'DOES_NOT_EXIST');
1306
  $::auth->assert($self->type_data->rights('view') || 'DOES_NOT_EXIST');
1306 1307
}
1307 1308

  
1308 1309
sub check_auth_for_edit {
1309 1310
  my ($self) = @_;
1310 1311

  
1311
  $::auth->assert($self->type_data->access('edit') || 'DOES_NOT_EXIST');
1312
  $::auth->assert($self->type_data->rights('edit') || 'DOES_NOT_EXIST');
1312 1313
}
1313 1314

  
1314 1315
# build the selection box for contacts
......
1396 1397
  # order here solves this problem.
1397 1398
  my $order;
1398 1399
  $order   = SL::DB::DeliveryOrder->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
1399
  $order ||= SL::DB::DeliveryOrder->new(orderitems  => [], currency_id => $::instance_conf->get_currency_id(), order_type => $self->type_data->validate($::form->{type}));
1400
  $order ||= SL::DB::DeliveryOrder->new(orderitems  => [], currency_id => $::instance_conf->get_currency_id(), order_type => $self->type_data->validate);
1400 1401

  
1401 1402
  my $cv_id_method = $self->cv . '_id';
1402 1403
  if (!$::form->{id} && $::form->{$cv_id_method}) {
......
1815 1816
    $item->active_discount_source($price_source->discount_from_source($item->active_discount_source));
1816 1817
  }
1817 1818

  
1818
  if ($self->order->${\ $self->type_data->nr_key } && $::instance_conf->get_webdav) {
1819
  if ($self->order->${\ $self->type_data->properties("nr_key") } && $::instance_conf->get_webdav) {
1819 1820
    my $webdav = SL::Webdav->new(
1820 1821
      type     => $self->type,
1821 1822
      number   => $self->order->number,
......
1827 1828
                                                } } @all_objects;
1828 1829
  }
1829 1830

  
1830
  $self->{template_args}{in_out}                                 = $self->type_data->transfer;
1831
  $self->{template_args}{in_out}                                 = $self->type_data->properties("transfer");
1831 1832
  $self->{template_args}{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
1832 1833

  
1833 1834
  $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
......
1841 1842
  my ($self, %params) = @_;
1842 1843

  
1843 1844
  my $deletion_allowed = $self->type_data->show_menu("delete");
1844
  my $may_edit_create  = $::auth->assert($self->type_data->access('edit') || 'DOES_NOT_EXIST', 1);
1845
  my $may_edit_create  = $::auth->assert($self->type_data->rights('edit') || 'DOES_NOT_EXIST', 1);
1845 1846

  
1846 1847
  for my $bar ($::request->layout->get('actionbar')) {
1847 1848
    $bar->add(
......
2174 2175
}
2175 2176

  
2176 2177
sub nr_key {
2177
  return $_[0]->type_data->nr_key;
2178
  return $_[0]->type_data->properties("nr_key");
2178 2179
}
2179 2180

  
2180 2181
sub save_and_redirect_to {
......
2278 2279
}
2279 2280

  
2280 2281
sub init_type_data {
2281
  SL::Controller::DeliveryOrder::TypeData->new($_[0]);
2282
  SL::DB::Helper::TypeDataProxy->new('SL::DB::DeliveryOrder', $::form->{type});
2282 2283
}
2283 2284

  
2284 2285
sub init_valid_types {
SL/Controller/DeliveryOrder/TypeData.pm
1
package SL::Controller::DeliveryOrder::TypeData;
2

  
3
use strict;
4
use Exporter qw(import);
5
use Scalar::Util qw(weaken);
6
use SL::Locale::String qw(t8);
7
use SL::DB::DeliveryOrder::TypeData qw(:types :subs);
8

  
9
my @export_types = qw(SALES_DELIVERY_ORDER_TYPE PURCHASE_DELIVERY_ORDER_TYPE SUPPLIER_DELIVERY_ORDER_TYPE RMA_DELIVERY_ORDER_TYPE);
10

  
11
our @EXPORT_OK = (@export_types);
12
our %EXPORT_TAGS = (types => \@export_types);
13

  
14
use Rose::Object::MakeMethods::Generic scalar => [ qw(c) ];
15

  
16
sub new {
17
  my ($class, $controller) = @_;
18
  my $o = bless {}, $class;
19

  
20
  if ($controller) {
21
    $o->c($controller);
22
    weaken($o->{c});
23
  }
24

  
25
  return $o;
26
}
27

  
28
sub validate {
29
  my ($self, $string) = @_;
30
  validate_type($string);
31
}
32

  
33
sub text {
34
  my ($self, $string) = @_;
35
  get3($self->c->type, "text", $string);
36
}
37

  
38
sub show_menu {
39
  my ($self, $string) = @_;
40
  get3($self->c->type, "show_menu", $string);
41
}
42

  
43
sub workflow {
44
  my ($self, $string) = @_;
45
  get3($self->c->type, "workflow", $string);
46
}
47

  
48
sub properties {
49
  my ($self, $string) = @_;
50
  get3($self->c->type, "properties", $string);
51
}
52

  
53
sub access {
54
  my ($self, $string) = @_;
55
  get3($_[0]->c->type, "rights", $string);
56
}
57

  
58
sub is_quotation {
59
  get3($_[0]->c->type, "properties", "is_quotation");
60
}
61

  
62
sub customervendor {
63
  get3($_[0]->c->type, "properties", "customervendor");
64
}
65

  
66
sub is_customer {
67
  get3($_[0]->c->type, "properties", "is_customer");
68
}
69

  
70
sub nr_key {
71
  get3($_[0]->c->type, "properties", "nr_key");
72
}
73

  
74
sub transfer {
75
  get3($_[0]->c->type, "properties", "transfer");
76
}
77

  
78
sub part_classification_query {
79
  my ($self, $string) = @_;
80
  get($self->c->type, "part_classification_query");
81
}
82

  
83
sub set_reqdate_by_type {
84
  my ($self) = @_;
85

  
86
  if (!$self->c->order->reqdate) {
87
    $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => 1));
88
  }
89
}
90

  
91
sub get_reqdate_by_type {
92
  my ($self, $reqdate, $saved_reqdate) = @_;
93

  
94
  if ($reqdate == $saved_reqdate) {
95
    return DateTime->today_local->next_workday(extra_days => 1);
96
  } else {
97
    return $reqdate;
98
  }
99
}
100

  
101
1;
SL/DB/Helper/TypeDataProxy.pm
35 35
  _via("get3", [ "rights" ], @_);
36 36
}
37 37

  
38
sub workflow {
39
  _via("get3", [ "workflow" ], @_);
40
}
41

  
42
sub part_classification_query {
43
  _via("get", [ "part_classification_query" ], @_);
44
}
45

  
38 46
sub _via {
39 47
  my $method = shift;
40 48
  my $additional_args = shift;

Auch abrufbar als: Unified diff