From 0ea9578a72ffd0f4ca7123f50d59f44d9d660aa5 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 10 Aug 2016 15:17:44 +0530 Subject: [PATCH] CRM-18472: Notice fixes ---------------------------------------- * CRM-18472: Notice fixes https://issues.civicrm.org/jira/browse/CRM-18472 --- CRM/Contact/Form/Task/LabelCommon.php | 15 +++++++++------ CRM/Member/Form/Task/Label.php | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CRM/Contact/Form/Task/LabelCommon.php b/CRM/Contact/Form/Task/LabelCommon.php index 4a9890cef6..076f7954de 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -53,13 +53,15 @@ class CRM_Contact_Form_Task_LabelCommon { //build contact string that needs to be printed $val = NULL; - foreach ($contactRows as $row => $value) { - foreach ($value as $k => $v) { - $val .= "$v\n"; - } + if (!empty($contactRows)) { + foreach ($contactRows as $row => $value) { + foreach ($value as $k => $v) { + $val .= "$v\n"; + } - $pdf->AddPdfLabel($val); - $val = ''; + $pdf->AddPdfLabel($val); + $val = ''; + } } $pdf->Output($fileName, 'D'); } @@ -80,6 +82,7 @@ class CRM_Contact_Form_Task_LabelCommon { */ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, $mergeSameAddress, $mergeSameHousehold) { $locName = NULL; + $rows = array(); //get the address format sequence from the config file $addressReturnProperties = CRM_Contact_Form_Task_LabelCommon::getAddressReturnProperties(); diff --git a/CRM/Member/Form/Task/Label.php b/CRM/Member/Form/Task/Label.php index ab89e930b0..6f38b9d969 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -111,19 +111,21 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { $individualFormat = TRUE; } // format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327) - foreach ($rows as $id => $row) { - if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) { - $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); - $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); - $temp = array(); - foreach ($val as $vals) { - $temp[] = $comm[$vals]; + if (!empty($rows)) { + foreach ($rows as $id => $row) { + if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) { + $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); + $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $temp = array(); + foreach ($val as $vals) { + $temp[] = $comm[$vals]; + } + $row['preferred_communication_method'] = implode(', ', $temp); } - $row['preferred_communication_method'] = implode(', ', $temp); - } - $row['id'] = $id; - $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields); - $rows[$id] = array($formatted); + $row['id'] = $id; + $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields); + $rows[$id] = array($formatted); + } } if ($isPerMembership) { -- 2.25.1