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