Lieferantennummer/Kundennummer in Kunden/Lieferantenberichten ersetzt durch schlicht...
[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., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #======================================================================
30 #
31 # customer/vendor module
32 #
33 #======================================================================
34
35 # $locale->text('Customers')
36 # $locale->text('Vendors')
37 # $locale->text('Add Customer')
38 # $locale->text('Add Vendor')
39 # $locale->text('Edit Customer')
40 # $locale->text('Edit Vendor')
41 # $locale->text('Customer saved!')
42 # $locale->text('Vendor saved!')
43 # $locale->text('Customer deleted!')
44 # $locale->text('Cannot delete customer!')
45 # $locale->text('Vendor deleted!')
46 # $locale->text('Cannot delete vendor!')
47
48 use CGI::Ajax;
49 use POSIX qw(strftime);
50
51 use SL::CT;
52 use SL::CVar;
53 use SL::ReportGenerator;
54
55 require "bin/mozilla/common.pl";
56 require "bin/mozilla/reportgenerator.pl";
57
58 1;
59
60 # end of main
61
62 sub add {
63   $lxdebug->enter_sub();
64
65   $auth->assert('customer_vendor_edit');
66
67   $form->{title}    = "Add";
68   $form->{callback} = "$form->{script}?action=add&db=$form->{db}" unless $form->{callback};
69
70   CT->populate_drop_down_boxes(\%myconfig, \%$form);
71
72   &form_header;
73   &form_footer;
74
75   $lxdebug->leave_sub();
76 }
77
78 sub search {
79   $lxdebug->enter_sub();
80
81   $auth->assert('customer_vendor_edit');
82
83   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
84
85   $form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
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->{jsscript} = 1;
95   $form->{title}    = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
96   $form->{fokus}    = 'Form.name';
97
98   $form->header();
99   print $form->parse_html_template('ct/search');
100
101   $lxdebug->leave_sub();
102 }
103
104 sub list_names {
105   $lxdebug->enter_sub();
106
107   $auth->assert('customer_vendor_edit');
108
109   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
110
111   report_generator_set_default_sort('name', 1);
112
113   CT->search(\%myconfig, \%$form);
114
115   my $cvar_configs = CVar->get_configs('module' => 'CT');
116
117   my @options;
118   if ($form->{status} eq 'all') {
119     push @options, $locale->text('All');
120   } elsif ($form->{status} eq 'orphaned') {
121     push @options, $locale->text('Orphaned');
122   }
123
124   push @options, $locale->text('Name') . " : $form->{name}"                    if $form->{name};
125   push @options, $locale->text('Contact') . " : $form->{contact}"              if $form->{contact};
126   push @options, $locale->text('Number') . qq| : $form->{"$form->{db}number"}| if $form->{"$form->{db}number"};
127   push @options, $locale->text('E-mail') . " : $form->{email}"                 if $form->{email};
128   push @options, $locale->text('Contact person (surname)')
129     . " : $form->{cp_name}"                                                    if $form->{cp_name};
130   push @options, $locale->text('Billing/shipping address (city)')
131     . " : $form->{addr_city}"                                                  if $form->{addr_city};
132
133   push @options, $locale->text('Billing/shipping address (zipcode)')
134     . " : $form->{zipcode}"                                                  if $form->{addr_zipcode};
135   push @options, $locale->text('Billing/shipping address (street)')
136     . " : $form->{street}"                                                  if $form->{addr_street};
137
138   my @columns = (
139     'id',        'name',  "$form->{db}number", 'contact',  'phone',
140     'fax',       'email', 'taxnumber', 'street', 'zipcode' , 'city', 'business', 'invnumber',
141     'ordnumber', 'quonumber'
142   );
143
144   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
145   my @searchable_custom_variables  = grep { $_->{searchable} }  @{ $cvar_configs };
146   my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
147
148   push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
149
150   my %column_defs = (
151     'id'                => { 'text' => $locale->text('ID'), },
152     "$form->{db}number" => { 'text' => $locale->text('Number'), },
153     'name'              => { 'text' => $locale->text('Name'), },
154     'contact'           => { 'text' => $locale->text('Contact'), },
155     'phone'             => { 'text' => $locale->text('Phone'), },
156     'fax'               => { 'text' => $locale->text('Fax'), },
157     'email'             => { 'text' => $locale->text('E-mail'), },
158     'cc'                => { 'text' => $locale->text('Cc'), },
159     'taxnumber'         => { 'text' => $locale->text('Tax Number'), },
160     'business'          => { 'text' => $locale->text('Type of Business'), },
161     'invnumber'         => { 'text' => $locale->text('Invoice'), },
162     'ordnumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
163     'quonumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation')   : $locale->text('Request for Quotation'), },
164     'street'            => { 'text' => $locale->text('Street'), },
165     'zipcode'           => { 'text' => $locale->text('Zipcode'), },
166     'city'              => { 'text' => $locale->text('City'), },
167     %column_defs_cvars,
168   );
169
170   map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
171
172   my @hidden_variables  = (qw(db status obsolete name contact email cp_name addr_city), "$form->{db}number", @searchable_custom_variables, map { "l_$_" } @columns);
173   my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables);
174   my $callback          = build_std_url('action=list_names', grep { $form->{$_} } @hidden_nondefault);
175   $form->{callback}     = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
176
177   foreach (@columns) {
178     my $sortdir              = $form->{sort} eq $_ ? 1 - $form->{sortdir} : $form->{sortdir};
179     $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=${sortdir}";
180   }
181
182   my ($ordertype, $quotationtype, $attachment_basename);
183   if ($form->{IS_CUSTOMER}) {
184     $form->{title}       = $locale->text('Customers');
185     $ordertype           = 'sales_order';
186     $quotationtype       = 'sales_quotation';
187     $attachment_basename = $locale->text('customer_list');
188
189   } else {
190     $form->{title}       = $locale->text('Vendors');
191     $ordertype           = 'purchase_order';
192     $quotationtype       = 'request_quotation';
193     $attachment_basename = $locale->text('vendor_list');
194   }
195
196   my $report = SL::ReportGenerator->new(\%myconfig, $form);
197
198   $report->set_options('top_info_text'         => join("\n", @options),
199                        'raw_bottom_info_text'  => $form->parse_html_template('ct/list_names_bottom'),
200                        'output_format'         => 'HTML',
201                        'title'                 => $form->{title},
202                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
203     );
204   $report->set_options_from_form();
205
206   $report->set_columns(%column_defs);
207   $report->set_column_order(@columns);
208
209   $report->set_export_options('list_names', @hidden_variables, qw(sort sortdir));
210
211   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
212
213   CVar->add_custom_variables_to_report('module'         => 'CT',
214                                        'trans_id_field' => 'id',
215                                        'configs'        => $cvar_configs,
216                                        'column_defs'    => \%column_defs,
217                                        'data'           => $form->{CT});
218
219   my $previous_id;
220
221   foreach my $ref (@{ $form->{CT} }) {
222     my $row = { map { $_ => { 'data' => '' } } @columns };
223
224     if ($ref->{id} ne $previous_id) {
225       $previous_id = $ref->{id};
226       map { $row->{$_}->{data} = $ref->{$_} } @columns;
227
228       $row->{name}->{link}  = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
229       $row->{email}->{link} = 'mailto:' . E($ref->{email});
230     }
231
232     my $base_url              = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
233     $row->{invnumber}->{link} = $base_url;
234     $row->{ordnumber}->{link} = $base_url . "&type=${ordertype}";
235     $row->{quonumber}->{link} = $base_url . "&type=${quotationtype}";
236     my $column                = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber';
237     $row->{$column}->{data}   = $ref->{$column};
238
239     $report->add_data($row);
240   }
241
242   $report->generate_with_headers();
243
244   $lxdebug->leave_sub();
245 }
246
247 sub edit {
248   $lxdebug->enter_sub();
249
250   $auth->assert('customer_vendor_edit');
251
252   # show history button
253   $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
254   #/show hhistory button
255
256   CT->get_tuple(\%myconfig, \%$form);
257   CT->populate_drop_down_boxes(\%myconfig, \%$form);
258
259   $form->{title} = "Edit";
260
261   # format discount
262   $form->{discount} *= 100;
263
264   &form_header;
265   &form_footer;
266
267   $lxdebug->leave_sub();
268 }
269
270 sub form_header {
271   $lxdebug->enter_sub();
272
273   $auth->assert('customer_vendor_edit');
274
275   $form->get_lists("employees" => "ALL_EMPLOYEES",
276                    "taxzones"  => "ALL_TAXZONES");
277   $form->get_pricegroup(\%myconfig, { all => 1 });
278
279   $form->{ALL_SALESMEN}   = $form->{ALL_EMPLOYEES};
280   $form->{taxincluded}    = ($form->{taxincluded}) ? "checked" : "";
281   $form->{is_admin}       = $myconfig{role} eq 'admin';
282   $form->{is_customer}    = $form->{db}     eq 'customer';
283   $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} };
284   $form->{shipto_label}   = sub { my $s = shift(@_); join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' ' };
285   $form->{contacts_label} = sub { join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname} };
286   $form->{taxzone_id}     = 0                                                               if !$form->{id};
287   $form->{jsscript}       = 1;
288   $form->{fokus}          = "ct.greeting";
289   $form->{AJAX}           = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(shipto contact delivery) ) ];
290
291   unshift @{ $form->{SHIPTO} },   +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' };
292   unshift @{ $form->{CONTACTS} }, +{ cp_id     => '0', cp_name => $locale->text('New contact') };
293
294   $form->{title} = $form->{title_save}
295                 || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
296
297   CT->query_titles_and_greetings(\%myconfig, \%$form);
298   map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
299
300   $form->{NOTES} ||= [ ];
301
302   $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id});
303
304   CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} });
305
306   $form->header;
307   print $form->parse_html_template('ct/form_header');
308
309   $lxdebug->leave_sub();
310 }
311
312 sub form_footer {
313   $lxdebug->enter_sub();
314
315   $auth->assert('customer_vendor_edit');
316
317   print $form->parse_html_template('ct/form_footer', { is_orphaned => $form->{status} eq 'orphaned',
318                                                        is_customer => $form->{db}     eq 'customer' });
319   $lxdebug->leave_sub();
320 }
321
322 sub add_transaction {
323   $lxdebug->enter_sub();
324
325   $auth->assert('customer_vendor_edit & ' .
326                 '(general_ledger         | invoice_edit         | vendor_invoice_edit | ' .
327                 ' request_quotation_edit | sales_quotation_edit | sales_order_edit    | purchase_order_edit)');
328
329 #  # saving the history
330 #  if(!exists $form->{addition}) {
331 #       $form->{addition} = "ADD TRANSACTION";
332 #       $form->save_history($form->dbconnect(\%myconfig));
333 #  }
334 #  # /saving the history
335
336   $form->isblank("name", $locale->text("Name missing!"));
337   if ($form->{"db"} eq "customer") {
338     CT->save_customer(\%myconfig, \%$form);
339   } else {
340     CT->save_vendor(\%myconfig, \%$form);
341   }
342
343   $form->{callback} = $form->escape($form->{callback}, 1);
344   $name = $form->escape("$form->{name}", 1);
345
346   $form->{callback} =
347     "$form->{script}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
348   $form->redirect;
349
350   $lxdebug->leave_sub();
351 }
352
353 sub save_and_ap_transaction {
354   $lxdebug->enter_sub();
355
356   $auth->assert('customer_vendor_edit & general_ledger');
357
358   $form->{script} = "ap.pl";
359   # saving the history
360   if(!exists $form->{addition}) {
361     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
362         $form->{addition} = "SAVED";
363         $form->save_history($form->dbconnect(\%myconfig));
364   }
365   # /saving the history
366   &add_transaction;
367   $lxdebug->leave_sub();
368 }
369
370 sub save_and_ar_transaction {
371   $lxdebug->enter_sub();
372
373   $auth->assert('customer_vendor_edit & general_ledger');
374
375   $form->{script} = "ar.pl";
376   # saving the history
377   if(!exists $form->{addition}) {
378     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
379         $form->{addition} = "SAVED";
380         $form->save_history($form->dbconnect(\%myconfig));
381   }
382   # /saving the history
383   &add_transaction;
384   $lxdebug->leave_sub();
385 }
386
387 sub save_and_invoice {
388   $lxdebug->enter_sub();
389
390   if ($form->{db} eq 'customer') {
391     $auth->assert('customer_vendor_edit & invoice_edit');
392   } else {
393     $auth->assert('customer_vendor_edit & vendor_invoice_edit');
394   }
395
396   $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
397   $form->{type} = "invoice";
398   # saving the history
399   if(!exists $form->{addition}) {
400     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
401         $form->{addition} = "SAVED";
402         $form->save_history($form->dbconnect(\%myconfig));
403   }
404   # /saving the history
405   &add_transaction;
406   $lxdebug->leave_sub();
407 }
408
409 sub save_and_rfq {
410   $lxdebug->enter_sub();
411
412   $auth->assert('customer_vendor_edit & request_quotation_edit');
413
414   $form->{script} = "oe.pl";
415   $form->{type}   = "request_quotation";
416   # saving the history
417   if(!exists $form->{addition}) {
418     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
419         $form->{addition} = "SAVED";
420         $form->save_history($form->dbconnect(\%myconfig));
421   }
422   # /saving the history
423   &add_transaction;
424   $lxdebug->leave_sub();
425 }
426
427 sub save_and_quotation {
428   $lxdebug->enter_sub();
429
430   $auth->assert('customer_vendor_edit & sales_quotation_edit');
431
432   $form->{script} = "oe.pl";
433   $form->{type}   = "sales_quotation";
434   # saving the history
435   if(!exists $form->{addition}) {
436     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
437         $form->{addition} = "SAVED";
438         $form->save_history($form->dbconnect(\%myconfig));
439   }
440   # /saving the history
441   &add_transaction;
442   $lxdebug->leave_sub();
443 }
444
445 sub save_and_order {
446   $lxdebug->enter_sub();
447
448   if ($form->{db} eq 'customer') {
449     $auth->assert('customer_vendor_edit & sales_order_edit');
450   } else {
451     $auth->assert('customer_vendor_edit & purchase_order_edit');
452   }
453
454   $form->{script} = "oe.pl";
455   $form->{type}   =
456     ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
457   # saving the history
458   if(!exists $form->{addition}) {
459     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
460         $form->{addition} = "SAVED";
461         $form->save_history($form->dbconnect(\%myconfig));
462   }
463   # /saving the history
464   &add_transaction;
465   $lxdebug->leave_sub();
466 }
467
468 sub save_and_close {
469   $lxdebug->enter_sub();
470
471   $auth->assert('customer_vendor_edit');
472
473   $msg = ucfirst $form->{db};
474   $imsg .= " saved!";
475
476   $form->isblank("name", $locale->text("Name missing!"));
477   if ($form->{"db"} eq "customer") {
478     $rc = CT->save_customer(\%myconfig, \%$form);
479   } else {
480     $rc = CT->save_vendor(\%myconfig, \%$form);
481   }
482   if ($rc == 3) {
483     $form->error($locale->text('customernumber not unique!'));
484   }
485   # saving the history
486   if(!exists $form->{addition}) {
487     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
488     $form->{addition} = "SAVED";
489         $form->save_history($form->dbconnect(\%myconfig));
490   }
491   # /saving the history
492   $form->redirect($locale->text($msg));
493
494   $lxdebug->leave_sub();
495 }
496
497 sub save {
498   $lxdebug->enter_sub();
499
500   $auth->assert('customer_vendor_edit');
501
502   $msg = ucfirst $form->{db};
503   $imsg .= " saved!";
504
505   $form->isblank("name", $locale->text("Name missing!"));
506
507   my $res;
508   if ($form->{"db"} eq "customer") {
509     $res = CT->save_customer(\%myconfig, \%$form);
510   } else {
511     $res = CT->save_vendor(\%myconfig, \%$form);
512   }
513
514   if (3 == $res) {
515     if ($form->{"db"} eq "customer") {
516       $form->error($locale->text('This customer number is already in use.'));
517     } else {
518       $form->error($locale->text('This vendor number is already in use.'));
519     }
520   }
521   # saving the history
522   if(!exists $form->{addition}) {
523     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
524         $form->{addition} = "SAVED";
525         $form->save_history($form->dbconnect(\%myconfig));
526   }
527   # /saving the history
528   &edit;
529   exit;
530   $lxdebug->leave_sub();
531 }
532
533 sub delete {
534   $lxdebug->enter_sub();
535
536   $auth->assert('customer_vendor_edit');
537
538   CT->delete(\%myconfig, \%$form);
539
540   $msg = ucfirst $form->{db};
541   $msg .= " deleted!";
542   # saving the history
543   if(!exists $form->{addition}) {
544     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
545         $form->{addition} = "DELETED";
546         $form->save_history($form->dbconnect(\%myconfig));
547   }
548   # /saving the history
549   $form->redirect($locale->text($msg));
550
551   $msg = "Cannot delete $form->{db}";
552   $form->error($locale->text($msg));
553
554   $lxdebug->leave_sub();
555 }
556
557 sub display {
558   $lxdebug->enter_sub();
559
560   $auth->assert('customer_vendor_edit');
561
562   &form_header();
563   &form_footer();
564
565   $lxdebug->leave_sub();
566 }
567
568 sub update {
569   $lxdebug->enter_sub();
570
571   $auth->assert('customer_vendor_edit');
572
573   &display();
574   $lxdebug->leave_sub();
575 }
576
577 sub get_contact {
578   $lxdebug->enter_sub();
579
580   $auth->assert('customer_vendor_edit');
581
582   CT->get_contact(\%myconfig, \%$form);
583   print $form->ajax_response_header(), join '__pjx__', map $form->{"cp_$_"},
584     qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used);
585   $lxdebug->leave_sub();
586
587 }
588
589 sub get_shipto {
590   $lxdebug->enter_sub();
591
592   $auth->assert('customer_vendor_edit');
593
594   CT->get_shipto(\%myconfig, \%$form);
595   print $form->ajax_response_header(),  join '__pjx__', map $form->{"shipto$_"},
596     qw(name department_1 department_2 street zipcode city country contact phone fax email used);
597   $lxdebug->leave_sub();
598
599 }
600
601 sub get_delivery {
602   $lxdebug->enter_sub();
603
604   $auth->assert('customer_vendor_edit');
605
606   CT->get_delivery(\%myconfig, \%$form );
607
608   print $form->ajax_response_header(), $form->parse_html_template('ct/get_delivery');
609
610   $lxdebug->leave_sub();
611 }
612
613 sub delete_shipto {
614   $main::lxdebug->enter_sub();
615
616   $auth->assert('customer_vendor_edit');
617
618   CT->get_shipto(\%myconfig, \%$form);
619
620   unless ($form->{shiptoused}) {
621     CT->delete_shipto($form->{shipto_id});
622     @$form{ grep /^shipto/, keys %$form } = undef;
623   }
624
625   edit();
626
627   $main::lxdebug->leave_sub();
628 }
629
630 sub delete_contact {
631   $main::lxdebug->enter_sub();
632
633   $auth->assert('customer_vendor_edit');
634
635   CT->get_contact(\%myconfig, \%$form);
636
637   unless ($form->{cp_used}) {
638     CT->delete_shipto($form->{cp_id});
639     @$form{ grep /^cp_/, keys %$form } = undef;
640   }
641
642   edit();
643
644   $main::lxdebug->leave_sub();
645 }
646
647 sub continue { call_sub($form->{nextsub}); }