]> wagnertech.de Git - mfinanz.git/blob - bin/mozilla/ct.pl
restart apache2 in postinst
[mfinanz.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::DB::Manager::PaymentTerm;
59 use SL::DB::Manager::TaxZone;
60 use SL::ReportGenerator;
61 use SL::Locale::String qw(t8);
62 use SL::MoreCommon qw(uri_encode);
63 use SL::ZUGFeRD;
64
65 require "bin/mozilla/common.pl";
66 require "bin/mozilla/reportgenerator.pl";
67
68 use strict;
69 1;
70
71 # end of main
72
73 sub _zugferd_settings {
74   return ([ -1, $::locale->text('Use settings from client configuration') ],
75           @SL::ZUGFeRD::customer_settings);
76 }
77
78 sub search {
79   $main::lxdebug->enter_sub();
80
81   my $form     = $main::form;
82   my $locale   = $main::locale;
83
84   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
85
86   $::auth->assert('customer_report_view') if  $form->{IS_CUSTOMER};
87   $::auth->assert('vendor_report_view')   if !$form->{IS_CUSTOMER};
88
89   $form->get_lists("business_types" => "ALL_BUSINESS_TYPES",
90                    "salesmen"       => "ALL_SALESMEN");
91   $form->{ALL_PAYMENT_TERMS} = SL::DB::Manager::PaymentTerm->get_all_sorted;
92   $form->{ALL_TAXZONES}      = SL::DB::Manager::TaxZone    ->get_all_sorted;
93   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
94
95   $form->{CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'CT');
96   ($form->{CUSTOM_VARIABLES_FILTER_CODE},
97    $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'      => $form->{CUSTOM_VARIABLES},
98                                                                            'include_prefix' => 'l_',
99                                                                            'include_value'  => 'Y');
100
101   $form->{title}    = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
102
103   $form->{ZUGFERD_SETTINGS} = [ _zugferd_settings() ];
104
105   setup_ct_search_action_bar();
106
107   $form->header();
108   print $form->parse_html_template('ct/search');
109
110   $main::lxdebug->leave_sub();
111 }
112
113 sub search_contact {
114   $::lxdebug->enter_sub;
115
116   $::auth->assert('contact_person_report_view');
117
118   $::form->{CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'Contacts');
119   ($::form->{CUSTOM_VARIABLES_FILTER_CODE},
120    $::form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'    => $::form->{CUSTOM_VARIABLES},
121                                                                            'include_prefix' => 'l.',
122                                                                            'filter_prefix'  => 'filter.',
123                                                                            'include_value'  => 'Y');
124
125   $::form->{title} = $::locale->text('Search contacts');
126
127   setup_ct_search_contact_action_bar();
128   $::form->header;
129   print $::form->parse_html_template('ct/search_contact');
130
131   $::lxdebug->leave_sub;
132 }
133
134 sub list_names {
135   $main::lxdebug->enter_sub();
136
137   my $form     = $main::form;
138   my %myconfig = %main::myconfig;
139   my $locale   = $main::locale;
140
141   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
142
143   report_generator_set_default_sort('name', 1);
144
145   CT->search(\%myconfig, \%$form);
146
147   my $cvar_configs = CVar->get_configs('module' => 'CT');
148
149   my @options;
150   if ($form->{status} eq 'all') {
151     push @options, $locale->text('All');
152   } elsif ($form->{status} eq 'orphaned') {
153     push @options, $locale->text('Orphaned');
154   }
155
156   my @zugferd_settings_list = _zugferd_settings();
157   my $zugferd_filter        = $form->{create_zugferd_invoices} eq '' ? undef : $zugferd_settings_list[$form->{create_zugferd_invoices} + 1]->[1];
158
159   push @options, $locale->text('Name')                               . " : $form->{name}"                  if $form->{name};
160   push @options, $locale->text('Department') . ' 1'                  . " : $form->{department_1}"          if $form->{department_1};
161   push @options, $locale->text('Department') . ' 2'                  . " : $form->{department_2}"          if $form->{department_2};
162   push @options, $locale->text('Contact')                            . " : $form->{contact}"               if $form->{contact};
163   push @options, $locale->text('Number')                           . qq| : $form->{"$form->{db}number"}|   if $form->{"$form->{db}number"};
164   push @options, $locale->text('E-mail')                             . " : $form->{email}"                 if $form->{email};
165   push @options, $locale->text('All phone numbers')                  . " : $form->{all_phonenumbers}"      if $form->{all_phonenumbers};
166   push @options, $locale->text('Contact person (surname)')           . " : $form->{cp_name}"               if $form->{cp_name};
167   push @options, $locale->text('Billing/shipping address (city)')    . " : $form->{addr_city}"             if $form->{addr_city};
168   push @options, $locale->text('Billing/shipping address (zipcode)') . " : $form->{addr_zipcode}"          if $form->{addr_zipcode};
169   push @options, $locale->text('Billing/shipping address (street)')  . " : $form->{addr_street}"           if $form->{addr_street};
170   push @options, $locale->text('Billing/shipping address (country)') . " : $form->{addr_country}"          if $form->{addr_country};
171   push @options, $locale->text('Billing/shipping address (GLN)')     . " : $form->{addr_gln}"              if $form->{addr_gln};
172   push @options, $locale->text('Quick Search')                       . " : $form->{all}"                   if $form->{all};
173   push @options, $locale->text('Factur-X/ZUGFeRD settings')          . " : $zugferd_filter"                if $zugferd_filter;
174   push @options, $locale->text('Dunning lock')                       . " : $form->{dunning_lock}"          if $form->{dunning_lock} ne '';
175
176   if ($form->{business_id}) {
177     my $business = SL::DB::Manager::Business->find_by(id => $form->{business_id});
178     if ($business) {
179       my $label = $form->{IS_CUSTOMER} ? $::locale->text('Customer type') : $::locale->text('Vendor type');
180       push @options, $label . " : " . $business->description;
181     }
182   }
183   if ($form->{salesman_id}) {
184     my $salesman = SL::DB::Manager::Employee->find_by(id => $form->{salesman_id});
185     if ($salesman) {
186       push @options, $locale->text('Salesman') . " : " . $salesman->name;
187     }
188   }
189
190   if ($form->{payment_id}) {
191     my $payment = SL::DB::Manager::PaymentTerm->find_by(id => $form->{payment_id});
192     if ($payment) {
193       push @options, $locale->text('Payment Term') . " : " . $payment->description;
194     }
195   }
196
197   if ($form->{taxzone_id}) {
198     my $tax_zone = SL::DB::Manager::TaxZone->find_by(id => $form->{taxzone_id});
199     if ($tax_zone) {
200       push @options, $locale->text('Tax rate') . " : " . $tax_zone->description;
201     }
202   }
203
204   if ( $form->{insertdatefrom} or $form->{insertdateto} ) {
205     push @options, $locale->text('Insert Date');
206     push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{insertdatefrom}, 1) if $form->{insertdatefrom};
207     push @options, $locale->text('Bis')  . " " . $locale->date(\%myconfig, $form->{insertdateto},   1) if $form->{insertdateto};
208   };
209
210   my @columns = (
211     'id',        'name',    "$form->{db}number",   'contact', 'main_contact_person',
212     'department_1',         'department_2',        'phone',   'discount',
213     'fax',       'email',   'taxnumber',           'street',    'zipcode' , 'city',
214     'business',  'payment', 'taxzone', 'invnumber', 'ordnumber',           'quonumber', 'salesman',
215     'country',   'gln',     'insertdate',           'pricegroup', 'contact_origin', 'invoice_mail',
216     'creditlimit', 'ustid', 'commercial_court', 'delivery_order_mail', 'dunning_lock'
217   );
218
219   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
220   my @searchable_custom_variables  = grep { $_->{searchable} }  @{ $cvar_configs };
221   my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
222
223   push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
224
225   my %column_defs = (
226     'id'                => { 'text' => $locale->text('ID'), },
227     "$form->{db}number" => { 'text' => $locale->text('Number'), },
228     'name'              => { 'text' => $form->{IS_CUSTOMER} ? $::locale->text('Customer Name') : $::locale->text('Vendor Name'), },
229     'contact'           => { 'text' => $locale->text('Contact'), },
230     'main_contact_person'  => { 'text' => $locale->text('Main Contact Person'), },
231     'department_1'      => { 'text' => $locale->text('Department') . " 1", },
232     'department_2'      => { 'text' => $locale->text('Department') . " 2", },
233     'phone'             => { 'text' => $locale->text('Phone'), },
234     'fax'               => { 'text' => $locale->text('Fax'), },
235     'email'             => { 'text' => $locale->text('E-mail'), },
236     'cc'                => { 'text' => $locale->text('Cc'), },
237     'taxnumber'         => { 'text' => $locale->text('Tax Number'), },
238     'business'          => { 'text' => $locale->text('Type of Business'), },
239     'invnumber'         => { 'text' => $locale->text('Invoice'), },
240     'ordnumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
241     'quonumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation')   : $locale->text('Request for Quotation'), },
242     'street'            => { 'text' => $locale->text('Street'), },
243     'zipcode'           => { 'text' => $locale->text('Zipcode'), },
244     'city'              => { 'text' => $locale->text('City'), },
245     'country'           => { 'text' => $locale->text('Country'), },
246     'gln'               => { 'text' => $locale->text('GLN'), },
247     'salesman'          => { 'text' => $locale->text('Salesman'), },
248     'discount'          => { 'text' => $locale->text('Discount'), },
249     'payment'           => { 'text' => $locale->text('Payment Terms'), },
250     'taxzone'           => { 'text' => $locale->text('Tax rate'), },
251     'insertdate'        => { 'text' => $locale->text('Insert Date'), },
252     'pricegroup'        => { 'text' => $locale->text('Pricegroup'), },
253     'invoice_mail'      => { 'text' => $locale->text('Email of the invoice recipient'), },
254     'delivery_order_mail' => { 'text' => $locale->text('Email of the delivery order recipient'), },
255     'contact_origin'    => { 'text' => $locale->text('Origin of personal data'), },
256     'creditlimit'       => { 'text' => $locale->text('Credit Limit'), },
257     'ustid'             => { 'text' => $locale->text('VAT ID'), },
258     'commercial_court'  => { 'text' => $locale->text('Commercial court'), },
259     create_zugferd_invoices => { text => $locale->text('Factur-X/ZUGFeRD settings'), },
260     'dunning_lock'      => { 'text' => $locale->text('Dunning lock'), },
261     %column_defs_cvars,
262   );
263
264   map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
265
266   my @hidden_variables  = ( qw(
267       db status obsolete name contact email cp_name addr_street addr_zipcode
268       addr_city addr_country addr_gln business_id salesman_id insertdateto insertdatefrom all
269       all_phonenumbers dunning_lock department_1 department_2 payment_id taxzone_id
270     ), "$form->{db}number",
271     map({ "cvar_$_->{name}" } @searchable_custom_variables),
272     map({'cvar_'. $_->{name} .'_from'} grep({$_->{type} eq 'date'} @searchable_custom_variables)),
273     map({'cvar_'. $_->{name} .'_to'}   grep({$_->{type} eq 'date'} @searchable_custom_variables)),
274     map({'cvar_'. $_->{name} .'_qtyop'} grep({$_->{type} eq 'number'} @searchable_custom_variables)),
275     map({ "l_$_" } @columns),
276   );
277
278   my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables);
279   my $callback          = build_std_url('action=list_names', grep { $form->{$_} } @hidden_nondefault);
280   $form->{callback}     = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
281
282   foreach (@columns) {
283     my $sortdir              = $form->{sort} eq $_ ? 1 - $form->{sortdir} : $form->{sortdir};
284     $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=${sortdir}";
285   }
286
287   my ($ordertype, $quotationtype, $attachment_basename);
288   if ($form->{IS_CUSTOMER}) {
289     $form->{title}       = $locale->text('Customers');
290     $ordertype           = 'sales_order';
291     $quotationtype       = 'sales_quotation';
292     $attachment_basename = $locale->text('customer_list');
293
294   } else {
295     $form->{title}       = $locale->text('Vendors');
296     $ordertype           = 'purchase_order';
297     $quotationtype       = 'request_quotation';
298     $attachment_basename = $locale->text('vendor_list');
299   }
300
301   my $report = SL::ReportGenerator->new(\%myconfig, $form);
302
303   $report->set_options('top_info_text'         => join("\n", @options),
304                        'raw_bottom_info_text'  => $form->parse_html_template('ct/list_names_bottom'),
305                        'output_format'         => 'HTML',
306                        'title'                 => $form->{title},
307                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
308     );
309   $report->set_options_from_form();
310   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
311
312   $report->set_columns(%column_defs);
313   $report->set_column_order(@columns);
314
315   $report->set_export_options('list_names', @hidden_variables, qw(sort sortdir));
316
317   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
318
319   CVar->add_custom_variables_to_report('module'         => 'CT',
320                                        'trans_id_field' => 'id',
321                                        'configs'        => $cvar_configs,
322                                        'column_defs'    => \%column_defs,
323                                        'data'           => $form->{CT});
324
325   my $previous_id;
326
327   foreach my $ref (@{ $form->{CT} }) {
328     my $row = { map { $_ => { 'data' => '' } } @columns };
329
330     if ($ref->{id} ne $previous_id) {
331       $previous_id = $ref->{id};
332       $ref->{discount} = $form->format_amount(\%myconfig, $ref->{discount} * 100.0, 2);
333       $ref->{creditlimit} = $form->format_amount(\%myconfig, $ref->{creditlimit}, 2);
334       map { $row->{$_}->{data} = $ref->{$_} } @columns;
335
336       $row->{name}->{link}  = build_std_url('script=controller.pl', 'action=CustomerVendor/edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
337       $row->{email}->{link} = 'mailto:' . E($ref->{email});
338     }
339
340     my $base_url              = build_std_url("script=controller.pl", 'action=Order/edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
341
342     $row->{invnumber}->{link} = $base_url;
343     $row->{ordnumber}->{link} = $base_url . "&type=${ordertype}";
344     $row->{quonumber}->{link} = $base_url . "&type=${quotationtype}";
345     my $column                = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber';
346     $row->{$column}->{data}   = $ref->{$column};
347
348     if (my $number = SL::CTI->sanitize_number(number => $ref->{phone})) {
349       $row->{phone}->{link}       = SL::CTI->call_link(number => $number);
350       $row->{phone}->{link_class} = 'cti_call_action';
351     }
352
353     $report->add_data($row);
354   }
355
356   setup_ct_list_names_action_bar();
357   $report->generate_with_headers();
358
359   $main::lxdebug->leave_sub();
360 }
361
362 sub list_contacts {
363   $::lxdebug->enter_sub;
364
365   $::form->{sortdir} = 1 unless defined $::form->{sortdir};
366
367   my @contacts     = CT->search_contacts(
368     search_term => $::form->{search_term},
369     filter      => $::form->{filter},
370   );
371
372   my $cvar_configs = CVar->get_configs('module' => 'Contacts');
373
374   my @columns      = qw(
375     cp_id vcname vcnumber cp_name cp_givenname cp_street cp_zipcode cp_city cp_phone1 cp_phone2 cp_privatphone
376     cp_mobile1 cp_mobile2 cp_fax cp_email cp_privatemail cp_abteilung cp_position cp_birthday cp_gender
377   );
378
379   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
380   my @searchable_custom_variables  = grep { $_->{searchable} }  @{ $cvar_configs };
381   my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
382
383   push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
384
385   my @visible_columns;
386   if ($::form->{l}) {
387     @visible_columns = grep { $::form->{l}{$_} } @columns;
388     push @visible_columns, qw(cp_phone1 cp_phone2)   if $::form->{l}{cp_phone};
389     push @visible_columns, qw(cp_mobile1 cp_mobile2) if $::form->{l}{cp_mobile};
390   } else {
391    @visible_columns = qw(vcname vcnumber cp_name cp_givenname cp_phone1 cp_phone2 cp_mobile1 cp_email);
392   }
393
394   my %column_defs  = (
395     'cp_id'        => { 'text' => $::locale->text('ID'), },
396     'vcname'       => { 'text' => $::locale->text('Customer/Vendor'), },
397     'vcnumber'     => { 'text' => $::locale->text('Customer/Vendor Number'), },
398     'cp_name'      => { 'text' => $::locale->text('Name'), },
399     'cp_givenname' => { 'text' => $::locale->text('Given Name'), },
400     'cp_street'    => { 'text' => $::locale->text('Street'), },
401     'cp_zipcode'   => { 'text' => $::locale->text('Zipcode'), },
402     'cp_city'      => { 'text' => $::locale->text('City'), },
403     'cp_phone1'    => { 'text' => $::locale->text('Phone1'), },
404     'cp_phone2'    => { 'text' => $::locale->text('Phone2'), },
405     'cp_mobile1'   => { 'text' => $::locale->text('Mobile1'), },
406     'cp_mobile2'   => { 'text' => $::locale->text('Mobile2'), },
407     'cp_email'     => { 'text' => $::locale->text('E-mail'), },
408     'cp_abteilung' => { 'text' => $::locale->text('Department'), },
409     'cp_position'  => { 'text' => $::locale->text('Function/position'), },
410     'cp_birthday'  => { 'text' => $::locale->text('Birthday'), },
411     'cp_gender'    => { 'text' => $::locale->text('Gender'), },
412     'cp_fax'       => { 'text' => $::locale->text('Fax'), },
413     'cp_privatphone' => { 'text' => $::locale->text('Private Phone') },
414     'cp_privatemail' => { 'text' => $::locale->text('Private E-mail') },
415     %column_defs_cvars,
416   );
417
418   map { $column_defs{$_}->{visible} = 1 } @visible_columns;
419
420   my @hidden_variables  = (qw(search_term filter l));
421   my $hide_vars         = { map { $_ => $::form->{$_} } @hidden_variables };
422   my @hidden_nondefault = grep({ $::form->{$_} } @hidden_variables);
423   my $callback          = build_std_url('action=list_contacts', join '&', map { E($_->[0]) . '=' . E($_->[1]) } @{ flatten($hide_vars) });
424   $::form->{callback}     = "$callback&sort=" . E($::form->{sort});
425
426   map { $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=" . ($::form->{sort} eq $_ ? 1 - $::form->{sortdir} : $::form->{sortdir}) } @columns;
427
428   $::form->{title} = $::locale->text('Contacts');
429
430   my $report     = SL::ReportGenerator->new(\%::myconfig, $::form);
431
432   my @options;
433   push @options, $::locale->text('Search term') . ': ' . $::form->{search_term} if $::form->{search_term};
434   for (qw(cp_name cp_givenname cp_title cp_email cp_abteilung cp_project)) {
435     push @options, $column_defs{$_}{text} . ': ' . $::form->{filter}{$_} if $::form->{filter}{$_};
436   }
437   if ($::form->{filter}{status}) {
438     push @options, $::locale->text('Status') . ': ' . (
439       $::form->{filter}{status} =~ /active/   ? $::locale->text('Active')   :
440       $::form->{filter}{status} =~ /orphaned/ ? $::locale->text('Orphaned') :
441       $::form->{filter}{status} =~ /all/      ? $::locale->text('All')      : ''
442     );
443   }
444
445
446   $report->set_options('top_info_text'       => join("\n", @options),
447                        'output_format'       => 'HTML',
448                        'title'               => $::form->{title},
449                        'attachment_basename' => $::locale->text('contact_list') . strftime('_%Y%m%d', localtime time),
450     );
451   $report->set_options_from_form;
452
453   $report->set_columns(%column_defs);
454   $report->set_column_order(@columns);
455
456   $report->set_export_options('list_contacts', @hidden_variables);
457
458   $report->set_sort_indicator($::form->{sort}, $::form->{sortdir});
459
460   CVar->add_custom_variables_to_report('module'         => 'Contacts',
461                                        'trans_id_field' => 'cp_id',
462                                        'configs'        => $cvar_configs,
463                                        'column_defs'    => \%column_defs,
464                                        'data'           => \@contacts);
465
466
467   foreach my $ref (@contacts) {
468     my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
469
470     $row->{vcname}->{link}   = build_std_url('script=controller.pl', 'action=CustomerVendor/edit', 'id=' . E($ref->{vcid}), 'db=' . E($ref->{db}), 'callback', @hidden_nondefault);
471     $row->{vcnumber}->{link} = $row->{vcname}->{link};
472
473     for (qw(cp_email cp_privatemail)) {
474       $row->{$_}->{link} = 'mailto:' . E($ref->{$_}) if $ref->{$_};
475     }
476
477     for (qw(cp_phone1 cp_phone2 cp_mobile1)) {
478       next unless my $number = SL::CTI->sanitize_number(number => $ref->{$_});
479
480       $row->{$_}->{link}       = SL::CTI->call_link(number => $number);
481       $row->{$_}->{link_class} = 'cti_call_action';
482     }
483
484     $report->add_data($row);
485   }
486
487   $report->generate_with_headers();
488
489   $::lxdebug->leave_sub;
490 }
491
492 sub setup_ct_search_action_bar {
493   my %params = @_;
494
495   for my $bar ($::request->layout->get('actionbar')) {
496     $bar->add(
497       action => [
498         t8('Search'),
499         submit    => [ '#form', { action => 'list_names' } ],
500         accesskey => 'enter',
501       ],
502     );
503   }
504 }
505
506 sub setup_ct_list_names_action_bar {
507   my %params = @_;
508
509   for my $bar ($::request->layout->get('actionbar')) {
510     $bar->add(
511       action => [
512         t8('Add'),
513         submit    => [ '#new_form', { action => 'CustomerVendor/add' } ],
514         accesskey => 'enter',
515       ],
516     );
517   }
518 }
519
520 sub setup_ct_search_contact_action_bar {
521   my %params = @_;
522
523   for my $bar ($::request->layout->get('actionbar')) {
524     $bar->add(
525       action => [
526         t8('Search'),
527         submit    => [ '#form', { action => 'list_contacts' } ],
528         accesskey => 'enter',
529       ],
530     );
531   }
532 }
533
534 sub continue { call_sub($main::form->{nextsub}); }