//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');
}
*/
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();
$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) {