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->with_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');
228 }) || die($db->error);
237 my @redirect_params = (
239 id => $self->{cv}->id,
240 db => ($self->is_vendor() ? 'vendor' : 'customer'),
243 if ( $self->{contact}->cp_id ) {
244 push(@redirect_params, contact_id => $self->{contact}->cp_id);
247 if ( $self->{shipto}->shipto_id ) {
248 push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
251 $self->redirect_to(@redirect_params);
254 sub action_save_and_close {
259 my $msg = $self->is_vendor() ? $::locale->text('Vendor saved') : $::locale->text('Customer saved');
260 $::form->redirect($msg);
264 my ($self, $script) = @_;
266 $::auth->assert('gl_transactions | ap_transactions | ar_transactions'.
267 '| invoice_edit | vendor_invoice_edit | ' .
268 ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit');
272 my $name = $::form->escape($self->{cv}->name, 1);
273 my $db = $self->is_vendor() ? 'vendor' : 'customer';
275 my $url = $self->url_for(
276 controller => $script,
279 $db .'_id' => $self->{cv}->id,
281 type => $::form->{type},
282 callback => $::form->{callback},
285 print $::form->redirect_header($url);
288 sub action_save_and_ar_transaction {
291 $main::auth->assert('ar_transactions');
293 $self->_transaction('ar.pl');
296 sub action_save_and_ap_transaction {
299 $main::auth->assert('ap_transactions');
301 $self->_transaction('ap.pl');
304 sub action_save_and_invoice {
307 if ( $self->is_vendor() ) {
308 $::auth->assert('vendor_invoice_edit');
310 $::auth->assert('invoice_edit');
313 $::form->{type} = 'invoice';
314 $self->_transaction($self->is_vendor() ? 'ir.pl' : 'is.pl');
317 sub action_save_and_order {
320 if ( $self->is_vendor() ) {
321 $::auth->assert('purchase_order_edit');
323 $::auth->assert('sales_order_edit');
326 $::form->{type} = $self->is_vendor() ? 'purchase_order' : 'sales_order';
327 $self->_transaction('oe.pl');
330 sub action_save_and_rfq {
333 $::auth->assert('request_quotation_edit');
335 $::form->{type} = 'request_quotation';
336 $self->_transaction('oe.pl');
339 sub action_save_and_quotation {
342 $::auth->assert('sales_quotation_edit');
344 $::form->{type} = 'sales_quotation';
345 $self->_transaction('oe.pl');
351 my $db = $self->{cv}->db;
353 if( !$self->is_orphaned() ) {
354 $self->action_edit();
357 $db->with_transaction(sub {
358 $self->{cv}->delete(cascade => 1);
360 my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
361 SL::DB::History->new(
362 trans_id => $self->{cv}->id,
363 snumbers => $snumbers,
364 employee_id => SL::DB::Manager::Employee->current->id,
365 addition => 'DELETED',
367 }) || die($db->error);
369 my $msg = $self->is_vendor() ? $::locale->text('Vendor deleted!') : $::locale->text('Customer deleted!');
370 $::form->redirect($msg);
376 sub action_delete_contact {
379 my $db = $self->{contact}->db;
381 if ( !$self->{contact}->cp_id ) {
382 SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete'));
385 $db->with_transaction(sub {
386 if ( $self->{contact}->used ) {
387 $self->{contact}->detach();
388 $self->{contact}->save();
389 SL::Helper::Flash::flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
391 $self->{contact}->delete(cascade => 1);
392 SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.'));
396 }) || die($db->error);
398 $self->{contact} = $self->_new_contact_object;
401 $self->action_edit();
404 sub action_delete_shipto {
407 my $db = $self->{shipto}->db;
409 if ( !$self->{shipto}->shipto_id ) {
410 SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete'));
413 $db->with_transaction(sub {
414 if ( $self->{shipto}->used ) {
415 $self->{shipto}->detach();
416 $self->{shipto}->save(cascade => 1);
417 SL::Helper::Flash::flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
419 $self->{shipto}->delete(cascade => 1);
420 SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.'));
424 }) || die($db->error);
426 $self->{shipto} = SL::DB::Shipto->new();
429 $self->action_edit();
437 controller => 'ct.pl',
439 db => $self->is_vendor() ? 'vendor' : 'customer',
442 if ( $::form->{callback} ) {
443 push(@url_params, callback => $::form->{callback});
446 $self->redirect_to(@url_params);
450 sub action_search_contact {
453 my $url = 'ct.pl?action=search_contact&db=customer';
455 if ( $::form->{callback} ) {
456 $url .= '&callback='. $::form->escape($::form->{callback});
459 print $::form->redirect_header($url);
463 sub action_get_delivery {
466 $::auth->assert('sales_all_edit');
468 my $dbh = $::form->get_standard_dbh();
470 my ($arap, $db, $qty_sign);
471 if ( $self->is_vendor() ) {
474 $qty_sign = ' * -1 AS qty';
481 my $where = ' WHERE 1=1';
484 if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
485 $where .= " AND ${arap}.shipto_id = ?";
486 push(@values, $::form->{shipto_id});
488 $where .= " AND ${arap}.${db}_id = ?";
489 push(@values, $::form->{id});
492 if ( $::form->{delivery_from} ) {
493 $where .= " AND ${arap}.transdate >= ?";
494 push(@values, conv_date($::form->{delivery_from}));
497 if ( $::form->{delivery_to} ) {
498 $where .= " AND ${arap}.transdate <= ?";
499 push(@values, conv_date($::form->{delivery_to}));
518 ON ". ($arap eq 'ar' ? '(ar.shipto_id = s.shipto_id) ' : '(ap.id = s.trans_id) ') ."
521 ON ${arap}.id = i.trans_id
527 ON (oe.ordnumber = ${arap}.ordnumber AND NOT ${arap}.ordnumber = ''
528 AND ". ($arap eq 'ar' ? 'oe.customer_id IS NOT NULL' : 'oe.vendor_id IS NOT NULL') ." )
531 ORDER BY ${arap}.transdate DESC LIMIT 15";
533 $self->{delivery} = selectall_hashref_query($::form, $dbh, $query, @values);
535 $self->render('customer_vendor/get_delivery', { layout => 0 });
538 sub action_ajaj_get_shipto {
545 my $name = 'shipto'. $_;
546 $name => $self->{shipto}->$name;
548 qw(_id name department_1 department_2 street zipcode city gln country contact phone fax email)
552 $data->{shipto_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{shipto}->cvars_by_config);
554 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
557 sub action_ajaj_get_contact {
565 my $name = 'cp_'. $_;
567 if ( $_ eq 'birthday' && $self->{contact}->$name ) {
568 $name => $self->{contact}->$name->to_lxoffice;
570 $name => $self->{contact}->$name;
574 id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2
575 satphone satfax project street zipcode city privatphone privatemail birthday
580 $data->{contact_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{contact}->cvars_by_config);
582 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
585 sub action_ajaj_autocomplete {
586 my ($self, %params) = @_;
588 my ($model, $manager, $number, $matches);
590 # first see if this is customer or vendor picking
591 if ($::form->{type} eq 'customer') {
592 $model = $self->customer_models;
593 $manager = 'SL::DB::Manager::Customer';
594 $number = 'customernumber';
595 } elsif ($::form->{type} eq 'vendor') {
596 $model = $self->vendor_models;
597 $manager = 'SL::DB::Manager::Vendor';
598 $number = 'vendornumber';
600 die "unknown type $::form->{type}";
603 # if someone types something, and hits enter, assume he entered the full name.
604 # if something matches, treat that as sole match
605 # unfortunately get_models can't do more than one per package atm, so we d it
606 # the oldfashioned way.
607 if ($::form->{prefer_exact}) {
609 if (1 == scalar @{ $exact_matches = $manager->get_all(
612 (salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
614 name => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
615 $number => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
620 $matches = $exact_matches;
624 $matches //= $model->get;
628 value => $_->displayable_name,
629 label => $_->displayable_name,
631 $number => $_->$number,
633 type => $::form->{type},
634 cvars => { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $_->cvars_by_config } },
638 $self->render(\ SL::JSON::to_json(\@hashes), { layout => 0, type => 'json', process => 0 });
641 sub action_test_page {
642 $::request->{layout}->add_javascripts('autocomplete_customer.js');
643 $_[0]->render('customer_vendor/test_page');
647 return $::form->{db} eq 'vendor';
651 return $::form->{db} eq 'customer';
657 if ( defined($self->{_is_orphaned}) ) {
658 return $self->{_is_orphaned};
661 my $arap = $self->is_vendor ? 'ap' : 'ar';
664 my $cv = $self->is_vendor ? 'vendor' : 'customer';
668 FROM '. $arap .' AS a
669 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
676 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
682 FROM delivery_orders a
683 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
687 if ( $self->is_vendor ) {
690 SELECT 1 FROM makemodel mm WHERE mm.make = ?';
694 my ($dummy) = selectrow_query($::form, $::form->get_standard_dbh(), $query, (conv_i($self->{cv}->id)) x $num_args);
696 return $self->{_is_orphaned} = !$dummy;
699 sub _copy_form_to_cvars {
700 my ($self, %params) = @_;
702 foreach my $cvar (@{ $params{target}->cvars_by_config }) {
703 my $value = $params{source}->{$cvar->config->name};
704 $value = $::form->parse_amount(\%::myconfig, $value) if $cvar->config->type eq 'number';
706 $cvar->value($value);
710 sub _instantiate_args {
713 my $curr_employee = SL::DB::Manager::Employee->current;
715 if ( $::form->{cv}->{id} ) {
716 if ( $self->is_vendor() ) {
717 $self->{cv} = SL::DB::Vendor->new(id => $::form->{cv}->{id})->load();
719 $self->{cv} = SL::DB::Customer->new(id => $::form->{cv}->{id})->load();
722 $self->{cv} = $self->_new_customer_vendor_object;
724 $self->{cv}->assign_attributes(%{$::form->{cv}});
726 if ( $self->is_customer() && $::form->{cv}->{taxincluded_checked} eq '' ) {
727 $self->{cv}->taxincluded_checked(undef);
730 $self->{cv}->hourly_rate($::instance_conf->get_customer_hourly_rate) if $self->is_customer && !$self->{cv}->hourly_rate;
732 if ( $::form->{note}->{id} ) {
733 $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load();
734 $self->{note_followup} = $self->{note}->follow_up;
735 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
737 $self->{note} = SL::DB::Note->new();
738 $self->{note_followup} = SL::DB::FollowUp->new();
739 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
742 $self->{note}->assign_attributes(%{$::form->{note}});
743 $self->{note}->created_by($curr_employee->id);
744 $self->{note}->trans_module('ct');
746 $self->{note_followup}->assign_attributes(%{$::form->{note_followup}});
747 $self->{note_followup}->note($self->{note});
748 $self->{note_followup}->created_by($curr_employee->id);
750 $self->{note_followup_link}->trans_type($self->is_vendor() ? 'vendor' : 'customer');
751 $self->{note_followup_link}->trans_info($self->{cv}->name);
753 if ( $::form->{shipto}->{shipto_id} ) {
754 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load();
756 $self->{shipto} = SL::DB::Shipto->new();
758 $self->{shipto}->assign_attributes(%{$::form->{shipto}});
759 $self->{shipto}->module('CT');
761 if ( $::form->{contact}->{cp_id} ) {
762 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact}->{cp_id})->load();
764 $self->{contact} = $self->_new_contact_object;
766 $self->{contact}->assign_attributes(%{$::form->{contact}});
768 $self->_copy_form_to_cvars(target => $self->{cv}, source => $::form->{cv_cvars});
769 $self->_copy_form_to_cvars(target => $self->{contact}, source => $::form->{contact_cvars});
770 $self->_copy_form_to_cvars(target => $self->{shipto}, source => $::form->{shipto_cvars});
773 sub _load_customer_vendor {
776 if ( $self->is_vendor() ) {
777 $self->{cv} = SL::DB::Vendor->new(id => $::form->{id})->load();
779 $self->{cv} = SL::DB::Customer->new(id => $::form->{id})->load();
782 if ( $::form->{note_id} ) {
783 $self->{note} = SL::DB::Note->new(id => $::form->{note_id})->load();
784 $self->{note_followup} = $self->{note}->follow_up;
785 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
787 $self->{note} = SL::DB::Note->new();
788 $self->{note_followup} = SL::DB::FollowUp->new();
789 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
792 if ( $::form->{shipto_id} ) {
793 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();
795 if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
796 die($::locale->text('Error'));
799 $self->{shipto} = SL::DB::Shipto->new();
802 if ( $::form->{contact_id} ) {
803 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact_id})->load();
805 if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
806 die($::locale->text('Error'));
809 $self->{contact} = $self->_new_contact_object;
813 sub _check_customer_vendor_all_edit {
816 unless ($::auth->assert('customer_vendor_all_edit', 1)) {
817 die($::locale->text("You don't have the rights to edit this customer.") . "\n")
818 if $self->{cv}->is_customer and
819 SL::DB::Manager::Employee->current->id != $self->{cv}->salesman_id;
823 sub _create_customer_vendor {
826 $self->{cv} = $self->_new_customer_vendor_object;
827 $self->{cv}->currency_id($::instance_conf->get_currency_id());
829 $self->{note} = SL::DB::Note->new();
831 $self->{note_followup} = SL::DB::FollowUp->new();
833 $self->{shipto} = SL::DB::Shipto->new();
835 $self->{contact} = $self->_new_contact_object;
841 my $dbh = $::form->get_standard_dbh();
845 $self->{all_business} = SL::DB::Manager::Business->get_all();
847 $self->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
850 'SELECT DISTINCT(greeting)
852 WHERE greeting IS NOT NULL AND greeting != \'\'
854 SELECT DISTINCT(greeting)
856 WHERE greeting IS NOT NULL AND greeting != \'\'
858 $self->{all_greetings} = [
861 selectall_hashref_query($::form, $dbh, $query)
866 'SELECT DISTINCT(cp_title) AS title
868 WHERE cp_title IS NOT NULL AND cp_title != \'\'
870 $self->{all_titles} = [
873 selectall_hashref_query($::form, $dbh, $query)
877 $self->{all_currencies} = SL::DB::Manager::Currency->get_all();
879 $self->{all_languages} = SL::DB::Manager::Language->get_all();
881 $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all_sorted();
883 if ( $::instance_conf->get_vertreter() ) {
891 selectall_hashref_query($::form, $dbh, $query)
895 if ( $business_ids->[0] ) {
896 $self->{all_salesman_customers} = SL::DB::Manager::Customer->get_all(query => [business_id => $business_ids]);
898 $self->{all_salesman_customers} = [];
901 $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id, deleted => 0 ] ]);
904 $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
906 $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all();
908 if ($self->{cv}->is_customer) {
909 $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all_sorted(query => [ or => [ id => $self->{cv}->pricegroup_id, obsolete => 0 ] ]);
913 'SELECT DISTINCT(cp_abteilung) AS department
915 WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
916 ORDER BY cp_abteilung';
917 $self->{all_departments} = [
919 { $_->{department}; }
920 selectall_hashref_query($::form, $dbh, $query)
924 $self->{contacts} = $self->{cv}->contacts;
925 $self->{contacts} ||= [];
927 $self->{shiptos} = $self->{cv}->shipto;
928 $self->{shiptos} ||= [];
930 $self->{notes} = SL::DB::Manager::Note->get_all(
932 trans_id => $self->{cv}->id,
933 trans_module => 'ct',
935 with_objects => ['follow_up'],
938 $self->{template_args} ||= {};
940 $::request->{layout}->add_javascripts('autocomplete_customer.js');
941 $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
944 sub _prepare_cvar_configs_for_ajaj {
945 my ($self, $cvars) = @_;
950 my $result = { type => $cvar->config->type };
952 if ($cvar->config->type eq 'number') {
953 $result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2);
955 } elsif ($result->{type} eq 'date') {
956 $result->{value} = $cvar->value ? $cvar->value->to_kivitendo : undef;
958 } elsif ($result->{type} =~ m{customer|vendor|part}) {
959 my $object = $cvar->value;
960 my $method = $result->{type} eq 'part' ? 'description' : 'name';
962 $result->{id} = int($cvar->number_value) || undef;
963 $result->{value} = $object ? $object->$method // '' : '';
966 $result->{value} = $cvar->value;
969 ( $cvar->config->name => $result )
971 } grep { $_->is_valid } @{ $cvars }
978 # check if feature is enabled (select normalize_vc_names from defaults)
979 return unless ($::instance_conf->get_normalize_vc_names);
981 return unless $self->{cv};
982 my $name = $self->{cv}->name;
986 $self->{cv}->name($name);
989 sub home_address_for_google_maps {
992 my $address = $::instance_conf->get_address // '';
993 $address =~ s{^\s+|\s+$|\r+}{}g;
994 $address =~ s{\n+}{,}g;
995 $address =~ s{\s+}{ }g;
1000 sub init_customer_models {
1003 SL::Controller::Helper::GetModels->new(
1004 controller => $self,
1005 model => 'Customer',
1008 by => 'customernumber',
1011 customernumber => t8('Customer Number'),
1014 ( salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
1019 sub init_vendor_models {
1022 SL::Controller::Helper::GetModels->new(
1023 controller => $self,
1027 by => 'vendornumber',
1030 vendornumber => t8('Vendor Number'),
1035 sub _new_customer_vendor_object {
1038 my $class = 'SL::DB::' . ($self->is_vendor ? 'Vendor' : 'Customer');
1042 custom_variables => [],
1046 sub _new_contact_object {
1049 return SL::DB::Contact->new(custom_variables => []);