use SL::CVar;
use SL::DB::Business;
use SL::DB::Default;
+use SL::Helper::Flash;
use SL::ReportGenerator;
require "bin/mozilla/common.pl";
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- $form->get_lists(employees => "ALL_EMPLOYEES",
- taxzones => "ALL_TAXZONES",
+ $form->get_lists(taxzones => "ALL_TAXZONES",
currencies => "ALL_CURRENCIES");
$form->get_pricegroup(\%myconfig, { all => 1 });
$form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::lx_office_conf{features}->{vertreter};
+ $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $::form->{FU_created_for_user}, deleted => 0 ] ]);
+ $form->{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $::form->{salesman_id}, deleted => 0 ] ]);
+ $form->{USER} = SL::DB::Manager::Employee->current;
- $form->{ALL_SALESMEN} = $form->{ALL_EMPLOYEES};
$form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
$form->{is_customer} = $form->{db} eq 'customer';
- $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} };
$form->{shipto_label} = \&_shipto_label;
$form->{contacts_label} = \&_contacts_label;
$form->{taxzone_id} = 0 if !$form->{id};
}
sub delete_contact {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
+ $::lxdebug->enter_sub;
+ $::auth->assert('customer_vendor_edit');
- my $form = $main::form;
- my %myconfig = %main::myconfig;
+ CT->get_contact(\%::myconfig, $::form);
- CT->get_contact(\%myconfig, \%$form);
+ my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id});
- unless ($form->{cp_used}) {
- CT->delete_contact($form->{cp_id});
- @$form{ grep /^cp_/, keys %$form } = undef;
+ if ($contact->used) {
+ $contact->detach;
+ flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
+ } else {
+ $contact->delete;
+ flash('info', $::locale->text('Contact deleted.'));
}
+ delete $::form->{$_} for grep /^cp_/, keys %$::form;
edit();
- $main::lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
sub ajax_autocomplete {