From 63997e2d4afd69a733745ac843b6456467807b21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 20 Feb 2012 17:01:33 +0100 Subject: [PATCH] =?utf8?q?Lieferadresse=20l=C3=B6schen=20ohne=20CT->delete?= =?utf8?q?=5Fshipto?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/ct.pl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 3cafbd93f..9e814e17b 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -711,23 +711,30 @@ sub get_delivery { } sub delete_shipto { - $main::lxdebug->enter_sub(); + $::lxdebug->enter_sub; + $::auth->assert('customer_vendor_edit'); - $main::auth->assert('customer_vendor_edit'); + if (!$::form->{shipto_id}) { + flash('error', $::locale->text('No shipto selected to delete')); + } else { - my $form = $main::form; - my %myconfig = %main::myconfig; + CT->get_shipto(\%::myconfig, $::form); - CT->get_shipto(\%myconfig, \%$form); + my $shipto = SL::DB::Manager::Shipto->find_by(shipto_id => $::form->{shipto_id}); - unless ($form->{shiptoused}) { - CT->delete_shipto($form->{shipto_id}); - @$form{ grep /^shipto/, keys %$form } = undef; + if ($shipto->used) { + $shipto->detach->save; + flash('info', $::locale->text('Shipto is in use and was flagged invalid.')); + } else { + $shipto->delete; + flash('info', $::locale->text('Shipto deleted.')); + } + delete $::form->{$_} for grep /^shipto/, keys %$::form; } edit(); - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub delete_contact { -- 2.20.1