Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 23c5a950

Von Sven Schöling vor fast 9 Jahren hinzugefügt

  • ID 23c5a95043040ef7c0eb84b160b701099a550a28
  • Vorgänger aa4fda0e
  • Nachfolger a01fc476

TopQuickSearch: Auftrag, Angebot, Lieferauftrag, Preisanfrage

Unterschiede anzeigen:

SL/Controller/TopQuickSearch.pm
17 17
  'SL::Controller::TopQuickSearch::Service',
18 18
  'SL::Controller::TopQuickSearch::Assembly',
19 19
  'SL::Controller::TopQuickSearch::Contact',
20
  'SL::Controller::TopQuickSearch::SalesQuotation',
21
  'SL::Controller::TopQuickSearch::SalesOrder',
22
  'SL::Controller::TopQuickSearch::RequestForQuotation',
23
  'SL::Controller::TopQuickSearch::PurchaseOrder',
20 24
  'SL::Controller::TopQuickSearch::GLTransaction',
21 25
);
22 26
my %modules_by_name;
SL/Controller/TopQuickSearch/OERecord.pm
1
package SL::Controller::TopQuickSearch::OERecord;
2

  
3
use strict;
4
use parent qw(Rose::Object);
5

  
6
use SL::Locale::String qw(t8);
7
use SL::DB::Order;
8
use SL::Controller::Helper::GetModels;
9
use SL::Controller::Base;
10

  
11
use Rose::Object::MakeMethods::Generic (
12
  'scalar --get_set_init' => [ qw(models) ],
13
);
14

  
15
# nope. this is only for subclassing
16
sub auth { 'NOT ALLOWED' }
17

  
18
sub name { ... }
19

  
20
sub description_config { ... }
21

  
22
sub description_field { ... }
23

  
24
sub query_autocomplete {
25
  my ($self) = @_;
26

  
27
  my $objects = $self->models->get;
28

  
29
  [
30
    map {
31
     value       => $_->digest,
32
     label       => $_->digest,
33
     id          => $_->id,
34
    }, @$objects
35
  ];
36
}
37

  
38
sub select_autocomplete {
39
  $_[0]->redirect_to_object($::form->{id});
40
}
41

  
42
sub do_search {
43
  my ($self) = @_;
44

  
45
  my $objects = $self->models->get;
46

  
47
  return !@$objects     ? ()
48
       : @$objects == 1 ? $self->redirect_to_object($objects->[0]->id)
49
       :                  $self->redirect_to_search($::form->{term});
50
}
51

  
52
sub redirect_to_search {
53
  SL::Controller::Base->new->url_for(
54
    controller => 'oe.pl',
55
    action     => 'orders',
56
    type       => $_[0]->type,
57
    vc         => $_[0]->vc,
58
    all        => $_[1],
59
    open       => 1,
60
    closed     => 1,
61
    sortdir    => 0,
62
    (map {; "l_$_" => 'Y' } $_[0]->number, qw(transdate cusordnumber reqdate name employee netamount)),
63
  );
64
}
65

  
66
sub redirect_to_object {
67
  SL::Controller::Base->new->url_for(
68
    controller => 'oe.pl',
69
    action     => 'edit',
70
    type       => $_[0]->type,
71
    vc         => $_[0]->vc,
72
    id         => $_[1],
73
  );
74
}
75

  
76
sub type {
77
  ...
78
}
79

  
80
sub cv {
81
  ...
82
}
83

  
84
sub quotation {
85
  $_[0]->type !~ /order/
86
}
87

  
88
sub number {
89
  $_[0]->quotation ? 'quonumber' : 'ordnumber'
90
}
91

  
92
sub init_models {
93
  my ($self) = @_;
94

  
95
  SL::Controller::Helper::GetModels->new(
96
    controller => $self,
97
    model      => 'Order',
98
    source     => {
99
      filter => {
100
        type => $self->type,
101
        'all:substr:multi::ilike' => $::form->{term},
102
      },
103
    },
104
    sorted     => {
105
      _default   => {
106
        by  => 'transdate',
107
        dir => 0,
108
      },
109
      transdate => t8('Transdate'),
110
    },
111
    paginated  => {
112
      per_page => 10,
113
    },
114
    with_objects => [ qw(customer vendor) ]
115
  )
116
}
117

  
118
1;
SL/Controller/TopQuickSearch/PurchaseOrder.pm
1
package SL::Controller::TopQuickSearch::PurchaseOrder;
2

  
3
use strict;
4
use parent qw(SL::Controller::TopQuickSearch::OERecord);
5

  
6
use SL::Locale::String qw(t8);
7

  
8
sub auth { 'purchase_order_edit' }
9

  
10
sub name { 'purchase_order' }
11

  
12
sub description_config { t8('Purchase Orders') }
13

  
14
sub description_field { t8('Purchase Orders') }
15

  
16
sub type { 'purchase_order' }
17

  
18
sub vc { 'vendor' }
19

  
20
1;
SL/Controller/TopQuickSearch/RequestForQuotation.pm
1
package SL::Controller::TopQuickSearch::RequestForQuotation;
2

  
3
use strict;
4
use parent qw(SL::Controller::TopQuickSearch::OERecord);
5

  
6
use SL::Locale::String qw(t8);
7

  
8
sub auth { 'request_quotation_edit' }
9

  
10
sub name { 'request_quotation' }
11

  
12
sub description_config { t8('Request Quotations') }
13

  
14
sub description_field { t8('Request Quotations') }
15

  
16
sub type { 'request_quotation' }
17

  
18
sub vc { 'vendor' }
19

  
20
1;
SL/Controller/TopQuickSearch/SalesOrder.pm
1
package SL::Controller::TopQuickSearch::SalesOrder;
2

  
3
use strict;
4
use parent qw(SL::Controller::TopQuickSearch::OERecord);
5

  
6
use SL::Locale::String qw(t8);
7

  
8
sub auth { 'sales_order_edit' }
9

  
10
sub name { 'sales_order' }
11

  
12
sub description_config { t8('Sales Orders') }
13

  
14
sub description_field { t8('Sales Orders') }
15

  
16
sub type { 'sales_order' }
17

  
18
sub vc { 'customer' }
19

  
20
1;
SL/Controller/TopQuickSearch/SalesQuotation.pm
1
package SL::Controller::TopQuickSearch::SalesQuotation;
2

  
3
use strict;
4
use parent qw(SL::Controller::TopQuickSearch::OERecord);
5

  
6
use SL::Locale::String qw(t8);
7

  
8
sub auth { 'sales_quotation_edit' }
9

  
10
sub name { 'sales_quotation' }
11

  
12
sub description_config { t8('Sales Quotations') }
13

  
14
sub description_field { t8('Sales Quotations') }
15

  
16
sub type { 'sales_quotation' }
17

  
18
sub vc { 'customer' }
19

  
20
1;
SL/DB/Manager/Order.pm
6 6

  
7 7
use SL::DB::Helper::Paginated;
8 8
use SL::DB::Helper::Sorted;
9
use SL::DB::Helper::Filtered;
9 10

  
10 11
sub object_class { 'SL::DB::Order' }
11 12

  
12 13
__PACKAGE__->make_manager_methods;
13 14

  
15
__PACKAGE__->add_filter_specs(
16
  type => sub {
17
    my ($key, $value, $prefix) = @_;
18
    return __PACKAGE__->type_filter($value, $prefix);
19
  },
20
  all => sub {
21
    my ($key, $value, $prefix) = @_;
22
    return or => [ map { $prefix . $_ => $value } qw(ordnumber quonumber customer.name vendor.name transaction_description) ]
23
  }
24
);
25

  
14 26
sub type_filter {
15 27
  my $class  = shift;
16 28
  my $type   = lc(shift || '');
SL/DB/Order.pm
210 210
  goto &transdate;
211 211
}
212 212

  
213
sub digest {
214
  my ($self) = @_;
215

  
216
  sprintf "%s %s %s (%s)",
217
    $self->number,
218
    $self->customervendor->name,
219
    $self->amount_as_number,
220
    $self->date->to_kivitendo;
221
}
222

  
213 223
1;
214 224

  
215 225
__END__

Auch abrufbar als: Unified diff