]> wagnertech.de Git - mfinanz.git/commitdiff
Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorJan Büren <jan@lx-office-hosting.de>
Tue, 17 Jan 2012 21:15:18 +0000 (22:15 +0100)
committerJan Büren <jan@lx-office-hosting.de>
Tue, 17 Jan 2012 21:15:18 +0000 (22:15 +0100)
1  2 
bin/mozilla/ct.pl

diff --combined bin/mozilla/ct.pl
index 21ec1c3d8aac6c43def86226727071cf50ef010e,b47d8e2624ad26263daa3394100f0aabc5b12428..b525535c2fe978089a664ee99c07e7e7986f1186
@@@ -51,6 -51,7 +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 +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;
@@@ -730,23 -731,25 +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 {