From: yashodha Date: Wed, 10 Aug 2016 09:47:44 +0000 (+0530) Subject: CRM-18472: Notice fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0ea9578a72ffd0f4ca7123f50d59f44d9d660aa5;p=civicrm-core.git CRM-18472: Notice fixes ---------------------------------------- * CRM-18472: Notice fixes https://issues.civicrm.org/jira/browse/CRM-18472 --- 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) {