CRM_Utils_System::setTitle(ts('Make Name Badges'));
//add select for label
- $label = CRM_Core_OptionGroup::values('event_badge');
+ $label = CRM_Badge_BAO_Layout::getList();
$this->add('select',
'badge_id',
*/
public function postProcess() {
$params = $this->controller->exportValues($this->_name);
- $config = CRM_Core_Config::singleton();
+ // get name badge layout info
+ $layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
+
+ // spit / get actual field names from token
+ $returnProperties = array();
+ if (!empty($layoutInfo['data']['token'])) {
+ foreach ($layoutInfo['data']['token'] as $index => $value) {
+ $token = CRM_Utils_Token::getTokens($value);
+ if (key($token) == 'contact') {
+ $element = $token['contact'][0];
+ }
+ else {
+ $element = $token['event'][0];
+ //FIX ME - we need to standardize event token names
+ if (!strpos($element, 'event_')) {
+ $element = 'event_' .$element;
+ }
+ }
+
+ // build returnproperties for query
+ $returnProperties[$element] = 1;
+
+ // add actual field name to row element
+ $layoutInfo['data']['rowElements'][$index] = $element;
+ }
+ }
- $returnProperties = CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT);
- $additionalFields = array('first_name', 'last_name', 'middle_name', 'current_employer');
+ // add additional required fields for query execution
+ $additionalFields = array('participant_register_date', 'participant_id');
foreach ($additionalFields as $field) {
$returnProperties[$field] = 1;
}
}
}
- // get the class name from the participantListingID
- $className = CRM_Core_OptionGroup::getValue('event_badge',
- $params['badge_id'],
- 'value',
- 'Integer',
- 'name'
- );
-
- $classFile = str_replace('_',
- DIRECTORY_SEPARATOR,
- $className
- ) . '.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.');
- }
-
- $eventBadgeClass = new $className();
- $eventBadgeClass->run($rows);
+ $eventBadgeClass = new CRM_Badge_BAO_Badge();
+ $eventBadgeClass->createLabels($rows, $layoutInfo);
}
}