Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2bccc0a2

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

  • ID 2bccc0a27d0c6917ab219aeb60efcbc9ae043205
  • Vorgänger 9bd36f35
  • Nachfolger 343d3419

TopQuickSearch: Alle Part Varianten for free

Unterschiede anzeigen:

SL/Controller/TopQuickSearch.pm
12 12
);
13 13

  
14 14
my @available_modules = qw(
15
  SL::Controller::TopQuickSearch::Article
16
  SL::Controller::TopQuickSearch::Part
17
  SL::Controller::TopQuickSearch::Service
15 18
  SL::Controller::TopQuickSearch::Assembly
16 19
  SL::Controller::TopQuickSearch::Contact
17 20
  SL::Controller::TopQuickSearch::GLTransaction
SL/Controller/TopQuickSearch/Article.pm
1
package SL::Controller::TopQuickSearch::Article;
2

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

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

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

  
15
sub auth { 'part_service_assembly_edit' }
16

  
17
sub name { 'article' }
18

  
19
sub description_config { t8('Article') }
20

  
21
sub description_field { t8('Article') }
22

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

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

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

  
37
sub select_autocomplete {
38
  redirect_to_part($::form->{id});
39
}
40

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

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

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

  
51
sub redirect_to_search {
52
  SL::Controller::Base->new->url_for(
53
    controller  => 'ic.pl',
54
    action      => 'generate_report',
55
    searchitems => 'assembly',
56
    all         => $_[0],
57
  );
58
}
59

  
60
sub redirect_to_part {
61
  SL::Controller::Base->new->url_for(
62
    controller => 'ic.pl',
63
    action     => 'edit',
64
    id         => $_[0],
65
  );
66
}
67

  
68
sub type {
69
  ()
70
}
71

  
72
sub init_models {
73
  my ($self) = @_;
74

  
75
  SL::Controller::Helper::GetModels->new(
76
    controller => $self,
77
    model      => 'Part',
78
    source     => {
79
      filter => {
80
        ($self->type),
81
        'all:substr:multi::ilike' => $::form->{term},
82
      },
83
    },
84
    sorted     => {
85
      _default   => {
86
        by  => 'partnumber',
87
        dir => 1,
88
      },
89
      partnumber => t8('Partnumber'),
90
    },
91
    paginated  => {
92
      per_page => 10,
93
    },
94
  )
95
}
96

  
97
1;
SL/Controller/TopQuickSearch/Assembly.pm
1 1
package SL::Controller::TopQuickSearch::Assembly;
2 2

  
3 3
use strict;
4
use parent qw(Rose::Object);
4
use parent qw(SL::Controller::TopQuickSearch::Article);
5 5

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

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

  
15
sub auth { 'part_service_assembly_edit' }
16 7

  
17 8
sub name { 'assembly' }
18 9

  
......
20 11

  
21 12
sub description_field { t8('Assemblies') }
22 13

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

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

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

  
37
sub select_autocomplete {
38
  redirect_to_part($::form->{id});
39
}
40

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

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

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

  
51
sub redirect_to_search {
52
  SL::Controller::Base->new->url_for(
53
    controller  => 'ic.pl',
54
    action      => 'generate_report',
55
    searchitems => 'assembly',
56
    all         => $_[0],
57
  );
58
}
59

  
60
sub redirect_to_part {
61
  SL::Controller::Base->new->url_for(
62
    controller => 'ic.pl',
63
    action     => 'edit',
64
    id         => $_[0],
65
  );
66
}
67

  
68
sub init_models {
69
  my ($self) = @_;
70

  
71
  SL::Controller::Helper::GetModels->new(
72
    controller => $self,
73
    model      => 'Part',
74
    source     => {
75
      filter => {
76
        type                      => 'assembly',
77
        'all:substr:multi::ilike' => $::form->{term},
78
      },
79
    },
80
    sorted     => {
81
      _default   => {
82
        by  => 'partnumber',
83
        dir => 1,
84
      },
85
      partnumber => t8('Partnumber'),
86
    },
87
    paginated  => {
88
      per_page => 10,
89
    },
90
  )
91
}
14
sub type { type => 'assembly' }
92 15

  
93 16
1;
SL/Controller/TopQuickSearch/Part.pm
1
package SL::Controller::TopQuickSearch::Part;
2

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

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

  
8
sub name { 'part' }
9

  
10
sub description_config { t8('Parts') }
11

  
12
sub description_field { t8('Parts') }
13

  
14
sub type { type => 'part' }
15

  
16
1;
SL/Controller/TopQuickSearch/Service.pm
1
package SL::Controller::TopQuickSearch::Service;
2

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

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

  
8
sub name { 'service' }
9

  
10
sub description_config { t8('Services') }
11

  
12
sub description_field { t8('Services') }
13

  
14
sub type { type => 'service' }
15

  
16
1;

Auch abrufbar als: Unified diff