1 package SL::Controller::CustomerVendor;
4 use parent qw(SL::Controller::Base);
9 use SL::Locale::String;
10 use SL::Controller::Helper::GetModels;
19 use SL::DB::PaymentTerm;
20 use SL::DB::Pricegroup;
23 use SL::DB::FollowUpLink;
27 use Rose::Object::MakeMethods::Generic (
28 'scalar --get_set_init' => [ qw(customer_models vendor_models) ],
32 __PACKAGE__->run_before(
34 $::auth->assert('customer_vendor_edit');
37 __PACKAGE__->run_before(
41 'save_and_ap_transaction',
42 'save_and_ar_transaction',
54 __PACKAGE__->run_before(
55 '_load_customer_vendor',
65 # make sure this comes after _load_customer_vendor
66 __PACKAGE__->run_before(
67 '_check_customer_vendor_all_edit',
74 'save_and_ap_transaction',
75 'save_and_ar_transaction',
87 __PACKAGE__->run_before(
88 '_create_customer_vendor',
94 __PACKAGE__->run_before('normalize_name');
100 $self->_pre_render();
101 $self->{cv}->assign_attributes(hourly_rate => $::instance_conf->get_customer_hourly_rate) if $self->{cv}->is_customer;
103 'customer_vendor/form',
104 title => ($self->is_vendor() ? $::locale->text('Add Vendor') : $::locale->text('Add Customer')),
105 %{$self->{template_args}}
112 $self->_pre_render();
114 'customer_vendor/form',
115 title => ($self->is_vendor() ? $::locale->text('Edit Vendor') : $::locale->text('Edit Customer')),
116 %{$self->{template_args}}
123 if ($::request->type eq 'json') {
128 $cv_hash = $self->{cv}->as_tree;
129 $cv_hash->{cvars} = $self->{cv}->cvar_as_hashref;
132 $self->render(\ SL::JSON::to_json($cv_hash), { layout => 0, type => 'json', process => 0 });
139 my @errors = $self->{cv}->validate;
141 flash('error', @errors);
142 $self->_pre_render();
144 'customer_vendor/form',
145 title => ($self->is_vendor() ? t8('Edit Vendor') : t8('Edit Customer')),
146 %{$self->{template_args}}
148 $::dispatcher->end_request;
151 my $db = $self->{cv}->db;
153 $db->do_transaction(sub {
155 if ( $self->is_vendor() ) {
156 if ( $self->{cv}->vendornumber ) {
157 $cvs_by_nr = SL::DB::Manager::Vendor->get_all(query => [vendornumber => $self->{cv}->vendornumber]);
160 if ( $self->{cv}->customernumber ) {
161 $cvs_by_nr = SL::DB::Manager::Customer->get_all(query => [customernumber => $self->{cv}->customernumber]);
165 foreach my $entry (@{$cvs_by_nr}) {
166 if( $entry->id != $self->{cv}->id ) {
168 $self->is_vendor() ? $::locale->text('This vendor number is already in use.') : $::locale->text('This customer number is already in use.');
170 $::form->error($msg);
174 $self->{cv}->save(cascade => 1);
176 $self->{contact}->cp_cv_id($self->{cv}->id);
177 if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) {
178 $self->{contact}->save(cascade => 1);
181 if( $self->{note}->subject ne '' && $self->{note}->body ne '' ) {
183 if ( !$self->{note_followup}->follow_up_date ) {
184 $::form->error($::locale->text('Date missing!'));
187 $self->{note}->trans_id($self->{cv}->id);
188 $self->{note}->save();
190 $self->{note_followup}->save();
192 $self->{note_followup_link}->follow_up_id($self->{note_followup}->id);
193 $self->{note_followup_link}->trans_id($self->{cv}->id);
194 $self->{note_followup_link}->save();
196 SL::Helper::Flash::flash_later('info', $::locale->text('Follow-Up saved.'));
199 $self->{shipto}->trans_id($self->{cv}->id);
200 if( $self->{shipto}->shiptoname ne '' ) {
201 $self->{shipto}->save(cascade => 1);
204 my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
205 SL::DB::History->new(
206 trans_id => $self->{cv}->id,
207 snumbers => $snumbers,
208 employee_id => SL::DB::Manager::Employee->current->id,
212 if ( $::form->{delete_notes} ) {
213 foreach my $note_id (@{ $::form->{delete_notes} }) {
214 my $note = SL::DB::Note->new(id => $note_id)->load();
215 if ( $note->follow_up ) {
216 if ( $note->follow_up->follow_up_link ) {
217 $note->follow_up->follow_up_link->delete(cascade => 'delete');
219 $note->follow_up->delete(cascade => 'delete');
221 $note->delete(cascade => 'delete');
224 }) || die($db->error);
233 my @redirect_params = (
235 id => $self->{cv}->id,
236 db => ($self->is_vendor() ? 'vendor' : 'customer'),
239 if ( $self->{contact}->cp_id ) {
240 push(@redirect_params, contact_id => $self->{contact}->cp_id);
243 if ( $self->{shipto}->shipto_id ) {
244 push(@redirect_params, shipto_id => $self->{shipto}->shipto_id);
247 $self->redirect_to(@redirect_params);
250 sub action_save_and_close {
255 my $msg = $self->is_vendor() ? $::locale->text('Vendor saved') : $::locale->text('Customer saved');
256 $::form->redirect($msg);
260 my ($self, $script) = @_;
262 $::auth->assert('general_ledger | invoice_edit | vendor_invoice_edit | ' .
263 ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit');
267 my $name = $::form->escape($self->{cv}->name, 1);
268 my $db = $self->is_vendor() ? 'vendor' : 'customer';
270 my $url = $self->url_for(
271 controller => $script,
274 $db .'_id' => $self->{cv}->id,
276 type => $::form->{type},
277 callback => $::form->{callback},
280 print $::form->redirect_header($url);
283 sub action_save_and_ar_transaction {
286 $main::auth->assert('general_ledger');
288 $self->_transaction('ar.pl');
291 sub action_save_and_ap_transaction {
294 $main::auth->assert('general_ledger');
296 $self->_transaction('ap.pl');
299 sub action_save_and_invoice {
302 if ( $self->is_vendor() ) {
303 $::auth->assert('vendor_invoice_edit');
305 $::auth->assert('invoice_edit');
308 $::form->{type} = 'invoice';
309 $self->_transaction($self->is_vendor() ? 'ir.pl' : 'is.pl');
312 sub action_save_and_order {
315 if ( $self->is_vendor() ) {
316 $::auth->assert('purchase_order_edit');
318 $::auth->assert('sales_order_edit');
321 $::form->{type} = $self->is_vendor() ? 'purchase_order' : 'sales_order';
322 $self->_transaction('oe.pl');
325 sub action_save_and_rfq {
328 $::auth->assert('request_quotation_edit');
330 $::form->{type} = 'request_quotation';
331 $self->_transaction('oe.pl');
334 sub action_save_and_quotation {
337 $::auth->assert('sales_quotation_edit');
339 $::form->{type} = 'sales_quotation';
340 $self->_transaction('oe.pl');
346 my $db = $self->{cv}->db;
348 if( !$self->is_orphaned() ) {
349 $self->action_edit();
352 $db->do_transaction(sub {
353 $self->{cv}->delete(cascade => 1);
355 my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber;
356 SL::DB::History->new(
357 trans_id => $self->{cv}->id,
358 snumbers => $snumbers,
359 employee_id => SL::DB::Manager::Employee->current->id,
360 addition => 'DELETED',
362 }) || die($db->error);
364 my $msg = $self->is_vendor() ? $::locale->text('Vendor deleted!') : $::locale->text('Customer deleted!');
365 $::form->redirect($msg);
371 sub action_delete_contact {
374 my $db = $self->{contact}->db;
376 if ( !$self->{contact}->cp_id ) {
377 SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete'));
380 $db->do_transaction(sub {
381 if ( $self->{contact}->used ) {
382 $self->{contact}->detach();
383 $self->{contact}->save();
384 SL::Helper::Flash::flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
386 $self->{contact}->delete(cascade => 1);
387 SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.'));
389 }) || die($db->error);
391 $self->{contact} = $self->_new_contact_object;
394 $self->action_edit();
397 sub action_delete_shipto {
400 my $db = $self->{shipto}->db;
402 if ( !$self->{shipto}->shipto_id ) {
403 SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete'));
406 $db->do_transaction(sub {
407 if ( $self->{shipto}->used ) {
408 $self->{shipto}->detach();
409 $self->{shipto}->save(cascade => 1);
410 SL::Helper::Flash::flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
412 $self->{shipto}->delete(cascade => 1);
413 SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.'));
415 }) || die($db->error);
417 $self->{shipto} = SL::DB::Shipto->new();
420 $self->action_edit();
428 controller => 'ct.pl',
430 db => $self->is_vendor() ? 'vendor' : 'customer',
433 if ( $::form->{callback} ) {
434 push(@url_params, callback => $::form->{callback});
437 $self->redirect_to(@url_params);
441 sub action_search_contact {
444 my $url = 'ct.pl?action=search_contact&db=customer';
446 if ( $::form->{callback} ) {
447 $url .= '&callback='. $::form->escape($::form->{callback});
450 print $::form->redirect_header($url);
454 sub action_get_delivery {
457 $::auth->assert('sales_all_edit');
459 my $dbh = $::form->get_standard_dbh();
461 my ($arap, $db, $qty_sign);
462 if ( $self->is_vendor() ) {
465 $qty_sign = ' * -1 AS qty';
472 my $where = ' WHERE 1=1';
475 if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
476 $where .= " AND ${arap}.shipto_id = ?";
477 push(@values, $::form->{shipto_id});
479 $where .= " AND ${arap}.${db}_id = ?";
480 push(@values, $::form->{id});
483 if ( $::form->{delivery_from} ) {
484 $where .= " AND ${arap}.transdate >= ?";
485 push(@values, conv_date($::form->{delivery_from}));
488 if ( $::form->{delivery_to} ) {
489 $where .= " AND ${arap}.transdate <= ?";
490 push(@values, conv_date($::form->{delivery_to}));
509 ON ". ($arap eq 'ar' ? '(ar.shipto_id = s.shipto_id) ' : '(ap.id = s.trans_id) ') ."
512 ON ${arap}.id = i.trans_id
518 ON (oe.ordnumber = ${arap}.ordnumber AND NOT ${arap}.ordnumber = ''
519 AND ". ($arap eq 'ar' ? 'oe.customer_id IS NOT NULL' : 'oe.vendor_id IS NOT NULL') ." )
522 ORDER BY ${arap}.transdate DESC LIMIT 15";
524 $self->{delivery} = selectall_hashref_query($::form, $dbh, $query, @values);
526 $self->render('customer_vendor/get_delivery', { layout => 0 });
529 sub action_ajaj_get_shipto {
536 my $name = 'shipto'. $_;
537 $name => $self->{shipto}->$name;
539 qw(_id name department_1 department_2 street zipcode city gln country contact phone fax email)
543 $data->{shipto_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{shipto}->cvars_by_config);
545 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
548 sub action_ajaj_get_contact {
556 my $name = 'cp_'. $_;
558 if ( $_ eq 'birthday' && $self->{contact}->$name ) {
559 $name => $self->{contact}->$name->to_lxoffice;
561 $name => $self->{contact}->$name;
565 id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2
566 satphone satfax project street zipcode city privatphone privatemail birthday
571 $data->{contact_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{contact}->cvars_by_config);
573 $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
576 sub action_ajaj_autocomplete {
577 my ($self, %params) = @_;
579 my ($model, $manager, $number, $matches);
581 # first see if this is customer or vendor picking
582 if ($::form->{type} eq 'customer') {
583 $model = $self->customer_models;
584 $manager = 'SL::DB::Manager::Customer';
585 $number = 'customernumber';
586 } elsif ($::form->{type} eq 'vendor') {
587 $model = $self->vendor_models;
588 $manager = 'SL::DB::Manager::Vendor';
589 $number = 'vendornumber';
591 die "unknown type $::form->{type}";
594 # if someone types something, and hits enter, assume he entered the full name.
595 # if something matches, treat that as sole match
596 # unfortunately get_models can't do more than one per package atm, so we d it
597 # the oldfashioned way.
598 if ($::form->{prefer_exact}) {
600 if (1 == scalar @{ $exact_matches = $manager->get_all(
603 (salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
605 name => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
606 $number => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
611 $matches = $exact_matches;
615 $matches //= $model->get;
619 value => $_->displayable_name,
620 label => $_->displayable_name,
622 $number => $_->$number,
624 type => $::form->{type},
625 cvars => { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $_->cvars_by_config } },
629 $self->render(\ SL::JSON::to_json(\@hashes), { layout => 0, type => 'json', process => 0 });
632 sub action_test_page {
633 $::request->{layout}->add_javascripts('autocomplete_customer.js');
634 $_[0]->render('customer_vendor/test_page');
638 return $::form->{db} eq 'vendor';
642 return $::form->{db} eq 'customer';
648 if ( defined($self->{_is_orphaned}) ) {
649 return $self->{_is_orphaned};
652 my $arap = $self->is_vendor ? 'ap' : 'ar';
655 my $cv = $self->is_vendor ? 'vendor' : 'customer';
659 FROM '. $arap .' AS a
660 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
667 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
673 FROM delivery_orders a
674 JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
678 if ( $self->is_vendor ) {
681 SELECT 1 FROM makemodel mm WHERE mm.make = ?';
685 my ($dummy) = selectrow_query($::form, $::form->get_standard_dbh(), $query, (conv_i($self->{cv}->id)) x $num_args);
687 return $self->{_is_orphaned} = !$dummy;
690 sub _copy_form_to_cvars {
691 my ($self, %params) = @_;
693 foreach my $cvar (@{ $params{target}->cvars_by_config }) {
694 my $value = $params{source}->{$cvar->config->name};
695 $value = $::form->parse_amount(\%::myconfig, $value) if $cvar->config->type eq 'number';
697 $cvar->value($value);
701 sub _instantiate_args {
704 my $curr_employee = SL::DB::Manager::Employee->current;
706 if ( $::form->{cv}->{id} ) {
707 if ( $self->is_vendor() ) {
708 $self->{cv} = SL::DB::Vendor->new(id => $::form->{cv}->{id})->load();
710 $self->{cv} = SL::DB::Customer->new(id => $::form->{cv}->{id})->load();
713 $self->{cv} = $self->_new_customer_vendor_object;
715 $self->{cv}->assign_attributes(%{$::form->{cv}});
717 if ( $self->is_customer() && $::form->{cv}->{taxincluded_checked} eq '' ) {
718 $self->{cv}->taxincluded_checked(undef);
721 $self->{cv}->hourly_rate($::instance_conf->get_customer_hourly_rate) if $self->is_customer && !$self->{cv}->hourly_rate;
723 if ( $::form->{note}->{id} ) {
724 $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load();
725 $self->{note_followup} = $self->{note}->follow_up;
726 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
728 $self->{note} = SL::DB::Note->new();
729 $self->{note_followup} = SL::DB::FollowUp->new();
730 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
733 $self->{note}->assign_attributes(%{$::form->{note}});
734 $self->{note}->created_by($curr_employee->id);
735 $self->{note}->trans_module('ct');
737 $self->{note_followup}->assign_attributes(%{$::form->{note_followup}});
738 $self->{note_followup}->note($self->{note});
739 $self->{note_followup}->created_by($curr_employee->id);
741 $self->{note_followup_link}->trans_type($self->is_vendor() ? 'vendor' : 'customer');
742 $self->{note_followup_link}->trans_info($self->{cv}->name);
744 if ( $::form->{shipto}->{shipto_id} ) {
745 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load();
747 $self->{shipto} = SL::DB::Shipto->new();
749 $self->{shipto}->assign_attributes(%{$::form->{shipto}});
750 $self->{shipto}->module('CT');
752 if ( $::form->{contact}->{cp_id} ) {
753 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact}->{cp_id})->load();
755 $self->{contact} = $self->_new_contact_object;
757 $self->{contact}->assign_attributes(%{$::form->{contact}});
759 $self->_copy_form_to_cvars(target => $self->{cv}, source => $::form->{cv_cvars});
760 $self->_copy_form_to_cvars(target => $self->{contact}, source => $::form->{contact_cvars});
761 $self->_copy_form_to_cvars(target => $self->{shipto}, source => $::form->{shipto_cvars});
764 sub _load_customer_vendor {
767 if ( $self->is_vendor() ) {
768 $self->{cv} = SL::DB::Vendor->new(id => $::form->{id})->load();
770 $self->{cv} = SL::DB::Customer->new(id => $::form->{id})->load();
773 if ( $::form->{note_id} ) {
774 $self->{note} = SL::DB::Note->new(id => $::form->{note_id})->load();
775 $self->{note_followup} = $self->{note}->follow_up;
776 $self->{note_followup_link} = $self->{note_followup}->follow_up_link;
778 $self->{note} = SL::DB::Note->new();
779 $self->{note_followup} = SL::DB::FollowUp->new();
780 $self->{note_followup_link} = SL::DB::FollowUpLink->new();
783 if ( $::form->{shipto_id} ) {
784 $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();
786 if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
787 die($::locale->text('Error'));
790 $self->{shipto} = SL::DB::Shipto->new();
793 if ( $::form->{contact_id} ) {
794 $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact_id})->load();
796 if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
797 die($::locale->text('Error'));
800 $self->{contact} = $self->_new_contact_object;
804 sub _check_customer_vendor_all_edit {
807 unless ($::auth->assert('customer_vendor_all_edit', 1)) {
808 die($::locale->text("You don't have the rights to edit this customer.") . "\n")
809 if $self->{cv}->is_customer and
810 SL::DB::Manager::Employee->current->id != $self->{cv}->salesman_id;
814 sub _create_customer_vendor {
817 $self->{cv} = $self->_new_customer_vendor_object;
818 $self->{cv}->currency_id($::instance_conf->get_currency_id());
820 $self->{note} = SL::DB::Note->new();
822 $self->{note_followup} = SL::DB::FollowUp->new();
824 $self->{shipto} = SL::DB::Shipto->new();
826 $self->{contact} = $self->_new_contact_object;
832 my $dbh = $::form->get_standard_dbh();
836 $self->{all_business} = SL::DB::Manager::Business->get_all();
838 $self->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
841 'SELECT DISTINCT(greeting)
843 WHERE greeting IS NOT NULL AND greeting != \'\'
845 SELECT DISTINCT(greeting)
847 WHERE greeting IS NOT NULL AND greeting != \'\'
849 $self->{all_greetings} = [
852 selectall_hashref_query($::form, $dbh, $query)
857 'SELECT DISTINCT(cp_title) AS title
859 WHERE cp_title IS NOT NULL AND cp_title != \'\'
861 $self->{all_titles} = [
864 selectall_hashref_query($::form, $dbh, $query)
868 $self->{all_currencies} = SL::DB::Manager::Currency->get_all();
870 $self->{all_languages} = SL::DB::Manager::Language->get_all();
872 $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all_sorted();
874 if ( $::instance_conf->get_vertreter() ) {
882 selectall_hashref_query($::form, $dbh, $query)
886 if ( $business_ids->[0] ) {
887 $self->{all_salesman_customers} = SL::DB::Manager::Customer->get_all(query => [business_id => $business_ids]);
889 $self->{all_salesman_customers} = [];
892 $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id, deleted => 0 ] ]);
895 $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
897 $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all();
899 $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all();
902 'SELECT DISTINCT(cp_abteilung) AS department
904 WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
905 ORDER BY cp_abteilung';
906 $self->{all_departments} = [
908 { $_->{department}; }
909 selectall_hashref_query($::form, $dbh, $query)
913 $self->{contacts} = $self->{cv}->contacts;
914 $self->{contacts} ||= [];
916 $self->{shiptos} = $self->{cv}->shipto;
917 $self->{shiptos} ||= [];
919 $self->{notes} = SL::DB::Manager::Note->get_all(
921 trans_id => $self->{cv}->id,
922 trans_module => 'ct',
924 with_objects => ['follow_up'],
927 $self->{template_args} ||= {};
929 $::request->{layout}->add_javascripts('autocomplete_customer.js');
930 $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
933 sub _prepare_cvar_configs_for_ajaj {
934 my ($self, $cvars) = @_;
939 my $result = { type => $cvar->config->type };
941 if ($cvar->config->type eq 'number') {
942 $result->{value} = $::form->format_amount(\%::myconfig, $cvar->value, -2);
944 } elsif ($result->{type} eq 'date') {
945 $result->{value} = $cvar->value ? $cvar->value->to_kivitendo : undef;
947 } elsif ($result->{type} =~ m{customer|vendor|part}) {
948 my $object = $cvar->value;
949 my $method = $result->{type} eq 'part' ? 'description' : 'name';
951 $result->{id} = int($cvar->number_value) || undef;
952 $result->{value} = $object ? $object->$method // '' : '';
955 $result->{value} = $cvar->value;
958 ( $cvar->config->name => $result )
960 } grep { $_->is_valid } @{ $cvars }
967 # check if feature is enabled (select normalize_vc_names from defaults)
968 return unless ($::instance_conf->get_normalize_vc_names);
970 return unless $self->{cv};
971 my $name = $self->{cv}->name;
975 $self->{cv}->name($name);
978 sub home_address_for_google_maps {
981 my $address = $::instance_conf->get_address // '';
982 $address =~ s{^\s+|\s+$|\r+}{}g;
983 $address =~ s{\n+}{,}g;
984 $address =~ s{\s+}{ }g;
989 sub init_customer_models {
992 SL::Controller::Helper::GetModels->new(
997 by => 'customernumber',
1000 customernumber => t8('Customer Number'),
1003 ( salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
1008 sub init_vendor_models {
1011 SL::Controller::Helper::GetModels->new(
1012 controller => $self,
1016 by => 'vendornumber',
1019 vendornumber => t8('Vendor Number'),
1024 sub _new_customer_vendor_object {
1027 my $class = 'SL::DB::' . ($self->is_vendor ? 'Vendor' : 'Customer');
1031 custom_variables => [],
1035 sub _new_contact_object {
1038 return SL::DB::Contact->new(custom_variables => []);