if (!empty($layout['data']['height_image_2'])) {
$formattedRow['height_image_2'] = $layout['data']['height_image_2'];
}
- if (!empty($row['participant_image_URL'])) {
- $formattedRow['participant_image'] = $row['participant_image_URL'];
+ if (!empty($row['image_URL']) && $layout['data']['show_participant_image'])
+ {
+ $formattedRow['participant_image'] = $row['image_URL'];
}
if (!empty($layout['data']['width_participant_image'])) {
$formattedRow['width_participant_image'] = $layout['data']['width_participant_image'];
case 'L':
$xAlign = 10;
break;
- case 'C':
- $xAlign = 35;
- break;
default:
break;
}
if ($formattedRow['token'][$i]['token'] != 'spacer') {
$value = $formattedRow['token'][$i]['value'];
}
-
+
+ $rowWidth = $this->pdf->width;
+ $offsetRows = array(1, 2, 3);
+ if (!empty($formattedRow['participant_image']) && !empty($formattedRow['participant_image_width']) && in_array($i, $offsetRows))
+ {
+ $rowWidth = $this->pdf->width - $formattedRow['participant_image_width'];
+ }
$offset = $this->pdf->getY() + $startOffset + $cellspacing;
$this->pdf->SetFont($formattedRow['token'][$i]['font_name'], $formattedRow['token'][$i]['font_style'],
$formattedRow['token'][$i]['font_size']);
- $this->pdf->MultiCell($this->pdf->width, 0, $value,
+ $this->pdf->MultiCell($rowWidth, 0, $value,
$this->border, $formattedRow['token'][$i]['text_alignment'], 0, 1, $x, $offset);
// set this to zero so that it is added only for first element
$layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
// spit / get actual field names from tokeni and individual contact image URLs
- $participant_image_URLs = array();
- if (CRM_Utils_Array::value('participant_image', $layoutInfo['data'])){
- $layoutInfo['data']['participant_image_URL'] = '';
- $queryString = "SELECT civicrm_participant.id as participant_id, civicrm_contact.image_URL FROM civicrm_contact LEFT JOIN civicrm_participant ON civicrm_contact.id = civicrm_participant.contact_id WHERE {$form->_componentClause};";
- $dao = CRM_Core_DAO::executeQuery($queryString);
- while ($dao->fetch()){
- $participant_image_URLs[$dao->participant_id] = $dao->image_URL;
- }
- }
$returnProperties = array();
if (!empty($layoutInfo['data']['token'])) {
foreach ($layoutInfo['data']['token'] as $index => $value) {
}
// add additional required fields for query execution
- $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id');
+ $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL');
foreach ($additionalFields as $field) {
$returnProperties[$field] = 1;
}
$rows[$dao->participant_id][$key] = isset($dao->$key) ? $dao->$key : NULL;
}
}
- foreach ($participant_image_URLs as $participantId => $participant_image_URL) {
- $rows[$participantId]['participant_image_URL'] = $participant_image_URL;
- }
+
$eventBadgeClass = new CRM_Badge_BAO_Badge();
$eventBadgeClass->createLabels($rows, $layoutInfo);
}
$fontStyles = CRM_Core_BAO_LabelFormat::getFontStyles();
$fontNames = CRM_Core_BAO_LabelFormat::getFontNames('name_badge');
$textAlignment = CRM_Core_BAO_LabelFormat::getTextAlignments();
+ $imageAlignment = $textAlignment;
+ unset($imageAlignment['C']);
$rowCount = self::FIELD_ROWCOUNT;
for ( $i =1; $i <= $rowCount; $i++ ) {
$this->add('text', 'height_image_2', ts('Height (mm)'), array('size' => 6));
- $this->add('checkbox', 'participant_image', ts('Use Participant Image?'));
+ $this->add('checkbox', 'show_participant_image', ts('Use Participant Image?'));
$this->add('text', 'width_participant_image', ts('Width (mm)'), array('size' => 6));
$this->add('text', 'height_participant_image', ts('Height (mm)'), array('size' => 6));
- $this->add('select', "alignment_participant_image", ts('Image Alignment'), $textAlignment);
+ $this->add('select', "alignment_participant_image", ts('Image Alignment'), $imageAlignment);
$this->add('checkbox', 'is_default', ts('Default?'));
$this->add('checkbox', 'is_active', ts('Enabled?'));