*/
static function formatLabel(&$row, &$layout) {
$formattedRow = array('labelFormat' => $layout['label_format_name']);
+ $formattedRow['labelTitle'] = $layout['title'];
+ $formattedRow['labelId'] = $layout['id'];
+
if (!empty($layout['data']['rowElements'])) {
foreach ($layout['data']['rowElements'] as $key => $element) {
if (!empty($layout['data']['height_image_2'])) {
$formattedRow['height_image_2'] = $layout['data']['height_image_2'];
}
+ if (!empty($row['image_URL']) && !empty($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'];
+ }
+ if (!empty($layout['data']['height_participant_image'])) {
+ $formattedRow['height_participant_image'] = $layout['data']['height_participant_image'];
+ }
+ if (!empty($layout['data']['alignment_participant_image'])) {
+ $formattedRow['alignment_participant_image'] = $layout['data']['alignment_participant_image'];
+ }
if (!empty($layout['data']['add_barcode'])) {
$formattedRow['barcode'] = array(
return $formattedRow;
}
+ /**
+ * @param $formattedRow
+ */
public function generateLabel($formattedRow) {
switch ($formattedRow['labelFormat']) {
case 'A6 Badge Portrait 150x106':
}
}
+ /**
+ * @param $formattedRow
+ * @param int $cellspacing
+ */
public function labelCreator(&$formattedRow, $cellspacing = 0) {
$this->lMarginLogo = 18;
$this->tMarginName = 20;
$x = $this->pdf->GetAbsX();
$y = $this->pdf->getY();
+ //call hook alterBadge
+ CRM_Utils_Hook::alterBadge($formattedRow['labelTitle'], $this, $formattedRow, $formattedRow['values']);
+
$startOffset = 0;
if (!empty($formattedRow['image_1'])) {
$this->printImage($formattedRow['image_1'], NULL, NULL, CRM_Utils_Array::value('width_image_1', $formattedRow),
$startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow);
}
+ if (CRM_Utils_Array::value('participant_image', $formattedRow)) {
+ $imageAlign = 0;
+ switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) {
+ case 'R':
+ $imageAlign = 68;
+ break;
+ case 'L':
+ $imageAlign = 0;
+ break;
+ default:
+ break;
+ }
+ $this->pdf->Image($formattedRow['participant_image'], $x + $imageAlign, $y + $startOffset, CRM_Utils_Array::value('width_participant_image', $formattedRow), CRM_Utils_Array::value('height_participant_image', $formattedRow));
+ if ($startOffset == NULL && CRM_Utils_Array::value('height_participant_image', $formattedRow)) {
+ $startOffset = CRM_Utils_Array::value('height_participant_image', $formattedRow);
+ }
+ }
+
$this->pdf->SetLineStyle(array(
'width' => 0.1,
'cap' => 'round',
$value = $formattedRow['token'][$i]['value'];
}
+ $xAlign = $x;
+ $rowWidth = $this->pdf->width;
+ if (!empty($formattedRow['participant_image']) && !empty($formattedRow['width_participant_image'])) {
+ $rowWidth = $this->pdf->width - $formattedRow['width_participant_image'];
+ if ($formattedRow['alignment_participant_image'] == 'L') {
+ $xAlign = $x + $formattedRow['width_participant_image'] + $imageAlign;
+ }
+ }
$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->border, $formattedRow['token'][$i]['text_alignment'], 0, 1, $x, $offset);
+ $this->pdf->MultiCell($rowWidth, 0, $value,
+ $this->border, $formattedRow['token'][$i]['text_alignment'], 0, 1, $xAlign, $offset);
// set this to zero so that it is added only for first element
$startOffset = 0;
/**
* Helper function to print images
+ *
* @param string $img image url
*
+ * @param string $x
+ * @param string $y
+ * @param null $w
+ * @param null $h
+ *
* @return void
* @access public
*/
$this->pdf->SetXY($x, $y);
}
+ /**
+ * @param $img
+ * @param int $imgRes
+ * @param null $w
+ * @param null $h
+ *
+ * @return array
+ */
static function getImageProperties($img, $imgRes = 300, $w = NULL, $h = NULL) {
$imgsize = getimagesize($img);
$f = $imgRes / 25.4;
}
/**
- * function to build badges parameters before actually creating badges.
+ * Build badges parameters before actually creating badges.
*
- * @param array $params associated array of submitted values
- * @params object $form form/controller object
+ * @param array $params associated array of submitted values
+ * @param CRM_Core_Form $form
*
* @return void
* @access public
// get name badge layout info
$layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
- // spit / get actual field names from token
+ // split/get actual field names from token and individual contact image URLs
$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;
}
$dao = CRM_Core_DAO::executeQuery($queryString);
$rows = array();
while ($dao->fetch()) {
+ $query->convertToPseudoNames($dao);
$rows[$dao->participant_id] = array();
foreach ($returnProperties as $key => $dontCare) {
$rows[$dao->participant_id][$key] = isset($dao->$key) ? $dao->$key : NULL;