diff --git a/modules/templates/datasources/letterbox_attachment.php b/modules/templates/datasources/letterbox_attachment.php index 1036d7410c8e599b15ee9ff6ea5c64e87d545792..11cf103b0df323d825ef4239d4b60f9d161dc22b 100755 --- a/modules/templates/datasources/letterbox_attachment.php +++ b/modules/templates/datasources/letterbox_attachment.php @@ -96,7 +96,7 @@ if (!empty($res_id)) { $stmt = $dbDatasource->query('SELECT firstname, lastname, user_id, mail, phone, initials FROM users WHERE user_id = ?', [$res_contact_id]); $myContact = $stmt->fetch(PDO::FETCH_ASSOC); $datasources['contact'][] = $myContact; - } elseif (!empty($context)) { + } elseif (!empty($context) && !empty($datasources['res_letterbox'][0]['address_id']) && !empty($datasources['res_letterbox'][0]['contact_id'])) { $stmt = $dbDatasource->query('SELECT * FROM view_contacts WHERE contact_id = ? and ca_id = ?', array($datasources['res_letterbox'][0]['contact_id'], $datasources['res_letterbox'][0]['address_id'])); $myContact = $stmt->fetch(PDO::FETCH_ASSOC); $myContact['postal_address'] = \Contact\controllers\ContactController::formatContactAddressAfnor($myContact);