1 package SL::Controller::CustomerVendor;
4 use parent qw(SL::Controller::Base);
6 use List::MoreUtils qw(any);
10 use SL::Helper::Flash;
11 use SL::Locale::String;
12 use SL::Controller::Helper::GetModels;
21 use SL::DB::PaymentTerm;
22 use SL::DB::Pricegroup;
25 use SL::DB::FollowUpLink;
29 use Rose::Object::MakeMethods::Generic (
30 'scalar --get_set_init' => [ qw(customer_models vendor_models) ],
34 __PACKAGE__->run_before(
36 $::auth->assert('customer_vendor_edit');
39 __PACKAGE__->run_before(
43 'save_and_ap_transaction',
44 'save_and_ar_transaction',
56 __PACKAGE__->run_before(
57 '_load_customer_vendor',
67 # make sure this comes after _load_customer_vendor
68 __PACKAGE__->run_before(
69 '_check_customer_vendor_all_edit',
76 'save_and_ap_transaction',
77 'save_and_ar_transaction',
89 __PACKAGE__->run_before(
90 '_create_customer_vendor',
96 __PACKAGE__->run_before('normalize_name');
102 $self->_pre_render();
103 $self->{cv}->assign_attributes(hourly_rate => $::instance_conf->get_customer_hourly_rate) if $self->{cv}->is_customer;
105 'customer_vendor/form',
106 title => ($self->is_vendor() ? $::locale->text('Add Vendor') : $::locale->text('Add Customer')),
107 %{$self->{template_args}}
114 $self->_pre_render();
116 'customer_vendor/form',
117 title => ($self->is_vendor() ? $::locale->text('Edit Vendor') : $::locale->text('Edit Customer')),
118 %{$self->{template_args}}
125 if ($::request->type eq 'json') {
130 $cv_hash = $self->{cv}->as_tree;
131 $cv_hash->{cvars} = $self->{cv}->cvar_as_hashref;
134 $self->render(\ SL::JSON::to_json($cv_hash), { layout => 0, type => 'json', process => 0 });
141 my @errors = $self->{cv}->validate;
143 flash('error', @errors);
144 $self->_pre_render();
146 'customer_vendor/form',
147 title => ($self->is_vendor() ? t8('Edit Vendor') : t8('Edit Customer')),
148 %{$self->{template_args}}
150 $::dispatcher->end_request;
153 my $db = $self->{cv}->db;
155 $db->do_transaction(sub {
157 if ( $self->is_vendor() ) {
158 if ( $self->{cv}->vendornumber ) {
159 $cvs_by_nr = SL::DB::Manager::Vendor->get_all(query => [vendornumber => $self->{cv}->vendornumber]);
162 if ( $self->{cv}->customernumber ) {
163 $cvs_by_nr = SL::DB::Manager::Customer->get_all(query => [customernumber => $self->{cv}->customernumber]);
167 foreach my $entry (@{$cvs_by_nr}) {
168 if( $entry->id != $self->{cv}->id ) {
170 $self->is_vendor() ? $::locale->text('This vendor number is already in use.') : $::locale->text('This customer number is already in use.');
172 $::form->error($msg);
176 $self->{cv}->save(cascade => 1);
178 $self->{contact}->cp_cv_id($self->{cv}->id);
179 if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) {
180 $self->{contact}->save(cascade => 1);
183 if( $self->{note}->subject ne '' && $self->{note}->body ne '' ) {
185 if ( !$self->{note_followup}->follow_up_date ) {
186 $::form->error($::locale->text('Date missing!'));
189 $self->{note}->trans_id($self->{cv}->id);
190 $self->{note}->save();
192 $self->{note_followup}->save();
194 $self->{note_followup_link}->follow_up_id($self->{note_followup}->id);
195 $self->{note_followup_link}->trans_id($self->{cv}->id);
196 $self->{note_followup_link}->save();
198 SL::Helper::Flash::flash_later('info', $::locale->text('Follow-Up saved.'));
201 $self->{shipto}->trans_id($self->{cv}->id);
202 if(any { $self->{shipto}->$_ ne '' } qw(shiptoname shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax shiptoemail)) {
203 $self->{shipto}->save(cascade => 1);
206 my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
207 SL::DB::History->new(
208 trans_id => $self->{cv}->id,
209 snumbers => $snumbers,
210 employee_id => SL::DB::Manager::Employee->current->id,
214 if ( $::form->{delete_notes} ) {
215 foreach my $note_id (@{ $::form->{delete_notes} }) {
216 my $note = SL::DB::Note->new(id => $note_id)->load();
217 if ( $note->follow_up ) {
218 if ( $note->follow_up->follow_up_link ) {
219 $note->follow_up->follow_up_link->delete(cascade => 'delete');
221 $note->follow_up->delete(cascade => 'delete');
223 $note->delete(cascade => 'delete');
226 }) || die($db->error);
235 my @redirect_params = (
237 id => $self->{cv}->id,
238 db => ($self->is_vendor() ? 'vendor' : 'customer'),
241 if ( $self->{contact}->cp_id ) {
242 push(@redirect_params, contact_id => $self->{contact}->cp_id);
245 if ( $self->{shipto}->shipto_id ) {
246 push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
249 $self->redirect_to(@redirect_params);
252 sub action_save_and_close {
257 my $msg = $self->is_vendor() ? $::locale->text('Vendor saved') : $::locale->text('Customer saved');
258 $::form->redirect($msg);
262 my ($self, $script) = @_;
264 $::auth->assert('general_ledger | invoice_edit | vendor_invoice_edit | ' .
265 ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit');
269 my $name = $::form->escape($self->{cv}->name, 1);
270 my $db = $self->is_vendor() ? 'vendor' : 'customer';
272 my $url = $self->url_for(
273 controller => $script,
276 $db .'_id' => $self->{cv}->id,
278 type => $::form->{type},
279 callback => $::form->{callback},
282 print $::form->redirect_header($url);
285 sub action_save_and_ar_transaction {
288 $main::auth->assert('general_ledger');
290 $self->_transaction('ar.pl');
293 sub action_save_and_ap_transaction {
296 $main::auth->assert('general_ledger');
298 $self->_transaction('ap.pl');
301 sub action_save_and_invoice {
304 if ( $self->is_vendor() ) {
305 $::auth->assert('vendor_invoice_edit');
307 $::auth->assert('invoice_edit');
310 $::form->{type} = 'invoice';
311 $self->_transaction($self->is_vendor() ? 'ir.pl' : 'is.pl');
314 sub action_save_and_order {
317 if ( $self->is_vendor() ) {
318 $::auth->assert('purchase_order_edit');
320 $::auth->assert('sales_order_edit');
323 $::form->{type} = $self->is_vendor() ? 'purchase_order' : 'sales_order';
324 $self->_transaction('oe.pl');
327 sub action_save_and_rfq {
330 $::auth->assert('request_quotation_edit');
332 $::form->{type} = 'request_quotation';
333 $self->_transaction('oe.pl');
336 sub action_save_and_quotation {
339 $::auth->assert('sales_quotation_edit');
341 $::form->{type} = 'sales_quotation';
342 $self->_transaction('oe.pl');
348 my $db = $self->{cv}->db;
350 if( !$self->is_orphaned() ) {
351 $self->action_edit();
354 $db->do_transaction(sub {
355 $self->{cv}->delete(cascade => 1);
357 my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
358 SL::DB::History->new(
359 trans_id => $self->{cv}->id,
360 snumbers => $snumbers,
361 employee_id => SL::DB::Manager::Employee->current->id,
362 addition => 'DELETED',
364 }) || die($db->error);
366 my $msg = $self->is_vendor() ? $::locale->text('Vendor deleted!') : $::locale->text('Customer deleted!');
367 $::form->redirect($msg);
373 sub action_delete_contact {
376 my $db = $self->{contact}->db;
378 if ( !$self->{contact}->cp_id ) {
379 SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete'));
382 $db->do_transaction(sub {
383 if ( $self->{contact}->used ) {
384 $self->{contact}->detach();
385 $self->{contact}->save();
386 SL::Helper::Flash::flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
388 $self->{contact}->delete(cascade => 1);
389 SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.'));
391 }) || die($db->error);
393 $self->{contact} = $self->_new_contact_object;
396 $self->action_edit();
399 sub action_delete_shipto {
402 my $db = $self->{shipto}->db;
404 if ( !$self->{shipto}->shipto_id ) {
405 SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete'));
408 $db->do_transaction(sub {
409 if ( $self->{shipto}->used ) {
410 $self->{shipto}->detach();
411 $self->{shipto}->save(cascade => 1);
412 SL::Helper::Flash::flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
414 $self->{shipto}->delete(cascade => 1);
415 SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.'));
417 }) || die($db->error);
419 $self->{shipto} = SL::DB::Shipto->new();
422 $self->action_edit();
430 controller => 'ct.pl',
432 db => $self->is_vendor() ? 'vendor' : 'customer',
435 if ( $::form->{callback} ) {
436 push(@url_params, callback => $::form->{callback});
439 $self->redirect_to(@url_params);
443 sub action_search_contact {
446 my $url = 'ct.pl?action=search_contact&db=customer';
448 if ( $::form->{callback} ) {
449 $url .= '&callback='. $::form->escape($::form->{callback});
452 print $::form->redirect_header($url);
456 sub action_get_delivery {
459 $::auth->assert('sales_all_edit');
461 my $dbh = $::form->get_standard_dbh();
463 my ($arap, $db, $qty_sign);
464 if ( $self->is_vendor() ) {
467 $qty_sign = ' * -1 AS qty';
474 my $where = ' WHERE 1=1';
477 if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
478 $where .= " AND ${arap}.shipto_id = ?";
479 push(@values, $::form->{shipto_id});
481 $where .= " AND ${arap}.${db}_id = ?";
482 push(@values, $::form->{id});
485 if ( $::form->{delivery_from} ) {
486 $where .= " AND ${arap}.transdate >= ?";
487 push(@values, conv_date($::form->{delivery_from}));
490 if ( $::form->{delivery_to} ) {
491 $where .= " AND ${arap}.transdate <= ?";
492 push(@values, conv_date($::form->{delivery_to}));
511 ON ". ($arap eq 'ar' ? '(ar.shipto_id = s.shipto_id) ' : '(ap.id = s.trans_id) ') ."
514 ON ${arap}.id = i.trans_id
520 ON (oe.ordnumber = ${arap}.ordnumber AND NOT ${arap}.ordnumber = ''
521 AND ". ($arap eq 'ar' ? 'oe.customer_id IS NOT NULL' : 'oe.vendor_id IS NOT NULL') ." )
524 ORDER BY ${arap}.transdate DESC LIMIT 15";
526 $self->{delivery} = selectall_hashref_query($::form, $dbh, $query, @values);
528 $self->render('customer_vendor/get_delivery', { layout => 0 });
531 sub action_ajaj_get_shipto {
538 my $name = 'shipto'. $_;
539 $name => $self->{shipto}->$name;
541 qw(_id name department_1 department_2 street zipcode city gln country contact phone fax email)
545 $data->{shipto_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{shipto}->cvars_by_config);
547 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
550 sub action_ajaj_get_contact {
558 my $name = 'cp_'. $_;
560 if ( $_ eq 'birthday' && $self->{contact}->$name ) {
561 $name => $self->{contact}->$name->to_lxoffice;
563 $name => $self->{contact}->$name;
567 id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2
568 satphone satfax project street zipcode city privatphone privatemail birthday
573 $data->{contact_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{contact}->cvars_by_config);
575 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
578 sub action_ajaj_autocomplete {
579 my ($self, %params) = @_;
581 my ($model, $manager, $number, $matches);
583 # first see if this is customer or vendor picking
584 if ($::form->{type} eq 'customer') {
585 $model = $self->customer_models;
586 $manager = 'SL::DB::Manager::Customer';
587 $number = 'customernumber';
588 } elsif ($::form->{type} eq 'vendor') {
589 $model = $self->vendor_models;
590 $manager = 'SL::DB::Manager::Vendor';
591 $number = 'vendornumber';
593 die "unknown type $::form->{type}";
596 # if someone types something, and hits enter, assume he entered the full name.
597 # if something matches, treat that as sole match
598 # unfortunately get_models can't do more than one per package atm, so we d it
599 # the oldfashioned way.
600 if ($::form->{prefer_exact}) {
602 if (1 == scalar @{ $exact_matches = $manager->get_all(
605 (salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
607 name => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
608 $number => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
613 $matches = $exact_matches;
617 $matches //= $model->get;
621 value => $_->displayable_name,
622 label => $_->displayable_name,
624 $number => $_->$number,
626 type => $::form->{type},
627 cvars => { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $_->cvars_by_config } },
631 $self->render(\ SL::JSON::to_json(\@hashes), { layout => 0, type => 'json', process => 0 });
634 sub action_test_page {
635 $::request->{layout}->add_javascripts('autocomplete_customer.js');
636 $_[0]->render('customer_vendor/test_page');
640 return $::form->{db} eq 'vendor';
644 return $::form->{db} eq 'customer';
650 if ( defined($self->{_is_orphaned}) ) {
651 return $self->{_is_orphaned};
654 my $arap = $self->is_vendor ? 'ap' : 'ar';
657 my $cv = $self->is_vendor ? 'vendor' : 'customer';
661 FROM '. $arap .' AS a
662 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
669 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
675 FROM delivery_orders a
676 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
680 if ( $self->is_vendor ) {
683 SELECT 1 FROM makemodel mm WHERE mm.make = ?';
687 my ($dummy) = selectrow_query($::form, $::form->get_standard_dbh(), $query, (conv_i($self->{cv}->id)) x $num_args);
689 return $self->{_is_orphaned} = !$dummy;
692 sub _copy_form_to_cvars {
693 my ($self, %params) = @_;
695 foreach my $cvar (@{ $params{target}->cvars_by_config }) {
696 my $value = $params{source}->{$cvar->config->name};
697 $value = $::form->parse_amount(\%::myconfig, $value) if $cvar->config->type eq 'number';
699 $cvar->value($value);
703 sub _instantiate_args {
706 my $curr_employee = SL::DB::Manager::Employee->current;
708 if ( $::form->{cv}->{id} ) {
709 if ( $self->is_vendor() ) {
710 $self->{cv} = SL::DB::Vendor->new(id => $::form->{cv}->{id})->load();
712 $self->{cv} = SL::DB::Customer->new(id => $::form->{cv}->{id})->load();
715 $self->{cv} = $self->_new_customer_vendor_object;
717 $self->{cv}->assign_attributes(%{$::form->{cv}});
719 if ( $self->is_customer() && $::form->{cv}->{taxincluded_checked} eq '' ) {
720 $self->{cv}->taxincluded_checked(undef);
723 $self->{cv}->hourly_rate($::instance_conf->get_customer_hourly_rate) if $self->is_customer && !$self->{cv}->hourly_rate;
725 if ( $::form->{note}->{id} ) {
726 $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load();
727 $self->{note_followup} = $self->{note}->follow_up;
728 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
730 $self->{note} = SL::DB::Note->new();
731 $self->{note_followup} = SL::DB::FollowUp->new();
732 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
735 $self->{note}->assign_attributes(%{$::form->{note}});
736 $self->{note}->created_by($curr_employee->id);
737 $self->{note}->trans_module('ct');
739 $self->{note_followup}->assign_attributes(%{$::form->{note_followup}});
740 $self->{note_followup}->note($self->{note});
741 $self->{note_followup}->created_by($curr_employee->id);
743 $self->{note_followup_link}->trans_type($self->is_vendor() ? 'vendor' : 'customer');
744 $self->{note_followup_link}->trans_info($self->{cv}->name);
746 if ( $::form->{shipto}->{shipto_id} ) {
747 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load();
749 $self->{shipto} = SL::DB::Shipto->new();
751 $self->{shipto}->assign_attributes(%{$::form->{shipto}});
752 $self->{shipto}->module('CT');
754 if ( $::form->{contact}->{cp_id} ) {
755 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact}->{cp_id})->load();
757 $self->{contact} = $self->_new_contact_object;
759 $self->{contact}->assign_attributes(%{$::form->{contact}});
761 $self->_copy_form_to_cvars(target => $self->{cv}, source => $::form->{cv_cvars});
762 $self->_copy_form_to_cvars(target => $self->{contact}, source => $::form->{contact_cvars});
763 $self->_copy_form_to_cvars(target => $self->{shipto}, source => $::form->{shipto_cvars});
766 sub _load_customer_vendor {
769 if ( $self->is_vendor() ) {
770 $self->{cv} = SL::DB::Vendor->new(id => $::form->{id})->load();
772 $self->{cv} = SL::DB::Customer->new(id => $::form->{id})->load();
775 if ( $::form->{note_id} ) {
776 $self->{note} = SL::DB::Note->new(id => $::form->{note_id})->load();
777 $self->{note_followup} = $self->{note}->follow_up;
778 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
780 $self->{note} = SL::DB::Note->new();
781 $self->{note_followup} = SL::DB::FollowUp->new();
782 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
785 if ( $::form->{shipto_id} ) {
786 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();
788 if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
789 die($::locale->text('Error'));
792 $self->{shipto} = SL::DB::Shipto->new();
795 if ( $::form->{contact_id} ) {
796 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact_id})->load();
798 if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
799 die($::locale->text('Error'));
802 $self->{contact} = $self->_new_contact_object;
806 sub _check_customer_vendor_all_edit {
809 unless ($::auth->assert('customer_vendor_all_edit', 1)) {
810 die($::locale->text("You don't have the rights to edit this customer.") . "\n")
811 if $self->{cv}->is_customer and
812 SL::DB::Manager::Employee->current->id != $self->{cv}->salesman_id;
816 sub _create_customer_vendor {
819 $self->{cv} = $self->_new_customer_vendor_object;
820 $self->{cv}->currency_id($::instance_conf->get_currency_id());
822 $self->{note} = SL::DB::Note->new();
824 $self->{note_followup} = SL::DB::FollowUp->new();
826 $self->{shipto} = SL::DB::Shipto->new();
828 $self->{contact} = $self->_new_contact_object;
834 my $dbh = $::form->get_standard_dbh();
838 $self->{all_business} = SL::DB::Manager::Business->get_all();
840 $self->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
843 'SELECT DISTINCT(greeting)
845 WHERE greeting IS NOT NULL AND greeting != \'\'
847 SELECT DISTINCT(greeting)
849 WHERE greeting IS NOT NULL AND greeting != \'\'
851 $self->{all_greetings} = [
854 selectall_hashref_query($::form, $dbh, $query)
859 'SELECT DISTINCT(cp_title) AS title
861 WHERE cp_title IS NOT NULL AND cp_title != \'\'
863 $self->{all_titles} = [
866 selectall_hashref_query($::form, $dbh, $query)
870 $self->{all_currencies} = SL::DB::Manager::Currency->get_all();
872 $self->{all_languages} = SL::DB::Manager::Language->get_all();
874 $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all_sorted();
876 if ( $::instance_conf->get_vertreter() ) {
884 selectall_hashref_query($::form, $dbh, $query)
888 if ( $business_ids->[0] ) {
889 $self->{all_salesman_customers} = SL::DB::Manager::Customer->get_all(query => [business_id => $business_ids]);
891 $self->{all_salesman_customers} = [];
894 $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id, deleted => 0 ] ]);
897 $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
899 $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all();
901 $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all();
904 'SELECT DISTINCT(cp_abteilung) AS department
906 WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
907 ORDER BY cp_abteilung';
908 $self->{all_departments} = [
910 { $_->{department}; }
911 selectall_hashref_query($::form, $dbh, $query)
915 $self->{contacts} = $self->{cv}->contacts;
916 $self->{contacts} ||= [];
918 $self->{shiptos} = $self->{cv}->shipto;
919 $self->{shiptos} ||= [];
921 $self->{notes} = SL::DB::Manager::Note->get_all(
923 trans_id => $self->{cv}->id,
924 trans_module => 'ct',
926 with_objects => ['follow_up'],
929 $self->{template_args} ||= {};
931 $::request->{layout}->add_javascripts('autocomplete_customer.js');
932 $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
935 sub _prepare_cvar_configs_for_ajaj {
936 my ($self, $cvars) = @_;
941 my $result = { type => $cvar->config->type };
943 if ($cvar->config->type eq 'number') {
944 $result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2);
946 } elsif ($result->{type} eq 'date') {
947 $result->{value} = $cvar->value ? $cvar->value->to_kivitendo : undef;
949 } elsif ($result->{type} =~ m{customer|vendor|part}) {
950 my $object = $cvar->value;
951 my $method = $result->{type} eq 'part' ? 'description' : 'name';
953 $result->{id} = int($cvar->number_value) || undef;
954 $result->{value} = $object ? $object->$method // '' : '';
957 $result->{value} = $cvar->value;
960 ( $cvar->config->name => $result )
962 } grep { $_->is_valid } @{ $cvars }
969 # check if feature is enabled (select normalize_vc_names from defaults)
970 return unless ($::instance_conf->get_normalize_vc_names);
972 return unless $self->{cv};
973 my $name = $self->{cv}->name;
977 $self->{cv}->name($name);
980 sub home_address_for_google_maps {
983 my $address = $::instance_conf->get_address // '';
984 $address =~ s{^\s+|\s+$|\r+}{}g;
985 $address =~ s{\n+}{,}g;
986 $address =~ s{\s+}{ }g;
991 sub init_customer_models {
994 SL::Controller::Helper::GetModels->new(
999 by => 'customernumber',
1002 customernumber => t8('Customer Number'),
1005 ( salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
1010 sub init_vendor_models {
1013 SL::Controller::Helper::GetModels->new(
1014 controller => $self,
1018 by => 'vendornumber',
1021 vendornumber => t8('Vendor Number'),
1026 sub _new_customer_vendor_object {
1029 my $class = 'SL::DB::' . ($self->is_vendor ? 'Vendor' : 'Customer');
1033 custom_variables => [],
1037 sub _new_contact_object {
1040 return SL::DB::Contact->new(custom_variables => []);