From a4e4f1a7ca65293cc7f3c45e29fc31571b4e91dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 4 Sep 2014 16:54:12 +0200 Subject: [PATCH] =?utf8?q?undefs=20f=C3=BCr=20find=5Fby=20ber=C3=BCcksicht?= =?utf8?q?igen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IS.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/SL/IS.pm b/SL/IS.pm index f6115a81d..e3ed35ff0 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -492,17 +492,21 @@ sub customer_details { ORDER BY cp.cp_id LIMIT 1|; my $ref = selectfirst_hashref_query($form, $dbh, $query, @values); - # we have no values, probably a invalid contact person. hotfix and first idea for issue #9 + # we have no values, probably a invalid contact person. hotfix and first idea for issue #10 if (!$ref) { my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id}); - $ref->{name} = $customer->name; - $ref->{street} = $customer->street; - $ref->{zipcode} = $customer->zipcode; - $ref->{country} = $customer->country; + if ($customer) { + $ref->{name} = $customer->name; + $ref->{street} = $customer->street; + $ref->{zipcode} = $customer->zipcode; + $ref->{country} = $customer->country; + } my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id}); - $ref->{cp_name} = $contact->cp_name; - $ref->{cp_givenname} = $contact->cp_givenname; - $ref->{cp_gender} = $contact->cp_gender; + if ($contact) { + $ref->{cp_name} = $contact->cp_name; + $ref->{cp_givenname} = $contact->cp_givenname; + $ref->{cp_gender} = $contact->cp_gender; + } } # remove id and taxincluded before copy back delete @$ref{qw(id taxincluded)}; -- 2.20.1