Revision 1c8c1067
Von Kivitendo Admin vor fast 9 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
40 | 40 |
use SL::Common; |
41 | 41 |
use SL::CVar; |
42 | 42 |
use SL::DBUtils; |
43 |
use Text::ParseWords; |
|
43 | 44 |
|
44 | 45 |
use strict; |
45 | 46 |
|
... | ... | |
224 | 225 |
push @values, conv_date($form->{insertdateto}); |
225 | 226 |
} |
226 | 227 |
|
228 |
if ($form->{all}) { |
|
229 |
my @tokens = parse_line('\s+', 0, $form->{all}); |
|
230 |
$where .= qq| AND ( |
|
231 |
ct.${cv}number ILIKE ? OR |
|
232 |
ct.name ILIKE ? |
|
233 |
)| for @tokens; |
|
234 |
push @values, ("%$_%")x2 for @tokens; |
|
235 |
} |
|
236 |
|
|
227 | 237 |
# Nur Kunden finden, bei denen ich selber der Verkäufer bin |
228 | 238 |
# Gilt nicht für Lieferanten |
229 | 239 |
if ($cv eq 'customer' && !$main::auth->assert('customer_vendor_all_edit', 1)) { |
SL/Controller/TopQuickSearch.pm | ||
---|---|---|
22 | 22 |
'SL::Controller::TopQuickSearch::RequestForQuotation', |
23 | 23 |
'SL::Controller::TopQuickSearch::PurchaseOrder', |
24 | 24 |
'SL::Controller::TopQuickSearch::GLTransaction', |
25 |
'SL::Controller::TopQuickSearch::Customer', |
|
26 |
'SL::Controller::TopQuickSearch::Vendor', |
|
25 | 27 |
); |
26 | 28 |
my %modules_by_name; |
27 | 29 |
|
... | ... | |
185 | 187 |
=head1 TODO |
186 | 188 |
|
187 | 189 |
* user configuration |
188 |
* searches for orders, customers, vendors |
|
189 | 190 |
|
190 | 191 |
=head1 BUGS |
191 | 192 |
|
SL/Controller/TopQuickSearch/Customer.pm | ||
---|---|---|
1 |
package SL::Controller::TopQuickSearch::Customer; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::TopQuickSearch::CustomerVendor); |
|
5 |
use SL::DB::Customer; |
|
6 |
|
|
7 |
use SL::Locale::String qw(t8); |
|
8 |
|
|
9 |
sub auth { 'customer_vendor_edit' } |
|
10 |
|
|
11 |
sub name { 'customer' } |
|
12 |
|
|
13 |
sub model { 'Customer' } |
|
14 |
|
|
15 |
sub db { 'customer' } |
|
16 |
|
|
17 |
sub description_config { t8('Customers') } |
|
18 |
|
|
19 |
sub description_field { t8('Customers') } |
|
20 |
|
|
21 |
1; |
SL/Controller/TopQuickSearch/CustomerVendor.pm | ||
---|---|---|
1 |
package SL::Controller::TopQuickSearch::CustomerVendor; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(Rose::Object); |
|
5 |
|
|
6 |
use SL::Locale::String qw(t8); |
|
7 |
use SL::Controller::Helper::GetModels; |
|
8 |
use SL::Controller::Base; |
|
9 |
|
|
10 |
use Rose::Object::MakeMethods::Generic ( |
|
11 |
'scalar --get_set_init' => [ qw(models) ], |
|
12 |
); |
|
13 |
|
|
14 |
# nope. this is only for subclassing |
|
15 |
sub auth { 'NOT ALLOWED' } |
|
16 |
|
|
17 |
sub name { ... } |
|
18 |
|
|
19 |
sub description_config { ... } |
|
20 |
|
|
21 |
sub description_field { ... } |
|
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 |
$_[0]->redirect_to_object($::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 ? $self->redirect_to_object($objects->[0]->id) |
|
48 |
: $self->redirect_to_search($::form->{term}); |
|
49 |
} |
|
50 |
|
|
51 |
sub redirect_to_search { |
|
52 |
SL::Controller::Base->new->url_for( |
|
53 |
controller => 'ct.pl', |
|
54 |
action => 'list_names', |
|
55 |
db => $_[0]->db, |
|
56 |
sortdir => 0, |
|
57 |
status => 'all', |
|
58 |
obsolete => 'N', |
|
59 |
all => $_[1], |
|
60 |
(map {; "l_$_" => 'Y' } $_[0]->db . "number", qw(name street contact phone zipcode email city country gln)), |
|
61 |
|
|
62 |
); |
|
63 |
} |
|
64 |
|
|
65 |
sub redirect_to_object { |
|
66 |
SL::Controller::Base->new->url_for( |
|
67 |
controller => 'CustomerVendor', |
|
68 |
action => 'edit', |
|
69 |
id => $_[1], |
|
70 |
); |
|
71 |
} |
|
72 |
|
|
73 |
sub init_models { |
|
74 |
my ($self) = @_; |
|
75 |
|
|
76 |
my $cvnumber = $self->db eq 'customer' ? 'customernumber' : 'vendornumber'; |
|
77 |
|
|
78 |
SL::Controller::Helper::GetModels->new( |
|
79 |
controller => $self, |
|
80 |
model => $self->model, |
|
81 |
source => { |
|
82 |
filter => { |
|
83 |
'all:substr:multi::ilike' => $::form->{term}, # all filter spec is set in SL::DB::Manager::Customer |
|
84 |
}, |
|
85 |
}, |
|
86 |
sorted => { |
|
87 |
_default => { |
|
88 |
by => $cvnumber, |
|
89 |
dir => 0, |
|
90 |
}, |
|
91 |
$cvnumber => $self->db eq 'customer' ? t8('Customer Number') : t8('Vendor Number'), |
|
92 |
}, |
|
93 |
paginated => { |
|
94 |
per_page => 10, |
|
95 |
}, |
|
96 |
) |
|
97 |
} |
|
98 |
|
|
99 |
sub type { |
|
100 |
... |
|
101 |
} |
|
102 |
|
|
103 |
sub cv { |
|
104 |
... |
|
105 |
} |
|
106 |
|
|
107 |
sub model { |
|
108 |
... |
|
109 |
}; |
|
110 |
|
|
111 |
1; |
SL/Controller/TopQuickSearch/Vendor.pm | ||
---|---|---|
1 |
package SL::Controller::TopQuickSearch::Vendor; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::TopQuickSearch::CustomerVendor); |
|
5 |
use SL::DB::Vendor; |
|
6 |
|
|
7 |
use SL::Locale::String qw(t8); |
|
8 |
|
|
9 |
sub auth { 'customer_vendor_edit' } |
|
10 |
|
|
11 |
sub name { 'vendor' } |
|
12 |
|
|
13 |
sub model { 'Vendor' } |
|
14 |
|
|
15 |
sub db { 'vendor' } |
|
16 |
|
|
17 |
sub description_config { t8('Vendors') } |
|
18 |
|
|
19 |
sub description_field { t8('Vendors') } |
|
20 |
|
|
21 |
1; |
bin/mozilla/ct.pl | ||
---|---|---|
146 | 146 |
push @options, $locale->text('Billing/shipping address (street)') . " : $form->{addr_street}" if $form->{addr_street}; |
147 | 147 |
push @options, $locale->text('Billing/shipping address (country)') . " : $form->{addr_country}" if $form->{addr_country}; |
148 | 148 |
push @options, $locale->text('Billing/shipping address (GLN)') . " : $form->{addr_gln}" if $form->{addr_gln}; |
149 |
push @options, $locale->text('Quick Search') . " : $form->{all}" if $form->{all}; |
|
149 | 150 |
|
150 | 151 |
if ($form->{business_id}) { |
151 | 152 |
my $business = SL::DB::Manager::Business->find_by(id => $form->{business_id}); |
Auch abrufbar als: Unified diff
TopQuickSearch für Kunden und Lieferanten