Merge branch 'debian' into b-3.6.1
[kivitendo-erp.git] / bin / mozilla / ct.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #  Contributors: Reed White <alta@alta-research.com>
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29 # MA 02110-1335, USA.
30 #======================================================================
31 #
32 # customer/vendor module
33 #
34 #======================================================================
35
36 # $locale->text('Customers')
37 # $locale->text('Vendors')
38 # $locale->text('Add Customer')
39 # $locale->text('Add Vendor')
40 # $locale->text('Edit Customer')
41 # $locale->text('Edit Vendor')
42 # $locale->text('Customer saved!')
43 # $locale->text('Vendor saved!')
44 # $locale->text('Customer deleted!')
45 # $locale->text('Cannot delete customer!')
46 # $locale->text('Vendor deleted!')
47 # $locale->text('Cannot delete vendor!')
48
49 use POSIX qw(strftime);
50
51 use SL::CT;
52 use SL::CTI;
53 use SL::CVar;
54 use SL::Request qw(flatten);
55 use SL::DB::Business;
56 use SL::DB::Default;
57 use SL::DB::DeliveryTerm;
58 use SL::ReportGenerator;
59 use SL::Locale::String qw(t8);
60 use SL::MoreCommon qw(uri_encode);
61 use SL::ZUGFeRD;
62
63 require "bin/mozilla/common.pl";
64 require "bin/mozilla/reportgenerator.pl";
65
66 use strict;
67 1;
68
69 # end of main
70
71 sub _zugferd_settings {
72   return ([ -1, $::locale->text('Use settings from client configuration') ],
73           @SL::ZUGFeRD::customer_settings);
74 }
75
76 sub search {
77   $main::lxdebug->enter_sub();
78
79   my $form     = $main::form;
80   my $locale   = $main::locale;
81
82   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
83
84   $form->get_lists("business_types" => "ALL_BUSINESS_TYPES",
85                    "salesmen"       => "ALL_SALESMEN");
86   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
87
88   $form->{CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'CT');
89   ($form->{CUSTOM_VARIABLES_FILTER_CODE},
90    $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'      => $form->{CUSTOM_VARIABLES},
91                                                                            'include_prefix' => 'l_',
92                                                                            'include_value'  => 'Y');
93
94   $form->{title}    = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
95
96   $form->{ZUGFERD_SETTINGS} = [ _zugferd_settings() ];
97
98   setup_ct_search_action_bar();
99
100   $form->header();
101   print $form->parse_html_template('ct/search');
102
103   $main::lxdebug->leave_sub();
104 }
105
106 sub search_contact {
107   $::lxdebug->enter_sub;
108
109   $::form->{CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'Contacts');
110   ($::form->{CUSTOM_VARIABLES_FILTER_CODE},
111    $::form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'    => $::form->{CUSTOM_VARIABLES},
112                                                                            'include_prefix' => 'l.',
113                                                                            'filter_prefix'  => 'filter.',
114                                                                            'include_value'  => 'Y');
115
116   $::form->{title} = $::locale->text('Search contacts');
117
118   setup_ct_search_contact_action_bar();
119   $::form->header;
120   print $::form->parse_html_template('ct/search_contact');
121
122   $::lxdebug->leave_sub;
123 }
124
125 sub list_names {
126   $main::lxdebug->enter_sub();
127
128   my $form     = $main::form;
129   my %myconfig = %main::myconfig;
130   my $locale   = $main::locale;
131
132   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
133
134   report_generator_set_default_sort('name', 1);
135
136   CT->search(\%myconfig, \%$form);
137
138   my $cvar_configs = CVar->get_configs('module' => 'CT');
139
140   my @options;
141   if ($form->{status} eq 'all') {
142     push @options, $locale->text('All');
143   } elsif ($form->{status} eq 'orphaned') {
144     push @options, $locale->text('Orphaned');
145   }
146
147   my @zugferd_settings_list = _zugferd_settings();
148   my $zugferd_filter        = $form->{create_zugferd_invoices} eq '' ? undef : $zugferd_settings_list[$form->{create_zugferd_invoices} + 1]->[1];
149
150   push @options, $locale->text('Name')                               . " : $form->{name}"                  if $form->{name};
151   push @options, $locale->text('Contact')                            . " : $form->{contact}"               if $form->{contact};
152   push @options, $locale->text('Number')                           . qq| : $form->{"$form->{db}number"}|   if $form->{"$form->{db}number"};
153   push @options, $locale->text('E-mail')                             . " : $form->{email}"                 if $form->{email};
154   push @options, $locale->text('All phone numbers')                  . " : $form->{all_phonenumbers}"      if $form->{all_phonenumbers};
155   push @options, $locale->text('Contact person (surname)')           . " : $form->{cp_name}"               if $form->{cp_name};
156   push @options, $locale->text('Billing/shipping address (city)')    . " : $form->{addr_city}"             if $form->{addr_city};
157   push @options, $locale->text('Billing/shipping address (zipcode)') . " : $form->{addr_zipcode}"          if $form->{addr_zipcode};
158   push @options, $locale->text('Billing/shipping address (street)')  . " : $form->{addr_street}"           if $form->{addr_street};
159   push @options, $locale->text('Billing/shipping address (country)') . " : $form->{addr_country}"          if $form->{addr_country};
160   push @options, $locale->text('Billing/shipping address (GLN)')     . " : $form->{addr_gln}"              if $form->{addr_gln};
161   push @options, $locale->text('Quick Search')                       . " : $form->{all}"                   if $form->{all};
162   push @options, $locale->text('Factur-X/ZUGFeRD settings')          . " : $zugferd_filter"                if $zugferd_filter;
163
164   if ($form->{business_id}) {
165     my $business = SL::DB::Manager::Business->find_by(id => $form->{business_id});
166     if ($business) {
167       my $label = $form->{IS_CUSTOMER} ? $::locale->text('Customer type') : $::locale->text('Vendor type');
168       push @options, $label . " : " . $business->description;
169     }
170   }
171   if ($form->{salesman_id}) {
172     my $salesman = SL::DB::Manager::Employee->find_by(id => $form->{salesman_id});
173     if ($salesman) {
174       push @options, $locale->text('Salesman') . " : " . $salesman->name;
175     }
176   }
177
178   if ( $form->{insertdatefrom} or $form->{insertdateto} ) {
179     push @options, $locale->text('Insert Date');
180     push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{insertdatefrom}, 1) if $form->{insertdatefrom};
181     push @options, $locale->text('Bis')  . " " . $locale->date(\%myconfig, $form->{insertdateto},   1) if $form->{insertdateto};
182   };
183
184   my @columns = (
185     'id',        'name',    "$form->{db}number",   'contact', 'main_contact_person',
186     'department_1',         'department_2',        'phone',   'discount',
187     'fax',       'email',   'taxnumber',           'street',    'zipcode' , 'city',
188     'business',  'payment', 'invnumber', 'ordnumber',           'quonumber', 'salesman',
189     'country',   'gln',     'insertdate',           'pricegroup', 'contact_origin', 'invoice_mail',
190     'creditlimit', 'ustid', 'commercial_court', 'delivery_order_mail'
191   );
192
193   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
194   my @searchable_custom_variables  = grep { $_->{searchable} }  @{ $cvar_configs };
195   my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
196
197   push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
198
199   my %column_defs = (
200     'id'                => { 'text' => $locale->text('ID'), },
201     "$form->{db}number" => { 'text' => $locale->text('Number'), },
202     'name'              => { 'text' => $form->{IS_CUSTOMER} ? $::locale->text('Customer Name') : $::locale->text('Vendor Name'), },
203     'contact'           => { 'text' => $locale->text('Contact'), },
204     'main_contact_person'  => { 'text' => $locale->text('Main Contact Person'), },
205     'department_1'      => { 'text' => $locale->text('Department') . " 1", },
206     'department_2'      => { 'text' => $locale->text('Department') . " 2", },
207     'phone'             => { 'text' => $locale->text('Phone'), },
208     'fax'               => { 'text' => $locale->text('Fax'), },
209     'email'             => { 'text' => $locale->text('E-mail'), },
210     'cc'                => { 'text' => $locale->text('Cc'), },
211     'taxnumber'         => { 'text' => $locale->text('Tax Number'), },
212     'business'          => { 'text' => $locale->text('Type of Business'), },
213     'invnumber'         => { 'text' => $locale->text('Invoice'), },
214     'ordnumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
215     'quonumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation')   : $locale->text('Request for Quotation'), },
216     'street'            => { 'text' => $locale->text('Street'), },
217     'zipcode'           => { 'text' => $locale->text('Zipcode'), },
218     'city'              => { 'text' => $locale->text('City'), },
219     'country'           => { 'text' => $locale->text('Country'), },
220     'gln'               => { 'text' => $locale->text('GLN'), },
221     'salesman'          => { 'text' => $locale->text('Salesman'), },
222     'discount'          => { 'text' => $locale->text('Discount'), },
223     'payment'           => { 'text' => $locale->text('Payment Terms'), },
224     'insertdate'        => { 'text' => $locale->text('Insert Date'), },
225     'pricegroup'        => { 'text' => $locale->text('Pricegroup'), },
226     'invoice_mail'      => { 'text' => $locale->text('Email of the invoice recipient'), },
227     'delivery_order_mail' => { 'text' => $locale->text('Email of the delivery order recipient'), },
228     'contact_origin'    => { 'text' => $locale->text('Origin of personal data'), },
229     'creditlimit'       => { 'text' => $locale->text('Credit Limit'), },
230     'ustid'             => { 'text' => $locale->text('VAT ID'), },
231     'commercial_court'  => { 'text' => $locale->text('Commercial court'), },
232     create_zugferd_invoices => { text => $locale->text('Factur-X/ZUGFeRD settings'), },
233     %column_defs_cvars,
234   );
235
236   map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
237
238   my @hidden_variables  = ( qw(
239       db status obsolete name contact email cp_name addr_street addr_zipcode
240       addr_city addr_country addr_gln business_id salesman_id insertdateto insertdatefrom all
241       all_phonenumbers
242     ), "$form->{db}number",
243     map({ "cvar_$_->{name}" } @searchable_custom_variables),
244     map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables)),
245     map({'cvar_'. $_->{name} .'_to'}   grep({$_->{type} eq 'date'} @searchable_custom_variables)),
246     map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables)),
247     map({ "l_$_" } @columns),
248   );
249
250   my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables);
251   my $callback          = build_std_url('action=list_names', grep { $form->{$_} } @hidden_nondefault);
252   $form->{callback}     = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
253
254   foreach (@columns) {
255     my $sortdir              = $form->{sort} eq $_ ? 1 - $form->{sortdir} : $form->{sortdir};
256     $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=${sortdir}";
257   }
258
259   my ($ordertype, $quotationtype, $attachment_basename);
260   if ($form->{IS_CUSTOMER}) {
261     $form->{title}       = $locale->text('Customers');
262     $ordertype           = 'sales_order';
263     $quotationtype       = 'sales_quotation';
264     $attachment_basename = $locale->text('customer_list');
265
266   } else {
267     $form->{title}       = $locale->text('Vendors');
268     $ordertype           = 'purchase_order';
269     $quotationtype       = 'request_quotation';
270     $attachment_basename = $locale->text('vendor_list');
271   }
272
273   my $report = SL::ReportGenerator->new(\%myconfig, $form);
274
275   $report->set_options('top_info_text'         => join("\n", @options),
276                        'raw_bottom_info_text'  => $form->parse_html_template('ct/list_names_bottom'),
277                        'output_format'         => 'HTML',
278                        'title'                 => $form->{title},
279                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
280     );
281   $report->set_options_from_form();
282   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
283
284   $report->set_columns(%column_defs);
285   $report->set_column_order(@columns);
286
287   $report->set_export_options('list_names', @hidden_variables, qw(sort sortdir));
288
289   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
290
291   CVar->add_custom_variables_to_report('module'         => 'CT',
292                                        'trans_id_field' => 'id',
293                                        'configs'        => $cvar_configs,
294                                        'column_defs'    => \%column_defs,
295                                        'data'           => $form->{CT});
296
297   my $previous_id;
298
299   foreach my $ref (@{ $form->{CT} }) {
300     my $row = { map { $_ => { 'data' => '' } } @columns };
301
302     if ($ref->{id} ne $previous_id) {
303       $previous_id = $ref->{id};
304       $ref->{discount} = $form->format_amount(\%myconfig, $ref->{discount} * 100.0, 2);
305       $ref->{creditlimit} = $form->format_amount(\%myconfig, $ref->{creditlimit}, 2);
306       map { $row->{$_}->{data} = $ref->{$_} } @columns;
307
308       $row->{name}->{link}  = build_std_url('script=controller.pl', 'action=CustomerVendor/edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
309       $row->{email}->{link} = 'mailto:' . E($ref->{email});
310     }
311
312     my $base_url              = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
313     if ($::instance_conf->get_feature_experimental_order) {
314       if ('oe' eq $ref->{module}) {
315         $base_url             = build_std_url("script=controller.pl", 'action=Order/edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
316       }
317     }
318
319     $row->{invnumber}->{link} = $base_url;
320     $row->{ordnumber}->{link} = $base_url . "&type=${ordertype}";
321     $row->{quonumber}->{link} = $base_url . "&type=${quotationtype}";
322     my $column                = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber';
323     $row->{$column}->{data}   = $ref->{$column};
324
325     if (my $number = SL::CTI->sanitize_number(number => $ref->{phone})) {
326       $row->{phone}->{link}       = SL::CTI->call_link(number => $number);
327       $row->{phone}->{link_class} = 'cti_call_action';
328     }
329
330     $report->add_data($row);
331   }
332
333   setup_ct_list_names_action_bar();
334   $report->generate_with_headers();
335
336   $main::lxdebug->leave_sub();
337 }
338
339 sub list_contacts {
340   $::lxdebug->enter_sub;
341
342   $::form->{sortdir} = 1 unless defined $::form->{sortdir};
343
344   my @contacts     = CT->search_contacts(
345     search_term => $::form->{search_term},
346     filter      => $::form->{filter},
347   );
348
349   my $cvar_configs = CVar->get_configs('module' => 'Contacts');
350
351   my @columns      = qw(
352     cp_id vcname vcnumber cp_name cp_givenname cp_street cp_zipcode cp_city cp_phone1 cp_phone2 cp_privatphone
353     cp_mobile1 cp_mobile2 cp_fax cp_email cp_privatemail cp_abteilung cp_position cp_birthday cp_gender
354   );
355
356   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
357   my @searchable_custom_variables  = grep { $_->{searchable} }  @{ $cvar_configs };
358   my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
359
360   push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
361
362   my @visible_columns;
363   if ($::form->{l}) {
364     @visible_columns = grep { $::form->{l}{$_} } @columns;
365     push @visible_columns, qw(cp_phone1 cp_phone2)   if $::form->{l}{cp_phone};
366     push @visible_columns, qw(cp_mobile1 cp_mobile2) if $::form->{l}{cp_mobile};
367   } else {
368    @visible_columns = qw(vcname vcnumber cp_name cp_givenname cp_phone1 cp_phone2 cp_mobile1 cp_email);
369   }
370
371   my %column_defs  = (
372     'cp_id'        => { 'text' => $::locale->text('ID'), },
373     'vcname'       => { 'text' => $::locale->text('Customer/Vendor'), },
374     'vcnumber'     => { 'text' => $::locale->text('Customer/Vendor Number'), },
375     'cp_name'      => { 'text' => $::locale->text('Name'), },
376     'cp_givenname' => { 'text' => $::locale->text('Given Name'), },
377     'cp_street'    => { 'text' => $::locale->text('Street'), },
378     'cp_zipcode'   => { 'text' => $::locale->text('Zipcode'), },
379     'cp_city'      => { 'text' => $::locale->text('City'), },
380     'cp_phone1'    => { 'text' => $::locale->text('Phone1'), },
381     'cp_phone2'    => { 'text' => $::locale->text('Phone2'), },
382     'cp_mobile1'   => { 'text' => $::locale->text('Mobile1'), },
383     'cp_mobile2'   => { 'text' => $::locale->text('Mobile2'), },
384     'cp_email'     => { 'text' => $::locale->text('E-mail'), },
385     'cp_abteilung' => { 'text' => $::locale->text('Department'), },
386     'cp_position'  => { 'text' => $::locale->text('Function/position'), },
387     'cp_birthday'  => { 'text' => $::locale->text('Birthday'), },
388     'cp_gender'    => { 'text' => $::locale->text('Gender'), },
389     'cp_fax'       => { 'text' => $::locale->text('Fax'), },
390     'cp_privatphone' => { 'text' => $::locale->text('Private Phone') },
391     'cp_privatemail' => { 'text' => $::locale->text('Private E-mail') },
392     %column_defs_cvars,
393   );
394
395   map { $column_defs{$_}->{visible} = 1 } @visible_columns;
396
397   my @hidden_variables  = (qw(search_term filter l));
398   my $hide_vars         = { map { $_ => $::form->{$_} } @hidden_variables };
399   my @hidden_nondefault = grep({ $::form->{$_} } @hidden_variables);
400   my $callback          = build_std_url('action=list_contacts', join '&', map { E($_->[0]) . '=' . E($_->[1]) } @{ flatten($hide_vars) });
401   $::form->{callback}     = "$callback&sort=" . E($::form->{sort});
402
403   map { $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=" . ($::form->{sort} eq $_ ? 1 - $::form->{sortdir} : $::form->{sortdir}) } @columns;
404
405   $::form->{title} = $::locale->text('Contacts');
406
407   my $report     = SL::ReportGenerator->new(\%::myconfig, $::form);
408
409   my @options;
410   push @options, $::locale->text('Search term') . ': ' . $::form->{search_term} if $::form->{search_term};
411   for (qw(cp_name cp_givenname cp_title cp_email cp_abteilung cp_project)) {
412     push @options, $column_defs{$_}{text} . ': ' . $::form->{filter}{$_} if $::form->{filter}{$_};
413   }
414   if ($::form->{filter}{status}) {
415     push @options, $::locale->text('Status') . ': ' . (
416       $::form->{filter}{status} =~ /active/   ? $::locale->text('Active')   :
417       $::form->{filter}{status} =~ /orphaned/ ? $::locale->text('Orphaned') :
418       $::form->{filter}{status} =~ /all/      ? $::locale->text('All')      : ''
419     );
420   }
421
422
423   $report->set_options('top_info_text'       => join("\n", @options),
424                        'output_format'       => 'HTML',
425                        'title'               => $::form->{title},
426                        'attachment_basename' => $::locale->text('contact_list') . strftime('_%Y%m%d', localtime time),
427     );
428   $report->set_options_from_form;
429
430   $report->set_columns(%column_defs);
431   $report->set_column_order(@columns);
432
433   $report->set_export_options('list_contacts', @hidden_variables);
434
435   $report->set_sort_indicator($::form->{sort}, $::form->{sortdir});
436
437   CVar->add_custom_variables_to_report('module'         => 'Contacts',
438                                        'trans_id_field' => 'cp_id',
439                                        'configs'        => $cvar_configs,
440                                        'column_defs'    => \%column_defs,
441                                        'data'           => \@contacts);
442
443
444   foreach my $ref (@contacts) {
445     my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
446
447     $row->{vcname}->{link}   = build_std_url('script=controller.pl', 'action=CustomerVendor/edit', 'id=' . E($ref->{vcid}), 'db=' . E($ref->{db}), 'callback', @hidden_nondefault);
448     $row->{vcnumber}->{link} = $row->{vcname}->{link};
449
450     for (qw(cp_email cp_privatemail)) {
451       $row->{$_}->{link} = 'mailto:' . E($ref->{$_}) if $ref->{$_};
452     }
453
454     for (qw(cp_phone1 cp_phone2 cp_mobile1)) {
455       next unless my $number = SL::CTI->sanitize_number(number => $ref->{$_});
456
457       $row->{$_}->{link}       = SL::CTI->call_link(number => $number);
458       $row->{$_}->{link_class} = 'cti_call_action';
459     }
460
461     $report->add_data($row);
462   }
463
464   $report->generate_with_headers();
465
466   $::lxdebug->leave_sub;
467 }
468
469 sub setup_ct_search_action_bar {
470   my %params = @_;
471
472   for my $bar ($::request->layout->get('actionbar')) {
473     $bar->add(
474       action => [
475         t8('Search'),
476         submit    => [ '#form', { action => 'list_names' } ],
477         accesskey => 'enter',
478       ],
479     );
480   }
481 }
482
483 sub setup_ct_list_names_action_bar {
484   my %params = @_;
485
486   for my $bar ($::request->layout->get('actionbar')) {
487     $bar->add(
488       action => [
489         t8('Add'),
490         submit    => [ '#new_form', { action => 'CustomerVendor/add' } ],
491         accesskey => 'enter',
492       ],
493     );
494   }
495 }
496
497 sub setup_ct_search_contact_action_bar {
498   my %params = @_;
499
500   for my $bar ($::request->layout->get('actionbar')) {
501     $bar->add(
502       action => [
503         t8('Search'),
504         submit    => [ '#form', { action => 'list_contacts' } ],
505         accesskey => 'enter',
506       ],
507     );
508   }
509 }
510
511 sub continue { call_sub($main::form->{nextsub}); }