}
if (CRM_Utils_Array::value('add_barcode', $layout['data'])) {
- $formattedRow['barcode'] = $layout['data']['barcode_alignment'];
+ $formattedRow['barcode'] = array(
+ 'alignment' => $layout['data']['barcode_alignment'],
+ 'type' => $layout['data']['barcode_type'],
+ );
}
// finally assign all the row values, so that we can use it for barcode etc
$this->border, $formattedRow['token'][4]['text_alignment'], 0, 1, $x, $y + $this->pdf->height - 5);
if (CRM_Utils_Array::value('barcode', $formattedRow)) {
- $style = array(
- 'position' => '',
- 'align' => '',
- 'stretch' => FALSE,
- 'fitwidth' => TRUE,
- 'cellfitalign' => '',
- 'border' => FALSE,
- 'hpadding' => 13.5,
- 'vpadding' => 'auto',
- 'fgcolor' => array(0, 0, 0),
- 'bgcolor' => FALSE,
- 'text' => FALSE,
- 'font' => 'helvetica',
- 'fontsize' => 8,
- 'stretchtext' => 0,
- );
+ $data = $formattedRow['values'];
- // barcode position
- $xAlign = $x;
- if ($formattedRow['barcode'] == 'L') {
- $xAlign += -12;
- }
- elseif ($formattedRow['barcode'] == 'R') {
- $xAlign += 30;
+ if ($formattedRow['barcode']['type'] == 'barcode') {
+ $data['current_value'] =
+ $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];
}
- elseif ($formattedRow['barcode'] == 'C') {
- $xAlign += 15;
+ else {
+ // view participant url
+ $data['current_value'] = CRM_Utils_System::url('civicrm/contact/view/participant',
+ 'action=view&reset=1&cid=' . $formattedRow['values']['contact_id'] . '&id='
+ . $formattedRow['values']['participant_id'],
+ TRUE,
+ NULL,
+ FALSE
+ );
}
- $data = $formattedRow['values'];
- $data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];
-
// call hook alterBarcode
- CRM_Utils_Hook::alterBarcode($data);
+ CRM_Utils_Hook::alterBarcode($data, $formattedRow['barcode']['type']);
+
+ if ($formattedRow['barcode']['type'] == 'barcode') {
+ // barcode position
+ $xAlign = $x;
+
+ switch ($formattedRow['barcode']['alignment']) {
+ case 'L':
+ $xAlign += -12;
+ break;
+ case 'R':
+ $xAlign += 30;
+ break;
+ case 'C':
+ $xAlign += 15;
+ break;
+ }
- $this->pdf->write1DBarcode($data['current_value'], 'C128', $xAlign, $y + $this->pdf->height - 10, '',
- 12, 0.4, $style, 'B');
+ $style = array(
+ 'position' => '',
+ 'align' => '',
+ 'stretch' => FALSE,
+ 'fitwidth' => TRUE,
+ 'cellfitalign' => '',
+ 'border' => FALSE,
+ 'hpadding' => 13.5,
+ 'vpadding' => 'auto',
+ 'fgcolor' => array(0, 0, 0),
+ 'bgcolor' => FALSE,
+ 'text' => FALSE,
+ 'font' => 'helvetica',
+ 'fontsize' => 8,
+ 'stretchtext' => 0,
+ );
+
+ $this->pdf->write1DBarcode($data['current_value'], 'C128', $xAlign, $y + $this->pdf->height - 10, '',
+ 12, 0.4, $style, 'B');
+ }
+ else {
+ // qr code position
+ $xAlign = $x;
+
+ switch ($formattedRow['barcode']['alignment']) {
+ case 'L':
+ $xAlign += -8;
+ break;
+ case 'R':
+ $xAlign += 63;
+ break;
+ case 'C':
+ $xAlign += 29;
+ break;
+ }
+
+ $style = array(
+ 'border' => false,
+ 'hpadding' => 13.5,
+ 'vpadding' => 'auto',
+ 'fgcolor' => array(0,0,0),
+ 'bgcolor' => false,
+ 'position' => '',
+ );
+
+ $this->pdf->write2DBarcode($data['current_value'], 'QRCODE,Q', $xAlign, $y + $this->pdf->height - 23, 30,
+ 30, $style, 'B');
+ }
}
}
$rowCount++;
$this->assign('rowCount', $rowCount);
+ $barcodeTypes = CRM_Core_SelectValues::getBarcodeTypes();
$this->add('checkbox', 'add_barcode', ts('Barcode?'));
- unset($textAlignment['J']);
+ $this->add('select', "barcode_type", ts('Type'), $barcodeTypes);
$this->add('select', "barcode_alignment", ts('Alignment'), $textAlignment);
+
$attributes = array('readonly'=> true);
$this->add('text', 'image_1', ts('Image (top right)'),
$attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));