X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9bbfd351cd106a108eac4195eeb582278d884582..d934ce3611:/bin/mozilla/ct.pl diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index a7d4eccd3..b525535c2 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -51,6 +51,7 @@ use SL::CT; use SL::CVar; use SL::DB::Business; use SL::DB::Default; +use SL::Helper::Flash; use SL::ReportGenerator; require "bin/mozilla/common.pl"; @@ -287,7 +288,7 @@ sub edit { # format discount $form->{discount} *= 100; # format uri - $form->{homepage} = 'http://' . $form->{homepage} unless $form->{homepage} =~ m|^https?://|; + $form->{homepage} = 'http://' . $form->{homepage} unless ((!$form->{homepage}) || $form->{homepage} =~ m|^https?://|); &form_header; &form_footer; @@ -313,15 +314,15 @@ sub form_header { my %myconfig = %main::myconfig; my $locale = $main::locale; - $form->get_lists(employees => "ALL_EMPLOYEES", - taxzones => "ALL_TAXZONES"); + $form->get_lists(employees => "ALL_EMPLOYEES", + 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_SALESMEN} = $form->{ALL_EMPLOYEES}; $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; - $form->{is_admin} = $myconfig{role} eq 'admin'; $form->{is_customer} = $form->{db} eq 'customer'; $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} }; $form->{shipto_label} = \&_shipto_label; @@ -346,6 +347,12 @@ sub form_header { } } + if (!$form->{'id'}) { + $form->{'currency'} = $form->get_default_currency(\%myconfig); + } else { + $form->{currency} = $form->{curr}; + } + $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id}); CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} }); @@ -724,23 +731,25 @@ sub delete_shipto { } 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 {