Ansprechperson und Lieferadresse nach Speichern von Kunden wiederöffnen
[kivitendo-erp.git] / SL / Controller / CustomerVendor.pm
1 package SL::Controller::CustomerVendor;
2
3 use strict;
4 use parent qw(SL::Controller::Base);
5
6 use SL::JSON;
7 use SL::DBUtils;
8 use SL::Helper::Flash;
9
10 use SL::DB::Customer;
11 use SL::DB::Vendor;
12 use SL::DB::Business;
13 use SL::DB::Employee;
14 use SL::DB::Language;
15 use SL::DB::TaxZone;
16 use SL::DB::Note;
17 use SL::DB::PaymentTerm;
18 use SL::DB::Pricegroup;
19 use SL::DB::Contact;
20 use SL::DB::FollowUp;
21 use SL::DB::History;
22 use SL::DB::Currency;
23
24 # safety
25 __PACKAGE__->run_before(
26   sub {
27     $::auth->assert('customer_vendor_edit');
28   }
29 );
30
31 __PACKAGE__->run_before(
32   '_instantiate_args',
33   only => [
34     'save',
35     'save_and_ap_transaction',
36     'save_and_ar_transaction',
37     'save_and_close',
38     'save_and_invoice',
39     'save_and_order',
40     'save_and_quotation',
41     'save_and_rfq',
42     'delete',
43     'delete_contact',
44     'delete_shipto',
45   ]
46 );
47
48 __PACKAGE__->run_before(
49   '_load_customer_vendor',
50   only => [
51     'edit',
52     'update',
53     'ajaj_get_shipto',
54     'ajaj_get_contact',
55   ]
56 );
57 __PACKAGE__->run_before(
58   '_create_customer_vendor',
59   only => [
60     'add',
61   ]
62 );
63
64 sub action_add {
65   my ($self) = @_;
66
67   $self->_pre_render();
68   $self->render(
69     'customer_vendor/form',
70     title => ($self->is_vendor() ? $::locale->text('Add Vendor') : $::locale->text('Add Customer')),
71     %{$self->{template_args}}
72   );
73 }
74
75 sub action_edit {
76   my ($self) = @_;
77
78   $self->_pre_render();
79   $self->render(
80     'customer_vendor/form',
81     title => ($self->is_vendor() ? $::locale->text('Edit Vendor') : $::locale->text('Edit Customer')),
82     %{$self->{template_args}}
83   );
84 }
85
86 sub _save {
87   my ($self) = @_;
88
89   my $db = $self->{cv}->db;
90
91   $db->do_transaction(sub {
92     my $cvs_by_nr;
93     if ( $self->is_vendor() ) {
94       if ( $self->{cv}->vendornumber ) {
95         $cvs_by_nr = SL::DB::Manager::Vendor->get_all(query => [vendornumber => $self->{cv}->vendornumber]);
96       }
97     } else {
98       if ( $self->{cv}->customernumber ) {
99         $cvs_by_nr = SL::DB::Manager::Customer->get_all(query => [customernumber => $self->{cv}->customernumber]);
100       }
101     }
102
103     foreach my $entry (@{$cvs_by_nr}) {
104       if( $entry->id != $self->{cv}->id ) {
105         my $msg =
106           $self->is_vendor() ? $::locale->text('This vendor number is already in use.') : $::locale->text('This customer number is already in use.');
107
108         $::form->error($msg);
109       }
110     }
111
112     $self->{cv}->save(cascade => 1);
113
114     $self->{contact}->cp_cv_id($self->{cv}->id);
115     if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) {
116       $self->{contact}->save();
117     }
118
119     if( $self->{note}->subject ne '' && $self->{note}->body ne '' ) {
120       $self->{note}->trans_id($self->{cv}->id);
121       $self->{note}->save();
122       $self->{note_followup}->save();
123
124       $self->{note} = SL::DB::Note->new();
125       $self->{note_followup} = SL::DB::FollowUp->new();
126     }
127
128     $self->{shipto}->trans_id($self->{cv}->id);
129     if( $self->{shipto}->shiptoname ne '' ) {
130       $self->{shipto}->save();
131     }
132
133     my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
134     SL::DB::History->new(
135       trans_id => $self->{cv}->id,
136       snumbers => $snumbers,
137       employee_id => SL::DB::Manager::Employee->current->id,
138       addition => 'SAVED',
139     )->save();
140   }) || die($db->error);
141
142 }
143
144 sub action_save {
145   my ($self) = @_;
146
147   $self->_save();
148
149   my @redirect_params = (
150     action => 'edit',
151     id     => $self->{cv}->id,
152     db     => ($self->is_vendor() ? 'vendor' : 'customer'),
153   );
154
155   if ( $self->{contact}->cp_id ) {
156     push(@redirect_params, contact_id => $self->{contact}->cp_id);
157   }
158
159   if ( $self->{shipto}->shipto_id ) {
160     push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
161   }
162
163   $self->redirect_to(@redirect_params);
164 }
165
166 sub action_save_and_close {
167   my ($self) = @_;
168
169   $self->_save();
170
171   my $msg = $self->is_vendor() ? $::locale->text('Vendor saved') : $::locale->text('Customer saved');
172   $::form->redirect($msg);
173 }
174
175 sub _transaction {
176   my ($self, $script) = @_;
177
178   $::auth->assert('general_ledger         | invoice_edit         | vendor_invoice_edit | ' .
179                  ' request_quotation_edit | sales_quotation_edit | sales_order_edit    | purchase_order_edit');
180
181   $self->_save();
182
183   my $callback = $::form->escape($::form->{callback}, 1);
184   my $name = $::form->escape($self->{cv}->name, 1);
185   my $db = $self->is_vendor() ? 'vendor' : 'customer';
186
187   my $url = $self->url_for(
188     controller => $script,
189     action     => 'add',
190     vc         => $db,
191     $db .'_id' => $self->{cv}->id,
192     $db        => $name,
193     type       => $::form->{type},
194     callback   => $callback,
195   );
196
197   print $::form->redirect_header($url);
198 }
199
200 sub action_save_and_ar_transaction {
201   my ($self) = @_;
202
203   $main::auth->assert('general_ledger');
204
205   $self->_transaction('ar.pl');
206 }
207
208 sub action_save_and_ap_transaction {
209   my ($self) = @_;
210
211   $main::auth->assert('general_ledger');
212
213   $self->_transaction('ap.pl');
214 }
215
216 sub action_save_and_invoice {
217   my ($self) = @_;
218
219   if ( $self->is_vendor() ) {
220     $::auth->assert('vendor_invoice_edit');
221   } else {
222     $::auth->assert('invoice_edit');
223   }
224
225   $::form->{type} = 'invoice';
226   $self->_transaction($self->is_vendor() ? 'ir.pl' : 'is.pl');
227 }
228
229 sub action_save_and_order {
230   my ($self) = @_;
231
232   if ( $self->is_vendor() ) {
233     $::auth->assert('purchase_order_edit');
234   } else {
235     $::auth->assert('sales_order_edit');
236   }
237
238   $::form->{type} = $self->is_vendor() ? 'purchase_order' : 'sales_order';
239   $self->_transaction('oe.pl');
240 }
241
242 sub action_save_and_rfq {
243   my ($self) = @_;
244
245   $::auth->assert('request_quotation_edit');
246
247   $::form->{type} = 'request_quotation';
248   $self->_transaction('oe.pl');
249 }
250
251 sub action_save_and_quotation {
252   my ($self) = @_;
253
254   $::auth->assert('sales_quotation_edit');
255
256   $::form->{type} = 'sales_quotation';
257   $self->_transaction('oe.pl');
258 }
259
260 sub action_delete {
261   my ($self) = @_;
262
263   my $db = $self->{cv}->db;
264
265   if( !$self->is_orphaned() ) {
266     $self->action_edit();
267   } else {
268
269     $db->do_transaction(sub {
270       $self->{cv}->delete(cascade => 1);
271
272       my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
273       SL::DB::History->new(
274         trans_id => $self->{cv}->id,
275         snumbers => $snumbers,
276         employee_id => SL::DB::Manager::Employee->current->id,
277         addition => 'DELETED',
278       )->save();
279     }) || die($db->error);
280
281     my $msg = $self->is_vendor() ? $::locale->text('Vendor deleted!') : $::locale->text('Customer deleted!');
282     $::form->redirect($msg);
283   }
284
285 }
286
287
288 sub action_delete_contact {
289   my ($self) = @_;
290
291   my $db = $self->{contact}->db;
292
293   if ( !$self->{contact}->cp_id ) {
294     SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete'));
295   } else {
296
297     $db->do_transaction(sub {
298       if ( $self->{contact}->used ) {
299         $self->{contact}->detach();
300         $self->{contact}->save();
301         SL::Helper::Flash::flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
302       } else {
303         $self->{contact}->delete(cascade => 1);
304         SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.'));
305       }
306     }) || die($db->error);
307
308     $self->{contact} = SL::DB::Contact->new();
309   }
310
311   $self->action_edit();
312 }
313
314 sub action_delete_shipto {
315   my ($self) = @_;
316
317   my $db = $self->{shipto}->db;
318
319   if ( !$self->{shipto}->shipto_id ) {
320     SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete'));
321   } else {
322
323     $db->do_transaction(sub {
324       if ( $self->{shipto}->used ) {
325         $self->{shipto}->detach();
326         $self->{shipto}->save(cascade => 1);
327         SL::Helper::Flash::flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
328       } else {
329         $self->{shipto}->delete(cascade => 1);
330         SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.'));
331       }
332     }) || die($db->error);
333
334     $self->{shipto} = SL::DB::Shipto->new();
335   }
336
337   $self->action_edit();
338 }
339
340
341 sub action_search {
342   my ($self) = @_;
343
344   my $url = 'ct.pl?action=search&db='. ($self->is_vendor() ? 'vendor' : 'customer');
345
346   if ( $::form->{callback} ) {
347     $url .= '&callback='. $::from->escape($::form->{callback});
348   }
349
350   print $::form->redirect_header($url);
351 }
352
353
354 sub action_search_contact {
355   my ($self) = @_;
356
357   my $url = 'ct.pl?action=search_contact&db=customer';
358
359   if ( $::form->{callback} ) {
360     $url .= '&callback='. $::from->escape($::form->{callback});
361   }
362
363   print $::form->redirect_header($url);
364 }
365
366
367 sub action_get_delivery {
368   my ($self) = @_;
369
370   my $dbh = $::form->get_standard_dbh();
371
372   my ($arap, $db, $qty_sign);
373   if ( $self->is_vendor() ) {
374     $arap = 'ap';
375     $db = 'vendor';
376     $qty_sign = ' * -1 AS qty';
377   } else {
378     $arap = 'ar';
379     $db = 'customer';
380     $qty_sign = '';
381   }
382
383   my $where = ' WHERE 1=1 ';
384   my @values;
385
386   if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
387     $where .= "AND ${arap}.shipto_id = ?";
388     push(@values, $::form->{shipto_id});
389   }
390
391   if ( $::form->{delivery_from} ) {
392     $where .= "AND ${arap}.transdate >= ?";
393     push(@values, conv_date($::form->{delivery_from}));
394   }
395
396   if ( $::form->{delivery_to} ) {
397     $where .= "AND ${arap}.transdate <= ?";
398     push(@values, conv_date($::form->{delivery_to}));
399   }
400
401   my $query =
402     "SELECT
403        s.shiptoname,
404        i.qty ${qty_sign},
405        ${arap}.id,
406        ${arap}.transdate,
407        ${arap}.invnumber,
408        ${arap}.ordnumber,
409        i.description,
410        i.unit,
411        i.sellprice,
412        oe.id AS oe_id,
413        invoice
414      FROM ${arap}
415
416      LEFT JOIN shipto s
417       ON ". ($arap eq 'ar' ? '(ar.shipto_id = s.shipto_id) ' : '(ap.id = s.trans_id) ') ."
418
419      LEFT JOIN invoice i
420        ON ${arap}.id = i.trans_id
421
422      LEFT JOIN parts p
423        ON p.id = i.parts_id
424
425      LEFT JOIN oe
426        ON (oe.ordnumber = ${arap}.ordnumber AND NOT ${arap}.ordnumber = '')
427
428      ${where}
429      ORDER BY ${arap}.transdate DESC LIMIT 15";
430
431   $self->{delivery} = selectall_hashref_query($::form, $dbh, $query, @values);
432
433   $self->render('customer_vendor/get_delivery', { layout => 0 });
434 }
435
436 sub action_ajaj_get_shipto {
437   my ($self) = @_;
438
439   my $data = {
440     map(
441       {
442         my $name = 'shipto'. $_;
443         $name => $self->{shipto}->$name;
444       }
445       qw(_id name department_1 department_2 street zipcode city country contact phone fax email)
446     )
447   };
448
449   $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
450 }
451
452 sub action_ajaj_get_contact {
453   my ($self) = @_;
454
455   my $data;
456
457   $data->{contact} = {
458     map(
459       {
460         my $name = 'cp_'. $_;
461
462         if ( $_ eq 'birthday' && $self->{contact}->$name ) {
463           $name => $self->{contact}->$name->to_lxoffice;
464         } else {
465           $name => $self->{contact}->$name;
466         }
467       }
468       qw(
469         id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2
470         satphone satfax project street zipcode city privatphone privatemail birthday
471       )
472     )
473   };
474
475   $data->{contact_cvars} = {
476     map(
477       {
478         if ( $_->config->type eq 'number' ) {
479           $_->config->name => $::form->format_amount(\%::myconfig, $_->value, -2);
480         } else {
481           $_->config->name => $_->value;
482         }
483       }
484       grep(
485         { $_->is_valid; }
486         @{$self->{contact}->cvars_by_config}
487       )
488     )
489   };
490
491   $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
492 }
493
494 sub action_ajaj_customer_autocomplete {
495   my ($self, %params) = @_;
496
497   my $limit = $::form->{limit} || 20;
498   my $type  = $::form->{type}  || {};
499   my $query = { ilike => '%'. $::form->{term} .'%' };
500
501   my @filter;
502   push(
503     @filter,
504     $::form->{column} ? ($::form->{column} => $query) : (or => [ customernumber => $query, name => $query ])
505   );
506
507   my $customers = SL::DB::Manager::Customer->get_all(query => [ @filter ], limit => $limit);
508   my $value_col = $::form->{column} || 'name';
509
510   my $data = [
511     map(
512       {
513         {
514           value => $_->can($value_col)->($_),
515           label => $_->displayable_name,
516           id    => $_->id,
517           customernumber => $_->customernumber,
518           name  => $_->name,
519         }
520       }
521       @{$customers}
522     )
523   ];
524
525   $self->render(\SL::JSON::to_json($data), { layout => 0, type => 'json' });
526 }
527
528 sub is_vendor {
529   return $::form->{db} eq 'vendor';
530 }
531
532 sub is_customer {
533   return $::form->{db} eq 'customer';
534 }
535
536 sub is_orphaned {
537   my ($self) = @_;
538
539   if ( defined($self->{_is_orphaned}) ) {
540     return $self->{_is_orphaned};
541   }
542
543   my $arap      = $self->is_vendor ? 'ap' : 'ar';
544   my $num_args  = 2;
545
546   my $cv = $self->is_vendor ? 'vendor' : 'customer';
547
548   my $query =
549    'SELECT a.id
550     FROM '. $arap .' AS a
551     JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
552     WHERE ct.id = ?
553
554     UNION
555
556     SELECT a.id
557     FROM oe a
558     JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
559     WHERE ct.id = ?';
560
561
562   if ( $self->is_vendor ) {
563     $query .=
564      ' UNION
565       SELECT 1 FROM makemodel mm WHERE mm.make = ?';
566     $num_args++;
567   }
568
569   my ($dummy) = selectrow_query($::form, $::form->get_standard_dbh(), $query, (conv_i($self->{cv}->id)) x $num_args);
570
571   return $self->{_is_orphaned} = !$dummy;
572 }
573
574 sub _instantiate_args {
575   my ($self) = @_;
576
577   my $curr_employee = SL::DB::Manager::Employee->current;
578
579   if ( $::form->{cv}->{id} ) {
580     if ( $self->is_vendor() ) {
581       $self->{cv} = SL::DB::Vendor->new(id => $::form->{cv}->{id})->load();
582     } else {
583       $self->{cv} = SL::DB::Customer->new(id => $::form->{cv}->{id})->load();
584     }
585   } else {
586     if ( $self->is_vendor() ) {
587       $self->{cv} = SL::DB::Vendor->new();
588     } else {
589       $self->{cv} = SL::DB::Customer->new();
590     }
591   }
592   $self->{cv}->assign_attributes(%{$::form->{cv}});
593
594   if ( $self->is_customer() && $::form->{cv}->{taxincluded_checked} eq '' ) {
595     $self->{cv}->taxincluded_checked(undef);
596   }
597
598
599   foreach my $cvar (@{$self->{cv}->cvars_by_config()}) {
600     my $value = $::form->{cv_cvars}->{$cvar->config->name};
601
602     if ( $cvar->config->type eq 'number' ) {
603       $value = $::form->parse_amount(\%::myconfig, $value);
604     }
605
606     $cvar->value($value);
607   }
608
609   if ( $::form->{note}->{id} ) {
610     $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load();
611   } else {
612     $self->{note} = SL::DB::Note->new();
613   }
614   $self->{note}->assign_attributes(%{$::form->{note}});
615   $self->{note}->created_by($curr_employee->id);
616   $self->{note}->trans_module('ct');
617
618   $self->{note_followup} = SL::DB::FollowUp->new();
619   $self->{note_followup}->assign_attributes(%{$::form->{note_followup}});
620   $self->{note_followup}->note($self->{note});
621   $self->{note_followup}->created_by($curr_employee->id);
622
623   if ( $::form->{shipto}->{shipto_id} ) {
624     $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load();
625   } else {
626     $self->{shipto} = SL::DB::Shipto->new();
627   }
628   $self->{shipto}->assign_attributes(%{$::form->{shipto}});
629   $self->{shipto}->module('CT');
630
631   if ( $::form->{contact}->{cp_id} ) {
632     $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact}->{cp_id})->load();
633   } else {
634     $self->{contact} = SL::DB::Contact->new();
635   }
636   $self->{contact}->assign_attributes(%{$::form->{contact}});
637
638   foreach my $cvar (@{$self->{contact}->cvars_by_config()}) {
639     my $value = $::form->{contact_cvars}->{$cvar->config->name};
640
641     if ( $cvar->config->type eq 'number' ) {
642       $value = $::form->parse_amount(\%::myconfig, $value);
643     }
644
645     $cvar->value($value);
646   }
647 }
648
649 sub _load_customer_vendor {
650   my ($self) = @_;
651
652   if ( $self->is_vendor() ) {
653     $self->{cv} = SL::DB::Vendor->new(id => $::form->{id})->load();
654   } else {
655     $self->{cv} = SL::DB::Customer->new(id => $::form->{id})->load();
656   }
657
658   $self->{note} = SL::DB::Note->new();
659   $self->{note_followup} = SL::DB::FollowUp->new();
660
661   if ( $::form->{shipto_id} ) {
662     $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();
663
664     if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
665       die($::locale->text('Error'));
666     }
667   } else {
668     $self->{shipto} = SL::DB::Shipto->new();
669   }
670
671   if ( $::form->{contact_id} ) {
672     $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact_id})->load();
673
674     if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
675       die($::locale->text('Error'));
676     }
677   } else {
678     $self->{contact} = SL::DB::Contact->new();
679   }
680 }
681
682 sub _create_customer_vendor {
683   my ($self) = @_;
684
685   if ( $self->is_vendor() ) {
686     $self->{cv} = SL::DB::Vendor->new();
687   } else {
688     $self->{cv} = SL::DB::Customer->new();
689   }
690   $self->{cv}->currency_id($::instance_conf->get_currency_id());
691
692   $self->{note} = SL::DB::Note->new();
693
694   $self->{note_followup} = SL::DB::FollowUp->new();
695
696   $self->{shipto} = SL::DB::Shipto->new();
697
698   $self->{contact} = SL::DB::Contact->new();
699 }
700
701 sub _pre_render {
702   my ($self) = @_;
703
704   my $dbh = $::form->get_standard_dbh();
705
706   my $query;
707
708   $self->{all_business} = SL::DB::Manager::Business->get_all();
709
710   $self->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
711
712   $query =
713     'SELECT DISTINCT(greeting)
714      FROM customer
715      WHERE greeting IS NOT NULL AND greeting != \'\'
716      UNION
717        SELECT DISTINCT(greeting)
718        FROM vendor
719        WHERE greeting IS NOT NULL AND greeting != \'\'
720      ORDER BY greeting';
721   $self->{all_greetings} = [
722     map(
723       { $_->{greeting}; }
724       selectall_hashref_query($::form, $dbh, $query)
725     )
726   ];
727
728   $query =
729     'SELECT DISTINCT(cp_title) AS title
730      FROM contacts
731      WHERE cp_title IS NOT NULL AND cp_title != \'\'
732      ORDER BY cp_title';
733   $self->{all_titles} = [
734     map(
735       { $_->{title}; }
736       selectall_hashref_query($::form, $dbh, $query)
737     )
738   ];
739
740   $self->{all_currencies} = SL::DB::Manager::Currency->get_all();
741
742   $self->{all_languages} = SL::DB::Manager::Language->get_all();
743
744   $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all();
745
746   if ( $::instance_conf->get_vertreter() ) {
747     $query =
748       'SELECT id
749        FROM business
750        WHERE salesman';
751     my $business_ids = [
752       map(
753         { $_->{id}; }
754         selectall_hashref_query($::form, $dbh, $query)
755       )
756     ];
757
758     if ( $business_ids->[0] ) {
759       $self->{all_salesman_customers} = SL::DB::Manager::Customer->get_all(query => [business_id => $business_ids]);
760     } else {
761       $self->{all_salesman_customers} = [];
762     }
763   } else {
764     $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id,  deleted => 0 ] ]);
765   }
766
767   $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
768
769   $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all();
770
771   $query =
772     'SELECT DISTINCT(cp_abteilung) AS department
773      FROM contacts
774      WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
775      ORDER BY cp_abteilung';
776   $self->{all_departments} = [
777     map(
778       { $_->{department}; }
779       selectall_hashref_query($::form, $dbh, $query)
780     )
781   ];
782
783   $self->{contacts} = $self->{cv}->contacts;
784   $self->{contacts} ||= [];
785
786   $self->{shiptos} = $self->{cv}->shipto;
787   $self->{shiptos} ||= [];
788
789   $self->{template_args} ||= {};
790
791   $::request->{layout}->add_javascripts('autocomplete_customer.js');
792   $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
793 }
794
795 1;