Commit | Line | Data |
---|---|---|
42c62ec1 KJ |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
42c62ec1 KJ |
5 | +--------------------------------------------------------------------+ |
6 | | This file is a part of CiviCRM. | | |
7 | | | | |
8 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
9 | | under the terms of the GNU Affero General Public License | | |
10 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
11 | | | | |
12 | | CiviCRM is distributed in the hope that it will be useful, but | | |
13 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
14 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
15 | | See the GNU Affero General Public License for more details. | | |
16 | | | | |
17 | | You should have received a copy of the GNU Affero General Public | | |
18 | | License and the CiviCRM Licensing Exception along | | |
19 | | with this program; if not, contact CiviCRM LLC | | |
20 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
21 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
22 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
23 | +--------------------------------------------------------------------+ | |
d25dd0ee | 24 | */ |
42c62ec1 KJ |
25 | |
26 | /** | |
27 | * | |
28 | * @package CRM | |
fa938177 | 29 | * @copyright CiviCRM LLC (c) 2004-2016 |
42c62ec1 KJ |
30 | */ |
31 | ||
32 | /** | |
ce064e4f | 33 | * Class CRM_Badge_Format_Badge. |
42c62ec1 KJ |
34 | * |
35 | * parent class for building name badges | |
36 | */ | |
f4e94ab8 | 37 | class CRM_Badge_BAO_Badge { |
382139c4 | 38 | |
db01bf2f | 39 | /** |
40 | * @var bool | |
41 | */ | |
382139c4 KJ |
42 | public $debug = FALSE; |
43 | ||
db01bf2f | 44 | /** |
45 | * @var int | |
46 | */ | |
382139c4 KJ |
47 | public $border = 0; |
48 | ||
42c62ec1 | 49 | /** |
eceb18cc | 50 | * This function is called to create name label pdf. |
42c62ec1 | 51 | * |
691efc59 TO |
52 | * @param array $participants |
53 | * Associated array with participant info. | |
54 | * @param array $layoutInfo | |
55 | * Associated array which contains meta data about format/layout. | |
42c62ec1 | 56 | */ |
1b1d29d8 | 57 | public function createLabels(&$participants, &$layoutInfo) { |
42c62ec1 KJ |
58 | $this->pdf = new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm'); |
59 | $this->pdf->Open(); | |
60 | $this->pdf->setPrintHeader(FALSE); | |
61 | $this->pdf->setPrintFooter(FALSE); | |
62 | $this->pdf->AddPage(); | |
42c62ec1 KJ |
63 | $this->pdf->SetGenerator($this, "generateLabel"); |
64 | ||
1b1d29d8 | 65 | // this is very useful for debugging, by default set to FALSE |
1b1d29d8 KJ |
66 | if ($this->debug) { |
67 | $this->border = "LTRB"; | |
68 | } | |
69 | ||
42c62ec1 KJ |
70 | foreach ($participants as $participant) { |
71 | $formattedRow = self::formatLabel($participant, $layoutInfo); | |
72 | $this->pdf->AddPdfLabel($formattedRow); | |
73 | } | |
74 | ||
75 | $this->pdf->Output(CRM_Utils_String::munge($layoutInfo['title'], '_', 64) . '.pdf', 'D'); | |
76 | CRM_Utils_System::civiExit(1); | |
77 | } | |
78 | ||
79 | /** | |
b44e3f84 | 80 | * Function to create structure and add meta data according to layout. |
42c62ec1 | 81 | * |
691efc59 TO |
82 | * @param array $row |
83 | * Row element that needs to be formatted. | |
84 | * @param array $layout | |
85 | * Layout meta data. | |
42c62ec1 | 86 | * |
a6c01b45 CW |
87 | * @return array |
88 | * row with meta data | |
42c62ec1 | 89 | */ |
00be9182 | 90 | public static function formatLabel(&$row, &$layout) { |
f4e94ab8 | 91 | $formattedRow = array('labelFormat' => $layout['label_format_name']); |
b62376e2 M |
92 | $formattedRow['labelTitle'] = $layout['title']; |
93 | $formattedRow['labelId'] = $layout['id']; | |
94 | ||
a7488080 | 95 | if (!empty($layout['data']['rowElements'])) { |
e135f2b5 | 96 | foreach ($layout['data']['rowElements'] as $key => $element) { |
8d5579e2 KJ |
97 | $value = ''; |
98 | if ($element) { | |
99 | $value = $row[$element]; | |
100 | // hack to fix date field display format | |
101 | if (strpos($element, '_date')) { | |
1a502055 | 102 | $value = CRM_Utils_Date::customFormat($value, "%B %E%f"); |
8d5579e2 | 103 | } |
be09a99d KJ |
104 | } |
105 | ||
42c62ec1 | 106 | $formattedRow['token'][$key] = array( |
be09a99d | 107 | 'value' => $value, |
42c62ec1 KJ |
108 | 'font_name' => $layout['data']['font_name'][$key], |
109 | 'font_size' => $layout['data']['font_size'][$key], | |
1c07f935 | 110 | 'font_style' => $layout['data']['font_style'][$key], |
42c62ec1 | 111 | 'text_alignment' => $layout['data']['text_alignment'][$key], |
50f52554 | 112 | 'token' => $layout['data']['token'][$key], |
42c62ec1 KJ |
113 | ); |
114 | } | |
115 | } | |
116 | ||
a7488080 | 117 | if (!empty($layout['data']['image_1'])) { |
42c62ec1 KJ |
118 | $formattedRow['image_1'] = $layout['data']['image_1']; |
119 | } | |
a7488080 | 120 | if (!empty($layout['data']['width_image_1'])) { |
07d113b7 PJ |
121 | $formattedRow['width_image_1'] = $layout['data']['width_image_1']; |
122 | } | |
a7488080 | 123 | if (!empty($layout['data']['height_image_1'])) { |
07d113b7 PJ |
124 | $formattedRow['height_image_1'] = $layout['data']['height_image_1']; |
125 | } | |
42c62ec1 | 126 | |
a7488080 | 127 | if (!empty($layout['data']['image_2'])) { |
42c62ec1 KJ |
128 | $formattedRow['image_2'] = $layout['data']['image_2']; |
129 | } | |
a7488080 | 130 | if (!empty($layout['data']['width_image_2'])) { |
07d113b7 PJ |
131 | $formattedRow['width_image_2'] = $layout['data']['width_image_2']; |
132 | } | |
a7488080 | 133 | if (!empty($layout['data']['height_image_2'])) { |
07d113b7 PJ |
134 | $formattedRow['height_image_2'] = $layout['data']['height_image_2']; |
135 | } | |
32d586ea | 136 | if (!empty($row['image_URL']) && !empty($layout['data']['show_participant_image'])) { |
609df1ed | 137 | $formattedRow['participant_image'] = $row['image_URL']; |
cf723d2e M |
138 | } |
139 | if (!empty($layout['data']['width_participant_image'])) { | |
140 | $formattedRow['width_participant_image'] = $layout['data']['width_participant_image']; | |
141 | } | |
142 | if (!empty($layout['data']['height_participant_image'])) { | |
143 | $formattedRow['height_participant_image'] = $layout['data']['height_participant_image']; | |
144 | } | |
145 | if (!empty($layout['data']['alignment_participant_image'])) { | |
146 | $formattedRow['alignment_participant_image'] = $layout['data']['alignment_participant_image']; | |
e0ef6999 | 147 | } |
42c62ec1 | 148 | |
a7488080 | 149 | if (!empty($layout['data']['add_barcode'])) { |
f38395f7 KJ |
150 | $formattedRow['barcode'] = array( |
151 | 'alignment' => $layout['data']['barcode_alignment'], | |
152 | 'type' => $layout['data']['barcode_type'], | |
153 | ); | |
42c62ec1 KJ |
154 | } |
155 | ||
7fd8017a KJ |
156 | // finally assign all the row values, so that we can use it for barcode etc |
157 | $formattedRow['values'] = $row; | |
158 | ||
42c62ec1 KJ |
159 | return $formattedRow; |
160 | } | |
f4e94ab8 | 161 | |
e0ef6999 EM |
162 | /** |
163 | * @param $formattedRow | |
164 | */ | |
f4e94ab8 KJ |
165 | public function generateLabel($formattedRow) { |
166 | switch ($formattedRow['labelFormat']) { | |
8b5dac1e | 167 | case 'A6 Badge Portrait 150x106': |
168 | case 'Hanging Badge 3-3/4" x 4-3"/4': | |
169 | self::labelCreator($formattedRow, 5); | |
170 | break; | |
3a872e59 | 171 | |
1b1d29d8 | 172 | case 'Avery 5395': |
8e9fd9e4 | 173 | default: |
8b5dac1e | 174 | self::labelCreator($formattedRow); |
f4e94ab8 KJ |
175 | break; |
176 | } | |
177 | } | |
178 | ||
e0ef6999 EM |
179 | /** |
180 | * @param $formattedRow | |
181 | * @param int $cellspacing | |
182 | */ | |
8b5dac1e | 183 | public function labelCreator(&$formattedRow, $cellspacing = 0) { |
09651125 | 184 | $this->lMarginLogo = 18; |
f4e94ab8 KJ |
185 | $this->tMarginName = 20; |
186 | ||
187 | $x = $this->pdf->GetAbsX(); | |
b246735d | 188 | $y = $this->pdf->getY(); |
f4e94ab8 | 189 | |
b09332e9 | 190 | //call hook alterBadge |
39798542 | 191 | CRM_Utils_Hook::alterBadge($formattedRow['labelTitle'], $this, $formattedRow, $formattedRow['values']); |
b09332e9 | 192 | |
d67e7cf5 | 193 | $startOffset = 0; |
a7488080 | 194 | if (!empty($formattedRow['image_1'])) { |
07d113b7 PJ |
195 | $this->printImage($formattedRow['image_1'], NULL, NULL, CRM_Utils_Array::value('width_image_1', $formattedRow), |
196 | CRM_Utils_Array::value('height_image_1', $formattedRow)); | |
8d5579e2 KJ |
197 | } |
198 | ||
a7488080 | 199 | if (!empty($formattedRow['image_2'])) { |
07d113b7 PJ |
200 | $this->printImage($formattedRow['image_2'], $x + 68, NULL, CRM_Utils_Array::value('width_image_2', $formattedRow), |
201 | CRM_Utils_Array::value('height_image_2', $formattedRow)); | |
d67e7cf5 | 202 | } |
203 | ||
204 | if ((CRM_Utils_Array::value('height_image_1', $formattedRow) > | |
353ffa53 TO |
205 | CRM_Utils_Array::value('height_image_2', $formattedRow)) && !empty($formattedRow['height_image_1']) |
206 | ) { | |
d67e7cf5 | 207 | $startOffset = CRM_Utils_Array::value('height_image_1', $formattedRow); |
208 | } | |
a7488080 | 209 | elseif (!empty($formattedRow['height_image_2'])) { |
d67e7cf5 | 210 | $startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow); |
8d5579e2 | 211 | } |
f4e94ab8 | 212 | |
b53cbfbc | 213 | if (!empty($formattedRow['participant_image'])) { |
5faddd8c | 214 | $imageAlign = 0; |
39798542 | 215 | switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) { |
cf723d2e | 216 | case 'R': |
5faddd8c | 217 | $imageAlign = 68; |
cf723d2e | 218 | break; |
3a872e59 | 219 | |
cf723d2e | 220 | case 'L': |
5faddd8c | 221 | $imageAlign = 0; |
cf723d2e | 222 | break; |
3a872e59 | 223 | |
cf723d2e M |
224 | default: |
225 | break; | |
226 | } | |
39798542 | 227 | $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)); |
228 | if ($startOffset == NULL && CRM_Utils_Array::value('height_participant_image', $formattedRow)) { | |
229 | $startOffset = CRM_Utils_Array::value('height_participant_image', $formattedRow); | |
cf723d2e M |
230 | } |
231 | } | |
232 | ||
e135f2b5 KJ |
233 | $this->pdf->SetLineStyle(array( |
234 | 'width' => 0.1, | |
235 | 'cap' => 'round', | |
236 | 'join' => 'round', | |
237 | 'dash' => '2,2', | |
21dfd5f5 | 238 | 'color' => array(0, 0, 200), |
e135f2b5 | 239 | )); |
f4e94ab8 | 240 | |
50f52554 | 241 | $rowCount = CRM_Badge_Form_Layout::FIELD_ROWCOUNT; |
d67e7cf5 | 242 | for ($i = 1; $i <= $rowCount; $i++) { |
50f52554 | 243 | if (!empty($formattedRow['token'][$i]['token'])) { |
244 | $value = ''; | |
245 | if ($formattedRow['token'][$i]['token'] != 'spacer') { | |
246 | $value = $formattedRow['token'][$i]['value']; | |
e0ef6999 EM |
247 | } |
248 | ||
5faddd8c | 249 | $xAlign = $x; |
609df1ed | 250 | $rowWidth = $this->pdf->width; |
39798542 | 251 | if (!empty($formattedRow['participant_image']) && !empty($formattedRow['width_participant_image'])) { |
5faddd8c | 252 | $rowWidth = $this->pdf->width - $formattedRow['width_participant_image']; |
39798542 | 253 | if ($formattedRow['alignment_participant_image'] == 'L') { |
5faddd8c | 254 | $xAlign = $x + $formattedRow['width_participant_image'] + $imageAlign; |
39798542 | 255 | } |
50f52554 | 256 | } |
8b5dac1e | 257 | $offset = $this->pdf->getY() + $startOffset + $cellspacing; |
d67e7cf5 | 258 | |
50f52554 | 259 | $this->pdf->SetFont($formattedRow['token'][$i]['font_name'], $formattedRow['token'][$i]['font_style'], |
260 | $formattedRow['token'][$i]['font_size']); | |
609df1ed | 261 | $this->pdf->MultiCell($rowWidth, 0, $value, |
5faddd8c | 262 | $this->border, $formattedRow['token'][$i]['text_alignment'], 0, 1, $xAlign, $offset); |
d67e7cf5 | 263 | |
264 | // set this to zero so that it is added only for first element | |
265 | $startOffset = 0; | |
50f52554 | 266 | } |
267 | } | |
7fd8017a | 268 | |
a7488080 | 269 | if (!empty($formattedRow['barcode'])) { |
f38395f7 | 270 | $data = $formattedRow['values']; |
7fd8017a | 271 | |
f38395f7 | 272 | if ($formattedRow['barcode']['type'] == 'barcode') { |
408b79bf | 273 | $data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id']; |
8afbd311 | 274 | } |
f38395f7 KJ |
275 | else { |
276 | // view participant url | |
277 | $data['current_value'] = CRM_Utils_System::url('civicrm/contact/view/participant', | |
278 | 'action=view&reset=1&cid=' . $formattedRow['values']['contact_id'] . '&id=' | |
279 | . $formattedRow['values']['participant_id'], | |
280 | TRUE, | |
281 | NULL, | |
282 | FALSE | |
283 | ); | |
8afbd311 KJ |
284 | } |
285 | ||
9399901d | 286 | // call hook alterBarcode |
f38395f7 KJ |
287 | CRM_Utils_Hook::alterBarcode($data, $formattedRow['barcode']['type']); |
288 | ||
289 | if ($formattedRow['barcode']['type'] == 'barcode') { | |
290 | // barcode position | |
291 | $xAlign = $x; | |
292 | ||
293 | switch ($formattedRow['barcode']['alignment']) { | |
294 | case 'L': | |
d3b0bbe1 | 295 | $xAlign += -14; |
f38395f7 | 296 | break; |
3a872e59 | 297 | |
f38395f7 | 298 | case 'R': |
93c52de0 | 299 | $xAlign += 27; |
f38395f7 | 300 | break; |
3a872e59 | 301 | |
f38395f7 | 302 | case 'C': |
d3b0bbe1 | 303 | $xAlign += 9; |
f38395f7 KJ |
304 | break; |
305 | } | |
9399901d | 306 | |
f38395f7 KJ |
307 | $style = array( |
308 | 'position' => '', | |
309 | 'align' => '', | |
310 | 'stretch' => FALSE, | |
311 | 'fitwidth' => TRUE, | |
312 | 'cellfitalign' => '', | |
313 | 'border' => FALSE, | |
314 | 'hpadding' => 13.5, | |
315 | 'vpadding' => 'auto', | |
316 | 'fgcolor' => array(0, 0, 0), | |
317 | 'bgcolor' => FALSE, | |
318 | 'text' => FALSE, | |
319 | 'font' => 'helvetica', | |
320 | 'fontsize' => 8, | |
321 | 'stretchtext' => 0, | |
322 | ); | |
323 | ||
d3b0bbe1 | 324 | $this->pdf->write1DBarcode($data['current_value'], 'C128', $xAlign, $y + $this->pdf->height - 10, '70', |
f38395f7 KJ |
325 | 12, 0.4, $style, 'B'); |
326 | } | |
327 | else { | |
328 | // qr code position | |
329 | $xAlign = $x; | |
330 | ||
331 | switch ($formattedRow['barcode']['alignment']) { | |
332 | case 'L': | |
d3b0bbe1 | 333 | $xAlign += -5; |
f38395f7 | 334 | break; |
3a872e59 | 335 | |
f38395f7 | 336 | case 'R': |
0ae95ef2 | 337 | $xAlign += 56; |
f38395f7 | 338 | break; |
3a872e59 | 339 | |
f38395f7 KJ |
340 | case 'C': |
341 | $xAlign += 29; | |
342 | break; | |
343 | } | |
344 | ||
345 | $style = array( | |
3a872e59 | 346 | 'border' => FALSE, |
f38395f7 KJ |
347 | 'hpadding' => 13.5, |
348 | 'vpadding' => 'auto', | |
3a872e59 TO |
349 | 'fgcolor' => array(0, 0, 0), |
350 | 'bgcolor' => FALSE, | |
f38395f7 KJ |
351 | 'position' => '', |
352 | ); | |
353 | ||
3a872e59 | 354 | $this->pdf->write2DBarcode($data['current_value'], 'QRCODE,H', $xAlign, $y + $this->pdf->height - 26, 30, |
d3b0bbe1 | 355 | 30, $style, 'B'); |
f38395f7 | 356 | } |
7fd8017a | 357 | } |
f4e94ab8 KJ |
358 | } |
359 | ||
360 | /** | |
eceb18cc | 361 | * Helper function to print images. |
fd31fa4c | 362 | * |
691efc59 TO |
363 | * @param string $img |
364 | * Image url. | |
f4e94ab8 | 365 | * |
fd31fa4c EM |
366 | * @param string $x |
367 | * @param string $y | |
368 | * @param null $w | |
369 | * @param null $h | |
f4e94ab8 | 370 | */ |
00be9182 | 371 | public function printImage($img, $x = '', $y = '', $w = NULL, $h = NULL) { |
1b1d29d8 KJ |
372 | if (!$x) { |
373 | $x = $this->pdf->GetAbsX(); | |
374 | } | |
375 | ||
376 | if (!$y) { | |
377 | $y = $this->pdf->GetY(); | |
378 | } | |
f4e94ab8 KJ |
379 | |
380 | $this->imgRes = 300; | |
381 | ||
382 | if ($img) { | |
07d113b7 | 383 | list($w, $h) = self::getImageProperties($img, $this->imgRes, $w, $h); |
1b1d29d8 KJ |
384 | $this->pdf->Image($img, $x, $y, $w, $h, '', '', '', FALSE, 72, '', FALSE, |
385 | FALSE, $this->debug, FALSE, FALSE, FALSE); | |
f4e94ab8 KJ |
386 | } |
387 | $this->pdf->SetXY($x, $y); | |
388 | } | |
6d4a64c8 | 389 | |
e0ef6999 EM |
390 | /** |
391 | * @param $img | |
392 | * @param int $imgRes | |
393 | * @param null $w | |
394 | * @param null $h | |
395 | * | |
396 | * @return array | |
397 | */ | |
00be9182 | 398 | public static function getImageProperties($img, $imgRes = 300, $w = NULL, $h = NULL) { |
07d113b7 PJ |
399 | $imgsize = getimagesize($img); |
400 | $f = $imgRes / 25.4; | |
401 | $w = !empty($w) ? $w : $imgsize[0] / $f; | |
402 | $h = !empty($h) ? $h : $imgsize[1] / $f; | |
403 | return array($w, $h); | |
404 | } | |
405 | ||
6d4a64c8 | 406 | /** |
100fef9d | 407 | * Build badges parameters before actually creating badges. |
6d4a64c8 | 408 | * |
691efc59 TO |
409 | * @param array $params |
410 | * Associated array of submitted values. | |
c490a46a | 411 | * @param CRM_Core_Form $form |
6d4a64c8 KJ |
412 | */ |
413 | public static function buildBadges(&$params, &$form) { | |
414 | // get name badge layout info | |
415 | $layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params); | |
416 | ||
c490a46a | 417 | // split/get actual field names from token and individual contact image URLs |
6d4a64c8 KJ |
418 | $returnProperties = array(); |
419 | if (!empty($layoutInfo['data']['token'])) { | |
420 | foreach ($layoutInfo['data']['token'] as $index => $value) { | |
421 | $element = ''; | |
422 | if ($value) { | |
423 | $token = CRM_Utils_Token::getTokens($value); | |
424 | if (key($token) == 'contact') { | |
425 | $element = $token['contact'][0]; | |
426 | } | |
427 | elseif (key($token) == 'event') { | |
428 | $element = $token['event'][0]; | |
429 | //FIX ME - we need to standardize event token names | |
4cb8f020 | 430 | if (substr($element, 0, 6) != 'event_') { |
6d4a64c8 KJ |
431 | $element = 'event_' . $element; |
432 | } | |
433 | } | |
434 | elseif (key($token) == 'participant') { | |
435 | $element = $token['participant'][0]; | |
436 | } | |
437 | ||
438 | // build returnproperties for query | |
439 | $returnProperties[$element] = 1; | |
440 | } | |
441 | ||
442 | // add actual field name to row element | |
443 | $layoutInfo['data']['rowElements'][$index] = $element; | |
444 | } | |
445 | } | |
446 | ||
447 | // add additional required fields for query execution | |
609df1ed | 448 | $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL'); |
6d4a64c8 KJ |
449 | foreach ($additionalFields as $field) { |
450 | $returnProperties[$field] = 1; | |
451 | } | |
452 | ||
453 | if ($form->_single) { | |
454 | $queryParams = NULL; | |
455 | } | |
456 | else { | |
457 | $queryParams = $form->get('queryParams'); | |
458 | } | |
459 | ||
460 | $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE, | |
461 | CRM_Contact_BAO_Query::MODE_EVENT | |
462 | ); | |
463 | ||
464 | list($select, $from, $where, $having) = $query->query(); | |
465 | if (empty($where)) { | |
466 | $where = "WHERE {$form->_componentClause}"; | |
467 | } | |
468 | else { | |
469 | $where .= " AND {$form->_componentClause}"; | |
470 | } | |
471 | ||
472 | $sortOrder = NULL; | |
473 | if ($form->get(CRM_Utils_Sort::SORT_ORDER)) { | |
474 | $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER); | |
475 | if (!empty($sortOrder)) { | |
476 | $sortOrder = " ORDER BY $sortOrder"; | |
477 | } | |
478 | } | |
479 | $queryString = "$select $from $where $having $sortOrder"; | |
480 | ||
481 | $dao = CRM_Core_DAO::executeQuery($queryString); | |
482 | $rows = array(); | |
483 | while ($dao->fetch()) { | |
6f294e25 | 484 | $query->convertToPseudoNames($dao); |
6d4a64c8 KJ |
485 | $rows[$dao->participant_id] = array(); |
486 | foreach ($returnProperties as $key => $dontCare) { | |
cffc5e59 CW |
487 | $value = isset($dao->$key) ? $dao->$key : NULL; |
488 | // Format custom fields | |
489 | if (strstr($key, 'custom_') && isset($value)) { | |
8cee0c70 | 490 | $value = CRM_Core_BAO_CustomField::displayValue($value, substr($key, 7), $dao->contact_id); |
cffc5e59 CW |
491 | } |
492 | $rows[$dao->participant_id][$key] = $value; | |
6d4a64c8 KJ |
493 | } |
494 | } | |
495 | ||
496 | $eventBadgeClass = new CRM_Badge_BAO_Badge(); | |
497 | $eventBadgeClass->createLabels($rows, $layoutInfo); | |
498 | } | |
96025800 | 499 | |
42c62ec1 | 500 | } |