DeliveryOrder: type_data nach SL/DB verschoben, damit das model auch drauf zugreifen...
[kivitendo-erp.git] / 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 use Rose::Object::MakeMethods::Generic scalar => [ qw(c) ];
10
11 sub new {
12   my ($class, $controller) = @_;
13   my $o = bless {}, $class;
14
15   if ($controller) {
16     $o->c($controller);
17     weaken($o->{c});
18   }
19
20   return $o;
21 }
22
23 sub text {
24   my ($self, $string) = @_;
25   get3($self->c->type, "text", $string);
26 }
27
28 sub show_menu {
29   my ($self, $string) = @_;
30   get3($self->c->type, "show_menu", $string);
31 }
32
33 sub workflow {
34   my ($self, $string) = @_;
35   get3($self->c->type, "workflow", $string);
36 }
37
38 sub properties {
39   my ($self, $string) = @_;
40   get3($self->c->type, "properties", $string);
41 }
42
43 sub access {
44   get($_[0]->c->type, "right");
45 }
46
47 sub is_quotation {
48   get3($_[0]->c->type, "properties", "is_quotation");
49 }
50
51 sub customervendor {
52   get3($_[0]->c->type, "properties", "customervendor");
53 }
54
55 sub is_customer {
56   get3($_[0]->c->type, "properties", "is_customer");
57 }
58
59 sub nr_key {
60   get3($_[0]->c->type, "properties", "nr_key");
61 }
62
63 sub part_classification_query {
64   my ($self, $string) = @_;
65   get($self->c->type, "part_classification_query");
66 }
67
68 sub set_reqdate_by_type {
69   my ($self) = @_;
70
71   if (!$self->c->order->reqdate) {
72     $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => 1));
73   }
74 }
75
76 sub get_reqdate_by_type {
77   my ($self, $reqdate, $saved_reqdate) = @_;
78
79   if ($reqdate == $saved_reqdate) {
80     return DateTime->today_local->next_workday(extra_days => 1);
81   } else {
82     return $reqdate;
83   }
84 }
85
86 1;