*
* parent class for building name badges
*/
-class CRM_Badge_Format_Badge {
- function printImage($img) {
- $x = $this->pdf->GetAbsX();
- $y = $this->pdf->GetY();
-
- $this->imgRes = 300;
-
- if ($img) {
- $imgsize = getimagesize($img);
- // mm
- $f = $this->imgRes / 25.4;
- $w = $imgsize[0] / $f;
- $h = $imgsize[1] / $f;
- $this->pdf->Image($img, $this->pdf->GetAbsX(), $this->pdf->GetY(), $w, $h, '', '', '', FALSE, 72, '', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
- }
- $this->pdf->SetXY($x, $y);
- }
-
+class CRM_Badge_BAO_Badge {
/**
* This function is called to create name label pdf
*
* @return void
* @access public
*/
- function createLabels(&$participants, &$layoutInfo) {
+ public function createLabels(&$participants, &$layoutInfo) {
$this->pdf = new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm');
$this->pdf->Open();
$this->pdf->setPrintHeader(FALSE);
* @return array $formattedRow row with meta data
*/
static function formatLabel(&$row, &$layout) {
- $formattedRow = array();
+ $formattedRow = array('labelFormat' => $layout['label_format_name']);
+
if (CRM_Utils_Array::value('rowElements', $layout['data'])) {
foreach($layout['data']['rowElements'] as $key => $element) {
$formattedRow['token'][$key] = array(
return $formattedRow;
}
+
+ public function generateLabel($formattedRow) {
+ switch ($formattedRow['labelFormat']) {
+ case 'Avery5395':
+ self::labelAvery5395($formattedRow);
+ break;
+ }
+ }
+
+ public function labelAvery5395(&$formattedRow) {
+ $this->lMarginLogo = 20;
+ $this->tMarginName = 20;
+
+ $x = $this->pdf->GetAbsX();
+ $y = $this->pdf->GetY();
+
+ $this->printImage($formattedRow['image_1']);
+
+ $this->pdf->SetLineStyle(array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', 'color' => array(0, 0, 200)));
+
+ $this->pdf->SetFontSize(9);
+ $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $formattedRow['token'][1]['value'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y);
+
+ $this->pdf->SetFontSize(20);
+ $this->pdf->MultiCell($this->pdf->width, 10, $formattedRow['token'][2]['value'], $this->border, "C", 0, 1, $x, $y + $this->tMarginName);
+ $this->pdf->SetFontSize(15);
+ $this->pdf->MultiCell($this->pdf->width, 0, $formattedRow['token'][3]['value'], $this->border, "C", 0, 1, $x, $this->pdf->getY());
+
+ $this->pdf->SetFontSize(9);
+ $this->pdf->SetXY($x, $y + $this->pdf->height - 5);
+ $date = CRM_Utils_Date::customFormat($formattedRow['token'][4]['value'], "%e %b");
+ $this->pdf->Cell($this->pdf->width, 0, $date, $this->border, 2, "R");
+ }
+
+ /**
+ * Helper function to print images
+ * @param string $img image url
+ *
+ * @return void
+ * @access public
+ */
+ function printImage($img) {
+ $x = $this->pdf->GetAbsX();
+ $y = $this->pdf->GetY();
+
+ $this->imgRes = 300;
+
+ if ($img) {
+ $imgsize = getimagesize($img);
+ // mm
+ $f = $this->imgRes / 25.4;
+ $w = $imgsize[0] / $f;
+ $h = $imgsize[1] / $f;
+ $this->pdf->Image($img, $this->pdf->GetAbsX(), $this->pdf->GetY(), $w, $h, '', '', '', FALSE, 72, '', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
+ }
+ $this->pdf->SetXY($x, $y);
+ }
}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
-*/
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
- * $Id$
- *
- */
-
-class CRM_Badge_Format_Avery5395 extends CRM_Badge_Format_Badge {
- public function generateLabel($participant) {
- $this->lMarginLogo = 20;
- $this->tMarginName = 20;
-
- $x = $this->pdf->GetAbsX();
- $y = $this->pdf->GetY();
-
- $this->printImage($participant['image_1']);
-
- $this->pdf->SetLineStyle(array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', 'color' => array(0, 0, 200)));
-
- $this->pdf->SetFontSize(9);
- $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $participant['token'][1]['value'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y);
-
- $this->pdf->SetFontSize(20);
- $this->pdf->MultiCell($this->pdf->width, 10, $participant['token'][2]['value'], $this->border, "C", 0, 1, $x, $y + $this->tMarginName);
- $this->pdf->SetFontSize(15);
- $this->pdf->MultiCell($this->pdf->width, 0, $participant['token'][3]['value'], $this->border, "C", 0, 1, $x, $this->pdf->getY());
-
- $this->pdf->SetFontSize(9);
- $this->pdf->SetXY($x, $y + $this->pdf->height - 5);
- $date = CRM_Utils_Date::customFormat($participant['token'][4]['value'], "%e %b");
- $this->pdf->Cell($this->pdf->width, 0, $date, $this->border, 2, "R");
- }
-}
}
}
- // build returnproperties
+ // build returnproperties for query
$returnProperties[$element] = 1;
// add actual field name to row element
}
}
- // check if name label format class exists
- $classFile = 'CRM/Badge/Format/' . $layoutInfo['label_format_name'] . '.php';
- $error = include_once($classFile);
- if ($error == FALSE) {
- CRM_Core_Error::fatal('Event Badge code file: ' . $classFile . ' does not exist. Please verify your custom event badge settings in CiviCRM administrative panel.');
- }
-
// add additional required fields for query execution
$additionalFields = array('participant_register_date', 'participant_id');
foreach ($additionalFields as $field) {
}
}
- // create badge class
- $className = 'CRM_Badge_Format_' . $layoutInfo['label_format_name'];
- $eventBadgeClass = new $className();
+ $eventBadgeClass = new CRM_Badge_BAO_Badge();
$eventBadgeClass->createLabels($rows, $layoutInfo);
}
}